mns_subscriber 0.4.8 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 2c88a41d79148adc4d58cb5d101e55fcbe802638
4
- data.tar.gz: 97812ed29057cfd8d1d0ed37921081d803341363
2
+ SHA256:
3
+ metadata.gz: ba7ffb83b3ae3627fe99ba11f1d3c6ca5b20beadf702ba658bf87a596a877dbb
4
+ data.tar.gz: 5070727cf3f6443a3653edfa9cee25a81fbdb7a91a9253a72a42a8a7fa122ecb
5
5
  SHA512:
6
- metadata.gz: 49af079b3e1b8aed2d3a0b821120861f510867e377e154ee639917537e7e736f2c11549390f701b108e9e9be9679ee7038d7ba4a2b7120c7a500e4c7c9a060f4
7
- data.tar.gz: 9ce3286962e3e3047b365a587370b6da6a470607978b501bc70e44be05bf3c397d10828cfc32e2ae9f33c706788e4db5c97b301f24ecaf169552c810fddce7c8
6
+ metadata.gz: 8773c8013caf65d54f7bb8a75543e5826f47a46c92235f4ea9766ea095f8cdcca4ae256ea9c65e8ef112f597eb8e5c46fb46d25b7a14d016d71630d6216b4fe2
7
+ data.tar.gz: 448558190b8e5082a8226cdf617b7c572a9125c6f57e2d5e9566f31bcc20b06e536ffeb5d1f334275f21cc0b3a1410ceaa1b143f3e26c589e383f3bffe45abf3
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -12,7 +12,10 @@ require 'recordx_sqlite'
12
12
  class MNSSubscriber < SPSSub
13
13
 
14
14
  def initialize(host: 'sps', port: 59000, dir: '.', options: {},
15
- timeline: nil)
15
+ timeline: nil, log: nil, hashtag_url: nil)
16
+
17
+ @log = log
18
+ log.info 'mns_subscriber/initialize: active' if log
16
19
 
17
20
  # note: a valid url_base must be provided
18
21
 
@@ -24,10 +27,25 @@ class MNSSubscriber < SPSSub
24
27
  target_xslt: '/xsl/page.xsl'
25
28
  }.merge(options)
26
29
 
27
- super(host: host, port: port)
30
+ super(host: host, port: port, log: log)
28
31
  @filepath, @timeline = dir, timeline
29
32
 
30
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 )
47
+
48
+ end
31
49
 
32
50
  end
33
51
 
@@ -38,6 +56,8 @@ class MNSSubscriber < SPSSub
38
56
  private
39
57
 
40
58
  def ontopic(topic, msg)
59
+
60
+ @log.info 'mns_subscriber/ontopic: topic: ' + topic.inspect if @topic
41
61
 
42
62
  a = topic.split('/')
43
63
  puts "%s: %s %s" % [topic, Time.now.to_s, msg.inspect]
@@ -57,6 +77,10 @@ class MNSSubscriber < SPSSub
57
77
 
58
78
  update_attributes(:title, subtopic=a[-2], title=msg)
59
79
 
80
+ when :image
81
+
82
+ update_attributes(:image, subtopic=a[-2], title=msg)
83
+
60
84
  when :delete
61
85
 
62
86
  delete_notice(subtopic=a[-2], msg)
@@ -70,29 +94,69 @@ class MNSSubscriber < SPSSub
70
94
 
71
95
  end
72
96
 
73
- def add_notice(topic, raw_msg, raw_id=Time.now)
97
+ def add_notice(topic, raw_msg, raw_id=nil)
74
98
 
99
+ @log.info 'mns_subscriber/add_notice: active' if @log
75
100
  topic_dir = File.join(@filepath, topic)
76
101
  notices = DailyNotices.new topic_dir, @options.merge(identifier: topic,
77
- title: topic.capitalize + ' daily notices')
102
+ title: topic.capitalize + ' daily notices', log: @log)
78
103
 
79
- id = (raw_id || Time.now).to_i
104
+ t = Time.now
105
+ id = (raw_id || t.to_i.to_s + t.strftime("%2N")).to_i
80
106
 
81
107
  # strip out any JSON from the end of the message
