daily_notices 0.6.2 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/daily_notices.rb +89 -42
- metadata +46 -42
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: be073789390a9bc4b8ee8f1355b359c43a03db7b39d4a1092811c5a0df281275
|
4
|
+
data.tar.gz: 2152532d8674c8486b50fce13a6329337c08994b7cd264bc11025a12d2259db0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ed7f49c33b34620f0a34c6f68fd0774e474e9de64f0890de135a1af8c26a8e34637398a0babee927259850ccbb9ca0ba791dc069d2a21fcf404a69f289b3294
|
7
|
+
data.tar.gz: ac0743f609fb732536bd2e2a5b03ff60c2a29f624b92cc2e9bb2cfd9f61f59bd49017c89aabeda9958a73037c1403415166095730a44ad5d3d1e62ba41af0090
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/daily_notices.rb
CHANGED
@@ -9,18 +9,18 @@ require 'fileutils'
|
|
9
9
|
require 'rss_creator'
|
10
10
|
|
11
11
|
|
12
|
-
|
13
12
|
class DailyNotices
|
14
13
|
|
15
14
|
attr_accessor :title, :description, :link, :dx_xslt, :rss_xslt
|
16
15
|
|
17
16
|
def initialize(filepath='', url_base: 'http:/127.0.0.1/', identifier: '',
|
18
17
|
dx_xslt: '', rss_xslt: '', target_page: :recordset,
|
19
|
-
target_xslt: '', title: 'daily notices'
|
18
|
+
target_xslt: '', title: 'daily notices', log: nil,
|
19
|
+
debug: false)
|
20
20
|
|
21
21
|
@filepath, @url_base, @dx_xslt, @rss_xslt, @target_page, @target_xslt, \
|
22
|
-
@identifier = filepath, url_base, dx_xslt, rss_xslt,
|
23
|
-
target_xslt, identifier
|
22
|
+
@identifier, @log, @debug = filepath, url_base, dx_xslt, rss_xslt, \
|
23
|
+
target_page, target_xslt, identifier, log, debug
|
24
24
|
|
25
25
|
|
26
26
|
@schema ||= 'items[title, identifier]/item(title, description, time, link)'
|
@@ -78,14 +78,15 @@ class DailyNotices
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def create(id: Time.now.to_i.to_s,
|
81
|
-
item: {time: Time.now.strftime('%H:%M %p - %d %b %Y'), title: nil})
|
81
|
+
item: {time: Time.now.strftime('%H:%M %p - %d %b %Y'), title: nil})
|
82
82
|
|
83
|
+
@log.info 'daily_notices/create: item: ' + item.inspect if @log
|
83
84
|
h = item
|
84
85
|
|
85
86
|
new_day() if @day != Time.now.day
|
86
87
|
|
87
88
|
if @dx.all.any? and
|
88
|
-
@dx.all.first.description == CGI.unescape(h[:description]) then
|
89
|
+
@dx.all.first.description == CGI.unescape(h[:description].to_s) then
|
89
90
|
|
90
91
|
return :duplicate
|
91
92
|
|
@@ -97,35 +98,12 @@ class DailyNotices
|
|
97
98
|
h[:time] ||= Time.now.strftime('%H:%M %p - %d %b %Y')
|
98
99
|
|
99
100
|
#@dx.create({description: description, time: time}, id: id)
|
101
|
+
puts 'before @dx.create' if @debug
|
100
102
|
@dx.create(h, id: id)
|
103
|
+
puts 'after @dx.create' if @debug
|
101
104
|
@dx.save @indexpath
|
102
105
|
|
103
|
-
|
104
|
-
File.write File.join(@filepath, @archive_path, 'index.html'), \
|
105
|
-
@dx.to_html(domain: @url_base)
|
106
|
-
else
|
107
|
-
|
108
|
-
target_path = File.join(@filepath, @archive_path, id, 'index.html')
|
109
|
-
FileUtils.mkdir_p File.dirname(target_path)
|
110
|
-
|
111
|
-
rx = @dx.find(id)
|
112
|
-
|
113
|
-
kvx = rx.to_kvx
|
114
|
-
yield kvx if block_given?
|
115
|
-
|
116
|
-
rxdoc = Rexle.new(kvx.to_xml)
|
117
|
-
rxdoc.instructions << ['xml-styelsheet',\
|
118
|
-
"title='XSL_formatting' type='text/xsl' href='#{@target_xslt}'"]
|
119
|
-
File.write target_path.sub(/\.html$/,'.xml', ), rxdoc.xml(pretty: true)
|
120
|
-
|
121
|
-
unless File.exists? @target_xslt then
|
122
|
-
File.write @target_xslt,
|
123
|
-
RxSliml.new(fields: %i(description time)).to_xslt
|
124
|
-
end
|
125
|
-
|
126
|
-
File.write target_path, rx.to_html(xslt: @target_xslt)
|
127
|
-
|
128
|
-
end
|
106
|
+
render_html_files(id)
|
129
107
|
|
130
108
|
# Add it to the RSS document
|
131
109
|
|
@@ -141,6 +119,34 @@ class DailyNotices
|
|
141
119
|
|
142
120
|
alias add create
|
143
121
|
|
122
|
+
|
123
|
+
def delete(id)
|
124
|
+
|
125
|
+
[@dx, @rss].each {|x| x.delete(id.to_s); x.save}
|
126
|
+
|
127
|
+
archive_path = Time.at(id.to_i).strftime("%Y/%b/%-d").downcase
|
128
|
+
indexpath = File.join(@filepath, archive_path, id.to_s)
|
129
|
+
|
130
|
+
FileUtils.rm_rf indexpath
|
131
|
+
|
132
|
+
id.to_s + ' deleted'
|
133
|
+
|
134
|
+
end
|
135
|
+
|
136
|
+
def description()
|
137
|
+
@rss.description
|
138
|
+
end
|
139
|
+
|
140
|
+
def description=(val)
|
141
|
+
@rss.description = val
|
142
|
+
end
|
143
|
+
|
144
|
+
def image=(val)
|
145
|
+
image_url, target_url = val.split
|
146
|
+
@rss.image_url = image_url
|
147
|
+
@rss.image_target_url = target_url
|
148
|
+
end
|
149
|
+
|
144
150
|
def title()
|
145
151
|
@rss.title
|
146
152
|
end
|
@@ -156,14 +162,7 @@ class DailyNotices
|
|
156
162
|
def link=(val)
|
157
163
|
@rss.link = val
|
158
164
|
end
|
159
|
-
|
160
|
-
def description()
|
161
|
-
@rss.description
|
162
|
-
end
|
163
|
-
|
164
|
-
def description=(val)
|
165
|
-
@rss.description = val
|
166
|
-
end
|
165
|
+
|
167
166
|
|
168
167
|
# If you wish override this method or use it in block form to add a
|
169
168
|
# notifier, callback routine or webhook, whenever a new record is added.
|
@@ -178,6 +177,10 @@ class DailyNotices
|
|
178
177
|
@rss.save @rssfile
|
179
178
|
end
|
180
179
|
|
180
|
+
def to_dx()
|
181
|
+
Dynarex.new @dx.to_xml
|
182
|
+
end
|
183
|
+
|
181
184
|
private
|
182
185
|
|
183
186
|
def create_link(id)
|
@@ -188,6 +191,8 @@ class DailyNotices
|
|
188
191
|
#
|
189
192
|
def new_day()
|
190
193
|
|
194
|
+
puts 'inside new_day' if @debug
|
195
|
+
|
191
196
|
@archive_path = Time.now.strftime("%Y/%b/%-d").downcase
|
192
197
|
|
193
198
|
@indexpath = File.join(@filepath, @archive_path, 'index.xml')
|
@@ -197,7 +202,9 @@ class DailyNotices
|
|
197
202
|
if File.exists? @indexpath then
|
198
203
|
@dx = Dynarex.new @indexpath
|
199
204
|
else
|
200
|
-
|
205
|
+
|
206
|
+
puts 'creating a new dx file' if @debug
|
207
|
+
@dx = Dynarex.new @schema, debug: @debug
|
201
208
|
@dx.order = 'descending'
|
202
209
|
@dx.default_key = @default_key
|
203
210
|
@dx.xslt = @dx_xslt
|
@@ -205,6 +212,46 @@ class DailyNotices
|
|
205
212
|
@dx.identifier = @identifier
|
206
213
|
end
|
207
214
|
|
215
|
+
end
|
216
|
+
|
217
|
+
def render_html_files(id)
|
218
|
+
|
219
|
+
puts 'inside render_html_files' if @debug
|
220
|
+
|
221
|
+
if @target_page == :recordset then
|
222
|
+
File.write File.join(@filepath, @archive_path, 'index.html'), \
|
223
|
+
@dx.to_html(domain: @url_base)
|
224
|
+
else
|
225
|
+
|
226
|
+
target_path = File.join(@filepath, @archive_path, id, 'index.html')
|
227
|
+
FileUtils.mkdir_p File.dirname(target_path)
|
228
|
+
|
229
|
+
rx = @dx.find(id)
|
230
|
+
|
231
|
+
puts 'rx: ' + rx.inspect if @debug
|
232
|
+
kvx = rx.to_kvx
|
233
|
+
|
234
|
+
yield kvx if block_given?
|
235
|
+
puts 'before kvx.to_xml' if @debug
|
236
|
+
puts 'kvx.to_xml : ' + kvx.to_xml.inspect
|
237
|
+
puts 'before 2 kvx.to_xml' if @debug
|
238
|
+
rxdoc = Rexle.new(kvx.to_xml)
|
239
|
+
puts 'after kvx.to_xml' if @debug
|
240
|
+
|
241
|
+
rxdoc.instructions << ['xml-styelsheet',\
|
242
|
+
"title='XSL_formatting' type='text/xsl' href='#{@target_xslt}'"]
|
243
|
+
File.write target_path.sub(/\.html$/,'.xml', ), rxdoc.xml(pretty: true)
|
244
|
+
|
245
|
+
unless File.exists? @target_xslt then
|
246
|
+
|
247
|
+
File.write @target_xslt,
|
248
|
+
RxSliml.new(fields: %i(description time)).to_xslt
|
249
|
+
end
|
250
|
+
|
251
|
+
File.write target_path, rx.to_html(xslt: @target_xslt)
|
252
|
+
|
253
|
+
end
|
254
|
+
|
208
255
|
end
|
209
256
|
|
210
|
-
end
|
257
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: daily_notices
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -10,28 +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
|
-
|
31
|
-
|
32
|
-
|
13
|
+
MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjEwMjI0MT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XD7oq0c3USmZtTGn4N8Cy1Sm0WR3RUvbYF6Dta2o1UKQ0vIko/i0kj
|
30
|
+
cNcvG6LcQkUt1mPhEMWAVoWvBL7xySN6yU9Ls7YmpW9Y+62v74NwGqx8c6N2VZKL
|
31
|
+
Vw24Rh4OC9e5cIjO+SR0KRI4+YFm86SnPsVXycqaHvMO8rNBgxGqR1FfFYrNUn0I
|
32
|
+
jafFtIcshyvSFoAaYK5GbPD8Xw/vZ/Red1SXdjmC4+j5ZtAx2c+vgK1lErjGqsYp
|
33
|
+
/XJl7PJxLwoAHYtYjensYXkRw8RZ7Re+HsW4IAmq1IQtBEYjjgWUwEhry56jQ/1A
|
34
|
+
ovxhAIUn9BlZdnsefgTYj2Cy+7z0VyGgWOwrxb1WmGNqjIvZtlFEQzm2yGelNIB2
|
35
|
+
mq989lGt58a/Y5CLIB7CrHXwKhKPrMrl9wrNJQaGhmKCpC48MvGPzmGUKYO3OTRK
|
36
|
+
QCT4F3Esm7/YTYtL3CQJWI1T
|
33
37
|
-----END CERTIFICATE-----
|
34
|
-
date:
|
38
|
+
date: 2021-02-24 00:00:00.000000000 Z
|
35
39
|
dependencies:
|
36
40
|
- !ruby/object:Gem::Dependency
|
37
41
|
name: rss_creator
|
@@ -39,20 +43,20 @@ dependencies:
|
|
39
43
|
requirements:
|
40
44
|
- - "~>"
|
41
45
|
- !ruby/object:Gem::Version
|
42
|
-
version: '0.
|
46
|
+
version: '0.4'
|
43
47
|
- - ">="
|
44
48
|
- !ruby/object:Gem::Version
|
45
|
-
version: 0.
|
49
|
+
version: 0.4.2
|
46
50
|
type: :runtime
|
47
51
|
prerelease: false
|
48
52
|
version_requirements: !ruby/object:Gem::Requirement
|
49
53
|
requirements:
|
50
54
|
- - "~>"
|
51
55
|
- !ruby/object:Gem::Version
|
52
|
-
version: '0.
|
56
|
+
version: '0.4'
|
53
57
|
- - ">="
|
54
58
|
- !ruby/object:Gem::Version
|
55
|
-
version: 0.
|
59
|
+
version: 0.4.2
|
56
60
|
- !ruby/object:Gem::Dependency
|
57
61
|
name: dx_sliml
|
58
62
|
requirement: !ruby/object:Gem::Requirement
|
@@ -62,7 +66,7 @@ dependencies:
|
|
62
66
|
version: '0.1'
|
63
67
|
- - ">="
|
64
68
|
- !ruby/object:Gem::Version
|
65
|
-
version: 0.1.
|
69
|
+
version: 0.1.8
|
66
70
|
type: :runtime
|
67
71
|
prerelease: false
|
68
72
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -72,49 +76,49 @@ dependencies:
|
|
72
76
|
version: '0.1'
|
73
77
|
- - ">="
|
74
78
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.1.
|
79
|
+
version: 0.1.8
|
76
80
|
- !ruby/object:Gem::Dependency
|
77
81
|
name: rx_sliml
|
78
82
|
requirement: !ruby/object:Gem::Requirement
|
79
83
|
requirements:
|
80
84
|
- - "~>"
|
81
85
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0.
|
86
|
+
version: '0.2'
|
83
87
|
- - ">="
|
84
88
|
- !ruby/object:Gem::Version
|
85
|
-
version: 0.1
|
89
|
+
version: 0.2.1
|
86
90
|
type: :runtime
|
87
91
|
prerelease: false
|
88
92
|
version_requirements: !ruby/object:Gem::Requirement
|
89
93
|
requirements:
|
90
94
|
- - "~>"
|
91
95
|
- !ruby/object:Gem::Version
|
92
|
-
version: '0.
|
96
|
+
version: '0.2'
|
93
97
|
- - ">="
|
94
98
|
- !ruby/object:Gem::Version
|
95
|
-
version: 0.1
|
99
|
+
version: 0.2.1
|
96
100
|
- !ruby/object:Gem::Dependency
|
97
101
|
name: rss_sliml
|
98
102
|
requirement: !ruby/object:Gem::Requirement
|
99
103
|
requirements:
|
100
|
-
- - "~>"
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
version: '0.1'
|
103
104
|
- - ">="
|
104
105
|
- !ruby/object:Gem::Version
|
105
|
-
version: 0.
|
106
|
+
version: 0.2.0
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0.2'
|
106
110
|
type: :runtime
|
107
111
|
prerelease: false
|
108
112
|
version_requirements: !ruby/object:Gem::Requirement
|
109
113
|
requirements:
|
110
|
-
- - "~>"
|
111
|
-
- !ruby/object:Gem::Version
|
112
|
-
version: '0.1'
|
113
114
|
- - ">="
|
114
115
|
- !ruby/object:Gem::Version
|
115
|
-
version: 0.
|
116
|
+
version: 0.2.0
|
117
|
+
- - "~>"
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0.2'
|
116
120
|
description:
|
117
|
-
email:
|
121
|
+
email: digital.robertson@gmail.com
|
118
122
|
executables: []
|
119
123
|
extensions: []
|
120
124
|
extra_rdoc_files: []
|
@@ -140,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
144
|
version: '0'
|
141
145
|
requirements: []
|
142
146
|
rubyforge_project:
|
143
|
-
rubygems_version: 2.
|
147
|
+
rubygems_version: 2.7.10
|
144
148
|
signing_key:
|
145
149
|
specification_version: 4
|
146
150
|
summary: A public facing noticeboard which is centered around an RSS feed.
|
metadata.gz.sig
CHANGED
Binary file
|