typedown2blog 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -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
- didWork = Spec::retriever.process do |popped|
42
- begin
43
- SecretMail::Controller.process Mail.new(popped) do |action, record, mail|
44
- blog_post = Typedown2Blog::BlogPost.new do
45
- case action.to_sym
46
- when :created then
47
- self.mail_to = mail.from[0]
48
- self.mail_from = record.secret_mail
49
- self.typedown_body = "! Your typedown2blog gateway\n#{record.secret_mail}\n"
50
- self.format = 'blogger'
51
- when :mail_to_blogger then
52
- self.mail_to = record.params
53
- self.format = 'blogger'
54
- self.import_mail :mail => mail
55
- when :mail_to_wordpress then
56
- self.mail_to = record.params
57
- self.format = 'wordpress'
58
- self.import_mail :mail => mail
59
- else
60
- raise "Unsupported action: " + action.to_s
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
- blog_post.post!
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
@@ -62,8 +62,8 @@ module Typedown2Blog
62
62
  text_part do
63
63
  self.charset = "UTF-8"
64
64
  body mail_body
65
- content_type mail_content_type
66
65
  end
66
+ text_part.content_type mail_content_type
67
67
  end
68
68
 
69
69
  mail_attachments.each do |a|
@@ -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/text" ]
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, "plain/text" ]
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: 25
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.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-08-23 00:00:00 +02:00
18
+ date: 2010-09-04 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency