* [PATCH] doc: use "builder" RubyGem to generate Atom feed
@ 2015-07-28 21:13 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2015-07-28 21:13 UTC (permalink / raw)
To: cmogstored-public; +Cc: Eric Wong
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'
--
EW
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2015-07-28 21:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-28 21:13 [PATCH] doc: use "builder" RubyGem to generate Atom feed Eric Wong
Code repositories for project(s) associated with this public inbox
https://yhbt.net/cmogstored.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).