You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by ru...@apache.org on 2017/04/25 05:38:44 UTC

[whimsy] branch master updated: use local copy of site-scan plus other fixes

This is an automated email from the ASF dual-hosted git repository.

rubys 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  b29c620   use local copy of site-scan plus other fixes
b29c620 is described below

commit b29c620358e6002d37534e25d56d96994e200142
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Tue Apr 25 01:37:36 2017 -0400

    use local copy of site-scan plus other fixes
    
    - show last crawl time
    - adjust spacing
    - hotlink links
---
 www/test/site-check.cgi | 49 ++++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 38 insertions(+), 11 deletions(-)

diff --git a/www/test/site-check.cgi b/www/test/site-check.cgi
index 855f2e8..4517295 100755
--- a/www/test/site-check.cgi
+++ b/www/test/site-check.cgi
@@ -9,26 +9,43 @@ require 'net/http'
 
 PAGETITLE = 'Apache TLP Website Link Checks'
 cols = %w( events foundation license sponsorship security thanks )
-DATAURI = 'http://intertwingly.net/tmp/site-check.json'
+DATAURI = 'https://whimsy.apache.org/public/site-scan.json'
 
 _html do
-  _body? do
+  _head do
     _style %{
       .table td {font-size: smaller;}
     }
+  end
+
+  _body? do
+
+    local_copy = File.expand_path('../public/site-check.json').untaint
+
+    if File.exist? local_copy
+      crawl_time = File.mtime(local_copy).rfc2822
+      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
+
     _whimsy_header PAGETITLE
+
     _whimsy_content do
       _div.panel.panel_default do
         _div!.panel_heading 'Common Links Found On TLP Sites'
-        _div.panel_body do
+        _div!.panel_body do
           _ 'Current (beta) status of Apache PMC top level websites vis-a-vis '
-          _a! 'required links', href: 'https://www.apache.org/foundation/marks/pmcs#navigation'
-          _ ', generated statically.'
-          _a! 'See crawler code', href: 'https://whimsy.apache.org/tools/site-check.rb'
-          _ ', and '
-          _a! 'raw JSON data', href: DATAURI         
-          _ ", last crawl time: TBD"
+          _a 'required links', href: 'https://www.apache.org/foundation/marks/pmcs#navigation'
+          _ ', generated statically.  '
+          _a 'See crawler code', href: 'https://whimsy.apache.org/tools/site-check.rb'
+          _ ' and '
+          _a 'raw JSON data', href: DATAURI         
+          _ ".  Last crawl time: #{crawl_time}."
         end
+
         _table.table.table_condensed.table_striped do
           _thead do  
             _tr do
@@ -38,7 +55,7 @@ _html do
               end
             end
           end
-          sites = JSON.parse(Net::HTTP.get(URI(DATAURI)))
+
           _tbody do
             sites.each do |n, links|
               _tr do
@@ -46,7 +63,16 @@ _html do
                   _a! "#{links['display_name']}", href: links['uri']
                 end
                 cols.each do |c|
-                  links[c] ? _td!(links[c].sub(/https?:\/\//, '').sub(/(www\.)?apache\.org/i, 'a.o')) : _td!('')
+                  if not links[c]
+                    _td ''
+                  elsif links[c] =~ /^http/
+                    _td do
+                      _a links[c].sub(/https?:\/\//, '').
+                        sub(/(www\.)?apache\.org/i, 'a.o'), href: links[c]
+                    end
+                  else
+                    _td links[c]
+                  end
                 end
               end
             end
@@ -54,6 +80,7 @@ _html do
         end
       end
     end      
+
     _script %{
       var table = $(".table").stupidtable();
       table.on("aftertablesort", function (event, data) {

-- 
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <co...@whimsical.apache.org>'].