imap-feeder 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
data/History.txt CHANGED
@@ -1,3 +1,10 @@
1
+ == 0.2.0 2008-07-5
2
+
3
+ * 1 major enhancement:
4
+ * HTML support! The new default format is set to HTML, for old configurations,
5
+ set $format = :html.
6
+ * Several bugfixes and improved documentation.
7
+
1
8
  == 0.1.0 2008-06-9
2
9
 
3
10
  * 1 major enhancement:
data/README.txt CHANGED
@@ -70,6 +70,36 @@ the script should generate some folders on your IMAP server and fetch the
70
70
  first round of feeds. If you are happy with the results, you can run the
71
71
  script regularly, for example using cron.
72
72
 
73
+ == Check Configuration
74
+
75
+ Imap feeder can check your feeds file for validity with regards to IMAP folder
76
+ names and connectivity to the webservers. Use the -c FEEDS_FILE option to run
77
+ the check and watch the output for errors and warnings.
78
+
79
+ == Troubleshooting
80
+
81
+ This section hopefully helps dealing with common problems that you might
82
+ encounter.
83
+
84
+ === Already running
85
+
86
+ If you're getting an error about imap-feeder "already running", this means that
87
+ imap-feeder either really is still running or it crashed during the last run and
88
+ couldn't clean up properly. In the last case, just remove the running_instance file
89
+ and rerun it.
90
+
91
+ === OPML file
92
+
93
+ The OPML import is not very well tested, it should certainly work with
94
+ Akregator's OPML files. If it doesn't work for you, don't hesitate to contact me
95
+ and send me your OPML file.
96
+
97
+ === Crashes
98
+
99
+ If imap-feeder crashes with a stacktrace, take a look at the log file for more
100
+ information. You might also want to raise the log level, see the settings file
101
+ for instructions.
102
+
73
103
  == Comments
74
104
 
75
105
  Thank you for using imap-feeder and don't forget to drop me an email if you
data/TODO.txt CHANGED
@@ -1,8 +1,6 @@
1
1
  Ideas for further development:
2
2
  * Adding new feeds through rssimap, without manually editing the file.
3
- * HTML-Mails (really?)
4
3
  * make the position of the link to the original configurable
5
- * embed images (e.g. for dilbert)
6
4
 
7
5
  * user-hooks that can interact with the feed processing:
8
6
  * to ignore items
data/bin/imap-feeder CHANGED
@@ -9,11 +9,12 @@ opts = CreateConfigParser.parse(ARGV)
9
9
 
10
10
  if opts.create
11
11
  $stdout.puts "Creating new configuration."
12
+ $log = Logger.new($stdout)
12
13
  ImapFeederConfig.create(opts.create_file, opts.folder)
13
14
  $stdout.puts "Please edit your settings.rb file now."
14
15
 
15
16
  elsif opts.check
16
- $stdout.puts "Checking configuration #{opts.check}"
17
+ $stdout.puts "Checking feeds #{opts.check}"
17
18
  $log = Logger.new($stdout)
18
19
  ImapFeederConfig.check(File.open(opts.check))
19
20
 
@@ -39,7 +40,8 @@ elsif ARGV.first and load(ARGV.first)
39
40
  :user => $user,
40
41
  :pass => $pass,
41
42
  :port => $port || "143",
42
- :use_ssl => $use_ssl || false
43
+ :use_ssl => $use_ssl || false,
44
+ :format => $format || :plain
43
45
  }
44
46
 
45
47
  if opts.pretend
@@ -55,10 +57,12 @@ elsif ARGV.first and load(ARGV.first)
55
57
  end
56
58
  end
57
59
 
58
- config = File.open($config)
59
- imapfeeder = ImapFeeder.new(@server, store, config)
60
- imapfeeder.run
61
- @server.disconnect
60
+ if @server
61
+ config = File.open($config)
62
+ imapfeeder = ImapFeeder.new(@server, store, config)
63
+ imapfeeder.run
64
+ @server.disconnect
65
+ end
62
66
 
63
67
  File.delete $running_instance
64
68
 
data/config/hoe.rb CHANGED
@@ -2,7 +2,7 @@ require 'imap-feeder/version'
2
2
 
3
3
  AUTHOR = 'Mirko Stocker' # can also be an array of Authors
4
4
  EMAIL = "me@misto.ch"
5
- DESCRIPTION = "Imap-feeder pushes your RSS and Atom feeds to an IMAP server."
5
+ DESCRIPTION = "Imap-feeder pushes entries from RSS and Atom feeds to an IMAP server."
6
6
  GEM_NAME = 'imap-feeder' # what ppl will type to install your gem
