aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xatom.cgi98
-rwxr-xr-xatom_single.rb47
-rw-r--r--bzr.rb9
-rwxr-xr-xindex.cgi2
4 files changed, 88 insertions, 68 deletions
diff --git a/atom.cgi b/atom.cgi
index 6a929f4..ef3f626 100755
--- a/atom.cgi
+++ b/atom.cgi
@@ -11,78 +11,42 @@ require "atom"
require "yaml"
require "cgi"
require "time"
+load "config.rb"
$cgi = CGI.new
-def readhistory dir
- log = `export LC_ALL=de_DE.UTF-8; bzr log -r -10.. "#{dir}"`.split("-"*60)
- log.collect!{|s| s.scan(/\nrevno: (.*)\ncommitter.*\n.*\ntimestamp: (.*)\nmessage:\n (.*)/).flatten}
- log.shift
- log.collect!{|r,t,c| [r.to_i,Time.parse(t),c]}
-end
-
feed = Atom::Feed.new
-if File.exist?("data.yaml")
- olddir = File.expand_path(".")
- Dir.chdir("..")
- load "config.rb"
- require "poll"
- require "datepoll"
- require "timepoll"
- Dir.chdir(olddir)
-
- poll = YAML::load_file("data.yaml")
-
- feed.title = poll.name
- feed.id = "urn:dudle:#{poll.class}:#{poll.name}"
- feed.updated = File.new("data.yaml").mtime
- feed.authors << Atom::Person.new(:name => 'dudle automatic notificator')
- feed.links << Atom::Link.new(:href => SITEURL + "atom.cgi", :rel => "self")
-
- log = readhistory "."
- log.each {|rev,time,comment|
- feed.entries << Atom::Entry.new do |e|
- e.title = comment
- e.links << Atom::Link.new(:href => "#{SITEURL}?revision=#{rev}")
- e.id = "urn:#{poll.class}:#{poll.name}:rev=#{rev}"
- e.updated = time
+load "config.rb"
+require "poll"
+require "datepoll"
+require "timepoll"
+feed.title = "dudle"
+feed.id = "urn:dudle:main"
+feed.authors << Atom::Person.new(:name => 'dudle automatic notificator')
+feed.links << Atom::Link.new(:href => SITEURL + "atom.cgi", :rel => "self")
+
+Dir.glob("*/data.yaml").sort_by{|f|
+ File.new(f).mtime
+}.reverse.collect{|f|
+ f.gsub(/\/data\.yaml$/,'')
+}.each{|site|
+ unless YAML::load_file("#{site}/data.yaml" ).hidden
+ unless defined?(firstround)
+ firstround = false
+ feed.updated = File.new("#{site}/data.yaml").mtime
end
- }
-
-else
- load "config.rb"
- require "poll"
- require "datepoll"
- require "timepoll"
- feed.title = "dudle"
- feed.id = "urn:dudle:main"
- feed.authors << Atom::Person.new(:name => 'dudle automatic notificator')
- feed.links << Atom::Link.new(:href => SITEURL + "atom.cgi", :rel => "self")
-
- Dir.glob("*/data.yaml").sort_by{|f|
- File.new(f).mtime
- }.reverse.collect{|f|
- f.gsub(/\/data\.yaml$/,'')
- }.each{|site|
- unless YAML::load_file("#{site}/data.yaml" ).hidden
- unless defined?(firstround)
- firstround = false
- feed.updated = File.new("#{site}/data.yaml").mtime
+
+ log = VCS.longhistory(site)
+ log.each {|rev,time,comment|
+ feed.entries << Atom::Entry.new do |e|
+ e.title = site
+ e.summary = comment
+ e.links << Atom::Link.new(:href => "#{SITEURL}#{site}/?revision=#{rev}")
+ e.id = "urn:dudle:main:#{site}:rev=#{rev}"
+ e.updated = time
end
-
- log = readhistory(site)
- log.each {|rev,time,comment|
- feed.entries << Atom::Entry.new do |e|
- e.title = site
- e.summary = comment
- e.links << Atom::Link.new(:href => "#{SITEURL}#{site}/?revision=#{rev}")
- e.id = "urn:dudle:main:#{site}:rev=#{rev}"
- e.updated = time
- end
- }
- end
- }
-
-end
+ }
+ end
+}
$cgi.out("type" => "application/atom+xml"){ feed.to_xml }
diff --git a/atom_single.rb b/atom_single.rb
new file mode 100755
index 0000000..557c4b0
--- /dev/null
+++ b/atom_single.rb
@@ -0,0 +1,47 @@
+#!/usr/bin/env ruby
+
+################################
+# Author: Benjamin Kellermann #
+# Licence: CC-by-sa 3.0 #
+# see Licence #
+################################
+
+require "rubygems"
+require "atom"
+require "yaml"
+require "cgi"
+require "time"
+load "config.rb"
+
+$cgi = CGI.new
+
+
+feed = Atom::Feed.new
+olddir = File.expand_path(".")
+Dir.chdir("..")
+load "config.rb"
+require "poll"
+require "datepoll"
+require "timepoll"
+Dir.chdir(olddir)
+
+poll = YAML::load_file("data.yaml")
+
+feed.title = poll.name
+feed.id = "urn:dudle:#{poll.class}:#{poll.name}"
+feed.updated = File.new("data.yaml").mtime
+feed.authors << Atom::Person.new(:name => 'dudle automatic notificator')
+feed.links << Atom::Link.new(:href => SITEURL + "atom.cgi", :rel => "self")
+
+log = VCS.longhistory "."
+log.each {|rev,time,comment|
+ feed.entries << Atom::Entry.new do |e|
+ e.title = comment
+ e.links << Atom::Link.new(:href => "#{SITEURL}?revision=#{rev}")
+ e.id = "urn:#{poll.class}:#{poll.name}:rev=#{rev}"
+ e.updated = time
+ end
+}
+
+
+$cgi.out("type" => "application/atom+xml"){ feed.to_xml }
diff --git a/bzr.rb b/bzr.rb
index 8f74edb..80ed128 100644
--- a/bzr.rb
+++ b/bzr.rb
@@ -1,4 +1,6 @@
BZRCMD="export LC_ALL=de_DE.UTF-8; bzr"
+require "time"
+
class VCS
def VCS.init
`#{BZRCMD} init`
@@ -19,6 +21,13 @@ class VCS
def VCS.history
`#{BZRCMD} log --forward`.split("-"*60)
end
+
+ def VCS.longhistory dir
+ log = `#{BZRCMD} log -r -10.. "#{dir}"`.split("-"*60)
+ log.collect!{|s| s.scan(/\nrevno: (.*)\ncommitter.*\n.*\ntimestamp: (.*)\nmessage:\n (.*)/).flatten}
+ log.shift
+ log.collect!{|r,t,c| [r.to_i,Time.parse(t),c]}
+ end
def VCS.commit comment
tmpfile = "/tmp/commitcomment.#{rand(10000)}"
diff --git a/index.cgi b/index.cgi
index 682a742..bccf86e 100755
--- a/index.cgi
+++ b/index.cgi
@@ -47,7 +47,7 @@ if $cgi.include?("create_poll")
Dir.chdir(SITE)
VCS.init
File.symlink("../participate.rb","index.cgi")
- File.symlink("../atom.cgi","atom.cgi")
+ File.symlink("../atom_single.rb","atom.cgi")
File.symlink("../config.cgi","config.cgi")
File.open("data.yaml","w").close
VCS.add("data.yaml")