about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-09-18 03:16:51 -0700
committerEric Wong <normalperson@yhbt.net>2009-09-18 13:19:13 -0700
commitebcbbc995a86698c29ee4784abb540bf5a872945 (patch)
tree04481e752bfc998d23a693c6b4c642806c8b9b43
parent5af05213b6629b2d61435d10101c68305608c0d2 (diff)
downloadunicorn-ebcbbc995a86698c29ee4784abb540bf5a872945.tar.gz
The ChangeLog feed points to the cgit repository viewer
and the NEWS one is its own feed of tags.  Web 2.0 here
we come!
-rw-r--r--GNUmakefile14
-rw-r--r--Rakefile82
2 files changed, 78 insertions, 18 deletions
diff --git a/GNUmakefile b/GNUmakefile
index d21d974..b6f340c 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -141,7 +141,7 @@ man:
         $(RM) $@+
 
 NEWS: GIT-VERSION-FILE
-        $(rake) -s history > $@+
+        $(rake) -s news_rdoc > $@+
         mv $@+ $@
 
 ChangeLog: GIT-VERSION-FILE
@@ -150,6 +150,11 @@ ChangeLog: GIT-VERSION-FILE
         git log | sed -e 's/^/    /' >> $@+
         mv $@+ $@
 
+news_atom := http://unicorn.bogomips.org/NEWS.atom.xml
+cgit_atom := http://git.bogomips.org/cgit/unicorn.git/atom/?h=master
+atom = <link rel="alternate" title="Atom feed" href="$(1)" \
+             type="application/atom+xml"/>
+
 # using rdoc 2.4.1+
 doc: .document $(ext)/unicorn_http.c NEWS ChangeLog
         > unicorn.1 && > unicorn_rails.1
@@ -159,6 +164,13 @@ doc: .document $(ext)/unicorn_http.c NEWS ChangeLog
         cd doc && for i in unicorn unicorn_rails; do \
           sed -e '/"documentation">/r man1/'$$i'.1.html' \
                 < $${i}_1.html > tmp && mv tmp $${i}_1.html; done
+        $(ruby) -i -p -e \
+          '$$_.gsub!("</title>",%q{\&$(call atom,$(cgit_atom))})' \
+          doc/ChangeLog.html
+        $(ruby) -i -p -e \
+          '$$_.gsub!("</title>",%q{\&$(call atom,$(news_atom))})' \
+          doc/NEWS.html doc/README.html
+        $(rake) -s news_atom > doc/NEWS.atom.xml
         cd doc && ln README.html tmp && mv tmp index.html
         $(RM) unicorn.1 unicorn_rails.1
 
diff --git a/Rakefile b/Rakefile
index 27e750a..16bcb6b 100644
--- a/Rakefile
+++ b/Rakefile
@@ -2,29 +2,77 @@
 
 # most tasks are in the GNUmakefile which offers better parallelism
 
-desc 'prints RDoc-formatted history'
-task :history do
-  tags = `git tag -l`.split(/\n/).grep(/^v[\d\.]+$/).reverse
-  timefmt = '%Y-%m-%d %H:%M UTC'
-
-  old_summaries = File.readlines(".CHANGELOG.old").inject({}) do |hash, line|
+def old_summaries
+  @old_summaries ||= File.readlines(".CHANGELOG.old").inject({}) do |hash, line|
     version, summary = line.split(/ - /, 2)
     hash[version] = summary
     hash
   end
+end
 
-  tags.each do |tag|
-    header, subject, body = `git cat-file tag #{tag}`.split(/\n\n/, 3)
-    tagger = header.split(/\n/).grep(/^tagger /).first.split(/\s/)
-    time = Time.at(tagger[-2].to_i).utc
-    puts "=== #{tag.sub(/^v/, '')} / #{time.strftime(timefmt)}"
-    puts ""
+def tags
+  timefmt = '%Y-%m-%dT%H:%M:%SZ'
+  @tags ||= `git tag -l`.split(/\n/).map do |tag|
+    next if tag == "v0.0.0"
+    if %r{\Av[\d\.]+\z} =~ tag
+      header, subject, body = `git cat-file tag #{tag}`.split(/\n\n/, 3)
+      header = header.split(/\n/)
+      tagger = header.grep(/\Atagger /).first
+      body ||= "initial"
+      {
+        :time => Time.at(tagger.split(/ /)[-2].to_i).utc.strftime(timefmt),
+        :tagger_name => %r{^tagger ([^<]+)}.match(tagger)[1],
+        :tagger_email => %r{<([^>]+)>}.match(tagger)[1],
+        :id => `git rev-parse refs/tags/#{tag}`.chomp!,
+        :tag => tag,
+        :subject => subject,
+        :body => (old = old_summaries[tag]) ? "#{old}\n#{body}" : body,
+      }
+    end
+  end.compact.sort { |a,b| b[:time] <=> a[:time] }
+end
 
-    if old_summary = old_summaries[tag]
-      print "  #{old_summary}\n"
+cgit_url = "http://git.bogomips.org/cgit/unicorn.git"
+
+desc 'prints news as an Atom feed'
+task :news_atom do
+  require 'nokogiri'
+  puts(Nokogiri::XML::Builder.new do
+    feed :xmlns => "http://www.w3.org/2005/Atom" do
+      id! "http://unicorn.bogomips.org/NEWS.atom.xml"
+      title "Unicorn news"
+      subtitle "Rack HTTP server for Unix and fast clients"
+      link! :rel => 'alternate', :type => 'text/html',
+            :href => 'http://unicorn.bogomips.org/NEWS.html'
+      updated tags.first[:time]
+      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
+          content(:type => 'text') { tag[:body] }
+        end
+      end
     end
+  end.to_xml)
+end
+
+desc 'prints RDoc-formatted news'
+task :news_rdoc do
+  tags.each do |tag|
+    time = tag[:time].tr!('T', ' ').gsub!(/:\d\dZ/, ' UTC')
+    puts "=== #{tag[:tag].sub(/^v/, '')} / #{time}"
+    puts ""
 
-    puts body ? body.gsub(/^/sm, "  ").gsub(/[ \t]+$/sm, "") : "  initial"
+    body = tag[:body]
+    puts tag[:body].gsub(/^/sm, "  ").gsub!(/[ \t]+$/sm, "")
     puts ""
   end
 end
@@ -33,8 +81,8 @@ desc "print release changelog for Rubyforge"
 task :release_changes do
   version = ENV['VERSION'] or abort "VERSION= needed"
   version = "v#{version}"
-  tags = `git tag -l`.split(/\n/)
-  prev = tags[tags.index(version) - 1]
+  vtags = tags.map { |tag| tag[:tag] =~ /\Av/ and tag[:tag] }.sort
+  prev = vtags[vtags.index(version) - 1]
   system('git', 'diff', '--stat', prev, version) or abort $?
   puts ""
   system('git', 'log', "#{prev}..#{version}") or abort $?