liveblog 0.8.9 → 0.9.0
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.tar.gz.sig +3 -1
- data/lib/liveblog.rb +73 -7
- metadata +6 -6
- metadata.gz.sig +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33c53e82127667a413e45929401e58109ff74124
|
4
|
+
data.tar.gz: 9930c0e34ab16183448268038141a08e539966d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b216c8fe6e62cbb61b929a22762fa9baca399efa038e9242775f0cc8bed6418426133dcae9c8b192ee1dd93bed27ab5133d657882fec89bf4c56c085403326b
|
7
|
+
data.tar.gz: 68c10823048b75b103ffa8979f48299db547e99ffc1fd22e91bc93613cf9ba98adb2ccad26048dcbc2061c7f5ef3b5004f996c68b8506d51ecbaf78040364940
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
@@ -1 +1,3 @@
|
|
1
|
-
|
1
|
+
%'3��?��[�밬)?f ��Iz�l.O-��-k��7bV��$F_|s�4U��
|
2
|
+
�N3��\5�$85�k�#���Jո����~&��;�7�m
|
3
|
+
����ܺ}��=�\���tt��zI�ZI�*yl@T8��1���U5hH�U�q��!)��{)99X>�j�<���{iW��q���C'��,]@hUW������cȷ���P�_@G8�� ����=�H�c�(��sO�� �eٝ�0t�ۨ�=�"�C
|
data/lib/liveblog.rb
CHANGED
@@ -32,8 +32,10 @@ class LiveBlog
|
|
32
32
|
|
33
33
|
h = SimpleConfig.new(config).to_h
|
34
34
|
|
35
|
-
dir, @urlbase, @edit_url, @css_url, @xsl_path,
|
36
|
-
|
35
|
+
dir, @urlbase, @edit_url, @css_url, @xsl_path, \
|
36
|
+
@xsl_url, @bannertext, @rss_title = \
|
37
|
+
%i(dir urlbase edit_url css_url xsl_path xsl_url bannertext rss_title)\
|
38
|
+
.map{|x| h[x]}
|
37
39
|
|
38
40
|
|
39
41
|
Dir.chdir dir
|
@@ -147,6 +149,65 @@ EOF
|
|
147
149
|
|
148
150
|
alias import new_file
|
149
151
|
|
152
|
+
def save_rss()
|
153
|
+
|
154
|
+
buffer = File.read File.join(path(), 'raw_formatted.xml')
|
155
|
+
doc = Rexle.new buffer
|
156
|
+
|
157
|
+
summary = doc.root.element 'summary'
|
158
|
+
|
159
|
+
dx = Dynarex.new 'liveblog[title,desc,link, pubdate, '\
|
160
|
+
+ 'lastbuild_date, lang]/entry(title, desc, created_at, uri, guid)'
|
161
|
+
|
162
|
+
dx.title = @rss_title || 'LiveBlog'
|
163
|
+
dx.desc = 'Latest LiveBlog posts fetched from ' + @urlbase
|
164
|
+
dx.link = @urlbase
|
165
|
+
dx.order = 'descending'
|
166
|
+
dx.pubdate = rss_timestamp(summary.text('published'))
|
167
|
+
dx.lastbuild_date = Time.now.strftime("%a, %-d %b %Y %H:%M:%S %Z")
|
168
|
+
dx.lang = 'en-gb'
|
169
|
+
|
170
|
+
doc.root.xpath('records/section/section/details').each do |x|
|
171
|
+
|
172
|
+
a = x.elements.to_a
|
173
|
+
h1 = a.shift.element('h1')
|
174
|
+
hashtag = h1.text[/#\w+$/]
|
175
|
+
created_at = rss_timestamp(h1.attributes[:created])
|
176
|
+
|
177
|
+
a.each do |node|
|
178
|
+
|
179
|
+
node.attributes.delete :created
|
180
|
+
node.attributes.delete :last_modified
|
181
|
+
|
182
|
+
node.traverse do |x|
|
183
|
+
|
184
|
+
x.attributes.delete :created
|
185
|
+
x.attributes.delete :last_modified
|
186
|
+
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
uri = doc.root.element('summary/link/text()') + hashtag
|
191
|
+
|
192
|
+
record = {
|
193
|
+
title: h1.text,
|
194
|
+
desc: a.map(&:xml).join("\n"),
|
195
|
+
created_at: created_at,
|
196
|
+
uri: uri,
|
197
|
+
guid: uri
|
198
|
+
}
|
199
|
+
|
200
|
+
dx.create record
|
201
|
+
end
|
202
|
+
|
203
|
+
dx.xslt_schema = 'channel[title:title,description:desc,link:link,'\
|
204
|
+
+ 'pubDate:pubdate,lastBuildDate:lastbuild_date,language:lang]/'\
|
205
|
+
+ 'item(title:title,link:uri,description:desc,pubDate:created_at,'\
|
206
|
+
+ 'guid:guid)'
|
207
|
+
File.write 'rss.xml', dx.to_rss
|
208
|
+
|
209
|
+
end
|
210
|
+
|
150
211
|
private
|
151
212
|
|
152
213
|
|
@@ -177,7 +238,8 @@ EOF
|
|
177
238
|
css_url: '/liveblog/liveblog.css',
|
178
239
|
xsl_path: File.join(dir, 'liveblog.xsl'),
|
179
240
|
xsl_url: '/liveblog/liveblog.xsl',
|
180
|
-
bannertext: ''
|
241
|
+
bannertext: '',
|
242
|
+
rss_title: "John Smith's LiveBlog"
|
181
243
|
}
|
182
244
|
end
|
183
245
|
|
@@ -199,6 +261,7 @@ EOF
|
|
199
261
|
@dx.save File.join(path(), 'index.xml')
|
200
262
|
File.write File.join(path(), 'index.txt'), @dx.to_s
|
201
263
|
save_html()
|
264
|
+
save_rss()
|
202
265
|
end
|
203
266
|
|
204
267
|
def save_html()
|
@@ -219,7 +282,8 @@ EOF
|
|
219
282
|
add summary, 'published', Time.now.strftime("%d-%m-%Y %H:%M")
|
220
283
|
add summary, 'prev_day', static_urlpath(@d-1)
|
221
284
|
add summary, 'next_day', @d == Date.today ? '' : static_urlpath(@d+1)
|
222
|
-
add summary, 'bannertext', @bannertext
|
285
|
+
add summary, 'bannertext', @bannertext
|
286
|
+
add summary, 'link', static_urlpath(@d)
|
223
287
|
|
224
288
|
tags = Rexle::Element.new('tags')
|
225
289
|
|
@@ -260,9 +324,7 @@ EOF
|
|
260
324
|
]
|
261
325
|
|
262
326
|
File.write formatted2_filepath, doc.xml(pretty: true)
|
263
|
-
|
264
|
-
|
265
|
-
|
327
|
+
|
266
328
|
# save the related CSS file locally if the file doesn't already exist
|
267
329
|
if not File.exists? 'liveblog.css' then
|
268
330
|
FileUtils.cp File.join(File.dirname(__FILE__), 'liveblog.css'),\
|
@@ -344,4 +406,8 @@ EOF
|
|
344
406
|
t.strftime "<time>%-I:%M%P</time>"
|
345
407
|
end
|
346
408
|
|
409
|
+
def rss_timestamp(s)
|
410
|
+
Time.parse(s).strftime("%a, %-d %b %Y %H:%M:%S %Z")
|
411
|
+
end
|
412
|
+
|
347
413
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: liveblog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
WoOSxvsTN7qoA8F0W4mkDpf+HhHxBOLTPykcHMIlx2gILLnNraaZ1rJlZAqWABGj
|
32
32
|
v8lGgeeqqjd5QA==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2015-03-
|
34
|
+
date: 2015-03-30 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: dynarex
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
version: '1.5'
|
43
43
|
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 1.5.
|
45
|
+
version: 1.5.13
|
46
46
|
type: :runtime
|
47
47
|
prerelease: false
|
48
48
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
version: '1.5'
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 1.5.
|
55
|
+
version: 1.5.13
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: martile
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -62,7 +62,7 @@ dependencies:
|
|
62
62
|
version: '0.5'
|
63
63
|
- - ">="
|
64
64
|
- !ruby/object:Gem::Version
|
65
|
-
version: 0.5.
|
65
|
+
version: 0.5.11
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
68
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -72,7 +72,7 @@ dependencies:
|
|
72
72
|
version: '0.5'
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.5.
|
75
|
+
version: 0.5.11
|
76
76
|
- !ruby/object:Gem::Dependency
|
77
77
|
name: simple-config
|
78
78
|
requirement: !ruby/object:Gem::Requirement
|
metadata.gz.sig
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
���j� 00��^���ɖwtf�|�=?g�
|