typedown2blog 0.1.1 → 0.1.2
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.
- data/VERSION +1 -1
- data/example/bin/pop2blog.rb +43 -33
- data/lib/typedown2blog/blog_post.rb +1 -1
- data/lib/typedown2blog/formatters.rb +2 -2
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/example/bin/pop2blog.rb
CHANGED
@@ -37,43 +37,53 @@ SecretMail::MailAction.mail_domain config["secret_mail"]["mail_domain"]
|
|
37
37
|
ActiveRecord::Base.establish_connection(config["db"])
|
38
38
|
|
39
39
|
|
40
|
+
errorCount = 0
|
40
41
|
loop do
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
42
|
+
begin
|
43
|
+
didWork = Spec::retriever.process do |popped|
|
44
|
+
begin
|
45
|
+
SecretMail::Controller.process Mail.new(popped) do |action, record, mail|
|
46
|
+
blog_post = Typedown2Blog::BlogPost.new do
|
47
|
+
case action.to_sym
|
48
|
+
when :created then
|
49
|
+
self.mail_to = mail.from[0]
|
50
|
+
self.mail_from = record.secret_mail
|
51
|
+
self.typedown_body = "! Your typedown2blog gateway\n#{record.secret_mail}\n"
|
52
|
+
self.format = 'blogger'
|
53
|
+
when :mail_to_blogger then
|
54
|
+
self.mail_to = record.params
|
55
|
+
self.format = 'blogger'
|
56
|
+
self.import_mail :mail => mail
|
57
|
+
when :mail_to_wordpress then
|
58
|
+
self.mail_to = record.params
|
59
|
+
self.format = 'wordpress'
|
60
|
+
self.import_mail :mail => mail
|
61
|
+
else
|
62
|
+
raise "Unsupported action: " + action.to_s
|
63
|
+
end
|
61
64
|
end
|
65
|
+
blog_post.post!
|
62
66
|
end
|
63
|
-
|
67
|
+
rescue => err
|
68
|
+
now = Time.now.strftime("%Y%m%d-%H%M%S")
|
69
|
+
uuid = UUIDTools::UUID.random_create.to_s
|
70
|
+
filename = "failed/#{now}-#{uuid}"
|
71
|
+
log.error filename + ", " + err.message
|
72
|
+
f = File.new(filename, "wb")
|
73
|
+
f.write(popped)
|
74
|
+
f.close()
|
75
|
+
f = File.new(filename + ".error", "wb")
|
76
|
+
f.write("#{err.message}\n#{err.backtrace.join("\n")}")
|
77
|
+
f.close()
|
64
78
|
end
|
65
|
-
rescue => err
|
66
|
-
now = Time.now.strftime("%Y%m%d-%H%M%S")
|
67
|
-
uuid = UUIDTools::UUID.random_create.to_s
|
68
|
-
filename = "failed/#{now}-#{uuid}"
|
69
|
-
log.error filename + ", " + err.message
|
70
|
-
f = File.new(filename, "wb")
|
71
|
-
f.write(popped)
|
72
|
-
f.close()
|
73
|
-
f = File.new(filename + ".error", "wb")
|
74
|
-
f.write("#{err.message}\n#{err.backtrace.join("\n")}")
|
75
|
-
f.close()
|
76
79
|
end
|
80
|
+
sleep(10) unless(didWork)
|
81
|
+
errorCount = 0
|
82
|
+
rescue => err
|
83
|
+
log.error "#{err.message}\n#{err.backtrace.join("\n")}"
|
84
|
+
|
85
|
+
errorCount += 1
|
86
|
+
seconds = [15 + errorCount * errorCount, 5 * 60].min
|
87
|
+
sleep(seconds)
|
77
88
|
end
|
78
|
-
sleep(10) unless(didWork)
|
79
89
|
end
|
@@ -16,7 +16,7 @@ module Typedown2Blog
|
|
16
16
|
def format_body typedown
|
17
17
|
doc = Typedown::Section.sectionize(typedown)
|
18
18
|
body = "#{doc.body.to_html}\n\n"
|
19
|
-
[ doc.title, body, "plain
|
19
|
+
[ doc.title, body, "text/plain" ]
|
20
20
|
end
|
21
21
|
|
22
22
|
new "wordpress"
|
@@ -28,7 +28,7 @@ module Typedown2Blog
|
|
28
28
|
def format_body typedown
|
29
29
|
doc = Typedown::Section.sectionize(typedown)
|
30
30
|
body = "<html>\n<body>\n#{doc.body.to_html}\n</body>\n</html>\n\n"
|
31
|
-
[ doc.title, body, "
|
31
|
+
[ doc.title, body, "text/html" ]
|
32
32
|
end
|
33
33
|
|
34
34
|
new "blogger"
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: typedown2blog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Rune Myrland
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-09-04 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|