From dc55a5b5bdd60850553ebf01adfe357d2a2a68b8 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 28 Jul 2015 20:58:49 +0000 Subject: doc: use "builder" RubyGem to generate Atom feed Nokogiri takes too long to build and install due to the C extension and bundled library. Prefer a widely-used pure-Ruby gem instead. --- HACKING | 4 ++-- Rakefile | 54 +++++++++++++++++++++++++++--------------------------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/HACKING b/HACKING index 47c73aa..caa9708 100644 --- a/HACKING +++ b/HACKING @@ -33,8 +33,8 @@ Additional development tools we use: * valgrind - http://valgrind.org/ * sparse - https://sparse.wiki.kernel.org/ -We also use Rake for pre-release checks, generating ChangeLog -and NEWS documentation, and Nokogiri for generating the Atom +We also use Rake for pre-release checks, generating ChangeLog and NEWS +documentation, and the "builder" RubyGem for generating the Atom feed for our website. Hack away! diff --git a/Rakefile b/Rakefile index 6552411..be3564b 100644 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,6 @@ # this is only used for release-related tasks and should not # be needed by normal development -require "nokogiri" # gem install nokogiri include Rake::DSL if defined?(Rake::DSL) url_base = "http://bogomips.org/cmogstored" @@ -31,35 +30,36 @@ end desc 'prints news as an Atom feed' task :news_atom do - require 'nokogiri' + require 'builder' # gem install builder new_tags = tags[0,10] - puts(Nokogiri::XML::Builder.new do - feed :xmlns => "http://www.w3.org/2005/Atom" do - id! "#{url_base}/NEWS.atom.xml" - title "cmogstored news" - subtitle "alternative mogstored implementation for MogileFS" - link! :rel => 'alternate', :type => 'text/plain', - :href => "#{url_base}/NEWS" - updated(new_tags.empty? ? "1970-01-01T00:00:00Z" : new_tags.first[:time]) - new_tags.each do |tag| - entry do - title tag[:subject] - updated tag[:time] - published tag[:time] - author { - name tag[:tagger_name] - email tag[:tagger_email] - } - url = "#{cgit_url}/tag/?id=#{tag[:tag]}" - link! :rel => "alternate", :type => "text/html", :href =>url - id! url - message_only = tag[:body].split(/\n.+\(\d+\):\n {6}/).first.strip - content({:type =>:text}, message_only) - content(:type =>:xhtml) { pre tag[:body] } - end + x = Builder::XmlMarkup.new(:indent => 2) + x.instruct! :xml, :encoding => 'UTF-8', :version => '1.0' + x.feed(:xmlns => "http://www.w3.org/2005/Atom") do + x.id "#{url_base}/NEWS.atom.xml" + x.title "cmogstored news" + x.subtitle "alternative mogstored implementation for MogileFS" + x.link :rel => 'alternate', :type => 'text/plain', + :href => "#{url_base}/NEWS" + x.updated(new_tags.empty? ? "1970-01-01T00:00:00Z" : new_tags.first[:time]) + new_tags.each do |tag| + x.entry do + x.title tag[:subject] + x.updated tag[:time] + x.published tag[:time] + x.author { + x.name tag[:tagger_name] + x.email tag[:tagger_email] + } + url = "#{cgit_url}/tag/?id=#{tag[:tag]}" + x.link :rel => "alternate", :type => "text/html", :href =>url + x.id url + message_only = tag[:body].split(/\n.+\(\d+\):\n {6}/).first.strip + x.content({:type =>:text}, message_only) + x.content(:type =>:xhtml) { x.pre tag[:body] } end end - end.to_xml) + end + puts x.target! end desc 'prints news as a text file' -- cgit v1.2.3-24-ge0c7