td2planet 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,37 @@
1
+ 2009-10-29 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
2
+
3
+ * td2planet.gemspec: add description.
4
+
5
+ 2009-10-28 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
6
+
7
+ * lib/td2planet/version.rb: bump up version.
8
+
9
+ * README, README.ja: update copyright year.
10
+
11
+ * lib/td2planet/*.rb: update copyright year. remove #-- and #++.
12
+
13
+ * README: update description. thanks debian-l10n-english ML.
14
+ http://lists.debian.org/debian-l10n-english/2007/06/msg00123.html
15
+
16
+ 2009-10-28 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
17
+
18
+ * lib/td2planet/formatter.rb: ignore error of URI.parse.
19
+ see http://bugs.debian.org/552186
20
+
21
+ 2009-10-28 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
22
+
23
+ * lib/td2planet/fetcher.rb: add User-Agent.
24
+
25
+ * lib/td2planet/fetcher.rb, lib/td2planet/formatter.rb,
26
+ data/td2planet/templates/day.rhtml,
27
+ data/td2planet/templates/footer.rhtml,
28
+ data/td2planet/templates/opml.rxml: allow missing properties.
29
+
30
+ 2007-06-05 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
31
+
32
+ * lib/td2planet/fetcher.rb (TD2Planet::Fetcher#fetch_all_rss):
33
+ do not stop when exception.
34
+
1
35
  2007-02-22 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
2
36
 
3
37
  * Initial public release.
data/README CHANGED
@@ -1,7 +1,9 @@
1
- = TD2Planet
2
- This is a planet implementation of ruby, mainly for tdiary.
1
+ = TD2Planet - Ruby-based server-side blog aggregator
3
2
 
4
- See http://www.planetplanet.org about planet.
3
+ This package is a server-side blog aggregator (commonly called a
4
+ 'planet') which is well-suited for aggregating tDiary-based blogs.
5
+
6
+ See http://www.planetplanet.org about 'planet'.
5
7
 
6
8
  == Install
7
9
  === Install using setup.rb
@@ -56,7 +58,7 @@ After customize, run "td2planet.rb -n config.yaml" to update output files.
56
58
  setup.rb:: GNU LGPL
57
59
  other files:: MIT-LICENSE
58
60
 
59
- Copyright (c) 2006, 2007 Kazuhiro NISHIYAMA
61
+ Copyright (c) 2006, 2007, 2009 Kazuhiro NISHIYAMA
60
62
 
61
63
  --
62
64
  # -*- coding: utf-8 -*-
data/README.ja CHANGED
@@ -59,7 +59,7 @@ output_htmlで指定したファイルには元のRSSのcontent:encodedの内容
59
59
  setup.rb:: GNU LGPL
60
60
  other files:: MIT-LICENSE
61
61
 
62
- Copyright (c) 2006, 2007 Kazuhiro NISHIYAMA
62
+ Copyright (c) 2006, 2007, 2009 Kazuhiro NISHIYAMA
63
63
 
64
64
  --
65
65
  # -*- coding: utf-8 -*-
data/bin/td2planet.rb CHANGED
File without changes
@@ -8,7 +8,7 @@
8
8
  <% else -%>
9
9
  <%=hk rss.channel.title %>
10
10
  <% end -%>
11
- <% if rss.channel.dc_creator -%>
11
+ <% if rss.channel.respond_to?(:dc_creator) && rss.channel.dc_creator -%>
12
12
  (<%=hk rss.channel.dc_creator %>)
13
13
  <% end -%>
14
14
  </span>
@@ -18,7 +18,7 @@
18
18
  <%= section(item, rss) -%>
19
19
  <% end -%>
20
20
  </div>
21
- <% if /./ =~ rss.channel.dc_rights.to_s -%>
21
+ <% if rss.channel.respond_to?(:dc_rights) && /./ =~ rss.channel.dc_rights.to_s -%>
22
22
  <div class="comment">
23
23
  <!--<div class="caption"></div>-->
24
24
  <div class="commentshort">
@@ -6,10 +6,12 @@
6
6
  <div class="block">
7
7
  <h3>Subscriptions</h3>
8
8
  <ul>
9
- <% @rss_list.sort_by{|rss| -rss.item.date.to_i }.each do |rss| -%>
9
+ <% @rss_list.sort_by{|rss| rss.respond_to?(:item) && rss.item.respond_to?(:date) ? -rss.item.date.to_i : 0 }.each do |rss| -%>
10
10
  <li>
11
11
  <a href="<%=hk rss.channel.link %>" title="<%=hk rss.channel.description %>"><%=hk rss.channel.title %></a>
12
+ <%- if rss.channel.respond_to?(:about) -%>
12
13
  <a href="<%=hk rss.channel.about %>">(feed)</a>
14
+ <%- end -%>
13
15
  </li>
14
16
  <% end -%>
15
17
  </ul>
@@ -12,7 +12,7 @@
12
12
  <% end -%>
13
13
  </head>
14
14
  <body>
15
- <% rss_list.sort_by{|rss| -rss.item.date.to_i }.each do |rss| -%>
15
+ <% rss_list.sort_by{|rss| rss.respond_to?(:item) && rss.item.respond_to?(:date) ? -rss.item.date.to_i : 0 }.each do |rss| -%>
16
16
  <outline text="<%=hk rss.channel.title %>" type="link" xmlUrl="<%=hk rss.channel.link %>"/>
17
17
  <% end -%>
18
18
  </body>
@@ -1,9 +1,7 @@
1
- #--
2
1
  # -*- mode: ruby; coding: utf-8 -*-
3
2
  # vim: set filetype=ruby ts=2 sw=2 sts=2 fenc=utf-8:
4
3
  #
5
- # copyright (c) 2006, 2007 Kazuhiro NISHIYAMA
6
- #++
4
+ # copyright (c) 2006, 2007, 2009 Kazuhiro NISHIYAMA
7
5
 
8
6
  require 'td2planet/formatter'
9
7
 
@@ -1,9 +1,7 @@
1
- #--
2
1
  # -*- mode: ruby; coding: utf-8 -*-
3
2
  # vim: set filetype=ruby ts=2 sw=2 sts=2 fenc=utf-8:
4
3
  #
5
- # copyright (c) 2006, 2007 Kazuhiro NISHIYAMA
6
- #++
4
+ # copyright (c) 2006, 2007, 2009 Kazuhiro NISHIYAMA
7
5
 
8
6
  require 'erb'
9
7
  require 'pathname'
@@ -12,12 +10,13 @@ require 'uri'
12
10
 
13
11
  module TD2Planet
14
12
  class Fetcher
15
- def initialize(cache_dir, dry_run=false)
13
+ def initialize(cache_dir, dry_run=false, user_agent="td2planet")
16
14
  @cache_dir = Pathname.new(cache_dir)
17
15
  unless @cache_dir.exist?
18
16
  @cache_dir.mkdir
19
17
  end
20
18
  @dry_run = dry_run
19
+ @user_agent = user_agent
21
20
  end
22
21
 
23
22
  def fetch_all_rss(uris)
@@ -31,14 +30,14 @@ module TD2Planet
31
30
  text = nil
32
31
  begin
33
32
  puts "fetch: #{uri}"
34
- text = URI.parse(uri).read
33
+ text = URI.parse(uri).read("User-Agent" => @user_agent)
35
34
  rescue Timeout::Error
36
35
  # fallback
37
36
  puts "ERROR: timeout #{uri}"
38
37
  text = cache_file.read
39
38
  rescue Exception
40
39
  puts "ERROR: #{$!} (#{$!.class}) on #{uri}"
41
- raise
40
+ next
42
41
  else
43
42
  if text.status[0] == '200' && /rss/ =~ text
44
43
  cache_file.open('wb'){|f| f.write(text) }
@@ -1,9 +1,7 @@
1
- #--
2
1
  # -*- mode: ruby; coding: utf-8 -*-
3
2
  # vim: set filetype=ruby ts=2 sw=2 sts=2 fenc=utf-8:
4
3
  #
5
- # copyright (c) 2006, 2007 Kazuhiro NISHIYAMA
6
- #++
4
+ # copyright (c) 2006, 2007, 2009 Kazuhiro NISHIYAMA
7
5
 
8
6
  require 'erb'
9
7
  require 'nkf'
@@ -28,7 +26,7 @@ module TD2Planet
28
26
  def_erb_method('footer()')
29
27
 
30
28
  def k(s)
31
- NKF.nkf('-wm0', s)
29
+ NKF.nkf('-wm0', s.to_s)
32
30
  end
33
31
  def hk(s)
34
32
  h(k(s))
@@ -75,13 +73,16 @@ module TD2Planet
75
73
  end
76
74
 
77
75
  def date_format(item)
76
+ return "" unless item.respond_to?(:date) && item.date
78
77
  item.date.localtime.strftime(@config['date_strftime_format'])
79
78
  end
80
79
  def sanchor_format(item)
80
+ return "" unless item.respond_to?(:date) && item.date
81
81
  item.date.localtime.strftime(@config['sanchor_strftime_format'])
82
82
  end
83
83
 
84
84
  def too_old?(item, sec=7*24*60*60)
85
+ return false unless item.respond_to?(:date) && item.date
85
86
  item.date < Time.now - sec
86
87
  end
87
88
 
@@ -126,19 +127,21 @@ module TD2Planet
126
127
  else
127
128
  uri
128
129
  end
130
+ rescue URI::InvalidURIError
131
+ attr_value
129
132
  end
130
133
 
131
134
  def tag_attr_relative_path_to_absolute_uri(tag, attr_name, base_uri)
132
- tag.gsub!(/#{attr_name}=([\"\'])([^\"\']+)\1/i) do
135
+ tag.gsub!(/#{Regexp.quote(attr_name)}=([\"\'])([^\"\']*)\1/i) do
133
136
  %Q!#{attr_name}=#{$1}#{relative_path_to_absolute_uri($2, base_uri)}#{$1}!
134
- end or tag.gsub!(/#{attr_name}=(\S+)/) do
137
+ end or tag.gsub!(/#{Regexp.quote(attr_name)}=(\S+)/) do
135
138
  %Q!#{attr_name}=#{relative_path_to_absolute_uri($1, base_uri)}!
136
139
  end
137
140
  tag
138
141
  end
139
142
 
140
143
  def to_section_body(item)
141
- if item.content_encoded
144
+ if item.respond_to?(:content_encoded) && item.content_encoded
142
145
  k(item.content_encoded).gsub(/<([aA]\b[\s\S]+?)>/) do
143
146
  a = tag_attr_relative_path_to_absolute_uri($1, "href", item.link)
144
147
  %Q!<#{a} rel="nofollow">!
@@ -165,11 +168,12 @@ module TD2Planet
165
168
  end
166
169
 
167
170
  def to_categories(item)
171
+ return "" unless item.respond_to?(:dc_subjects)
168
172
  h(item.dc_subjects.collect{|s|"[#{k(s.content)}]" if /./ =~ s.content})
169
173
  end
170
174
 
171
175
  def to_author(item)
172
- if item.dc_creator
176
+ if item.respond_to?(:dc_creator) && item.dc_creator
173
177
  " (#{hk(item.dc_creator)})"
174
178
  else
175
179
  ""
@@ -1,9 +1,7 @@
1
- #--
2
1
  # -*- mode: ruby; coding: utf-8 -*-
3
2
  # vim: set filetype=ruby ts=2 sw=2 sts=2 fenc=utf-8:
4
3
  #
5
- # copyright (c) 2006, 2007 Kazuhiro NISHIYAMA
6
- #++
4
+ # copyright (c) 2006, 2007, 2009 Kazuhiro NISHIYAMA
7
5
 
8
6
  require 'optparse'
9
7
  require 'td2planet/fetcher'
@@ -1,9 +1,7 @@
1
- #--
2
1
  # -*- mode: ruby; coding: utf-8 -*-
3
2
  # vim: set filetype=ruby ts=2 sw=2 sts=2 fenc=utf-8:
4
3
  #
5
- # copyright (c) 2006, 2007 Kazuhiro NISHIYAMA
6
- #++
4
+ # copyright (c) 2006, 2007, 2009 Kazuhiro NISHIYAMA
7
5
 
8
6
  require 'td2planet/formatter'
9
7
 
@@ -1,13 +1,11 @@
1
- #--
2
1
  # -*- mode: ruby; coding: utf-8 -*-
3
2
  # vim: set filetype=ruby ts=2 sw=2 sts=2 fenc=utf-8:
4
3
  #
5
- # copyright (c) 2006, 2007 Kazuhiro NISHIYAMA
6
- #++
4
+ # copyright (c) 2006, 2007, 2009 Kazuhiro NISHIYAMA
7
5
 
8
6
  module TD2Planet
9
- TD2PLANET_VERSION = "0.1.0"
10
- TD2PLANET_RELEASE_DATE = "2007-02-22"
7
+ TD2PLANET_VERSION = "0.2.0"
8
+ TD2PLANET_RELEASE_DATE = "2009-10-29"
11
9
 
12
10
  # return ruby version string (simulate output of ruby -v)
13
11
  def self.ruby_version
@@ -1,9 +1,7 @@
1
- #--
2
1
  # -*- mode: ruby; coding: utf-8 -*-
3
2
  # vim: set filetype=ruby ts=2 sw=2 sts=2 fenc=utf-8:
4
3
  #
5
- # copyright (c) 2006, 2007 Kazuhiro NISHIYAMA
6
- #++
4
+ # copyright (c) 2006, 2007, 2009 Kazuhiro NISHIYAMA
7
5
 
8
6
  require 'pathname'
9
7
 
metadata CHANGED
@@ -1,33 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.2
3
- specification_version: 1
4
2
  name: td2planet
5
3
  version: !ruby/object:Gem::Version
6
- version: 0.1.0
7
- date: 2007-02-22 00:00:00 +09:00
8
- summary: planet of ruby, mainly for tdiary
9
- require_paths:
10
- - lib
11
- email: zn@mbf.nifty.com
12
- homepage: http://rubyforge.org/projects/td2planet/
13
- rubyforge_project: td2planet
14
- description:
15
- autorequire:
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
4
+ version: 0.2.0
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
6
  authors:
30
7
  - Kazuhiro NISHIYAMA
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-10-29 00:00:00 +09:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Ruby-based server-side blog aggregator
17
+ email: zn@mbf.nifty.com
18
+ executables:
19
+ - td2planet.rb
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README
24
+ - README.ja
31
25
  files:
32
26
  - ChangeLog
33
27
  - MIT-LICENSE
@@ -48,8 +42,11 @@ files:
48
42
  - lib/td2planet/sample_formatter.rb
49
43
  - lib/td2planet/version.rb
50
44
  - lib/td2planet/writer.rb
51
- test_files: []
45
+ has_rdoc: true
46
+ homepage: http://rubyforge.org/projects/td2planet/
47
+ licenses: []
52
48
 
49
+ post_install_message:
53
50
  rdoc_options:
54
51
  - --charset
55
52
  - utf-8
@@ -57,14 +54,26 @@ rdoc_options:
57
54
  - --line-numbers
58
55
  - --main
59
56
  - README
60
- extra_rdoc_files:
61
- - README
62
- - README.ja
63
- executables:
64
- - td2planet.rb
65
- extensions: []
66
-
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: "0"
64
+ version:
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: "0"
70
+ version:
67
71
  requirements: []
68
72
 
69
- dependencies: []
73
+ rubyforge_project: td2planet
74
+ rubygems_version: 1.3.2
75
+ signing_key:
76
+ specification_version: 3
77
+ summary: planet of ruby, mainly for tdiary
78
+ test_files: []
70
79