whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [whimsy] branch master updated: Use committee-info.yaml instead of parsing index.html
Date Thu, 17 Oct 2019 14:01:25 GMT
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 0df4749  Use committee-info.yaml instead of parsing index.html
0df4749 is described below

commit 0df47495ea111d47f9b5864124cc83a55f08bf4c
Author: Sebb <sebb@apache.org>
AuthorDate: Thu Oct 17 15:01:14 2019 +0100

    Use committee-info.yaml instead of parsing index.html
    
    N.B. The initial data for committee-info.yaml
    was taken from index.html.
---
 lib/whimsy/asf/site.rb | 90 +++++++-------------------------------------------
 1 file changed, 12 insertions(+), 78 deletions(-)

diff --git a/lib/whimsy/asf/site.rb b/lib/whimsy/asf/site.rb
index 869c4e4..1d0853e 100644
--- a/lib/whimsy/asf/site.rb
+++ b/lib/whimsy/asf/site.rb
@@ -1,113 +1,47 @@
 require_relative '../asf'
-require 'nokogiri'
+require 'yaml'
 
 module ASF
 
   # A list of ASF sites, formed by parsing
-  # <tt>asf/infrastructure/site/trunk/content</tt> from svn.
+  # <tt>private/committers/board/committee-info.yaml</tt> from svn.
 
   class Site
-    # add entries that are not currently defined in index.html (or elsewhere)
-    @@default = {
-      "brandmanagement" => {
-        link: "http://www.apache.org/foundation/marks/pmcs",
-        text: "define how Apache projects should refer to trademarks and display their brand"
-      },
-      "comdev" => {
-        link: "http://community.apache.org/",
-        text: "Resources to help people become involved with Apache projects"
-      },
-      "executiveassistant" => {
-        link: "http://www.apache.org/foundation/ASF-EA.html",
-        text: "Executive Assistant"
-      },
-      "fundraising" => {
-        link: "http://www.apache.org/foundation/contributing.html",
-        text: "Fund Raising"
-      },
-      "infrastructure" => {
-        link: "http://www.apache.org/dev/infrastructure.html",
-        text: "Infrastructure Team"
-      },
-      "legalaffairs" => {
-        link: "http://www.apache.org/legal/",
-        text: "Establishing and managing legal policies"
-      },
-      "marketingandpublicity" => {
-        link: "http://www.apache.org/press/",
-        text: "public relations and for the press-related issues"
-      },
-      "security" => {
-        link: "http://www.apache.org/security/",
-        text: "Security Team"
-      },
-      "tac" => {
-        link: "http://www.apache.org/travel/",
-        text: "Travel Assistance Committee"
-      },
-      "w3crelations" => {
-        link: "http://www.apache.org/foundation/foundation-projects.html#w3c",
-        text: "Liaison between the ASF and the World Wide Web Consortium"
-      },
-    }
     @@list = {}
+    @@mtime = 0
 
-    # a Hash of all sites.  Keys are the committee names.  Values are a hash
-    # with <tt>:link</tt>, and <tt>:text<tt> values.
+    # parse the data file
     def self.list
-      templates = ASF::SVN['site-root']
-      file = File.join(templates, 'index.html')
+      board = ASF::SVN.find('board')
+      file = File.join(board, 'committee-info.yaml')
       if not File.exist?(file)
-        Wunderbar.error "Unable to find 'infrastructure/site/trunk/content/index.html'"
+        Wunderbar.error "Unable to find 'committee-info.yaml'"
         return {}
       end
       return @@list if not @@list.empty? and File.mtime(file) == @@mtime
+      yaml = YAML.load_file file
       @@mtime = File.mtime(file)
-
-      @@list = @@default
-
-      Committee.load_committee_info
-      doc = Nokogiri::HTML.parse(File.read(file))
-      list = doc.at("#by_name")
-      if list
-        list.search('a').each do |a|
-          @@list[Committee.find(a.text).name] = 
-            {link: a['href'], text: a['title']}
-        end
-      end
-
-      list = doc.at("#by_category")
-      if list
-        list.search('a').each do |a|
-          if a['title']
-            @@list[Committee.find(a.text).name] = 
-              {link: a['href'], text: a['title']}
-          end
-        end
-      end
-
-      @@list
+      @@list = yaml[:cttees].merge yaml[:tlps]
     end
 
-    # find the site for a give committee.
+    # find the site for a given committee.
     def self.find(committee)
       committee = committee.name if ASF::Committee == committee
       list[committee]
     end
   end
 
-
   class Committee
     # website for this committee.  Data is sourced from ASF::Site.
     def site
       site = ASF::Site.find(name)
-      site[:link] if site
+      site[:site] if site
     end
 
     # description for this committee.  Data is sourced from ASF::Site.
     def description
       site = ASF::Site.find(name)
-      site[:text] if site
+      site[:description] if site
     end
   end
 end


Mime
View raw message