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:
- 2157 Bytes
1 | require 'open-uri' |
2 | require 'time' |
3 | require 'rexml/document' |
4 | |
5 | # Example: |
6 | # |
7 | # flickr = Flickr.new('http://www.flickr.com/services/feeds/photos_public.gne?id=40235412@N00&format=rss_200') |
8 | # flickr.pics.each do |pic| |
9 | # puts "#{pic.title} @ #{pic.link} updated at #{pic.date}" |
10 | # end |
11 | # |
12 | class FlickrAggregation |
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 |
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 | description.scan( /(http:\/\/(farm1|farm2|static|photos).*?\.jpg)/ ).first.first |
39 | end |
40 | def thumb |
41 | image.gsub( /\_m\./, '_t.' ) |
42 | end |
43 | def square |
44 | image.gsub( /\_m\./, '_s.' ) |
45 | end |
46 | end |
47 | |
48 | # Pass the url to the RSS feed you would like to keep tabs on |
49 | # by default this will request the rss from the server right away and |
50 | # fill the tasks array |
51 | def initialize(url, refresh = true) |
52 | self.pics = [] |
53 | self.url = url |
54 | self.refresh if refresh |
55 | end |
56 | |
57 | # This method lets you refresh the tasks int the tasks array |
58 | # useful if you keep the object cached in memory and |
59 | def refresh |
60 | open(@url) do |http| |
61 | parse(http.read) |
62 | end |
63 | end |
64 | |
65 | private |
66 | |
67 | def parse(body) |
68 | |
69 | xml = Document.new(body) |
70 | |
71 | self.pics = [] |
72 | self.link = XPath.match(xml, "//channel/link/text()").to_s |
73 | self.title = XPath.match(xml, "//channel/title/text()").to_s |
74 | self.description = XPath.match(xml, "//channel/description/text()").to_s |
75 | |
76 | XPath.each(xml, "//item/") do |elem| |
77 | |
78 | picture = Picture.new |
79 | picture.title = XPath.match(elem, "title/text()").to_s |
80 | picture.date = XPath.match(elem, "pubDate/text()").to_s |
81 | picture.link = XPath.match(elem, "link/text()").to_s |
82 | picture.description = XPath.match(elem, "description/text()").to_s |
83 | |
84 | pics << picture |
85 | end |
86 | end |
87 | end |
88 | |
89 |