mns_subscriber 0.6.1 → 0.6.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ba7ffb83b3ae3627fe99ba11f1d3c6ca5b20beadf702ba658bf87a596a877dbb
4
- data.tar.gz: 5070727cf3f6443a3653edfa9cee25a81fbdb7a91a9253a72a42a8a7fa122ecb
3
+ metadata.gz: 2099c1bf98a5fa9859568e0ce7e71f1c0fa1eb695254241d2b47d99aac67472e
4
+ data.tar.gz: de2866f869b308ea2b5b18e982480a3a29ebf839f67a196c1c74517f1b79c2f8
5
5
  SHA512:
6
- metadata.gz: 8773c8013caf65d54f7bb8a75543e5826f47a46c92235f4ea9766ea095f8cdcca4ae256ea9c65e8ef112f597eb8e5c46fb46d25b7a14d016d71630d6216b4fe2
7
- data.tar.gz: 448558190b8e5082a8226cdf617b7c572a9125c6f57e2d5e9566f31bcc20b06e536ffeb5d1f334275f21cc0b3a1410ceaa1b143f3e26c589e383f3bffe45abf3
6
+ metadata.gz: 3c9b72b377b23bb5070991510caab1ec8d5a208b848bd2065388459fd5e731ea9b325edd751f68853ecf8c6c4bd82ebe9df2a9171667728d5f1b9371dbc614ee
7
+ data.tar.gz: 31468678c034180943413d76f0c728e5848aafb9253d06ecf9255d647f8e56afe041ecfffbf24917571210dd57d6f11f23943323b1d71b317d32387d503cea7f
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -24,7 +24,9 @@ class MNSSubscriber < SPSSub
24
24
  dx_xslt: '/xsl/dynarex.xsl',
25
25
  rss_xslt: '/xsl/feed.xsl',
26
26
  target_page: :page,
27
- target_xslt: '/xsl/page.xsl'
27
+ target_xslt: '/xsl/page.xsl',
28
+ local_media_path: '/home/user/media',
29
+ url_media_path: 'http://media.yourwebsitehere.co.uk/'
28
30
  }.merge(options)
29
31
 
30
32
  super(host: host, port: port, log: log)
@@ -85,6 +87,40 @@ class MNSSubscriber < SPSSub
85
87
 
86
88
  delete_notice(subtopic=a[-2], msg)
87
89
 
90
+ when :json
91
+
92
+ # JSON contains a message and 1 or more media files
93
+ h = JSON.parse msg, symbolize_names: true
94
+
95
+ subtopic = a[-2]
96
+
97
+ t = Time.now
98
+ id = t.to_i.to_s + t.strftime("%2N")
99
+
100
+ filepath = File.join(@options[:local_media_path], 'images')
101
+
102
+ a = h[:files].map.with_index do |f,i|
103
+
104
+ file = "%s%s" % [(id.to_i + i+1).to_s(36).reverse, File.extname(f)]
105
+ dest = File.join(filepath, file)
106
+
107
+ FileUtils.cp f, dest
108
+ FileUtils.chmod 0755, dest
109
+
110
+ dir = File.extname(file) =~ /\.(?:jpg|png)/ ? 'images' : ''
111
+ url = [@options[:url_media_path], dir, file].join('/')
112
+
113
+ href = [@options[:url_base].sub(/\/$/,''), subtopic, 'status', id,
114
+ 'photo', (i+1).to_s ].join('/')
115
+ "<a href='%s'><img class='img1' src='%s'/></a>" % [href, url]
116
+
117
+ end
118
+
119
+ div = a.any? ? "<div id='media'>#{a.join}</div>" : ''
120
+
121
+ add_notice(subtopic, h[:msg] + "\n" + div, id)
122
+
123
+
88
124
  else
89
125
 
90
126
  subtopic, id = a[1..-1]
@@ -98,7 +134,12 @@ class MNSSubscriber < SPSSub
98
134
 
99
135
  @log.info 'mns_subscriber/add_notice: active' if @log
100
136
  topic_dir = File.join(@filepath, topic)
101
- notices = DailyNotices.new topic_dir, @options.merge(identifier: topic,
137
+
138
+ options = @options.clone
139
+ options.delete :local_media_path
140
+ options.delete :url_media_path
141
+
142
+ notices = DailyNotices.new topic_dir, options.merge(identifier: topic,
102
143
  title: topic.capitalize + ' daily notices', log: @log)
103
144
 
104
145
  t = Time.now
@@ -177,11 +218,16 @@ class MNSSubscriber < SPSSub
177
218
 
178
219
  def delete_notice(topic, msg)
179
220
 
221
+
180
222
  topic_dir = File.join(@filepath, topic)
181
223
 
224
+ id = msg.to_i
225
+
226
+ feed = DailyNotices.new topic_dir, log: @log
227
+ feed.delete id
228
+
182
229
  notices = RecordxSqlite.new(File.join(topic_dir, 'notices.db'),
183
230
  table: 'notices')
184
- id = msg.to_i
185
231
  notices.delete id
186
232
 
187
233
  indexdb = File.join(topic_dir, 'index.db')
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.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  yOAycOYzp7fxmPl3/HV5D0YOJwuy1XslA50GQJwq12A5vMyUGUCHuxH/zKZcM/zr
36
36
  0QZaKiVqq5ZeGvni0eQSavhQ
37
37
  -----END CERTIFICATE-----
38
- date: 2021-02-27 00:00:00.000000000 Z
38
+ date: 2021-03-06 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: mtlite
@@ -118,7 +118,7 @@ dependencies:
118
118
  - !ruby/object:Gem::Version
119
119
  version: 0.3.1
120
120
  description:
121
- email: james@jamesrobertson.eu
121
+ email: digital.robertson@gmail.com
122
122
  executables: []
123
123
  extensions: []
124
124
  extra_rdoc_files: []
metadata.gz.sig CHANGED
Binary file