mns_subscriber 0.6.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/mns_subscriber.rb +428 -190
- data.tar.gz.sig +0 -0
- metadata +37 -17
- 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: d423aeed6fde9fb4b40f93118cdd02873b3d1c06725b03be6b85c39d854e1e41
|
4
|
+
data.tar.gz: 48073f7faea2f5874fb85ec995751196829a24c64f0b0a8813933fc61d9b2e55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72a1b222c7f4093c7f94b76c806b17d503645536fdb8b0bd7f024190274ea8e85ae85d0b22564e5cd33a2e158fc339315a66a9c0cd04ea8cc4cd1506691b94e1
|
7
|
+
data.tar.gz: 177387347a89ef47d2f927a7f34eb24a922c63b151d642912ac85a2a7b731315c4512c385e43880df50f97bc45659769f8214a9186948863cbe58343189ad3a0
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/mns_subscriber.rb
CHANGED
@@ -7,216 +7,454 @@ require 'mtlite'
|
|
7
7
|
require 'sps-sub'
|
8
8
|
require 'daily_notices'
|
9
9
|
require 'recordx_sqlite'
|
10
|
+
require 'easyimg_utils'
|
10
11
|
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
def initialize(host: 'sps', port: 59000, dir: '.', options: {},
|
15
|
-
timeline: nil, log: nil, hashtag_url: nil)
|
16
|
-
|
17
|
-
@log = log
|
18
|
-
log.info 'mns_subscriber/initialize: active' if log
|
19
|
-
|
20
|
-
# note: a valid url_base must be provided
|
21
|
-
|
22
|
-
@options = {
|
23
|
-
url_base: 'http://yourwebsitehere.co.uk/',
|
24
|
-
dx_xslt: '/xsl/dynarex.xsl',
|
25
|
-
rss_xslt: '/xsl/feed.xsl',
|
26
|
-
target_page: :page,
|
27
|
-
target_xslt: '/xsl/page.xsl'
|
28
|
-
}.merge(options)
|
29
|
-
|
30
|
-
super(host: host, port: port, log: log)
|
31
|
-
@filepath, @timeline = dir, timeline
|
32
|
-
|
33
|
-
@index = nil
|
34
|
-
@hashtags = nil
|
35
|
-
|
36
|
-
|
37
|
-
if hashtag_url then
|
38
|
-
|
39
|
-
@hashtag_url = @options[:url_base] + hashtag_url.sub(/^\//,'')
|
40
|
-
|
41
|
-
hashtag_path = File.join(dir, 'hashtag')
|
42
|
-
tagdb = File.join(hashtag_path, 'index.db')
|
43
|
-
FileUtils.mkdir_p File.dirname(tagdb)
|
44
|
-
|
45
|
-
h = {hashtags: {id: '', tag: '', topic: '', noticeid: ''}}
|
46
|
-
@hashtags = RecordxSqlite.new(tagdb, table: h )
|
13
|
+
module MNSSubscriber
|
47
14
|
|
15
|
+
class NoticeMgr
|
16
|
+
include RXFHelperModule
|
17
|
+
using ColouredText
|
18
|
+
|
19
|
+
def initialize(sps=nil, dir: '.', db_path: '.', options: {}, timeline: nil,
|
20
|
+
hashtag_url: nil, log: nil, debug: false)
|
21
|
+
|
22
|
+
@sps, @log, @debug = sps, log, debug
|
23
|
+
|
24
|
+
# note: a valid url_base must be provided
|
25
|
+
@options = {
|
26
|
+
url_base: 'http://yourwebsitehere.co.uk/',
|
27
|
+
dx_xslt: '/xsl/dynarex.xsl',
|
28
|
+
rss_xslt: '/xsl/feed.xsl',
|
29
|
+
target_page: :page,
|
30
|
+
target_xslt: '/xsl/page.xsl',
|
31
|
+
local_media_path: '/home/user/media',
|
32
|
+
url_media_path: 'http://media.yourwebsitehere.co.uk/'
|
33
|
+
}.merge(options)
|
34
|
+
|
35
|
+
|
36
|
+
@filepath, @db_path, @timeline = dir, db_path, timeline
|
37
|
+
|
38
|
+
@index = nil
|
39
|
+
@hashtags = nil
|
40
|
+
|
41
|
+
|
42
|
+
if hashtag_url then
|
43
|
+
|
44
|
+
@hashtag_url = @options[:url_base] + hashtag_url.sub(/^\//,'')
|
45
|
+
|
46
|
+
hashtag_path = File.join(dir, 'hashtag')
|
47
|
+
tagdb = File.join(db_path, 'hashtag', 'index.db')
|
48
|
+
tagdb_dir = File.join(hashtag_path, 'index.db')
|
49
|
+
FileX.mkdir_p File.dirname(tagdb_dir)
|
50
|
+
|
51
|
+
h = {hashtags: {id: '', tag: '', topic: '', noticeid: ''}}
|
52
|
+
@hashtags = RecordxSqlite.new(tagdb, table: h )
|
53
|
+
|
54
|
+
end
|
48
55
|
end
|
49
56
|
|
50
|
-
|
57
|
+
def incoming(topic, msg)
|
51
58
|
|
52
|
-
|
53
|
-
|
54
|
-
end
|
59
|
+
a = topic.split('/')
|
60
|
+
context = a.last.to_sym
|
55
61
|
|
56
|
-
|
57
|
-
|
58
|
-
def ontopic(topic, msg)
|
59
|
-
|
60
|
-
@log.info 'mns_subscriber/ontopic: topic: ' + topic.inspect if @topic
|
61
|
-
|
62
|
-
a = topic.split('/')
|
63
|
-
puts "%s: %s %s" % [topic, Time.now.to_s, msg.inspect]
|
64
|
-
|
65
|
-
|
66
|
-
case a.last.to_sym
|
67
|
-
|
68
|
-
when :profile
|
69
|
-
|
70
|
-
update_attributes(:description, subtopic=a[-2], profile=msg)
|
71
|
-
|
72
|
-
when :link
|
73
|
-
|
74
|
-
update_attributes(:link, subtopic=a[-2], link=msg)
|
75
|
-
|
76
|
-
when :title
|
77
|
-
|
78
|
-
update_attributes(:title, subtopic=a[-2], title=msg)
|
79
|
-
|
80
|
-
when :image
|
81
|
-
|
82
|
-
update_attributes(:image, subtopic=a[-2], title=msg)
|
83
|
-
|
84
|
-
when :delete
|
85
|
-
|
86
|
-
delete_notice(subtopic=a[-2], msg)
|
87
|
-
|
88
|
-
else
|
89
|
-
|
90
|
-
subtopic, id = a[1..-1]
|
91
|
-
add_notice(subtopic, msg, id)
|
92
|
-
|
93
|
-
end
|
62
|
+
case context
|
63
|
+
when :profile
|
94
64
|
|
95
|
-
|
65
|
+
#update_attributes(:description, subtopic=a[-2], profile=msg)
|
66
|
+
h = JSON.parse msg, symbolize_names: true
|
67
|
+
update_profile(subtopic=a[-2], h)
|
68
|
+
|
69
|
+
when :link
|
70
|
+
puts 'we have a link' if @debug
|
71
|
+
update_attributes(:link, subtopic=a[-2], link=msg)
|
72
|
+
|
73
|
+
when :title
|
74
|
+
|
75
|
+
update_attributes(:title, subtopic=a[-2], title=msg)
|
76
|
+
|
77
|
+
when :image
|
78
|
+
#puts 'we have an image'
|
79
|
+
update_attributes(:image, subtopic=a[-2], title=msg)
|
80
|
+
|
81
|
+
when :delete
|
82
|
+
|
83
|
+
delete_notice(subtopic=a[-2], msg)
|
84
|
+
|
85
|
+
when :json
|
86
|
+
|
87
|
+
# JSON contains a message and 1 or more media files
|
88
|
+
h = JSON.parse msg, symbolize_names: true
|
89
|
+
puts 'h: ' + h.inspect if @debug
|
90
|
+
|
91
|
+
subtopic = a[-2]
|
92
|
+
|
93
|
+
t = Time.now
|
94
|
+
id = t.to_i.to_s + t.strftime("%2N")
|
95
|
+
|
96
|
+
filepath = File.join(@options[:local_media_path], 'images')
|
97
|
+
|
98
|
+
a = h[:files].map.with_index do |f,i|
|
99
|
+
|
100
|
+
# is f an Array object containing various sized images of the 1 file?
|
101
|
+
a2 = f.is_a?(Array) ? f : [f]
|
102
|
+
|
103
|
+
scale = a2.map do |imgfile|
|
104
|
+
|
105
|
+
scale = imgfile[/(_\w+)\.\w+$/,1].to_s
|
106
|
+
file = "%s%s%s" % [(id.to_i + i+1).to_s(36).reverse, scale, File.extname(imgfile)]
|
107
|
+
dest = File.join(filepath, file)
|
108
|
+
|
109
|
+
FileX.cp imgfile, dest
|
110
|
+
FileX.chmod 0755, dest
|
111
|
+
|
112
|
+
file
|
113
|
+
|
114
|
+
end
|
115
|
+
|
116
|
+
puts 'scale: ' + scale.inspect
|
117
|
+
index = scale[2] ? 2 : (scale[1] ? 1 : 0)
|
118
|
+
file1 = scale[index]
|
119
|
+
|
120
|
+
dir = File.extname(file1) =~ /\.(?:jpg|png)/ ? 'images' : ''
|
121
|
+
url = [@options[:url_media_path], dir, file1].join('/')
|
122
|
+
|
123
|
+
href = [@options[:url_base].sub(/\/$/,''), subtopic, 'status', id,
|
124
|
+
'photo', (i+1).to_s ].join('/')
|
125
|
+
# find the best y position for the image letterbox view
|
126
|
+
pct = EasyImgUtils.new(a2[index]).best_viewport
|
127
|
+
pct2 = (pct / 10.0).to_i * 10
|
128
|
+
|
129
|
+
align = if pct < 35 then
|
130
|
+
|
131
|
+
if pct < 10 then
|
132
|
+
:top
|
133
|
+
else
|
134
|
+
'y' + pct2.to_s
|
135
|
+
end
|
136
|
+
|
137
|
+
elsif pct >= 70
|
138
|
+
:bottom
|
139
|
+
else
|
140
|
+
#'y' + pct.to_s
|
141
|
+
:center
|
142
|
+
end
|
96
143
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
144
|
+
{url: url, align: align}
|
145
|
+
|
146
|
+
end
|
147
|
+
|
148
|
+
|
149
|
+
card = if h[:card] then
|
150
|
+
|
151
|
+
puts 'h[:card]: ' + h[:card].inspect
|
152
|
+
puts 'a: ' + a.inspect
|
153
|
+
|
154
|
+
if h[:card][:summary_large_image] then
|
155
|
+
|
156
|
+
h[:card][:summary_large_image][:img] = a[2][:url] if a.any?
|
157
|
+
h[:card]
|
158
|
+
|
159
|
+
elsif h[:card][:summary]
|
160
|
+
|
161
|
+
h[:card][:summary][:img] = a[0][:url] if a.any?
|
162
|
+
h[:card]
|
163
|
+
|
164
|
+
end
|
165
|
+
|
166
|
+
elsif a.any?
|
167
|
+
{images: a}
|
168
|
+
end
|
169
|
+
puts 'before build'
|
170
|
+
#puts ('card: ' + card.inspect).debug
|
171
|
+
|
172
|
+
h[:msg] += build(card) if card
|
173
|
+
add_notice(subtopic, h[:msg].gsub('<','<')\
|
174
|
+
.gsub('>','>').gsub("\r",''), id,
|
175
|
+
(card ? card.to_json : nil))
|
176
|
+
|
177
|
+
else
|
178
|
+
|
179
|
+
subtopic, id = a[1..-1]
|
180
|
+
add_notice(subtopic, msg, id)
|
181
|
+
|
182
|
+
end
|
116
183
|
end
|
117
|
-
|
118
|
-
if @hashtag_url then
|
119
184
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
185
|
+
private
|
186
|
+
|
187
|
+
def add_notice(topic, raw_msg, raw_id=nil, card=nil)
|
188
|
+
|
189
|
+
@log.info 'mns_subscriber/add_notice: active' if @log
|
190
|
+
|
191
|
+
if @log then
|
192
|
+
@log.debug 'mns_subscriber/add_notice: @db_path:' + @db_path.inspect
|
124
193
|
end
|
125
|
-
|
126
|
-
# add the record to the database
|
127
|
-
tags.each do |tag|
|
128
|
-
|
129
|
-
t = Time.now
|
130
|
-
id2 = (t.to_i.to_s + t.strftime("%2N")).to_i
|
131
|
-
h = {id: id2, tag: tag, topic: topic, noticeid: id}
|
132
194
|
|
133
|
-
|
134
|
-
|
195
|
+
topic_dir = File.join(@filepath, 'u', topic)
|
196
|
+
topic_db_dir = File.join(@db_path, 'u', topic)
|
197
|
+
|
198
|
+
|
199
|
+
options = @options.clone
|
200
|
+
options.delete :local_media_path
|
201
|
+
options.delete :url_media_path
|
202
|
+
|
203
|
+
notices = DailyNotices.new topic_dir, **options.merge(identifier: topic,
|
204
|
+
title: topic.capitalize + ' daily notices', log: @log)
|
205
|
+
|
206
|
+
t = Time.now
|
207
|
+
id = (raw_id || t.to_i.to_s + t.strftime("%2N")).to_i
|
208
|
+
|
209
|
+
# strip out any JSON from the end of the message
|
210
|
+
msg, raw_json = raw_msg.split(/(?=\{.*)/)
|
211
|
+
|
212
|
+
msg = ' ' if msg.nil?
|
213
|
+
mtlite = MTLite.new(msg)
|
214
|
+
|
215
|
+
desc = if mtlite.to_html(para: false) =~ /<\w+/ then
|
216
|
+
mtlite.to_html(para: true, ignore_domainlabel:true)
|
217
|
+
else
|
218
|
+
mtlite.to_s
|
219
|
+
end
|
220
|
+
|
221
|
+
if @hashtag_url then
|
222
|
+
|
223
|
+
tags = desc.scan(/(?<= #)\w+/)
|
224
|
+
|
225
|
+
desc.gsub!(/ [#\$][a-zA-Z]\w+/) do |rawx|
|
226
|
+
|
227
|
+
x = rawx.lstrip
|
228
|
+
baseurl = x[0] == '#' ? @hashtag_url : 'search?q='
|
229
|
+
url = baseurl + CGI.escape(x.sub(/^#/,''))
|
230
|
+
" <a href='%s'>%s</a>" % [url, x]
|
231
|
+
|
232
|
+
end
|
233
|
+
|
234
|
+
# add the record to the database
|
235
|
+
tags.each do |tag|
|
236
|
+
|
237
|
+
t = Time.now
|
238
|
+
id2 = (t.to_i.to_s + t.strftime("%2N")).to_i
|
239
|
+
h = {id: id2, tag: tag, topic: topic, noticeid: id}
|
240
|
+
|
241
|
+
@hashtags.create h if @hashtags
|
242
|
+
|
243
|
+
end
|
244
|
+
|
245
|
+
end
|
246
|
+
|
247
|
+
title = mtlite.to_s.lines.first.chomp
|
248
|
+
title = title[0..136] + ' ...' if title.length > 140
|
249
|
+
|
250
|
+
h = {
|
251
|
+
title: title,
|
252
|
+
description: desc,
|
253
|
+
topic: topic,
|
254
|
+
card: card
|
255
|
+
}
|
256
|
+
#puts 'inside add_notice h: ' + h.inspect
|
257
|
+
return_status = notices.add(item: h, id: id.to_s)
|
258
|
+
#puts 'return_status: ' + return_status.inspect
|
259
|
+
|
260
|
+
return if return_status == :duplicate
|
261
|
+
|
262
|
+
rxnotices = RecordxSqlite.new(File.join(topic_db_dir, 'notices.db'),
|
263
|
+
table: {notices: {id: 0, description: '', message: ''}})
|
264
|
+
|
265
|
+
begin
|
266
|
+
rxnotices.create id: id.to_s, description: desc, message: msg
|
267
|
+
rescue
|
268
|
+
puts 'warning: rxnotices.create -> ' + ($!).inspect
|
135
269
|
end
|
136
|
-
|
270
|
+
|
271
|
+
if raw_json then
|
272
|
+
|
273
|
+
record = JSON.parse(raw_json)
|
274
|
+
index = RecordxSqlite.new(File.join(topic_db_dir, 'index.db'),
|
275
|
+
table: {items: record})
|
276
|
+
index.create record
|
277
|
+
|
278
|
+
update_index_xml(index, topic_dir)
|
279
|
+
|
280
|
+
end
|
281
|
+
|
282
|
+
@sps.notice "%s/add: %s/status/%s" % [@timeline, topic, id] if @timeline
|
283
|
+
|
284
|
+
sleep 0.3
|
285
|
+
|
137
286
|
end
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
287
|
+
|
288
|
+
def delete_notice(topic, msg)
|
289
|
+
|
290
|
+
topic_dir = File.join(@filepath, topic)
|
291
|
+
topic_db_dir = File.join(@db_path, topic)
|
292
|
+
|
293
|
+
id = msg.to_i
|
294
|
+
|
295
|
+
feed = DailyNotices.new topic_dir, log: @log
|
296
|
+
feed.delete id
|
297
|
+
|
298
|
+
notices = RecordxSqlite.new(File.join(topic_db_dir, 'notices.db'),
|
299
|
+
table: 'notices')
|
300
|
+
notices.delete id
|
301
|
+
|
302
|
+
indexdb = File.join(topic_db_dir, 'index.db')
|
303
|
+
|
304
|
+
if File.exists? indexdb then
|
305
|
+
|
306
|
+
index = RecordxSqlite.new(indexdb, table: 'items')
|
307
|
+
index.delete id
|
308
|
+
update_index_xml(index, topic_dir)
|
309
|
+
end
|
310
|
+
|
159
311
|
end
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
312
|
+
|
313
|
+
# builds the HTML for a given card
|
314
|
+
#
|
315
|
+
def build(card)
|
316
|
+
puts 'inside build'
|
317
|
+
|
318
|
+
#return card.inspect
|
319
|
+
#next unless card.is_a? Hash
|
320
|
+
|
321
|
+
if card.is_a? Hash then
|
322
|
+
|
323
|
+
card2 = case card.keys.first
|
324
|
+
when :images
|
325
|
+
|
326
|
+
card[:images].map.with_index do |img, i|
|
327
|
+
|
328
|
+
"<img class='img1' src='%s'/>" % img[:url]
|
329
|
+
|
330
|
+
end.join
|
331
|
+
|
332
|
+
when :summary_large_image
|
333
|
+
|
334
|
+
h2 = card[:summary_large_image]
|
335
|
+
|
336
|
+
rawdesc = h2[:desc]
|
337
|
+
|
338
|
+
desc = rawdesc.length > 147 ? rawdesc[0..147] + '...' : rawdesc
|
339
|
+
site = h2[:url][/https?:\/\/([^\/]+)/,1].sub(/^www\./,'')
|
340
|
+
title = h2[:title]
|
341
|
+
img = h2[:img]
|
342
|
+
url = h2[:url]
|
343
|
+
|
344
|
+
# The following Card HTML template is for use with the RSS feed.
|
345
|
+
# The actual HTML template for the card is rendered dynamically
|
346
|
+
# from the web server.
|
347
|
+
"
|
348
|
+
<div class='card'><a href='#{url}' target='_blank'>" +
|
349
|
+
"<div class='top-crop center'><img src='#{img}'/></div>" +
|
350
|
+
"<span class='title'>#{title}</span></a><p>#{desc}</p>" +
|
351
|
+
"<span class='link'><span class='linkurl'>#{site}</span></span></div>"
|
352
|
+
|
353
|
+
when :summary
|
354
|
+
|
355
|
+
h2 = card[:summary]
|
356
|
+
puts 'h2: ' + h2.inspect
|
357
|
+
rawdesc = h2[:desc]
|
358
|
+
|
359
|
+
desc = rawdesc.length > 120 ? rawdesc[0..120] + '...' : rawdesc
|
360
|
+
site = h2[:url][/https?:\/\/([^\/]+)(?=\/)/,1].sub(/^www\./,'')
|
361
|
+
title = h2[:title]
|
362
|
+
img = h2[:img]
|
363
|
+
url = h2[:url]
|
364
|
+
|
365
|
+
# The following Card HTML template is for use with the RSS feed.
|
366
|
+
# The actual HTML template for the card is rendered dynamically
|
367
|
+
# from the web server.
|
368
|
+
|
369
|
+
"<div class='card2'><a href='#{url}' target='_blank'><div><div id='col1'>" +
|
370
|
+
"<img src='#{img}'></div><div id='col2'><div id='content'>" +
|
371
|
+
"<span class='title'>#{title}</span><span class='desc'>#{desc}</span>" +
|
372
|
+
"<span class='link'><span class='linkurl'>#{site}</span></span></div>" +
|
373
|
+
"</div></div></a></div>"
|
374
|
+
|
375
|
+
end
|
376
|
+
end
|
377
|
+
|
170
378
|
end
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
notices.delete id
|
186
|
-
|
187
|
-
indexdb = File.join(topic_dir, 'index.db')
|
188
|
-
|
189
|
-
if File.exists? indexdb then
|
190
|
-
|
191
|
-
index = RecordxSqlite.new(indexdb, table: 'items')
|
192
|
-
index.delete id
|
193
|
-
update_index_xml(index, topic_dir)
|
379
|
+
|
380
|
+
def update_index_xml(index, topic_dir)
|
381
|
+
|
382
|
+
# create the index.xml file
|
383
|
+
|
384
|
+
a = index.order(:desc).first(15)
|
385
|
+
a2 = a.map {|x| h = x.to_h; id = h.delete(:id); {item_id: id}.merge(h)}
|
386
|
+
|
387
|
+
dx = Dynarex.new
|
388
|
+
dx.import a2
|
389
|
+
dx.order ='descending'
|
390
|
+
|
391
|
+
dx.save File.join(topic_dir, 'index.xml')
|
392
|
+
|
194
393
|
end
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
394
|
+
|
395
|
+
def update_attributes(attribute, topic, value)
|
396
|
+
|
397
|
+
topic_dir = File.join(@filepath, topic)
|
398
|
+
notices = DailyNotices.new topic_dir, **@options.merge(identifier: topic)
|
399
|
+
notices.method((attribute.to_s + '=').to_sym).call(value)
|
400
|
+
notices.save
|
401
|
+
|
402
|
+
end
|
403
|
+
|
404
|
+
def update_profile(topic, h)
|
405
|
+
|
406
|
+
topic_dir = File.join(@filepath, topic)
|
407
|
+
notices = DailyNotices.new topic_dir, **@options.merge(identifier: topic)
|
408
|
+
|
409
|
+
valid_keys = %i(title identifier image bio location website banner_image)
|
410
|
+
|
411
|
+
h.each_pair do |key, value|
|
412
|
+
|
413
|
+
next unless valid_keys.include? key
|
414
|
+
|
415
|
+
attribute = key.to_s
|
416
|
+
notices.method((attribute + '=').to_sym).call(value)
|
417
|
+
|
418
|
+
end
|
419
|
+
|
420
|
+
notices.save
|
421
|
+
|
422
|
+
end
|
423
|
+
|
424
|
+
|
211
425
|
end
|
212
426
|
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
427
|
+
class Client < SPSSub
|
428
|
+
|
429
|
+
def initialize(host: 'sps', port: 59000, dir: '.', db_path: '.',
|
430
|
+
options: {}, timeline: nil, log: nil, hashtag_url: nil)
|
431
|
+
|
432
|
+
@log = log
|
433
|
+
log.info 'mns_subscriber/initialize: active' if log
|
434
|
+
@nm = NoticeMgr.new(self, dir: dir, db_path: db_path, options: options, timeline: timeline,
|
435
|
+
hashtag_url: hashtag_url, log: log, debug: true)
|
436
|
+
|
437
|
+
super(host: host, port: port, log: log)
|
438
|
+
|
439
|
+
end
|
440
|
+
|
441
|
+
def subscribe(topicx='notice/*', topic: topicx)
|
442
|
+
super(topic: topic)
|
443
|
+
end
|
444
|
+
|
445
|
+
private
|
446
|
+
|
447
|
+
def ontopic(topic, msg)
|
448
|
+
|
449
|
+
@log.info 'mns_subscriber/ontopic: topic: ' + topic.inspect if @topic
|
450
|
+
|
451
|
+
a = topic.split('/')
|
452
|
+
#puts "%s: %s %s" % [topic, Time.now.to_s, msg.inspect]
|
453
|
+
|
454
|
+
@nm.incoming topic, msg
|
455
|
+
|
456
|
+
end
|
457
|
+
|
220
458
|
end
|
221
459
|
|
222
460
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mns_subscriber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,28 +35,28 @@ cert_chain:
|
|
35
35
|
yOAycOYzp7fxmPl3/HV5D0YOJwuy1XslA50GQJwq12A5vMyUGUCHuxH/zKZcM/zr
|
36
36
|
0QZaKiVqq5ZeGvni0eQSavhQ
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date:
|
38
|
+
date: 2022-01-19 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: mtlite
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
|
-
- - ">="
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: 0.4.0
|
47
44
|
- - "~>"
|
48
45
|
- !ruby/object:Gem::Version
|
49
46
|
version: '0.4'
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 0.4.1
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
|
-
- - ">="
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
version: 0.4.0
|
57
54
|
- - "~>"
|
58
55
|
- !ruby/object:Gem::Version
|
59
56
|
version: '0.4'
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 0.4.1
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: sps-sub
|
62
62
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,22 +81,22 @@ dependencies:
|
|
81
81
|
name: daily_notices
|
82
82
|
requirement: !ruby/object:Gem::Requirement
|
83
83
|
requirements:
|
84
|
-
- - ">="
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
version: 0.7.0
|
87
84
|
- - "~>"
|
88
85
|
- !ruby/object:Gem::Version
|
89
86
|
version: '0.7'
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.7.3
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 0.7.0
|
97
94
|
- - "~>"
|
98
95
|
- !ruby/object:Gem::Version
|
99
96
|
version: '0.7'
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: 0.7.3
|
100
100
|
- !ruby/object:Gem::Dependency
|
101
101
|
name: recordx_sqlite
|
102
102
|
requirement: !ruby/object:Gem::Requirement
|
@@ -106,7 +106,7 @@ dependencies:
|
|
106
106
|
version: '0.3'
|
107
107
|
- - ">="
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: 0.3.
|
109
|
+
version: 0.3.3
|
110
110
|
type: :runtime
|
111
111
|
prerelease: false
|
112
112
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -116,9 +116,29 @@ dependencies:
|
|
116
116
|
version: '0.3'
|
117
117
|
- - ">="
|
118
118
|
- !ruby/object:Gem::Version
|
119
|
-
version: 0.3.
|
119
|
+
version: 0.3.3
|
120
|
+
- !ruby/object:Gem::Dependency
|
121
|
+
name: easyimg_utils
|
122
|
+
requirement: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - "~>"
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0.7'
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: 0.7.4
|
130
|
+
type: :runtime
|
131
|
+
prerelease: false
|
132
|
+
version_requirements: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - "~>"
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0.7'
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: 0.7.4
|
120
140
|
description:
|
121
|
-
email:
|
141
|
+
email: digital.robertson@gmail.com
|
122
142
|
executables: []
|
123
143
|
extensions: []
|
124
144
|
extra_rdoc_files: []
|
metadata.gz.sig
CHANGED
Binary file
|