polyrex-feed-reader 0.5.10 → 0.5.11
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 +4 -4
- checksums.yaml.gz.sig +2 -3
- data.tar.gz.sig +0 -0
- data/lib/feeds.xsl +7 -1
- data/lib/polyrex-feed-reader.rb +65 -11
- metadata +1 -1
- metadata.gz.sig +1 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3e9f65a84bf29c0045a70fdf9a4977938b9eeaf
|
4
|
+
data.tar.gz: 866757cc281304194410d6d23d62398d9e61b61d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48f03a52b317a7187bf583b32214b458acda5a6902fd688800dc874eebce045d163bbb5166451db1dbf70c4f3e7e0e379ebf600aed875c729c7ce35558d226de
|
7
|
+
data.tar.gz: 5120ec5fcc0ae3370b2d139d0bde3bb6ad25678588bab161542880e1f5149b2aa48933bca206f94b3067df77033bc83618b3c304ca52523b121e3f2906c1d83e
|
checksums.yaml.gz.sig
CHANGED
@@ -1,3 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
vɆ`W:�Ƙ��eNw��wڙ �4Ġ�Hz;�v�+���q�
|
1
|
+
`�kʐ�
|
2
|
+
b����Cx1��w6��p�~H���n�%��@�|_�f�t��g�C���rQ�Xۺ`jԂ8Q��x�s`%��Y�����?���X��v/����a���l��_�(�۴�{JH�w��A?�(�;9���������0ڑ�
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/feeds.xsl
CHANGED
@@ -17,7 +17,6 @@
|
|
17
17
|
<header>
|
18
18
|
<a name="top"/>
|
19
19
|
<xsl:apply-templates select='summary'/>
|
20
|
-
|
21
20
|
<div>
|
22
21
|
<ul>
|
23
22
|
<li>hotter</li>
|
@@ -51,6 +50,13 @@
|
|
51
50
|
|
52
51
|
<xsl:template match='feeds/summary'>
|
53
52
|
<a href="javascript:window.location.reload()"><h1><xsl:value-of select='title'/></h1></a>
|
53
|
+
<p></p>
|
54
|
+
<ul>
|
55
|
+
<li>last updated: <xsl:value-of select="last_modified"/></li>
|
56
|
+
<li>feed count: <xsl:value-of select="feed_count"/></li>
|
57
|
+
<li><a href="feeds.opml">feeds.opml</a></li>
|
58
|
+
<li><a href="latest.html">latest</a></li></ul>
|
59
|
+
|
54
60
|
</xsl:template>
|
55
61
|
|
56
62
|
<xsl:template match='records/column'>
|
data/lib/polyrex-feed-reader.rb
CHANGED
@@ -14,6 +14,13 @@ DAY = HOUR * 24
|
|
14
14
|
WEEK = DAY * 7
|
15
15
|
MONTH = DAY * 30
|
16
16
|
|
17
|
+
W3CENTITIES =<<EOF
|
18
|
+
<!DOCTYPE stylesheet [
|
19
|
+
<!ENTITY % w3centities-f PUBLIC "-//W3C//ENTITIES Combined Set//EN//XML"
|
20
|
+
"http://www.w3.org/2003/entities/2007/w3centities-f.ent">
|
21
|
+
%w3centities-f;
|
22
|
+
]>
|
23
|
+
EOF
|
17
24
|
|
18
25
|
class PolyrexFeedReader
|
19
26
|
|
@@ -23,6 +30,10 @@ class PolyrexFeedReader
|
|
23
30
|
|
24
31
|
end
|
25
32
|
|
33
|
+
def feed_count()
|
34
|
+
@polyrex.xpath 'count(records/column/records/section/records/feed)'
|
35
|
+
end
|
36
|
+
|
26
37
|
def feeds_to_html()
|
27
38
|
|
28
39
|
feeds do |feed, filename|
|
@@ -35,13 +46,7 @@ class PolyrexFeedReader
|
|
35
46
|
|
36
47
|
def fetch_feeds()
|
37
48
|
|
38
|
-
|
39
|
-
<!DOCTYPE stylesheet [
|
40
|
-
<!ENTITY % w3centities-f PUBLIC "-//W3C//ENTITIES Combined Set//EN//XML"
|
41
|
-
"http://www.w3.org/2003/entities/2007/w3centities-f.ent">
|
42
|
-
%w3centities-f;
|
43
|
-
]>
|
44
|
-
EOF
|
49
|
+
|
45
50
|
|
46
51
|
feeds do |feed, filename|
|
47
52
|
|
@@ -55,7 +60,7 @@ EOF
|
|
55
60
|
a = xml.lines.to_a
|
56
61
|
line1 = a.shift
|
57
62
|
a.unshift %Q{<?xml-stylesheet title="XSL_formatting" type="text/xsl" href="dynarex-feed.xsl"?>\n}
|
58
|
-
a.unshift
|
63
|
+
a.unshift W3CENTITIES
|
59
64
|
a.unshift line1
|
60
65
|
a.join
|
61
66
|
end
|
@@ -66,12 +71,14 @@ EOF
|
|
66
71
|
|
67
72
|
def refresh
|
68
73
|
|
74
|
+
@datetimestamp = datetimestamp()
|
75
|
+
|
69
76
|
feeds do |feed, filename|
|
70
77
|
|
71
78
|
d = Dynarex.new filename
|
72
79
|
|
73
|
-
feed.last_accessed = datetimestamp
|
74
|
-
feed.last_modified = datetimestamp
|
80
|
+
feed.last_accessed = @datetimestamp
|
81
|
+
feed.last_modified = @datetimestamp if feed.last_modified.empty?
|
75
82
|
feed.xhtml = filename
|
76
83
|
|
77
84
|
items = d.to_h[0..2]
|
@@ -104,7 +111,7 @@ EOF
|
|
104
111
|
feed.create.item h
|
105
112
|
end
|
106
113
|
|
107
|
-
feed.last_modified = datetimestamp
|
114
|
+
feed.last_modified = @datetimestamp
|
108
115
|
|
109
116
|
end
|
110
117
|
end
|
@@ -124,7 +131,52 @@ EOF
|
|
124
131
|
xsltproc 'feeds.xsl', @polyrex.to_xml, filepath
|
125
132
|
end
|
126
133
|
|
134
|
+
def save_latestnews(filename='latest.html')
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
last_modified = @polyrex.summary.last_modified
|
139
|
+
e = @polyrex.xpath 'records/column/records/section/records/'\
|
140
|
+
+ 'feed[summary/last_modified="' + last_modified + '"]'
|
141
|
+
|
142
|
+
dynarex = Dynarex.new 'feeds/feed(source, title, link, description)'
|
143
|
+
|
144
|
+
e.each() do |feed|
|
145
|
+
|
146
|
+
summary = feed.element 'records/item/summary'
|
147
|
+
|
148
|
+
record = {
|
149
|
+
source: feed.text('summary/title'),
|
150
|
+
title: summary.text('title'),
|
151
|
+
link: summary.text('link'),
|
152
|
+
description: summary.text('description')
|
153
|
+
}
|
154
|
+
dynarex.create record
|
155
|
+
end
|
156
|
+
|
157
|
+
#filename = 'latest.xml'
|
158
|
+
=begin
|
159
|
+
dynarex.save(filename) do |xml|
|
160
|
+
a = xml.lines.to_a
|
161
|
+
line1 = a.shift
|
162
|
+
a.unshift %Q{<?xml-stylesheet title="XSL_formatting" type="text/xsl" href="latest.xsl"?>\n}
|
163
|
+
a.unshift W3CENTITIES
|
164
|
+
a.unshift line1
|
165
|
+
a.join
|
166
|
+
end
|
167
|
+
=end
|
168
|
+
|
169
|
+
xsltproc 'latest.xsl', dynarex.to_xml, filename
|
170
|
+
end
|
171
|
+
|
172
|
+
def save_opml(filepath='feeds.opml')
|
173
|
+
xsltproc 'opml-feeds.xsl', @polyrex.to_xml, filepath
|
174
|
+
end
|
175
|
+
|
127
176
|
def save_xml(filepath='feeds.xml')
|
177
|
+
@polyrex.summary.last_modified = @datetimestamp
|
178
|
+
@polyrex.summary.feed_count = @polyrex.xpath \
|
179
|
+
'count(records/column/records/section/records/feed)'
|
128
180
|
@polyrex.save filepath, pretty: true
|
129
181
|
end
|
130
182
|
|
@@ -162,6 +214,7 @@ EOF
|
|
162
214
|
|
163
215
|
def nothing_new?(feed)
|
164
216
|
|
217
|
+
feed.last_accessed = Time.now - WEEK if feed.last_accessed.empty?
|
165
218
|
feed.occurrence == 'daily' and \
|
166
219
|
Time.parse(feed.last_accessed) + DAY > Time.now
|
167
220
|
end
|
@@ -184,6 +237,7 @@ EOF
|
|
184
237
|
end
|
185
238
|
end
|
186
239
|
|
240
|
+
|
187
241
|
def xsltproc(xslfilename, xml, filepath='feeds.html')
|
188
242
|
|
189
243
|
lib = File.dirname(__FILE__)
|
metadata
CHANGED
metadata.gz.sig
CHANGED
@@ -1,3 +1 @@
|
|
1
|
-
|
2
|
-
i:�}�Iѐ6���ƃ������4TL�\aѹ�ȩeJMF~J"P�|�?��?�H��k�AN��Y��
|
3
|
-
��kiK?�!��O��}ɟ(�rQ��\,K��R��Iv�]��� �朲�!�(�3Z�9���6��:A�7�zǦ�
|
1
|
+
�����D�>>���D����V���:4#��G<����R�s�e3������)<�3T��V�8]�z�c�t"}_�&ݠX��~[����;�_�4Fm��_5�u��U�+o� �Z�\��6��<%��_,
|