blob: 612d64cb138098ae9391011101e44e8f0f056d16 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
#!/usr/bin/env ruby
################################
# Author: Benjamin Kellermann #
# Licence: CC-by-sa 3.0 #
# see Licence #
################################
require "rubygems"
require "atom"
require "yaml"
require "cgi"
$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,DateTime.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"
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
end
}
else
load "config.rb"
require "poll"
require "datepoll"
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
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
$cgi.out("type" => "application/atom+xml"){ feed.to_xml }
|