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