liveblog-plugin-dxtags 0.1.0 → 0.2.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
  SHA1:
3
- metadata.gz: 957a77e99bf04067e8b26c4d301cf74a7f10c382
4
- data.tar.gz: 7208bd04274495061803b048117a4f0bb670b905
3
+ metadata.gz: 10ab650d860311f56fe865d5430da84fb1bab11b
4
+ data.tar.gz: 0bd3fa207c167598847cec64f62b2217471bd2c5
5
5
  SHA512:
6
- metadata.gz: 8aac3fe19f304968b1ba86281b3e17ed6a7c385fbabb13e57742bab2e657441d3a9ee6121d15f5e590f118529bc2d669bb22cd89607aa677671351863b19ee55
7
- data.tar.gz: 4e27e7ffc5f779a82cd4c73f7e343478aa077da21a43a58a742cb017f77038db4b6586bdeb2f73750193490407a9144bb169c123b25c3cf2d4e9e37062e82048
6
+ metadata.gz: f781e9c7bbd373faeaa4f0de2981e0f71790ec5caed5663da7d54f8ef6ec28c87cfbd1701723c715be32ef4c5eb6d707fab6742070b184d6333f1896170586d5
7
+ data.tar.gz: 4875707baf95bb8f143b3a05a665b301bd9d4f7acda6dc99e166a9624418d65ae0283179720f9c7ca25c33cd42937d1734cf08ba2046b0d9980678fe306438d9
checksums.yaml.gz.sig CHANGED
Binary file
@@ -2,6 +2,7 @@
2
2
 
3
3
  # file: liveblog-plugin-dxtags.rb
4
4
 
5
+ require 'polyrex'
5
6
  require 'dynarex-tags'
6
7
 
7
8
 
@@ -10,6 +11,7 @@ class LiveBlogPluginDxTags
10
11
  def initialize(settings: {}, variables: {})
11
12
 
12
13
  @parent_filepath = variables[:filepath]
14
+ @todays_filepath = variables[:todays_filepath]
13
15
 
14
16
  end
15
17
 
@@ -22,11 +24,73 @@ class LiveBlogPluginDxTags
22
24
  title.scan(/\B#(\w+)(?=\s|$)/).map do |x|
23
25
 
24
26
  hashtag = x.first
25
- [hashtag, title, urlpath + '#' + hashtag]
27
+ [hashtag, title.sub(/#\s+/,''), urlpath + '#' + hashtag]
26
28
  end
27
29
 
28
30
  end
29
31
 
32
+ return unless @todays_filepath
33
+
34
+ px = Polyrex.new 'tags/tag[label]/entry[title, url]'
35
+ px.save File.join(@todays_filepath, 'tags-seealso.xml')
36
+
37
+ end
38
+
39
+ def on_new_section(raw_entry, hashtag)
40
+
41
+ # check the dxtags file for any matching hashtags
42
+
43
+ filepath = File.join(@parent_filepath, 'tags', hashtag + '.xml')
44
+
45
+ return unless File.exists? filepath
46
+
47
+ dx = Dynarex.new filepath
48
+ recs = dx.to_h
49
+
50
+ pxfilepath = File.join(@todays_filepath, 'tags-seealso.xml')
51
+ px = Polyrex.new pxfilepath
52
+ px.create.tag( label: hashtag) {|create| recs.each {|h| create.entry h} }
53
+ px.save pxfilepath, pretty: true
54
+
55
+ end
56
+
57
+ def on_doc_update(doc)
58
+
59
+ pxfilepath = File.join(@todays_filepath, 'tags-seealso.xml')
60
+ px = Polyrex.new pxfilepath
61
+
62
+ doc.root.xpath('records/section').each do |node|
63
+
64
+ r = px.find_by_tag_label node.attributes[:id]
65
+
66
+ if r then
67
+
68
+ xml = RexleBuilder.new
69
+ a = xml.aside do
70
+
71
+ xml.div do
72
+
73
+ xml.h1 'see also'
74
+
75
+ xml.ul do
76
+
77
+ r.records.each do |record|
78
+
79
+ xml.li do
80
+ xml.a({href: record.url}, record.title)
81
+ end
82
+
83
+ end
84
+ end # /ul
85
+ end # /div
86
+ end # /aside
87
+
88
+ node.add_element Rexle.new(a).root
89
+
90
+ end
91
+
92
+ end
93
+
30
94
  end
31
95
 
32
96
 
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: liveblog-plugin-dxtags
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  N4FNEHt4LyjhMIkH/Dpq5NOxOazGcql9I6CwBisvXhE0cyht9YSUjRO1uDvv6B/g
32
32
  c4UKnHyLClIcQQ==
33
33
  -----END CERTIFICATE-----
34
- date: 2015-06-13 00:00:00.000000000 Z
34
+ date: 2015-10-12 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: dynarex-tags
@@ -53,6 +53,26 @@ dependencies:
53
53
  - - ">="
54
54
  - !ruby/object:Gem::Version
55
55
  version: 0.2.3
56
+ - !ruby/object:Gem::Dependency
57
+ name: polyrex
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '1.0'
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: 1.0.6
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - "~>"
71
+ - !ruby/object:Gem::Version
72
+ version: '1.0'
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 1.0.6
56
76
  description:
57
77
  email: james@r0bertson.co.uk
58
78
  executables: []
@@ -80,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
100
  version: '0'
81
101
  requirements: []
82
102
  rubyforge_project:
83
- rubygems_version: 2.4.6
103
+ rubygems_version: 2.4.8
84
104
  signing_key:
85
105
  specification_version: 4
86
106
  summary: A LiveBlog plugin which creates or updates the hashtags lookup files from
metadata.gz.sig CHANGED
Binary file