about summary refs log tree commit
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-12-14 09:00:39 +0000
committerEric Wong <e@80x24.org>2015-12-14 09:01:26 +0000
commitcbd58d1773cc19c20dca507831527a1742df4291 (patch)
tree042d0dfd84a80ee1442662ca9d02d9685f32a4cb
parent45cc4780b2d4fa38ba6f451a7fc2c9a731ca09f2 (diff)
downloaddtas-0.12.x-stable.tar.gz
This will hopefully allow readers to follow along
with developments more easily.
-rw-r--r--.gitignore1
-rw-r--r--Rakefile83
2 files changed, 72 insertions, 12 deletions
diff --git a/.gitignore b/.gitignore
index 0e9490e..211acee 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,7 @@
 /GIT-VERSION-FILE
 /Manifest.txt
 /NEWS
+/NEWS.atom
 /pkg
 /lib/dtas/version.rb
 /coverage.dump
diff --git a/Rakefile b/Rakefile
index 5fe5837..b94fee6 100644
--- a/Rakefile
+++ b/Rakefile
@@ -2,20 +2,37 @@
 # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
 require 'tempfile'
 include Rake::DSL
+
+def tags
+  timefmt = '%Y-%m-%dT%H:%M:%SZ'
+  @tags ||= `git tag -l --sort=-v:refname`.split(/\n/).map do |tag|
+    if %r{\Av[\d\.]+} =~ tag
+      header, subject, body = `git cat-file tag #{tag}`.split(/\n\n/, 3)
+      header = header.split(/\n/)
+      tagger = header.grep(/\Atagger /).first
+      {
+        time: Time.at(tagger.split(/ /)[-2].to_i).utc.strftime(timefmt),
+        tagger_name: %r{^tagger ([^<]+)}.match(tagger)[1].strip,
+        tagger_email: %r{<([^>]+)>}.match(tagger)[1].strip,
+        id: `git rev-parse refs/tags/#{tag}`.chomp!,
+        tag: tag,
+        subject: subject,
+        body: body,
+      }
+    end
+  end.compact.sort { |a,b| b[:time] <=> a[:time] }
+end
+
 task "NEWS" do
   latest = nil
   fp = Tempfile.new("NEWS", ".")
   fp.sync = true
-  `git tag -l --sort=-v:refname`.split(/\n/).each do |tag|
-    %r{\Av(.+)} =~ tag or next
-    version = $1
-    header, subject, body = `git cat-file tag #{tag}`.split(/\n\n/, 3)
-    header = header.split(/\n/)
-    tagger = header.grep(/\Atagger /)[0]
-    time = Time.at(tagger.split(/ /)[-2].to_i).utc
-    latest ||= time
-    date = time.strftime("%Y-%m-%d")
-    fp.puts "# #{version} / #{date}\n\n#{subject}"
+  tags.each do |tag|
+    version = tag[:tag].delete 'v'
+    fp.puts "# #{version} / #{tag[:time].split('T')[0]}"
+    fp.puts
+    fp.puts tag[:subject]
+    body = tag[:body]
     if body && body.strip.size > 0
       fp.puts "\n\n#{body}"
     end
@@ -29,12 +46,54 @@ task "NEWS" do
   assert_equal fp.read, File.read("NEWS") rescue nil
   fp.chmod 0644
   File.rename(fp.path, "NEWS")
+end
+
+desc 'prints news as an Atom feed'
+task 'NEWS.atom' do
+  require 'builder' # gem install builder
+  url_base = 'http://dtas.80x24.org/'
+  cgit_url = 'http://80x24.org/dtas.git/'
+  new_tags = tags[0,10]
+  x = Builder::XmlMarkup.new
+  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"
+    x.title "dtas news"
+    x.subtitle 'duct tape audio suite for *nix'
+    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
+        x.content(type: :xhtml) do
+          x.div(xmlns: 'http://www.w3.org/1999/xhtml') do
+            x.pre tag[:body]
+          end
+        end
+      end
+    end
+  end
+
+  fp = Tempfile.new(%w(NEWS .atom), ".")
+  fp.sync = true
+  fp.puts x.target!
+  fp.chmod 0644
+  File.rename fp.path, 'NEWS.atom'
   fp.close!
 end
 
-task rsync_docs: "NEWS" do
+task rsync_docs: %w(NEWS NEWS.atom) do
   dest = ENV["RSYNC_DEST"] || "80x24.org:/srv/dtas/"
-  top = %w(INSTALL NEWS README COPYING)
+  top = %w(INSTALL NEWS README COPYING NEWS.atom)
   files = []
 
   # git-set-file-times is distributed with rsync,