You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by se...@apache.org on 2017/05/16 22:29:22 UTC
[whimsy] branch master updated: Allow script to be tested as CLI
code
This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git
The following commit(s) were added to refs/heads/master by this push:
new 8b510c5 Allow script to be tested as CLI code
8b510c5 is described below
commit 8b510c547be5971eeaa04043739225bd8517e853
Author: Sebb <se...@apache.org>
AuthorDate: Tue May 16 23:29:20 2017 +0100
Allow script to be tested as CLI code
---
www/site.cgi | 50 ++++++++++++++++++++++++++++++++------------------
1 file changed, 32 insertions(+), 18 deletions(-)
diff --git a/www/site.cgi b/www/site.cgi
index ed768dc..5f38b6c 100755
--- a/www/site.cgi
+++ b/www/site.cgi
@@ -10,10 +10,6 @@ end
$LOAD_PATH.unshift File.realpath(File.expand_path('../../lib', __FILE__))
require 'json'
-require 'whimsy/asf/themes'
-require 'wunderbar'
-require 'wunderbar/bootstrap'
-require 'wunderbar/jquery/stupidtable'
require 'net/http'
require 'time' # for httpdate
@@ -71,6 +67,38 @@ def analyze(sites)
]
end
+def getsites
+ local_copy = File.expand_path('../public/site-scan.json', __FILE__).untaint
+ if File.exist? local_copy
+ crawl_time = File.mtime(local_copy).httpdate # show time in same format as last-mod
+ sites = JSON.parse(File.read(local_copy))
+ else
+ response = Net::HTTP.get_response(URI(DATAURI))
+ crawl_time = response['last-modified']
+ sites = JSON.parse(response.body)
+ end
+ return sites, crawl_time
+end
+
+sites, crawl_time = getsites()
+
+analysis = analyze(sites)
+
+# Allow CLI testing, e.g. "PATH_INFO=/ ruby www/site.cgi >test.json"
+# SCRIPT_NAME will always be set for a CGI invocation
+unless ENV['SCRIPT_NAME']
+ puts JSON.pretty_generate(analysis)
+ exit
+end
+
+# Only required for CGI use
+# if these are required earlier, the code creates an unnecessary 'assets' directory
+
+require 'whimsy/asf/themes'
+require 'wunderbar'
+require 'wunderbar/bootstrap'
+require 'wunderbar/jquery/stupidtable'
+
# Determine the color of a given table cell, given:
# - overall analysis of the sites, in particular the third column
# which is a list projects that successfully matched the check
@@ -96,20 +124,6 @@ _html do
_body? do
- path = env['PATH_INFO']
-
- local_copy = File.expand_path('../public/site-scan.json', __FILE__).untaint
-
- if File.exist? local_copy
- crawl_time = File.mtime(local_copy).httpdate # show time in same format as last-mod
- sites = JSON.parse(File.read(local_copy))
- else
- response = Net::HTTP.get_response(URI(DATAURI))
- crawl_time = response['last-modified']
- sites = JSON.parse(response.body)
- end
- analysis = analyze(sites)
-
_whimsy_header PAGETITLE
_whimsy_content do
--
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <co...@whimsical.apache.org>'].
Re: [whimsy] branch master updated: ... bundle update
Posted by Sam Ruby <ru...@intertwingly.net>.
On Wed, May 24, 2017 at 10:13 AM, Shane Curcuru <as...@shanecurcuru.org> wrote:
> Sam Ruby wrote on 5/18/17 2:44 PM:
>> Are you running with the latest wunderbar?
>
> Reminder: if assets/ or wunderbar aren't behaving for you, do:
>
> $ bundle update
>
> Since Sam changed wunderbar and related stuff that the _html code in
> many scripts relies on, your local gems may not have been updated for:
>
> https://github.com/apache/whimsy/commit/739b75a07838cd5b13c4a36f0d8163bc4be1f163
>
>> Wunderbar will ensure that a specific version of a dependency is
>> available, even taking the steps necessary to create it. If you are
>> running a back level of wunderbar, it may decide that the version of
>> the assets in the www/assets directory aren't the right ones, and will
>> create the necessary files in the directory of the cgi.
>
> Much nicer now!
There still are stray older copies of various stylesheets and scripts
in the repository that need to be cleaned up.
Also, glyphicons may now be working:
https://github.com/apache/whimsy/commit/5211cfc0926c54f99e2ea44c711a521eeec9f6ce
- Sam Ruby
Re: [whimsy] branch master updated: ... bundle update
Posted by Shane Curcuru <as...@shanecurcuru.org>.
Sam Ruby wrote on 5/18/17 2:44 PM:
> Are you running with the latest wunderbar?
Reminder: if assets/ or wunderbar aren't behaving for you, do:
$ bundle update
Since Sam changed wunderbar and related stuff that the _html code in
many scripts relies on, your local gems may not have been updated for:
https://github.com/apache/whimsy/commit/739b75a07838cd5b13c4a36f0d8163bc4be1f163
>
> Wunderbar will ensure that a specific version of a dependency is
> available, even taking the steps necessary to create it. If you are
> running a back level of wunderbar, it may decide that the version of
> the assets in the www/assets directory aren't the right ones, and will
> create the necessary files in the directory of the cgi.
Much nicer now!
>
> - Sam Ruby
>
> On Tue, May 16, 2017 at 6:29 PM, <se...@apache.org> wrote:
>> +
>> +# Only required for CGI use
>> +# if these are required earlier, the code creates an unnecessary 'assets' directory
>> +
>> +require 'whimsy/asf/themes'
>> +require 'wunderbar'
>> +require 'wunderbar/bootstrap'
>> +require 'wunderbar/jquery/stupidtable'
--
- Shane
https://www.apache.org/foundation/marks/resources
Re: [whimsy] branch master updated: Allow script to be tested as CLI code
Posted by Sam Ruby <ru...@intertwingly.net>.
Are you running with the latest wunderbar?
Wunderbar will ensure that a specific version of a dependency is
available, even taking the steps necessary to create it. If you are
running a back level of wunderbar, it may decide that the version of
the assets in the www/assets directory aren't the right ones, and will
create the necessary files in the directory of the cgi.
- Sam Ruby
On Tue, May 16, 2017 at 6:29 PM, <se...@apache.org> wrote:
> +
> +# Only required for CGI use
> +# if these are required earlier, the code creates an unnecessary 'assets' directory
> +
> +require 'whimsy/asf/themes'
> +require 'wunderbar'
> +require 'wunderbar/bootstrap'
> +require 'wunderbar/jquery/stupidtable'