7
7
  RUBYFORGE_PROJECT = 'imap-feeder' # The unix name for your project
8
8
  HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
@@ -11,8 +11,8 @@ Usage: #{$0} [options] to create or check your configuration
11
11
  or #{$0} SETTINGS_FILE to run the script
12
12
  EOF
13
13
 
14
- opts.on("-c", "--check-settings SETTINGS_FILE",
15
- "Check an existing configuration") do |file|
14
+ opts.on("-c", "--check-settings FEEDS_FILE",
15
+ "Check a feed file") do |file|
16
16
  options.check = file
17
17
  end
18
18
 
@@ -28,10 +28,18 @@ class Message
28
28
  @body ||= strip_html(@params[:body] || @params[:url] || "")
29
29
  end
30
30
 
31
+ def html_body
32
+ dec(@params[:body])
33
+ end
34
+
31
35
  def time
32
36
  @time ||= (@params[:time] || Time.now.localtime).rfc2822
33
37
  end
34
38
 
39
+ def url
40
+ @url ||= @params[:url]
41
+ end
42
+
35
43
  def quote(str)
36
44
  return "" if not str
37
45
  str.gsub(/[^a-zA-Z0-9 -_:,\.]+/) {|to_quote| quote_if_necessary(to_quote, "UTF-8")}
@@ -42,21 +50,28 @@ class Message
42
50
  end
43
51
 
44
52
  def format
45
- url = @params[:url]
53
+ construct_message "plain", "#{body}" + (url ? "\n\n#{url}" : "")
54
+ end
55
+
56
+ def as_html
57
+ construct_message "html", "#{html_body}" + (url ? "<br/><br/><a href='#{url}'>#{url}</a>" : "")
58
+ end
59
+
60
+ private
61
+
62
+ def construct_message(type, body)
46
63
  return <<-EOF
47
64
  Date: #{time}
48
65
  Subject: #{quote(title)}
49
66
  From: #{quote(from)}
50
- Content-Type: text/plain;
67
+ Content-Type: text/#{type};
51
68
  charset="utf-8"
52
69
  Content-Transfer-Encoding: 8bit
53
70
 
54
- #{body}#{"\n\n" + url if url}
71
+ #{body}
55
72
  EOF
56
73
  end
57
74
 
58
- private
59
-
60
75
  def replace(doc, element)
61
76
  doc.search(element) do |found|
62
77
  replacement = block_given? ? yield(found) : found.innerHTML
@@ -19,7 +19,7 @@ class MessageStore
19
19
  def add_new(folder, titles, number_of_entries = MESSAGES_TO_STORE)
20
20
  @root[folder] ||= []
21
21
  @root[folder].unshift(*titles)
22
- @root[folder].slice!((number_of_entries * 2)..-1)
22
+ @root[folder].slice!((number_of_entries * 10)..-1)
23
23
  @root[folder].compact!
24
24
  end
25
25
 
@@ -9,6 +9,7 @@ class Server
9
9
  def initialize(params)
10
10
  @connection = Net::IMAP.new(params[:host], params[:port], params[:use_ssl])
11
11
  result = @connection.login(params[:user], params[:pass])
12
+ @format = params[:format]
12
13
  end
13
14
 
14
15
  def disconnect
@@ -17,7 +18,14 @@ class Server
17
18
 
18
19
  def send(message, folder="INBOX")
19
20
  @connection.select(folder)
20
- message = message.format.gsub(/\n/, "\r\n")
21
+
22
+ if @format == :html
23
+ message = message.as_html
24
+ else
25
+ message = message.format
26
+ end
27
+
28
+ message.gsub!(/\n/, "\r\n")
21
29
  @connection.append(folder, message, nil, Time.now)
22
30
  end
23
31
 
@@ -1,7 +1,7 @@
1
1
  class ImapFeeder #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 1
4
+ MINOR = 2
5
5
  TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
data/settings.rb.example CHANGED
@@ -17,6 +17,11 @@ BASEDIR="#{ENV['HOME']}/.imap-feeder"
17
17
  $tidy_path = "/usr/lib/libtidy.so"
18
18
 
19
19
 
20
+ # Controls if the entries are sent as html or plain-text
21
+ # Values are:
22
+ # :html
23
+ # :plain
24
+ $format = :html
20
25
 
21
26
  # imap-feeder needs a file to store the last message for each feed
22
27
  # so it doesn't fetch old entries. Where should that file be?
