omah 0.9.3 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/lib/omah.rb +87 -84
  4. data.tar.gz.sig +0 -0
  5. metadata +34 -28
  6. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9aac212e95ded24b3d052b9c3a5749f5082b0351931a32562bef49c2bfc4318d
4
- data.tar.gz: 6829eed1f65cb9e735749a05e0df56f7dc0d2e50cc721a75afc5ebe8f596e2cb
3
+ metadata.gz: d1b29960de678baaa04b089b86091f22d62c3595a64f5304d23d32488a4333ee
4
+ data.tar.gz: b347eabaa96a1e72ff664d081ac70fc29d9adaea59746b3b602990d4a53c1ad3
5
5
  SHA512:
6
- metadata.gz: 8752cbfe114e772a7c57066e996e43fd9bdcab9baa50c3be7adf178413284c0959fdec920b869e1c04dae1505cb4795dbe7761450f506a4d0331b5c57137fd40
7
- data.tar.gz: e9d557fc91f7d488f1c4b0b4a3b445b830ed8bf393e27b1e5116f8e138103b1521e1c077e97f485be2936d7c5ab7c34e3e0651f9be0c483d6e48044a762168a7
6
+ metadata.gz: 73585b352b0c63c2d959eb62f45954b55d1a673be0cd15b0b7c91d782ea918095689c437b73c1b82cb997b4b0be01c90427aba723e2220e634ecc368c7f7b1e5
7
+ data.tar.gz: ead2fe673624b908532e9caa6c2ecbf2884205778a100085e3a59e5031cdf04cbd3a127ff180739c8491b2d9a9a3373a900a148cad03302924c10e61c5c7fb4f
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/omah.rb CHANGED
@@ -11,9 +11,11 @@ module Library
11
11
 
12
12
  def fetch_file(filename)
13
13
 
14
- lib = File.dirname(__FILE__)
15
- File.read File.join(lib,'..','stylesheet',filename)
16
-
14
+ #lib = File.dirname(__FILE__)
15
+ #File.read filename
16
+ lib = 'http://a0.jamesrobertson.me.uk/rorb/r/ruby/omah/'
17
+ URI.open(File.join(lib, filename),
18
+ 'UserAgent' => 'Omah'){|x| x.read }
17
19
  end
18
20
  end
19
21
 
@@ -21,14 +23,14 @@ class Omah
21
23
 
22
24
  include Library
23
25
  include RXFHelperModule
24
-
26
+
25
27
  def initialize(user: 'user', filepath: '.', \
26
- options: {xslt: 'listing.xsl', url_base: 'http://localhost/' },
28
+ options: {xslt: 'listing.xsl', url_base: 'http://localhost/' },
27
29
  plugins: [], webpath: '/email', debug: false)
28
30
 
29
-
31
+
30
32
  puts 'inside Omah::initialize' if @debug
31
-
33
+
32
34
  @user = user
33
35
  @xslt = options[:xslt]
34
36
  @css = options[:css]
@@ -40,87 +42,87 @@ class Omah
40
42
  @debug = debug
41
43
 
42
44
  puts 'Omah::initialize filepath: ' + filepath.inspect if @debug
43
-
45
+
44
46
  FileX.chdir filepath
45
47
 
46
48
  puts 'Omah::initialize making directory ' + @filepath_user if @debug
47
- FileX.mkdir_p @filepath_user
49
+ FileX.mkdir_p @filepath_user
48
50
 
49
51
  FileX.chdir @filepath_user
50
-
52
+
51
53
  dailyfile = File.join(@filepath_user, 'dynarexdaily.xml')
52
-
54
+
53
55
  x = if FileX.exists? dailyfile then dailyfile
54
56
 
55
57
  else
56
-
58
+
57
59
  'messages[date, prev_date, next_date]/message(msg_id, tags, from, ' + \
58
60
  'to, subject, date, txt_filepath, html_filepath, attachment1, ' + \
59
- 'attachment2, attachment3, attachments)'
61
+ 'attachment2, attachment3, attachments)'
60
62
 
61
63
  end
62
64
 
63
65
  puts 'Omah::initialize before DynarexDaily' if @debug
64
- @dd = DynarexDaily.new x, dir_archive: :yearly, debug: @debug
66
+ @dd = DynarexDaily.new x, dir_archive: :yearly, debug: @debug
65
67
  puts 'Omah::initialize after DynarexDaily' if @debug
