Author: sebb
Date: Fri Apr 27 13:20:14 2018
New Revision: 1830351

URL: http://svn.apache.org/viewvc?rev=1830351&view=rev
Log:
Create a public JSON version of the project data

Modified:
    attic/site-jekyll/src/_plugins/postwrite.rb

Modified: attic/site-jekyll/src/_plugins/postwrite.rb
URL: 
http://svn.apache.org/viewvc/attic/site-jekyll/src/_plugins/postwrite.rb?rev=1830351&r1=1830350&r2=1830351&view=diff
==============================================================================
--- attic/site-jekyll/src/_plugins/postwrite.rb (original)
+++ attic/site-jekyll/src/_plugins/postwrite.rb Fri Apr 27 13:20:14 2018
@@ -2,8 +2,14 @@
 # This is run after the site has been written
 # Note that the dist/GHOST name is assumed to be the same as the project
 
+# The script also creates a JSON version of the input data for public 
consumption
+# The version omits details that are internal only.
+
+require 'json' 
+
 # Register this code to run in the site scope after the site has been written
 Jekyll::Hooks.register :site, :post_write do |site|
+  output=Array.new()
   site.data['projects'].each do |prj|
     project = prj['project']   
     if project # Not all entries correspond to a project
@@ -18,5 +24,25 @@ Jekyll::Hooks.register :site, :post_writ
         end
       end
     end
+    prout = Hash.new()
+    # Extract the useful keys
+    %W{name stem retired project subproject website mailnames dist scmURL 
issueURL wiki board description}.each do |k|
+      case k
+        when 'dist'
+          if prj[k]
+            if prj[k] == ''
+#              prout[k] = ''
+            else
+              prout[k] = "http://archive.apache.org/dist/#{prj[k]}";
+            end
+          end
+        # TODO any others need massaging?
+        else
+          prout[k] = prj[k] if prj[k]
+      end
+    end
+    output << prout
   end
+  puts site.dest
+  File.write(File.join(site.dest,'projects.json'), 
JSON.pretty_generate(output))
 end
\ No newline at end of file


Reply via email to