data/test/test_message.rb CHANGED
@@ -118,6 +118,39 @@ EOF
118
118
  end
119
119
  end
120
120
 
121
+ class HtmlMessageTest < Test::Unit::TestCase
122
+
123
+ def test_bold_text
124
+ t = Time.parse("Mon, Mar 05 2007 15:26:16 +0100")
125
+ m = Message.new(:title => "something bold", :body => "<strong>body</strong>second", :time => t)
126
+ assert_equal(<<-EOF, m.as_html)
127
+ Date: Mon, 05 Mar 2007 15:26:16 +0100
128
+ Subject: something bold
129
+ From: Unknown <spam@example.org>
130
+ Content-Type: text/html;
131
+ charset="utf-8"
132
+ Content-Transfer-Encoding: 8bit
133
+
134
+ <strong>body</strong>second
135
+ EOF
136
+ end
137
+
138
+ def test_url
139
+ t = Time.parse("Mon, Mar 05 2007 15:26:16 +0100")
140
+ m = Message.new(:title => "with url", :body => "body", :time => t, :url => "http://url")
141
+ assert_equal(<<-EOF, m.as_html)
142
+ Date: Mon, 05 Mar 2007 15:26:16 +0100
143
+ Subject: with url
144
+ From: Unknown <spam@example.org>
145
+ Content-Type: text/html;
146
+ charset="utf-8"
147
+ Content-Transfer-Encoding: 8bit
148
+
149
+ body<br/><br/><a href='http://url'>http://url</a>
150
+ EOF
151
+ end
152
+
153
+ end
121
154
 
122
155
  class MessageFormatterTest < Test::Unit::TestCase
123
156
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imap-feeder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mirko Stocker
@@ -29,11 +29,12 @@ cert_chain:
29
29
  uqXC6cgFmydQfHaHeH24NZ6LBcoaacZYI/xsdm+9S18u2P+G/LAGOg==
30
30
  -----END CERTIFICATE-----
31
31
 
32
- date: 2008-06-09 00:00:00 +02:00
32
+ date: 2008-07-05 00:00:00 +02:00
33
33
  default_executable:
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: actionmailer
37
+ type: :runtime
37
38
  version_requirement:
38
39
  version_requirements: !ruby/object:Gem::Requirement
39
40
  requirements:
@@ -43,6 +44,7 @@ dependencies:
43
44
  version:
44
45
  - !ruby/object:Gem::Dependency
45
46
  name: hpricot
47
+ type: :runtime
46
48
  version_requirement:
47
49
  version_requirements: !ruby/object:Gem::Requirement
48
50
  requirements:
@@ -52,6 +54,7 @@ dependencies:
52
54
  version:
53
55
  - !ruby/object:Gem::Dependency
54
56
  name: htmlentities
57
+ type: :runtime
55
58
  version_requirement:
56
59
  version_requirements: !ruby/object:Gem::Requirement
57
60
  requirements:
@@ -61,6 +64,7 @@ dependencies:
61
64
  version:
62
65
  - !ruby/object:Gem::Dependency
63
66
  name: tidy
67
+ type: :runtime
64
68
  version_requirement:
65
69
  version_requirements: !ruby/object:Gem::Requirement
66
70
  requirements:
@@ -70,6 +74,7 @@ dependencies:
70
74
  version:
71
75
  - !ruby/object:Gem::Dependency
72
76
  name: simple-rss
77
+ type: :runtime
73
78
  version_requirement:
74
79
  version_requirements: !ruby/object:Gem::Requirement
75
80
  requirements:
@@ -77,7 +82,7 @@ dependencies:
77
82
  - !ruby/object:Gem::Version
78
83
  version: "1.1"
79
84
  version:
80
- description: Imap-feeder pushes your RSS and Atom feeds to an IMAP server.
85
+ description: Imap-feeder pushes entries from RSS and Atom feeds to an IMAP server.
81
86
  email:
82
87
  - me@misto.ch
83
88
  executables:
@@ -162,10 +167,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
167
  requirements: []
163
168
 
164
169
  rubyforge_project: imap-feeder
165
- rubygems_version: 1.1.1
170
+ rubygems_version: 1.2.0
166
171
  signing_key:
167
172
  specification_version: 2
168
- summary: Imap-feeder pushes your RSS and Atom feeds to an IMAP server.
173
+ summary: Imap-feeder pushes entries from RSS and Atom feeds to an IMAP server.
169
174
  test_files:
170
175
  - test/test_imapfeederconfig.rb
171
176
  - test/test_opmlreader.rb
metadata.gz.sig CHANGED
Binary file