Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 193
- Log:
First stage commit of Typo 4.1, modified for the ROOL site.
Includes all local modifications but a final pass needs to be
made to delete any files left over from earlier Typo versions
that shouldn't be here anymore. See the 'tags' section of the
repository for a clean Typo 4.1 tree.Note that symlinks to shared files in the RISC OS Open theme
directory have been deliberately included this time around; I
decided that on balance it was better to leave them in as
placeholders, since unlike symlinks in app/views/shared, the
Typo theme structure is not a standard Rails concept.
- Author:
- rool
- Date:
- Wed Apr 04 18:51:02 +0100 2007
- Size:
- 2077 Bytes
1 | require 'open-uri' |
2 | require 'time' |
3 | require 'rexml/document' |
4 | |
5 | # Example: |
6 | # |
7 | # magnolia = MagnoliaAggregation.new('http://ma.gnolia.com/rss/full/people/steve.longdo/') |
8 | # magnolia.pics.each do |pic| |
9 | # puts "#{pic.title} @ #{pic.link} updated at #{pic.date}" |
10 | # end |
11 | # |
12 | class MagnoliaAggregation |
13 | include REXML |
14 | |
15 | def choose(num) |
16 | return pics unless pics.size > num |
17 | bag = [] |
18 | set = pics.dup |
19 | num.times {|x| bag << set.delete_at(rand(set.size))} |
20 | bag |
21 | end |
22 | |
23 | attr_accessor :url, :pics, :link, :title, :description |
24 | |
25 | # This object holds given information of a picture |
26 | class Picture |
27 | attr_accessor :link, :title, :date, :description, :image |
28 | |
29 | def to_s |
30 | title |
31 | end |
32 | |
33 | def date=(value) |
34 | @date = Time.parse(value) |
35 | end |
36 | |
37 | def image |
38 | begin |
39 | CGI.unescapeHTML(description.scan( /(http:\/\/(scst.srv.girafa.com).*\")/ ).first.first).chomp('"') |
40 | rescue Exception => e |
41 | p e |
42 | nil |
43 | end |
44 | end |
45 | end |
46 | |
47 | def initialize(url, refresh = true) |
48 | self.pics = [] |
49 | self.url = url |
50 | self.refresh if refresh |
51 | end |
52 | |
53 | def refresh |
54 | open(@url) do |http| |
55 | parse(http.read) |
56 | end |
57 | end |
58 | |
59 | private |
60 | |
61 | def parse(body) |
62 | # Not checking filesize here yet. Just looking for the not found condition... |
63 | xml = Document.new(body) |
64 | |
65 | self.pics = [] |
66 | self.link = XPath.match(xml, "//channel/link/text()").to_s |
67 | self.title = XPath.match(xml, "//channel/title/text()").to_s |
68 | self.description = XPath.match(xml, "//channel/description/text()").to_s |
69 | |
70 | XPath.each(xml, "//item/") do |elem| |
71 | picture = Picture.new |
72 | picture.title = XPath.match(elem, "title/text()").to_s |
73 | picture.date = XPath.match(elem, "pubDate/text()").to_s |
74 | picture.link = XPath.match(elem, "link/text()").to_s |
75 | picture.description = XPath.match(elem, "description/text()").to_s |
76 | pics << picture unless picture.image.nil? || picture.image.match(/not found/) |
77 | end |
78 | end |
79 | end |
80 | |
81 |