mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Simple offline atom generator for tracking site changes.
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@427 19e92222-5c0b-0410-8929-a290d50e31e9
This commit is contained in:
parent
fb5ab504ae
commit
4cc2cb7c59
1 changed files with 86 additions and 0 deletions
86
doc/site/atom.rb
Normal file
86
doc/site/atom.rb
Normal file
|
@ -0,0 +1,86 @@
|
|||
require 'rubygems'
|
||||
require 'atom/collection'
|
||||
require 'find'
|
||||
require 'yaml'
|
||||
require 'redcloth'
|
||||
|
||||
$site ="http://mongrel.rubyforge.org/"
|
||||
|
||||
zed = Atom::Author.new
|
||||
zed.name = "Zed A. Shaw"
|
||||
zed.uri = $site
|
||||
zed.email = "zedNOSPAMshaw A-T zedNOSPAMshaw.com"
|
||||
|
||||
|
||||
f = Atom::Feed.new
|
||||
f.id = $site
|
||||
f.authors << zed
|
||||
|
||||
link = Atom::Link.new
|
||||
link["href"] = $site + "/feed.atom"
|
||||
link["rel"] = "self"
|
||||
f.links << link
|
||||
link = Atom::Link.new
|
||||
link["href"] = $site
|
||||
link["rel"] = "via"
|
||||
f.links << link
|
||||
|
||||
f.title = "Mongrel Web Server"
|
||||
f.subtitle = "Faster Is Possible"
|
||||
f.updated = Time.now
|
||||
f.generator = "atom-tools"
|
||||
f.rights = "Copyright Zed A. Shaw with contributors. All rights reserved."
|
||||
|
||||
class Page
|
||||
attr_accessor :path
|
||||
attr_accessor :stat
|
||||
attr_accessor :uri
|
||||
attr_accessor :info
|
||||
|
||||
def initialize(path)
|
||||
@path = path
|
||||
@stat = File.stat(path)
|
||||
@uri = $site + path.match(/^src(.*)\.page/)[1] + ".html"
|
||||
@info = YAML.load_file(path)
|
||||
end
|
||||
|
||||
def <=>(other)
|
||||
other.stat.mtime <=> self.stat.mtime
|
||||
end
|
||||
|
||||
def to_html
|
||||
if not @html
|
||||
content = open(path) { |f| f.read(1024) }
|
||||
content.gsub!(/^---.*---/m,"")
|
||||
content = content + "...\n\"Read more\":#{uri}"
|
||||
r = RedCloth.new(content)
|
||||
@html = r.to_html
|
||||
end
|
||||
|
||||
@html
|
||||
end
|
||||
end
|
||||
|
||||
pages = []
|
||||
|
||||
Find.find("src") do |path|
|
||||
if /.page$/ === path and !path.index("index.page") and not /src\/[a-z]*\.page/ === path
|
||||
pages << Page.new(path)
|
||||
end
|
||||
end
|
||||
|
||||
pages.sort!
|
||||
|
||||
pages[0 .. 30].each do |p|
|
||||
e = Atom::Entry.new
|
||||
e.id = p.uri
|
||||
e.title = p.info["title"]
|
||||
link = Atom::Link.new
|
||||
link["href"] = p.uri
|
||||
e.links << link
|
||||
e.updated = p.stat.mtime
|
||||
f.entries << e
|
||||
end
|
||||
|
||||
|
||||
puts f.to_s
|
Loading…
Reference in a new issue