feed2email 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -10
- data/README.md +138 -86
- data/bin/f2e +6 -4
- data/bin/feed2email +6 -4
- data/bin/feed2email-migrate +23 -0
- data/lib/feed2email.rb +6 -9
- data/lib/feed2email/cli.rb +112 -75
- data/lib/feed2email/config.rb +72 -52
- data/lib/feed2email/core_ext.rb +10 -0
- data/lib/feed2email/database.rb +75 -0
- data/lib/feed2email/entry.rb +149 -15
- data/lib/feed2email/feed.rb +111 -130
- data/lib/feed2email/feed_autodiscoverer.rb +8 -10
- data/lib/feed2email/migrate/convert_feeds_migration.rb +29 -0
- data/lib/feed2email/migrate/feeds_import_migration.rb +42 -0
- data/lib/feed2email/migrate/history_import_migration.rb +42 -0
- data/lib/feed2email/migrate/migration.rb +42 -0
- data/lib/feed2email/migrate/split_history_migration.rb +32 -0
- data/lib/feed2email/open-uri.rb +7 -0
- data/lib/feed2email/opml_exporter.rb +109 -0
- data/lib/feed2email/opml_importer.rb +52 -0
- data/lib/feed2email/redirection_checker.rb +2 -2
- data/lib/feed2email/smtp_connection.rb +59 -0
- data/lib/feed2email/version.rb +1 -1
- metadata +55 -30
- data/bin/feed2email-migrate-feedlist +0 -36
- data/bin/feed2email-migrate-history +0 -29
- data/lib/feed2email/feed_history.rb +0 -82
- data/lib/feed2email/feed_list.rb +0 -147
- data/lib/feed2email/lazy_smtp_connection.rb +0 -35
- data/lib/feed2email/mail.rb +0 -84
data/lib/feed2email/mail.rb
DELETED
@@ -1,84 +0,0 @@
|
|
1
|
-
require 'mail'
|
2
|
-
require 'feed2email/configurable'
|
3
|
-
require 'feed2email/version'
|
4
|
-
|
5
|
-
module Feed2Email
|
6
|
-
class Mail
|
7
|
-
include Configurable
|
8
|
-
|
9
|
-
def initialize(entry, feed_title)
|
10
|
-
@entry = entry
|
11
|
-
@feed_title = feed_title
|
12
|
-
end
|
13
|
-
|
14
|
-
def send
|
15
|
-
build_mail.deliver!
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def body_html
|
21
|
-
%{
|
22
|
-
<html>
|
23
|
-
<body>
|
24
|
-
<h1><a href="%{uri}">%{title}</a></h1>
|
25
|
-
%{content}
|
26
|
-
<p>%{published}</p>
|
27
|
-
<p><a href="%{uri}">%{uri}</a></p>
|
28
|
-
<p>--<br>
|
29
|
-
Sent by <a href="https://github.com/agorf/feed2email">feed2email
|
30
|
-
#{VERSION}</a> at #{Time.now}</p>
|
31
|
-
</body>
|
32
|
-
</html>
|
33
|
-
}.gsub(/^\s+/, '') % {
|
34
|
-
content: entry.content,
|
35
|
-
published: published,
|
36
|
-
title: entry.title.strip_html,
|
37
|
-
uri: entry.uri.escape_html,
|
38
|
-
}
|
39
|
-
end
|
40
|
-
|
41
|
-
def body_text
|
42
|
-
body_html.to_markdown
|
43
|
-
end
|
44
|
-
|
45
|
-
def build_mail
|
46
|
-
::Mail.new.tap do |m|
|
47
|
-
m.from = %{"#{feed_title}" <#{config['sender']}>}
|
48
|
-
m.to = config['recipient']
|
49
|
-
m.subject = entry.title.strip_html
|
50
|
-
m.html_part = build_mail_part('text/html', body_html)
|
51
|
-
m.text_part = build_mail_part('text/plain', body_text)
|
52
|
-
|
53
|
-
m.delivery_method(*delivery_method_params)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def build_mail_part(content_type, body)
|
58
|
-
part = ::Mail::Part.new
|
59
|
-
part.content_type = "#{content_type}; charset=UTF-8"
|
60
|
-
part.body = body
|
61
|
-
part
|
62
|
-
end
|
63
|
-
|
64
|
-
def delivery_method_params
|
65
|
-
if config.smtp_configured?
|
66
|
-
[:smtp_connection, connection: Feed2Email.smtp_connection]
|
67
|
-
else
|
68
|
-
[:sendmail, location: config['sendmail_path']]
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def entry; @entry end
|
73
|
-
|
74
|
-
def feed_title; @feed_title end
|
75
|
-
|
76
|
-
def published
|
77
|
-
return nil unless entry.author || entry.published
|
78
|
-
text = 'Published'
|
79
|
-
text << " by #{entry.author}" if entry.author
|
80
|
-
text << " at #{entry.published}" if entry.published
|
81
|
-
text
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|