Revisão | cf84a71d7d35c704609d0f92502e183471bdecc7 (tree) |
---|---|
Hora | 2007-02-20 00:02:09 |
Autor | ikeji <ikeji@f836...> |
Commiter | ikeji |
custom_feed handling date and link
thx to moonrock
git-svn-id: http://dev.ikejima.org/src/svn/pragger/trunk@310 f8368ae4-1e99-dc11-9799-0018f35ab5fa
@@ -6,10 +6,10 @@ def custom_feed(config,data) | ||
6 | 6 | items = [] |
7 | 7 | data.each do |input| |
8 | 8 | body = "" |
9 | - pp(config['capture']) | |
10 | 9 | if(config['capture']) |
11 | - input =~ Regexp.new(config['capture'],Regexp::MULTILINE) | |
12 | - body = $1 | |
10 | + if input =~ Regexp.new(config['capture'],Regexp::MULTILINE) | |
11 | + body = $1 | |
12 | + end | |
13 | 13 | else |
14 | 14 | body = input |
15 | 15 | end |
@@ -26,16 +26,47 @@ def custom_feed(config,data) | ||
26 | 26 | if(config['title']) |
27 | 27 | title = Regexp.new(config['title']) |
28 | 28 | items.each do|i| |
29 | - i =~ title | |
30 | - mytitle = $1 | |
31 | - i.instance_eval do | |
32 | - @title = mytitle | |
33 | - def title | |
34 | - @title | |
29 | + if i =~ title | |
30 | + mytitle = $1 | |
31 | + i.instance_eval do | |
32 | + @title = mytitle | |
33 | + def title | |
34 | + @title | |
35 | + end | |
36 | + end | |
37 | + end | |
38 | + end | |
39 | + end | |
40 | + | |
41 | + if(config['date']) | |
42 | + date = Regexp.new(config['date']) | |
43 | + items.each do|i| | |
44 | + if i =~ date | |
45 | + mydate = Time.parse($1) | |
46 | + i.instance_eval do | |
47 | + @date = mydate | |
48 | + def date | |
49 | + @date | |
50 | + end | |
35 | 51 | end |
36 | 52 | end |
37 | 53 | end |
38 | 54 | end |
39 | 55 | |
56 | + if config['link'] and config['url'] | |
57 | + link = Regexp.new(config['link']) | |
58 | + items.each do|i| | |
59 | + if i =~ link | |
60 | + mylink = config['url'] ? (config['url'] + '#' + $1) : $1 | |
61 | + i.instance_eval do | |
62 | + @link = mylink | |
63 | + def link | |
64 | + @link | |
65 | + end | |
66 | + end | |
67 | + end | |
68 | + end | |
69 | + end | |
70 | + | |
40 | 71 | return items |
41 | 72 | end |