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 0829973 Merge shared code
0829973 is described below
commit 0829973cad07796ae36084fff6ea8548561e8dc4
Author: Sebb <[email protected]>
AuthorDate: Sun Sep 12 17:06:40 2021 +0100
Merge shared code
---
www/pods.cgi | 94 ++--------------------------------------
www/site.cgi | 91 ++------------------------------------
www/{pods.cgi => site_or_pod.rb} | 43 ++++++++++--------
3 files changed, 31 insertions(+), 197 deletions(-)
diff --git a/www/pods.cgi b/www/pods.cgi
index ce2a910..ef2c6b7 100755
--- a/www/pods.cgi
+++ b/www/pods.cgi
@@ -1,96 +1,8 @@
#!/usr/bin/env ruby
PAGETITLE = "Apache Podling Website Checks" # Wvisible:sites,brand
-# ensure that there is a path (even a slash will do) after the script name
-unless ENV['PATH_INFO'] and not ENV['PATH_INFO'].empty?
- print "Status: 301 Moved Permanently\r\n"
- print "Location: #{ENV['SCRIPT_URL']}/\r\n"
- print "\r\n"
- exit
+def cgi_for_tlps
+ false
end
-$LOAD_PATH.unshift '/srv/whimsy/lib'
-require 'json'
-require 'net/http'
-require 'time' # for httpdate
-require 'whimsy/sitestandards'
-
-# Gather and analyze scans for TLP websites
-cgi_for_tlps = false
-sites, crawl_time = SiteStandards.get_sites(cgi_for_tlps)
-checks_performed = SiteStandards.get_checks(cgi_for_tlps)
-analysis = SiteStandards.analyze(sites, checks_performed)
-
-# 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 'wunderbar'
-require 'wunderbar/bootstrap'
-require 'wunderbar/jquery/stupidtable'
-require 'whimsy/asf/themes'
-require 'whimsy/sitewebsite'
-
-_html do
- _head do
- _style %{
- .table td {font-size: smaller;}
- }
- end
- _body? do
- _whimsy_body(
- title: PAGETITLE,
- subtitle: 'Checking Podling Websites For required content',
- related: {
- "/committers/tools" => "Whimsy Tool Listing",
- "/site/" => "TLP Website Checker",
- "https://www.apache.org/foundation/marks/pmcs#navigation" => "Required
PMC Links Policy",
- "https://github.com/apache/whimsy/blob/master/www#{ENV['SCRIPT_NAME']}"
=> "See This Source Code",
- "mailto:[email protected]?subject=[SITE] Website Checker
Question" => "Questions? Email Whimsy PMC"
- },
- helpblock: -> {
- _p do
- _div.bg_danger 'NOTE: most podlings may not pass these checks yet
during incubation - but they are expected to pass them before graduation.'
- _p do
- _ 'This script periodically crawls all Apache project and podling
websites to check them for a few specific links or text blocks that all
projects are expected to have.'
- _ 'The checks include verifying that all '
- _a 'required links', href:
'https://www.apache.org/foundation/marks/pmcs#navigation'
- _ ' appear on a project homepage, along with an "image" check if
project logo files are in apache.org/img'
- end
- _p! do
- _a 'View the crawler code', href:
'https://github.com/apache/whimsy/blob/master/tools/site-scan.rb'
- _ ', '
- _a 'website display code', href:
"https://github.com/apache/whimsy/blob/master/www#{ENV['SCRIPT_NAME']}"
- _ ', '
- _a 'validation checks details', href:
"https://github.com/apache/whimsy/blob/master/lib/whimsy/sitewebsite.rb"
- _ ', and '
- _a 'raw JSON data', href:
"#{SiteStandards.get_url(false)}#{SiteStandards.get_filename(cgi_for_tlps)}"
- _ '.'
- _br
- _ "Last crawl time: #{crawl_time} over #{sites.size} websites."
- end
- end
- }
- ) do
- # Encapsulate data display (same for projects and podlings)
- display_application(path_info, sites, analysis, checks_performed,
cgi_for_tlps)
- end
-
- _script %{
- var table = $(".table").stupidtable();
- table.on("aftertablesort", function (event, data) {
- var th = $(this).find("th");
- th.find(".arrow").remove();
- var dir = $.fn.stupidtable.dir;
- var arrow = data.direction === dir.ASC ? "↑" : "↓";
- th.eq(data.column).append('<span class="arrow">' + arrow +'</span>');
- });
- }
- end
-end
+require_relative 'site_or_pod'
diff --git a/www/site.cgi b/www/site.cgi
index 5f1455c..c8f2693 100755
--- a/www/site.cgi
+++ b/www/site.cgi
@@ -1,93 +1,8 @@
#!/usr/bin/env ruby
PAGETITLE = "Apache Project Website Checks" # Wvisible:sites,brand
-# ensure that there is a path (even a slash will do) after the script name
-unless ENV['PATH_INFO'] and not ENV['PATH_INFO'].empty?
- print "Status: 301 Moved Permanently\r\n"
- print "Location: #{ENV['SCRIPT_URL']}/\r\n"
- print "\r\n"
- exit
+def cgi_for_tlps
+ true
end
-$LOAD_PATH.unshift '/srv/whimsy/lib'
-require 'json'
-require 'net/http'
-require 'time' # for httpdate
-require 'whimsy/sitestandards'
-
-# Gather and analyze scans for TLP websites
-cgi_for_tlps = true
-sites, crawl_time = SiteStandards.get_sites(cgi_for_tlps)
-checks_performed = SiteStandards.get_checks(cgi_for_tlps)
-analysis = SiteStandards.analyze(sites, checks_performed)
-
-# 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 'wunderbar'
-require 'wunderbar/bootstrap'
-require 'wunderbar/jquery/stupidtable'
-require 'whimsy/asf/themes'
-require 'whimsy/sitewebsite'
-
-_html do
- _head do
- _style %{
- .table td {font-size: smaller;}
- }
- end
- _body? do
- _whimsy_body(
- title: PAGETITLE,
- subtitle: "Checking #{cgi_for_tlps ? 'Project' : 'Podling'} Websites For
required content",
- related: {
- "/committers/tools" => "Whimsy Tool Listing",
- "/pods/" => "PPMC Podling Website Checker",
- "https://www.apache.org/foundation/marks/pmcs#navigation" => "Required
PMC Links Policy",
- "https://github.com/apache/whimsy/blob/master/www#{ENV['SCRIPT_NAME']}"
=> "See This Source Code",
- "mailto:[email protected]?subject=[SITE] Website Checker
Question" => "Questions? Email Whimsy PMC"
- },
- helpblock: -> {
- _p do
- _ 'This script periodically crawls all Apache project and podling
websites to check them for a few specific links or text blocks that all
projects are expected to have.'
- _ 'The checks include verifying that all '
- _a 'required links', href:
'https://www.apache.org/foundation/marks/pmcs#navigation'
- _ ' appear on a project homepage, along with an "image" check if
project logo files are in apache.org/img'
- end
- _p! do
- _a 'View the crawler code', href:
'https://github.com/apache/whimsy/blob/master/tools/site-scan.rb'
- _ ', '
- _a 'website display code', href:
"https://github.com/apache/whimsy/blob/master/www#{ENV['SCRIPT_NAME']}"
- _ ', '
- _a 'validation checks details', href:
"https://github.com/apache/whimsy/blob/master/lib/whimsy/sitewebsite.rb"
- _ ', and '
- _a 'raw JSON data', href:
"#{SiteStandards.get_url(false)}#{SiteStandards.get_filename(cgi_for_tlps)}"
- _ '.'
- _br
- _ "Last crawl time: #{crawl_time} over #{sites.size} websites."
- end
- }
- ) do
- # Encapsulate data display (same for projects and podlings)
- display_application(path_info, sites, analysis, checks_performed,
cgi_for_tlps)
- end
-
- _script %{
- var table = $(".table").stupidtable();
- table.on("aftertablesort", function (event, data) {
- var th = $(this).find("th");
- th.find(".arrow").remove();
- var dir = $.fn.stupidtable.dir;
- var arrow = data.direction === dir.ASC ? "↑" : "↓";
- th.eq(data.column).append('<span class="arrow">' + arrow +'</span>');
- });
- }
- end
-end
+require_relative 'site_or_pod'
diff --git a/www/pods.cgi b/www/site_or_pod.rb
old mode 100755
new mode 100644
similarity index 70%
copy from www/pods.cgi
copy to www/site_or_pod.rb
index ce2a910..f253585
--- a/www/pods.cgi
+++ b/www/site_or_pod.rb
@@ -1,5 +1,4 @@
-#!/usr/bin/env ruby
-PAGETITLE = "Apache Podling Website Checks" # Wvisible:sites,brand
+# Shared code used by pods.cgi and site.cgi
# ensure that there is a path (even a slash will do) after the script name
unless ENV['PATH_INFO'] and not ENV['PATH_INFO'].empty?
@@ -16,7 +15,6 @@ require 'time' # for httpdate
require 'whimsy/sitestandards'
# Gather and analyze scans for TLP websites
-cgi_for_tlps = false
sites, crawl_time = SiteStandards.get_sites(cgi_for_tlps)
checks_performed = SiteStandards.get_checks(cgi_for_tlps)
analysis = SiteStandards.analyze(sites, checks_performed)
@@ -43,22 +41,32 @@ _html do
.table td {font-size: smaller;}
}
end
+ if cgi_for_tlps
+ other = "/pods/"
+ other_text = "PPMC Podling Website Checker"
+ else
+ other = "/site/"
+ other_text = "TLP Website Checker"
+ end
_body? do
_whimsy_body(
- title: PAGETITLE,
- subtitle: 'Checking Podling Websites For required content',
- related: {
- "/committers/tools" => "Whimsy Tool Listing",
- "/site/" => "TLP Website Checker",
- "https://www.apache.org/foundation/marks/pmcs#navigation" => "Required
PMC Links Policy",
- "https://github.com/apache/whimsy/blob/master/www#{ENV['SCRIPT_NAME']}"
=> "See This Source Code",
- "mailto:[email protected]?subject=[SITE] Website Checker
Question" => "Questions? Email Whimsy PMC"
- },
- helpblock: -> {
- _p do
- _div.bg_danger 'NOTE: most podlings may not pass these checks yet
during incubation - but they are expected to pass them before graduation.'
+ title: PAGETITLE,
+ subtitle: "Checking #{cgi_for_tlps ? 'Project' : 'Podling'} Websites For
required content",
+ related: {
+ "/committers/tools" => "Whimsy Tool Listing",
+ other => other_text,
+ "https://www.apache.org/foundation/marks/pmcs#navigation" => "Required
PMC Links Policy",
+
"https://github.com/apache/whimsy/blob/master/www#{ENV['SCRIPT_NAME']}" => "See
This Source Code",
+ "mailto:[email protected]?subject=[SITE] Website Checker
Question" => "Questions? Email Whimsy PMC"
+ },
+ helpblock: -> {
+ unless cgi_for_tlps
+ _div.bg_danger %{NOTE: most podlings may not pass these checks yet
during incubation -
+ but they are expected to pass them before
graduation.}
+ end
_p do
- _ 'This script periodically crawls all Apache project and podling
websites to check them for a few specific links or text blocks that all
projects are expected to have.'
+ _ 'This script periodically crawls all Apache project and podling
websites to check them '
+ _ 'for a few specific links or text blocks that all projects are
expected to have.'
_ 'The checks include verifying that all '
_a 'required links', href:
'https://www.apache.org/foundation/marks/pmcs#navigation'
_ ' appear on a project homepage, along with an "image" check if
project logo files are in apache.org/img'
@@ -75,8 +83,7 @@ _html do
_br
_ "Last crawl time: #{crawl_time} over #{sites.size} websites."
end
- end
- }
+ }
) do
# Encapsulate data display (same for projects and podlings)
display_application(path_info, sites, analysis, checks_performed,
cgi_for_tlps)