mymedia 0.5.6 → 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
2
  SHA256:
3
- metadata.gz: a9017547d1a397550cf5ca9814c06c40dfbf124788d2f70886ed140cd522de5b
4
- data.tar.gz: a00880daf1a062ab77d0680caf230cf68f774cba51c658bbec2ebd700038d20a
3
+ metadata.gz: 02b5ffbf1ed71c431dc65112e3ab5a5b05c52b01a2a537e0457b3045f672751d
4
+ data.tar.gz: c238a9c94a91f8d4e0037a0f0fe5e268f68d28a147f37d15c75c93f080b8534d
5
5
  SHA512:
6
- metadata.gz: 64b2f5b76497d425093526fdd9da114211c3389dc6df4f0eb12344f146e618620f2e42c3621c2008e8b57dcdf44f7f970ed51720e6789b168824e53d7b04e149
7
- data.tar.gz: c760bdf0090e8be9980176da22599e8c75e2efa19394b4a492d53f84e9ca8a2a58b1ea6087280397ab4b0f256fc3f7ee231fa5c4fa9a695fa6a59d5fd3de1341
6
+ metadata.gz: 803e7329a524b7825f447fd3260eee37525c96b4c6713ff44ba175978d679e7d08cd6731ff30cc497dafbae0af1a92ce9fae4ad21bb5ceb5d502f604ad46b856
7
+ data.tar.gz: 9130e7e15377c05b99677637ae158c3f105f40dcf6fe1f66d49c1c65b7f8464ad44c0d0f4255b91581893f374ffd2011a808bb227a2228c55afdba866510e889
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/mymedia.rb CHANGED
@@ -14,6 +14,21 @@ require 'rxfileio'
14
14
  require 'wordsdotdat'
15
15
 
16
16
 