82
108
  msg, raw_json = raw_msg.split(/(?=\{.*)/)
83
109
 
110
+ mtlite = MTLite.new(msg)
111
+
112
+ desc = if mtlite.to_html(para: false) =~ /<\w+/ then
113
+ mtlite.to_html(para: true, ignore_domainlabel:true)
114
+ else
115
+ mtlite.to_s
116
+ end
117
+
118
+ if @hashtag_url then
119
+
120
+ tags = desc.scan(/(?<=#)\w+/)
121
+
122
+ desc.gsub!(/#\w+/) do |x|
123
+ "<a href='%s%s'>%s</a>" % [@hashtag_url, x[1..-1], x]
124
+ 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
+
133
+ @hashtags.create h if @hashtags
134
+
135
+ end
136
+
137
+ end
138
+
139
+ title = mtlite.to_s.lines.first.chomp
140
+ title = title[0..136] + ' ...' if title.length > 140
141
+
84
142
  h = {
85
- description: MTLite.new(msg)
86
- .to_html(para: true, ignore_domainlabel:true),
143
+ title: title,
144
+ description: desc,
87
145
  topic: topic
88
146
  }
147
+
89
148
  return_status = notices.add(item: h, id: id.to_s)
90
149
 
91
150
  return if return_status == :duplicate
92
151
 
93
152
  rxnotices = RecordxSqlite.new(File.join(topic_dir, 'notices.db'),
94
- table: {notices: {id: 0, message: ''}})
95
- rxnotices.create id: id.to_s, message: msg
153
+ table: {notices: {id: 0, description: '', message: ''}})
154
+
155
+ begin
156
+ rxnotices.create id: id.to_s, description: desc, message: msg
157
+ rescue
158
+ puts 'warning: rxnotices.create -> ' + ($!).inspect
159
+ end
96
160
 
97
161
  if raw_json then
98
162
 
@@ -155,4 +219,4 @@ class MNSSubscriber < SPSSub
155
219
 
156
220
  end
157
221
 
158
- end
222
+ end
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.8
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -10,49 +10,53 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
14
- YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
15
- 8ixkARkWAmV1MB4XDTE2MTExMjEzMjQxNFoXDTE3MTExMjEzMjQxNFowSDESMBAG
16
- A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
- EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
18
- ggEBAMqFKnOPj+Kvhml9lNrIzC2gky+FnaKMe2WdsJV4vjPJmdzDEXLQSiUgCVPK
19
- S+0dqi6Z3oM70oxcC8v6VAD/dqM4HTriOK4Nv1JPw9T+BgYqHGouK3lZreNw4wVV
20
- estB6K5HbD37Gxk6uPWxcmkODCZDLPDBEllLa8NH88uz4shWl24/i+9wxLwNnipb
21
- tn2vLTKsfFKdqLWqmayBXhTEhfc70bBhmX5ZzchZi+Vsv7s69QHRWrmxT62D5O6Q
22
- +qOWwFuZ/6Z7yFpjJmIfygkj/x+V8X8fQUGjDOqDT/uYFy9XvI+p5JkT07GsP5PX
23
- E+7hp0eUkeclVrTyAKG7TkfkrYUCAwEAAaOBijCBhzAJBgNVHRMEAjAAMAsGA1Ud
24
- DwQEAwIEsDAdBgNVHQ4EFgQUxf5o+IcWWZwAdWo1fmsk6kSdNz4wJgYDVR0RBB8w
25
- HYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1h
26
- c3RlckBqYW1lc3JvYmVydHNvbi5ldTANBgkqhkiG9w0BAQUFAAOCAQEAkpQ4ktXo
27
- B8riOdNUzvVlDquhwrFZwl8eWe/A5j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JW32COaqFgLsM206ncMq4flTZ
24
+ 5mU2/Cwz7SxWQQe0cIzTH+o1pejIS83IRRMgHEtgyki0yUKDcoZVhvNujrMCAwEA
25
+ AaOBijCBhzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU0a7RWUQ4
26
+ bjy71dOj2inlBZ1u+NIwJgYDVR0RBB8wHYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0
27
+ c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1hc3RlckBqYW1lc3JvYmVydHNvbi5ldTAN
28
+ BgkqhkiG9w0BAQsFAAOCAYEANZXVYK9Ut5FWc27EOT5ajSB/DVW6GXUMWGXNVLll
29
+ x6o5OX9r4xHlINGsTEI4q01kCBQsJCjQKNFOrUss+TsEFgXremusnniPwypvoCZh
30
+ JAmmUktsIKuKmgkJ6h1hhuJf6g90++v4iVvBHt53nhN8NaGYe4Oc2OwXTfxHam0X
31
+ JfCSR+Aw2QfaQvZKi8inGHgLmM61ABpIGTZ8lwzR6fizANDF6EQ7vNixJMSZExzP
32
+ s1BgeI/oTI1Y7UNeUtwWA8NkQ1bczUBH4FDUab4QRIbBYhXz+Hs8ddtugTzcmRwf
33
+ W0wI6iCh95fKaCbmSS5MY3dYMexH07A1XFGyHWOogCEWWYZ4ho+a44Fm0Uotp5ky
34
+ TjsXYJbdzlsAVQKfCSIfCi3T/k4bp/2wc342j/WYjkKLN4aZID+E9P/VX1Nc0m/s
35
+ yOAycOYzp7fxmPl3/HV5D0YOJwuy1XslA50GQJwq12A5vMyUGUCHuxH/zKZcM/zr
36
+ 0QZaKiVqq5ZeGvni0eQSavhQ
33
37
  -----END CERTIFICATE-----
34
- date: 2017-07-04 00:00:00.000000000 Z
38
+ date: 2021-02-27 00:00:00.000000000 Z
35
39
  dependencies:
36
40
  - !ruby/object:Gem::Dependency
37
41
  name: mtlite
38
42
  requirement: !ruby/object:Gem::Requirement
39
43
  requirements:
40
- - - "~>"
41
- - !ruby/object:Gem::Version
42
- version: '0.3'
43
44
  - - ">="
44
45
  - !ruby/object:Gem::Version
45
- version: 0.3.4
46
+ version: 0.4.0
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '0.4'
46
50
  type: :runtime
47
51
  prerelease: false
48
52
  version_requirements: !ruby/object:Gem::Requirement
49
53
  requirements:
50
- - - "~>"
51
- - !ruby/object:Gem::Version
52
- version: '0.3'
53
54
  - - ">="
54
55
  - !ruby/object:Gem::Version
55
- version: 0.3.4
56
+ version: 0.4.0
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '0.4'
56
60
  - !ruby/object:Gem::Dependency
57
61
  name: sps-sub
58
62
  requirement: !ruby/object:Gem::Requirement
@@ -62,7 +66,7 @@ dependencies:
62
66
  version: '0.3'
63
67
  - - ">="
64
68
  - !ruby/object:Gem::Version
65
- version: 0.3.5
69
+ version: 0.3.7
66
70
  type: :runtime
67
71
  prerelease: false
68
72
  version_requirements: !ruby/object:Gem::Requirement
@@ -72,47 +76,47 @@ dependencies:
72
76
  version: '0.3'
73
77
  - - ">="
74
78
  - !ruby/object:Gem::Version
75
- version: 0.3.5
79
+ version: 0.3.7
76
80
  - !ruby/object:Gem::Dependency
77
81
  name: daily_notices
78
82
  requirement: !ruby/object:Gem::Requirement
79
83
  requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '0.6'
83
84
  - - ">="
84
85
  - !ruby/object:Gem::Version
85
- version: 0.6.1
86
+ version: 0.7.0
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.7'
86
90
  type: :runtime
87
91
  prerelease: false
88
92
  version_requirements: !ruby/object:Gem::Requirement
89
93
  requirements:
90
- - - "~>"
91
- - !ruby/object:Gem::Version
92
- version: '0.6'
93
94
  - - ">="
94
95
  - !ruby/object:Gem::Version
95
- version: 0.6.1
96
+ version: 0.7.0
97
+ - - "~>"
98
+ - !ruby/object:Gem::Version
99
+ version: '0.7'
96
100
  - !ruby/object:Gem::Dependency
97
101
  name: recordx_sqlite
98
102
  requirement: !ruby/object:Gem::Requirement
99
103
  requirements:
100
104
  - - "~>"
101
105
  - !ruby/object:Gem::Version
102
- version: '0.2'
106
+ version: '0.3'
103
107
  - - ">="
104
108
  - !ruby/object:Gem::Version
105
- version: 0.2.6
109
+ version: 0.3.1
106
110
  type: :runtime
107
111
  prerelease: false
108
112
  version_requirements: !ruby/object:Gem::Requirement
109
113
  requirements:
110
114
  - - "~>"
111
115
  - !ruby/object:Gem::Version
112
- version: '0.2'
116
+ version: '0.3'
113
117
  - - ">="
114
118
  - !ruby/object:Gem::Version
115
- version: 0.2.6
119
+ version: 0.3.1
116
120
  description:
117
121
  email: james@jamesrobertson.eu
118
122
  executables: []
@@ -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.6.8
147
+ rubygems_version: 2.7.10
144
148
  signing_key:
145
149
  specification_version: 4
146
150
  summary: Creates microblog posts from different identities by subscribing to the SPS
metadata.gz.sig CHANGED
Binary file