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:
- 1899 Bytes
1 | require 'open-uri' |
2 | require 'time' |
3 | require 'rexml/document' |
4 | |
5 | # Example: |
6 | # |
7 | # tada = Tada.new('http://<nick>.tadalist.com/lists/feed/<id>?token=<token>') |
8 | # tada.tasks.each do |task| |
9 | # puts "#{task.title} @ #{task.link} updated at #{task.date}" |
10 | # end |
11 | # |
12 | class Tada |
13 | include REXML |
14 | |
15 | attr_accessor :url, :tasks, :link, :title, :description |
16 | |
17 | # This object holds given information of a task |
18 | class TaskItem < Struct.new(:link, :title, :date, :status) |
19 | def to_s; title end |
20 | def date=(value); super(Time.parse(value)) end |
21 | end |
22 | |
23 | # Pass the url to the RSS feed you would like to keep tabs on |
24 | # by default this will request the rss from the server right away and |
25 | # fill the tasks array def initialize(url, refresh = true) |
26 | def initialize(url, refresh = true) |
27 | self.tasks = [] |
28 | self.url = url |
29 | self.refresh if refresh |
30 | end |
31 | |
32 | # This method lets you refresh the tasks int the tasks array |
33 | # useful if you keep the object cached in memory and |
34 | def refresh |
35 | open(@url) do |http| |
36 | parse(http.read) |
37 | end |
38 | end |
39 | |
40 | private |
41 | |
42 | def parse(body) |
43 | |
44 | xml = Document.new(body) |
45 | |
46 | self.tasks = [] |
47 | self.link = XPath.match(xml, "//channel/link/text()") |
48 | self.title = XPath.match(xml, "//channel/title/text()") |
49 | self.description = XPath.match(xml, "//channel/description/text()") |
50 | |
51 | XPath.each(xml, "//item/") do |elem| |
52 | |
53 | title = XPath.match(elem, "title/text()").to_s |
54 | |
55 | # extract the status from the title |
56 | status = if title =~ /^(.+): (.+)$/ |
57 | title = $2 |
58 | $1.downcase.intern |
59 | else |
60 | :unknown |
61 | end |
62 | |
63 | task = TaskItem.new |
64 | task.title = title |
65 | task.status = status |
66 | |
67 | task.date = XPath.match(elem, "pubDate/text()").to_s |
68 | task.link = XPath.match(elem, "link/text()").to_s |
69 | |
70 | tasks << task |
71 | end |
72 | |
73 | self.tasks = tasks.sort_by { |task| task.status.to_s } |
74 | end |
75 | end |