17
+ require 'rxfileio'
18
+ require 'wordsdotdat'
19
+
20
+ module StringFilter
21
+
22
+ def normalize(s)
23
+
24
+ r = s.downcase.gsub(/\s#\w+/,'').strip.gsub(/\W/,'-').gsub(/-{2,}/,'-')\
25
+ .gsub(/^-|-$/,'')
26
+ return s.scan(/#(\w+)/)[0..1].join('_').downcase if r.empty?
27
+ return r
28
+ end
29
+
30
+ end
31
+
17
32
  module MyMedia
18
33
 
19
34
  class MyMediaPublisherException < Exception
@@ -23,9 +38,10 @@ module MyMedia
23
38
  class Publisher
24
39
  include RXFReadWriteModule
25
40
 
26
- def initialize(opts={})
41
+ def initialize(opts={}, debug: false)
27
42
  @index_page = true
28
43
  @opts = opts
44
+ @debug = debug
29
45
  end
30
46
 
31
47
  protected
@@ -38,7 +54,10 @@ module MyMedia
38
54
  dynarex = if FileX.exists? dynarex_filepath then
39
55
  Dynarex.new(dynarex_filepath)
40
56
  else
41
- Dynarex.new(@schema)
57
+ puts '@schema: ' + @schema.inspect if @debug
58
+ dx = Dynarex.new(@schema)
59
+ dx.xslt_schema = @xslt_schema
60
+ dx
42
61
  end
43
62
 
44
63
  dynarex.create record, id: opt[:id]
@@ -133,7 +152,7 @@ module MyMedia
133
152
 
134
153
  def find(keyword)
135
154
 
136
- json_filepath = "%s/%s/dynarex.json" % [@home, @public_type]
155
+ json_filepath = File.join(@home, @www, @public_type, 'dynarex.json')
137
156
 
138
157
  if FileX.exists? json_filepath then
139
158
 
@@ -152,7 +171,7 @@ module MyMedia
152
171
 
153
172
  def search(keyword)
154
173
 
155
- json_filepath = "%s/%s/dynarex.json" % [@home, @public_type]
174
+ json_filepath = File.join(@home, @www, @public_type, 'dynarex.json')
156
175
 
157
176
  if FileX.exists? json_filepath then
158
177
 
@@ -171,7 +190,7 @@ module MyMedia
171
190
 
172
191
  def find_sourcefile(id)
173
192
 
174
- json_filepath = "%s/%s/dynarex.json" % [@home, @public_type]
193
+ json_filepath = File.join(@home, @www, @public_type, 'dynarex.json')
175
194
 
176
195
  if FileX.exists? json_filepath then
177
196
 
@@ -183,12 +202,15 @@ module MyMedia
183
202
 
184
203
  end
185
204
  end
205
+
206
+
186
207
 
187
208
  class BaseException < Exception
188
209
  end
189
210
 
190
211
  class Base < Publisher
191
212
  include RXFileIOModule
213
+ include StringFilter
192
214
 
193
215
  attr_reader :to_s, :destination
194
216
 
@@ -235,8 +257,8 @@ module MyMedia
235
257
 
236
258
  def add_feed_item(raw_msg, record, options={})
237
259
 
238
- dynarex_filepath = File.join([@home, @public_type, 'dynarex.xml'])
239
- id = Increment.update(File.join([@home, @public_type, 'counter.txt']))
260
+ dynarex_filepath = File.join([@home, @www, @public_type, 'dynarex.xml'])
261
+ id = Increment.update(File.join([@home, @www, @public_type, 'counter.txt']))
240
262
  static_url = @static_baseurl + id
241
263
  record[:uri] = static_url
242
264
 
@@ -393,15 +415,7 @@ module MyMedia
393
415
 
394
416
  static_url
395
417
 
396
- end
397
-
398
- def normalize(s)
399
-
400
- r = s.downcase.gsub(/\s#\w+/,'').strip.gsub(/\W/,'-').gsub(/-{2,}/,'-')\
401
- .gsub(/^-|-$/,'')
402
- return s.scan(/#(\w+)/)[0..1].join('_').downcase if r.empty?
403
- return r
404
- end
418
+ end
405
419
 
406
420
  end
407
421
 
@@ -411,18 +425,24 @@ module MyMedia
411
425
 
412
426
  class Frontpage < Publisher
413
427
 
414
- def initialize(config: nil, public_type: '', rss: nil)
428
+ def initialize(config: nil, public_type: '', rss: nil, debug: false)
415
429
 
416
430
  raise FrontpageException, "no config found" if config.nil?
417
431
 
432
+ @debug = debug
433
+
418
434
  c = SimpleConfig.new(config).to_h
419
435
 
420
436
  @home = c[:home]
437
+ @www = c[:www]
421
438
  @index_page = c[:index_page] == 'true'
422
439
  @public_type = public_type
423
440
  @rss = rss
424
441
  @sps = c[:sps]
425
442
  @opts = {username: c[:username], password: c[:password]}
443
+ @schema = 'posts/post(url, title, meta)'
444
+ @xslt_schema = 'channel[title:title,description:desc]/' + \
445
+ 'item(title:title,link:url)'
426
446
 
427
447
  end
428
448
 
@@ -442,13 +462,19 @@ module MyMedia
442
462
  raw_msg, static_url, target_url = \
443
463
  record[:title], record[:url], record[:static_url]
444
464
 
465
+ puts 'vars: ' + [@home, @www, @public_type].inspect if @debug
466
+
445
467
  dynarex_filepath = File.join(@home, @www, @public_type, 'dynarex.xml')
446
468
  raw_dynarex_filepath = File.join(@home, @www, 'r', @public_type, 'dynarex.xml')
447
469
 
448
470
  publish_dynarex(dynarex_filepath, record, {rss: @rss || false})
449
471
  publish_dynarex(raw_dynarex_filepath, record, {rss: @rss || false})
450
472
 
451
- publish_timeline(raw_msg, static_url, target_url)
473
+ # 26-feb-2023 the following line was disabled because there's a
474
+ # better alternative to updating a timeline using the noticesys gem.
475
+ # to-do: Somehow integrate this with the new system.
476
+ #
477
+ #publish_timeline(raw_msg, static_url, target_url)
452
478
  send_message(msg: 'publish_to_lists completed')
453
479
 
454
480
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mymedia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -36,7 +36,7 @@ cert_chain:
36
36
  XV2ORsrE0BA5hbgbfiQFazW2d62rWKrt3CTi36GNST95GXGBpapX9CyezadYE+5i
37
37
  D3/VNb1+lseG5sGSOWMV8J01/J89XOfp5Gk=
38
38
  -----END CERTIFICATE-----
39
- date: 2023-02-22 00:00:00.000000000 Z
39
+ date: 2023-03-01 00:00:00.000000000 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: dir-to-xml
metadata.gz.sig CHANGED
Binary file