66
68
  # is it a new day?
67
-
69
+
68
70
  if @dd.records.empty? then
69
-
70
- date_yesterday = File.join(@filepath_user,
71
+
72
+ date_yesterday = File.join(@filepath_user,
71
73
  (Date.today - 1).strftime("%Y/%b/%d").downcase)
72
-
73
- @dd.prev_date = File.join(@webpath_user,
74
+
75
+ @dd.prev_date = File.join(@webpath_user,
74
76
  (Date.today - 1).strftime("%Y/%b/%d").downcase)
75
-
77
+
76
78
  # add the next_day field value to the previous day file
77
-
79
+
78
80
  file_yesterday = date_yesterday + '/index.xml'
79
81
 
80
82
  if FileX.exists? file_yesterday then
81
-
83
+
82
84
  dx_yesterday = Dynarex.new file_yesterday
83
- dx_yesterday.next_date = File.join(@webpath_user,
85
+ dx_yesterday.next_date = File.join(@webpath_user,
84
86
  (Date.today).strftime("%Y/%b/%d").downcase)
85
87
  dx_yesterday.xslt = options[:archive_xsl] if options[:archive_xsl]
86
88
  dx_yesterday.save
87
89
  end
88
-
90
+
89
91
  end
90
-
92
+
91
93
  # intialize plugins
92
-
94
+
93
95
  puts 'Omah::initialize before plugins' if @debug
94
-
96
+
95
97
  @plugins = plugins.inject([]) do |r, plugin|
96
-
98
+
97
99
  name, settings = plugin
98
-
100
+
99
101
  puts 'Omah::initialize plugin: ' + name.inspect if @debug
100
-
102
+
101
103
  return r if settings[:active] == false and !settings[:active]
102
-
104
+
103
105
  klass_name = 'OmahPlugin' + name.to_s.split(/[-_]/)\
104
106
  .map{|x| x.capitalize}.join
105
107
 
106
- r << Kernel.const_get(klass_name).new(settings: settings,
108
+ r << Kernel.const_get(klass_name).new(settings: settings,
107
109
  variables: @variables, debug: @debug)
108
110
 
109
- end
111
+ end
110
112
 
111
113
  end
112
114
 
113
115
  def store(messages)
114
116
 
115
117
  messages.each.with_index do |x,i|
116
-
118
+
117
119
  email, msg = x
118
-
120
+
119
121
  begin
120
-
122
+
121
123
  puts "i: %d msg: %s" % [i, msg] if @debug
122
124
  subject = msg[:subject] || ''
123
-
125
+
124
126
  title = subject.gsub(/\W+/,'-')[0,30].sub(/^-/,'').sub(/-$/,'')
125
127
 
126
128
  a = @dd.all.select {|x| x.subject == subject}
@@ -135,7 +137,7 @@ class Omah
135
137
 
136
138
  path = archive()
137
139
 
138
- x_filepath = File.join(path, x_file)
140
+ x_filepath = File.join(path, x_file)
139
141
 
140
142
  puts 'FileX.pwd ' + FileX.pwd if @debug
141
143
  puts 'Omah::store before mkdir_p path: ' + path.inspect if @debug
@@ -149,7 +151,7 @@ class Omah
149
151
  header = %i(from to subject).inject({}) {|r,x| r.merge(x => msg[x]) }
150
152
  filepath = File.join(@filepath_user, x_filepath + '.kvx')
151
153
  Kvx.new(header, debug: false).save filepath
152
-
154
+
153
155
  txt_filepath = x_filepath + '.txt'
154
156
  FileX.write File.join(@filepath_user, txt_filepath), \
155
157
  text_sanitiser(msg[:body_text].to_s)
@@ -157,17 +159,20 @@ class Omah
157
159
  html_filepath = x_filepath + '.html'
158
160
  FileX.write File.join(@filepath_user, html_filepath), \
159
161
  html_sanitiser(msg[:body_html].to_s)
160
-
162
+
161
163
  parts_path = []
162
-
164
+
165
+ h = msg.merge(txt_filepath: txt_filepath, \
166
+ html_filepath: html_filepath)
167
+
163
168
  # save the attachments
164
169
  if msg[:attachments].length > 0 then
165
-
170
+
166
171
  attachment_path = File.join(path, title + ordinal)
167
172
  FileX.mkdir_p attachment_path
168
-
173
+
169
174
  msg[:attachments][0..2].each.with_index do |x, i|
170
-
175
+
171
176
  name, buffer = x
172
177
  parts_path[i] = File.join(attachment_path, name.gsub('/',''))
173
178
  begin
@@ -175,29 +180,27 @@ class Omah
175
180
  rescue
176
181
  puts ($!)
177
182
  end
178
-
179
- end
180
-
183
+
184
+ end
185
+
181
186
  h[:attachments] = msg[:attachments].map(&:first)
182
187
 
183
188
  end
184
-
189
+
185
190
  msg.delete :attachments
186
191
 
187
- h = msg.merge(txt_filepath: txt_filepath, \
188
- html_filepath: html_filepath)
189
192
  parts_path.each.with_index do |path, i|
190
193
  h.merge!("attachment#{i+1}" => @webpath_user + '/' + path)
191
194
  end
192
-
195
+
193
196
  if parts_path.any? then
194
-
197
+
195
198
  attachments = parts_path.map do |path|
196
- "<li><a href='%s'>%s</a></li>" % [@webpath_user + '/' + path,
199
+ "<li><a href='%s'>%s</a></li>" % [@webpath_user + '/' + path,
197
200
  File.basename(path)]
198
201
  end
199
-
200
-
202
+
203
+
201
204
  html_page= %Q(
202
205
  <html>
203
206
  <head>
@@ -206,7 +209,7 @@ html_page= %Q(
206
209
  <style></style>
207
210
  </head>
208
211
  <body>
209
- <iframe src='../#{File.basename(html_filepath)}'></iframe>
212
+ <iframe src='../#{File.basename(html_filepath)}'></iframe>
210
213
  <h2>attachments</h2>
211
214
  <ul>
212
215
  #{attachments.join("\n")}
@@ -222,70 +225,70 @@ html_page= %Q(
222
225
  h[:link] = File.join(@url_base, @webpath_user, html_filepath)
223
226
 
224
227
  @plugins.each {|x| x.on_newmessage(h) if x.respond_to? :on_newmessage }
225
-
228
+
226
229
  @dd.create h
227
-
228
-
230
+
231
+
229
232
  # remove the message from the server
230
233
  #jr250918 email.delete
231
-
234
+
232
235
  rescue
233
236
  puts 'Omah::store warning: ' + ($!).inspect
234
237
  end
235
238
 
236
239
  end
237
-
240
+
238
241
  if @xslt then
239
-
242
+
240
243
  unless FileX.exists? @xslt then
241
244
  FileX.write File.expand_path(@xslt), fetch_file(@xslt)
242
245
  FileX.write File.expand_path(@css), fetch_file(@css) if @css and \
243
246
  not FileX.exists? @css
244
247
  end
245
-
248
+
246
249
  @dd.xslt = @xslt
247
250
 
248
251
  end
249
-
250
-
252
+
253
+
251
254
  doc = @dd.to_doc
252
255
 
253
256
  doc.root.xpath('records/message').each do |message|
254
-
257
+
255
258
  classify message.element('from')
256
259
  classify message.element('to')
257
-
260
+
258
261
  end
259
262
 
260
- @plugins.each do |x|
263
+ @plugins.each do |x|
261
264
  x.on_newmail(messages, doc) if x.respond_to? :on_newmail
262
265
  end
263
-
266
+
264
267
  FileX.write File.join(@filepath_user, 'dynarexdaily.xml'), \
265
268
  doc.xml(pretty: true)
266
-
269
+
267
270
  end
268
-
271
+
269
272
  private
270
-
273
+
271
274
  def archive()
272
-
275
+
273
276
  t = Time.now
274
277
  path = File.join ['archive', t.year.to_s, \
275
278
  Date::MONTHNAMES[t.month].downcase[0..2], t.day.to_s]
276
279
 
277
- end
278
-
280
+ end
281
+
279
282
  def classify(e)
280
-
281
- s = e.text.to_s
283
+
284
+ s = e.text.to_s
282
285
  return if s.empty?
283
-
286
+
284
287
  e.attributes[:css_class] = NoVowels.compact(s.gsub(/\W+/,''))
285
- end
288
+ end
286
289
 
287
290
  def html_sanitiser(s)
288
- # Parsing HTML has proved problematic either way. Instead we will just
291
+ # Parsing HTML has proved problematic either way. Instead we will just
289
292
  # return whatever is given.
290
293
  =begin
291
294
  begin
@@ -298,12 +301,12 @@ html_page= %Q(
298
301
  =end
299
302
  s
300
303
  end
301
-
304
+
302
305
 
303
306
  def text_sanitiser(s)
304
- # Parsing HTML has proved problematic either way. Instead we will just
307
+ # Parsing HTML has proved problematic either way. Instead we will just
305
308
  # return whatever is given.
306
- =begin
309
+ =begin
307
310
  begin
308
311
  Rexle.new "<root>#{s}</root>"
309
312
  s2 = s
@@ -314,6 +317,6 @@ html_page= %Q(
314
317
  =end
315
318
  s
316
319
  end
317
-
320
+
318
321
 
319
322
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omah
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -10,27 +10,32 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDXjCCAkagAwIBAgIBATANBgkqhkiG9w0BAQUFADAsMSowKAYDVQQDDCFnZW1t
14
- YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTgwNzI0MjE1NDUxWhcN
15
- MTkwNzI0MjE1NDUxWjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
- cnRzb24vREM9ZXUwggEiMA0GCSqGS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zE4g/jsKAIOkO9spU7uVcYAitadHZqmF1Y5/D64P1xo
30
+ ScfV1uRp3Dbeq3QQHqSPNTj17QXlspdaNw+tBJrI1O8/aTutwDg6tkcaC/yqGwFt
31
+ +bh7rB9730zTdurLNUTfruHI38CRSOjt4BkucvmuC17rHhx4h9jMCi6zu5rtengR
32
+ lnLA6WVHlggce4nsMEBQIZZLUOssW32OPGDVbjh/24jNpVukqRm5sQFRWWuWkrwd
33
+ jNJY60a6JkLn4Ahvzrhm2n7anGKTOpyVS62Qu8w6cUkjXpmwXWXWVN9N7/POG7EO
34
+ xgj1UqJaKqMEg3TAr0auf2iXyXfhxbRVryltYk+3SkZWbITs95cEbmfWSgoVu6os
35
+ v/Ouz34Li0pxu+f3q+Z4+FRkBjMmW1X8RIaeSj9LAirhInezIc2b9CkS5c5zkwkZ
36
+ S/OWSwnVm2eKNuPrpAfd36Wk
32
37
  -----END CERTIFICATE-----
33
- date: 2019-03-03 00:00:00.000000000 Z
38
+ date: 2021-11-18 00:00:00.000000000 Z
34
39
  dependencies:
35
40
  - !ruby/object:Gem::Dependency
36
41
  name: dynarex-daily
@@ -58,20 +63,20 @@ dependencies:
58
63
  requirements:
59
64
  - - "~>"
60
65
  - !ruby/object:Gem::Version
61
- version: '0.3'
66
+ version: '0.5'
62
67
  - - ">="
63
68
  - !ruby/object:Gem::Version
64
- version: 0.3.2
69
+ version: 0.5.3
65
70
  type: :runtime
66
71
  prerelease: false
67
72
  version_requirements: !ruby/object:Gem::Requirement
68
73
  requirements:
69
74
  - - "~>"
70
75
  - !ruby/object:Gem::Version
71
- version: '0.3'
76
+ version: '0.5'
72
77
  - - ">="
73
78
  - !ruby/object:Gem::Version
74
- version: 0.3.2
79
+ version: 0.5.3
75
80
  - !ruby/object:Gem::Dependency
76
81
  name: novowels
77
82
  requirement: !ruby/object:Gem::Requirement
@@ -93,7 +98,7 @@ dependencies:
93
98
  - !ruby/object:Gem::Version
94
99
  version: 0.1.3
95
100
  description:
96
- email: james@jamesrobertson.eu
101
+ email: digital.robertson@gmail.com
97
102
  executables: []
98
103
  extensions: []
99
104
  extra_rdoc_files: []
@@ -120,8 +125,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
125
  - !ruby/object:Gem::Version
121
126
  version: '0'
122
127
  requirements: []
123
- rubygems_version: 3.0.1
128
+ rubyforge_project:
129
+ rubygems_version: 2.7.10
124
130
  signing_key:
125
131
  specification_version: 4
126
- summary: 'Offline Mail Helper: Stores email messages in a file directory archive'
132
+ summary: 'Offline Mail Helper: Stores email messages in a file directory archive.'
127
133
  test_files: []
metadata.gz.sig CHANGED
Binary file