polyrex-feed-reader 0.5.2 → 0.5.3
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 +0 -0
- data.tar.gz.sig +0 -0
- data/lib/feeds.css +26 -0
- data/lib/feeds.xsl +29 -6
- data/lib/polyrex-feed-reader.rb +47 -38
- metadata +2 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 47a7aace6f3d7cc60230f93bf1a384a62dbfa7b4
|
|
4
|
+
data.tar.gz: eaa4c3d079ff38c22c86a3bd7c4af409173a1147
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 08b16d48dcad4f15803b6eeac7a09621cac5aad686d6a879b17d7a0316c5811e9d96e42f10f124efee83fb9f68bcab7ead6e6d2f58305d544b2fa670619b6ed3
|
|
7
|
+
data.tar.gz: da59709a80a748fbe1b832d48f72aac8ecfb0c4cfe6398ffff7176ed0ff33816dc456b68c56cc6ad661372cd65560314dc70f0bfceaa7086b08b2ab17b1f97c7
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data.tar.gz.sig
CHANGED
|
Binary file
|
data/lib/feeds.css
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
body {background-color: #39a}
|
|
2
|
+
|
|
3
|
+
body>div {
|
|
4
|
+
background-color: #19b;
|
|
5
|
+
float: left;
|
|
6
|
+
width: 200px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
body div div {
|
|
10
|
+
background-color: #9fa;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
div div>ul {
|
|
14
|
+
background-color: #eba;
|
|
15
|
+
list-style-type: none;
|
|
16
|
+
margin: 0.1em; padding: 0.2em;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
div div>ul>li {
|
|
20
|
+
background-color: #efa;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
div div>ul>li a {
|
|
24
|
+
background-color: #aaa;
|
|
25
|
+
text-decoration: none;
|
|
26
|
+
}
|
data/lib/feeds.xsl
CHANGED
|
@@ -3,29 +3,52 @@
|
|
|
3
3
|
<xsl:output method="html" indent="yes" />
|
|
4
4
|
|
|
5
5
|
<xsl:template match='feeds'>
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
<html>
|
|
8
|
+
<head>
|
|
9
|
+
<title><xsl:value-of select="summary/title" /></title>
|
|
10
|
+
<link rel="stylesheet" type="text/css" href="feeds.css" />
|
|
11
|
+
</head>
|
|
12
|
+
|
|
13
|
+
<body onload="" style="font-family:helvetica,arial;">
|
|
14
|
+
|
|
7
15
|
<xsl:apply-templates select='summary'/>
|
|
8
16
|
<xsl:apply-templates select='records'/>
|
|
9
|
-
</
|
|
17
|
+
</body>
|
|
18
|
+
</html>
|
|
10
19
|
</xsl:template>
|
|
11
20
|
|
|
21
|
+
|
|
22
|
+
|
|
12
23
|
<xsl:template match='feeds/summary'>
|
|
13
24
|
<h1><xsl:value-of select='title'/></h1>
|
|
14
25
|
</xsl:template>
|
|
15
26
|
|
|
16
27
|
<xsl:template match='records/column'>
|
|
28
|
+
<div id="{summary/id}">
|
|
29
|
+
<xsl:apply-templates select='summary'/>
|
|
30
|
+
<xsl:apply-templates select='records/section'/>
|
|
31
|
+
</div>
|
|
32
|
+
</xsl:template>
|
|
33
|
+
|
|
34
|
+
<xsl:template match='column/summary'>
|
|
35
|
+
<h2><xsl:value-of select='id'/></h2>
|
|
36
|
+
</xsl:template>
|
|
17
37
|
|
|
38
|
+
<xsl:template match='records/section'>
|
|
39
|
+
<div>
|
|
18
40
|
<xsl:apply-templates select='summary'/>
|
|
19
41
|
<xsl:apply-templates select='records/feed'>
|
|
20
42
|
<xsl:sort select="summary/recent" order="ascending"/>
|
|
21
43
|
</xsl:apply-templates>
|
|
22
|
-
|
|
44
|
+
</div>
|
|
23
45
|
</xsl:template>
|
|
24
46
|
|
|
25
|
-
<xsl:template match='
|
|
26
|
-
<h2><xsl:value-of select='
|
|
47
|
+
<xsl:template match='section/summary'>
|
|
48
|
+
<h2><xsl:value-of select='title'/></h2>
|
|
27
49
|
</xsl:template>
|
|
28
50
|
|
|
51
|
+
|
|
29
52
|
<xsl:template match='records/feed'>
|
|
30
53
|
|
|
31
54
|
<xsl:apply-templates select='summary'>
|
|
@@ -47,7 +70,7 @@
|
|
|
47
70
|
</xsl:template>
|
|
48
71
|
|
|
49
72
|
<xsl:template match='item/summary'>
|
|
50
|
-
<h4><xsl:value-of disable-output-escaping="yes" select='title'/></h4>
|
|
73
|
+
<a href="{link}" target="_blank"><h4><xsl:value-of disable-output-escaping="yes" select='title'/></h4></a>
|
|
51
74
|
<p><xsl:value-of disable-output-escaping="yes" select='description'/></p>
|
|
52
75
|
</xsl:template>
|
|
53
76
|
|
data/lib/polyrex-feed-reader.rb
CHANGED
|
@@ -34,75 +34,75 @@ class PolyrexFeedReader
|
|
|
34
34
|
|
|
35
35
|
def fetch_feeds()
|
|
36
36
|
|
|
37
|
-
feeds = @polyrex.xpath('//column/records/feed/summary')
|
|
37
|
+
feeds = @polyrex.xpath('//column/records/section/records/feed/summary')
|
|
38
38
|
|
|
39
39
|
feeds.each do |feed|
|
|
40
40
|
|
|
41
|
-
puts "fetching %s
|
|
41
|
+
puts "fetching %s " % feed.text('rss_url').inspect
|
|
42
42
|
|
|
43
43
|
rtd = RSStoDynarex.new feed.text('rss_url')
|
|
44
44
|
dynarex = rtd.to_dynarex
|
|
45
45
|
dynarex.save "%s.xml" % feed.text('title')\
|
|
46
|
-
.downcase.gsub(/\s/,'').gsub('
|
|
46
|
+
.downcase.gsub(/\s/,'').gsub(/\W/,'_')
|
|
47
47
|
end
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
-
def datetimestamp()
|
|
51
|
-
|
|
52
|
-
hour, minutes, day, year = Time.now.to_a.values_at 2,1,3,5
|
|
53
|
-
meridian, month = Time.now.strftime("%p %b").split
|
|
54
|
-
"%d:%s%s %s %s %s" % [hour, minutes, meridian.downcase, \
|
|
55
|
-
day.ordinal, month, year]
|
|
56
|
-
end
|
|
57
|
-
|
|
58
50
|
def refresh
|
|
59
51
|
|
|
60
52
|
@polyrex.records.each do |column|
|
|
61
53
|
|
|
62
|
-
column.records.each do |
|
|
54
|
+
column.records.each do |section|
|
|
55
|
+
|
|
56
|
+
section.records.each do |feed|
|
|
63
57
|
|
|
64
|
-
|
|
65
|
-
|
|
58
|
+
filename = "%s.xml" % feed.title\
|
|
59
|
+
.downcase.gsub(/\s/,'').gsub(/\W/,'_')
|
|
66
60
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
61
|
+
d = Dynarex.new filename
|
|
62
|
+
feed.last_accessed = datetimestamp()
|
|
63
|
+
feed.last_modified = datetimestamp() if feed.last_modified.empty?
|
|
70
64
|
|
|
71
|
-
|
|
65
|
+
items = d.to_h[0..2]
|
|
72
66
|
|
|
73
|
-
|
|
74
|
-
|
|
67
|
+
if feed.records.length > 0 and \
|
|
68
|
+
items.first[:title] == feed.item[0].title then
|
|
69
|
+
feed.recent = recency(feed.last_modified)
|
|
70
|
+
next
|
|
71
|
+
end
|
|
75
72
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
next
|
|
80
|
-
end
|
|
73
|
+
feed.recent = '1hot'
|
|
74
|
+
feed.records.remove_all
|
|
75
|
+
items.each.with_index do |x, i|
|
|
81
76
|
|
|
82
|
-
|
|
83
|
-
feed.records.remove_all
|
|
84
|
-
items.each.with_index do |x, i|
|
|
77
|
+
h = {title: x[:title], link: x[:link]}
|
|
85
78
|
|
|
86
|
-
|
|
79
|
+
if i == 0 then
|
|
87
80
|
|
|
88
|
-
|
|
81
|
+
raw_desc = CGI.unescapeHTML(x[:description]).gsub(/<\/?[^>]*>/, "")
|
|
82
|
+
desc = raw_desc.length > 300 ? raw_desc[0..296] + ' ...' : raw_desc
|
|
83
|
+
h[:description] = desc
|
|
84
|
+
end
|
|
89
85
|
|
|
90
|
-
|
|
91
|
-
desc = raw_desc.length > 300 ? raw_desc[0..296] + ' ...' : raw_desc
|
|
92
|
-
h[:description] = desc
|
|
86
|
+
feed.create.item h
|
|
93
87
|
end
|
|
94
88
|
|
|
95
|
-
feed.
|
|
89
|
+
feed.last_modified = datetimestamp()
|
|
96
90
|
end
|
|
97
|
-
|
|
98
|
-
feed.last_modified = datetimestamp()
|
|
99
|
-
|
|
100
91
|
end
|
|
101
92
|
end
|
|
102
93
|
end
|
|
103
94
|
|
|
104
95
|
alias update_doc refresh
|
|
105
96
|
|
|
97
|
+
def save_css(filepath='feeds.css')
|
|
98
|
+
|
|
99
|
+
lib = File.dirname(__FILE__)
|
|
100
|
+
css_buffer = File.read(lib + '/feeds.css')
|
|
101
|
+
#css_buffer = File.read('feeds.css')
|
|
102
|
+
|
|
103
|
+
File.write filepath, css_buffer
|
|
104
|
+
end
|
|
105
|
+
|
|
106
106
|
def save_html(filepath='feeds.html')
|
|
107
107
|
|
|
108
108
|
lib = File.dirname(__FILE__)
|
|
@@ -120,6 +120,14 @@ class PolyrexFeedReader
|
|
|
120
120
|
|
|
121
121
|
private
|
|
122
122
|
|
|
123
|
+
def datetimestamp()
|
|
124
|
+
|
|
125
|
+
hour, minutes, day, year = Time.now.to_a.values_at 2,1,3,5
|
|
126
|
+
meridian, month = Time.now.strftime("%p %b").split
|
|
127
|
+
"%d:%02d%s %s %s %s" % [hour, minutes, meridian.downcase, \
|
|
128
|
+
day.ordinal, month, year]
|
|
129
|
+
end
|
|
130
|
+
|
|
123
131
|
def recency(time)
|
|
124
132
|
|
|
125
133
|
case (Time.now - Time.parse(time))
|
|
@@ -139,7 +147,8 @@ if __FILE__ == $0 then
|
|
|
139
147
|
pfr = PolyrexFeedReader.new(px)
|
|
140
148
|
pfr.fetch_feeds
|
|
141
149
|
pfr.refresh
|
|
142
|
-
pfr.save_xml
|
|
150
|
+
pfr.save_xml 'feeds.xml'
|
|
143
151
|
pfr.save_html 'feeds.html'
|
|
152
|
+
pfr.save_css 'feeds.css'
|
|
144
153
|
|
|
145
154
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: polyrex-feed-reader
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.5.
|
|
4
|
+
version: 0.5.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- James Robertson
|
|
@@ -81,6 +81,7 @@ extra_rdoc_files: []
|
|
|
81
81
|
files:
|
|
82
82
|
- lib/polyrex-feed-reader.rb
|
|
83
83
|
- lib/feeds.xsl
|
|
84
|
+
- lib/feeds.css
|
|
84
85
|
homepage: https://github.com/jrobertson/polyrex-feed-reader
|
|
85
86
|
licenses:
|
|
86
87
|
- MIT
|
metadata.gz.sig
CHANGED
|
Binary file
|