radiant-rss_reader-extension 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,132 @@
1
+ source 'http://devwww.con-way.com/gemserver/'
2
+ # source 'https://rubygems.org'
3
+
4
+ # If you make any changes in this file, please run `bundle install`.
5
+ # If new versions of your installed gems are available, run `bundle update`
6
+
7
+ gem 'rake', '~> 10.0.2'
8
+ gem 'radiant', '~> 1.1.4'
9
+
10
+ # Other dependencies
11
+ gem "curb"
12
+ gem "maxcdn"
13
+ gem "yajl-ruby"
14
+ gem "system_timer"
15
+ gem 'compass-rails', '~> 1.0.3'
16
+ gem 'iconv', :platform => :mri_19
17
+ gem 'mime-types', '< 2.0'
18
+
19
+ if RUBY_PLATFORM =~ /darwin/ # tested on Mavericks
20
+ gem "libv8", "~> 3.16.14.3", :platform => :mri_19
21
+ gem "therubyracer", "~> 0.12.1", :platform => :mri_19 # javascript runtime
22
+ else
23
+ ## compatible on production Linux servers
24
+ gem "libv8", "3.3.10.2"
25
+ gem "therubyracer", "0.10.2" # javascript runtime
26
+ end
27
+
28
+ # SQLite is the default database connection but only suitable for local use
29
+ # gem 'sqlite3', '~> 1.3.5'
30
+
31
+ # To use MySQL
32
+ # gem 'mysql', '~> 2.8.1'
33
+
34
+ # Postgres
35
+ # gem 'pg', '~> 0.11.0'
36
+
37
+ # Default Extensions
38
+ gem 'radiant-archive-extension', '~> 1.0.7'
39
+ # gem 'radiant-clipped-extension', '~> 1.1.0'
40
+ gem 'radiant-debug-extension', '~> 1.0.2'
41
+ gem 'radiant-exporter-extension', '~> 1.1.0'
42
+ gem 'radiant-markdown_filter-extension', '~> 1.0.2'
43
+ gem 'radiant-sheets-extension', '~> 1.1.0'
44
+ gem 'radiant-snippets-extension', '~> 1.1.2'
45
+ gem 'radiant-site_templates-extension', '~> 1.0.6'
46
+ gem 'radiant-smarty_pants_filter-extension', '~> 1.0.2'
47
+ gem 'radiant-textile_filter-extension', '~> 1.0.4'
48
+
49
+
50
+ # Language packs
51
+ # gem 'radiant-dutch_language_pack-extension', '~> 1.0.1'
52
+ # gem 'radiant-french_language_pack-extension', '~> 1.0.0'
53
+ # gem 'radiant-german_language_pack-extension', '~> 1.0.1'
54
+ # gem 'radiant-italian_language_pack-extension', '~> 1.0.0'
55
+ # gem 'radiant-japanese_language_pack-extension', '~> 1.0.0'
56
+ # gem 'radiant-russian_language_pack-extension', '~> 1.0.0'
57
+
58
+ # A standard gem extension
59
+ # gem 'radiant-example-extension', :version => '~> 1.0.0'
60
+ gem 'radiant-banner_rotator-extension'
61
+ gem 'radiant-cache_by_page-extension'
62
+ gem 'radiant-concurrent_draft-extension'
63
+ gem 'radiant-copy_move-extension'
64
+ # gem 'radiant-file_sytem-extension', :git => 'git@github.com:avonderluft/radiant-file-system-extension.git' # no gemspec
65
+ gem 'radiant-help-extension'
66
+ gem 'radiant-import_export-extension'
67
+ gem 'radiant-language_redirect-extension'
68
+ gem 'radiant-mailer-extension'
69
+ gem 'radiant-page_group_permissions-extension'
70
+ gem 'radiant-page_list_view-extension'
71
+ # gem 'radiant-polls-extension'
72
+ gem 'radiant-rss_reader-extension'
73
+ gem 'radiant-settings-extension'
74
+ gem 'radiant-sitemap_search-extension'
75
+ gem 'radiant-templates-extension'
76
+
77
+ # Your own forked extension
78
+ # gem 'radiant-modified-extension', :git => 'git://github.com/your/fork.git'
79
+
80
+ # Gems you need for production, but not in your test or development environment
81
+ group :production do
82
+ gem 'ruby-oci8'
83
+ gem 'activerecord-oracle_enhanced-adapter'
84
+ end
85
+
86
+ # A local extension in development
87
+ # gem 'radiant-new-extension', :path => '/path/to/extension/root'
88
+
89
+ # Gems you would like to have in your development environment
90
+ group :development do
91
+ # you may need to install the mysql gem below manually on OSX with:
92
+ # $ ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
93
+ # If that does not work, try $ brew install mysql
94
+ gem 'mysql', '~> 2.8.1'
95
+ # gem 'passenger', '3.0.14' # not needed for prod, using apache module
96
+ gem 'jeweler'
97
+ gem 'wirble'
98
+ gem 'hirb'
99
+ gem 'pry'
100
+ gem 'ruby18_source_location', :platforms => :mri_18
101
+ gem "binding_of_caller", :platform => :ruby_19
102
+ gem "better_errors", :platform => :ruby_19
103
+ end
104
+
105
+ # If you're running tests or specs
106
+ group :test do
107
+ gem "test-unit", "~> 1.2.3"
108
+ gem 'cucumber-rails', '~> 0.3.2'
109
+ gem 'database_cleaner', '~> 0.6.5'
110
+ gem 'webrat', '~> 0.7.3'
111
+ gem 'rspec-rails', '~> 1.3.3'
112
+ gem 'sqlite3', '~> 1.3.4'
113
+ gem 'ZenTest', '~> 4.6.2', :platforms => [:mri_18, :mri_19]
114
+ # gem 'ZenTest', '~> 4.9.5'
115
+ # For Ruby 1.8.7
116
+ gem 'rdoc', '~> 3.12.2', :platforms => :mri_18
117
+ gem 'rdoc-data', '3.12', :platforms => :mri_18
118
+ # Custom
119
+ gem 'autotest', '~>4.4.5'
120
+ # gem 'autotest-fsevent', '~>0.2.3' # not compatible with Mavericks
121
+ gem 'autotest-growl', '~>0.2.6'
122
+ gem 'autotest-rails', '~>4.1.0'
123
+ gem 'syntax', '~>1.0.0'
124
+ # Get rid of some deprecation warnings when running specs
125
+ # Rubygems
126
+ if (defined?(Deprecate))
127
+ Deprecate.skip = true
128
+ elsif (defined?(Gem::Deprecate))
129
+ Gem::Deprecate.skip = true
130
+ end
131
+ end
132
+
@@ -0,0 +1,266 @@
1
+ GEM
2
+ remote: http://devwww.con-way.com/gemserver/
3
+ specs:
4
+ RedCloth (4.2.9)
5
+ ZenTest (4.6.2)
6
+ actionmailer (2.3.18)
7
+ actionpack (= 2.3.18)
8
+ actionpack (2.3.18)
9
+ activesupport (= 2.3.18)
10
+ rack (~> 1.1.0)
11
+ activerecord (2.3.18)
12
+ activesupport (= 2.3.18)
13
+ activerecord-oracle_enhanced-adapter (1.4.2)
14
+ activeresource (2.3.18)
15
+ activesupport (= 2.3.18)
16
+ activesupport (2.3.18)
17
+ acts_as_tree (0.1.1)
18
+ addressable (2.3.6)
19
+ autotest (4.4.6)
20
+ ZenTest (>= 4.4.1)
21
+ autotest-growl (0.2.16)
22
+ autotest-rails (4.1.2)
23
+ ZenTest (~> 4.5)
24
+ better_errors (0.9.0)
25
+ coderay (>= 1.0.0)
26
+ erubis (>= 2.6.6)
27
+ binding_of_caller (0.7.1)
28
+ debug_inspector (>= 0.0.1)
29
+ bluecloth (2.1.0)
30
+ builder (3.2.2)
31
+ chunky_png (1.3.0)
32
+ coderay (1.0.9)
33
+ coffee-script (2.2.0)
34
+ coffee-script-source
35
+ execjs
36
+ coffee-script-source (1.7.0)
37
+ compass (0.12.2)
38
+ chunky_png (~> 1.2)
39
+ fssm (>= 0.2.7)
40
+ sass (~> 3.1)
41
+ compass-rails (1.0.3)
42
+ compass (>= 0.12.2, < 0.14)
43
+ cucumber (1.3.14)
44
+ builder (>= 2.1.2)
45
+ diff-lcs (>= 1.1.3)
46
+ gherkin (~> 2.12)
47
+ multi_json (>= 1.7.5, < 2.0)
48
+ multi_test (>= 0.1.1)
49
+ cucumber-rails (0.3.2)
50
+ cucumber (>= 0.8.0)
51
+ curb (0.8.5)
52
+ curb-fu (0.6.2)
53
+ curb (>= 0.5.4.0)
54
+ rack-test (>= 0.2.0)
55
+ database_cleaner (0.6.7)
56
+ debug_inspector (0.0.2)
57
+ delocalize (0.2.6)
58
+ diff-lcs (1.2.5)
59
+ erubis (2.7.0)
60
+ execjs (2.0.2)
61
+ faraday (0.9.0.rc7)
62
+ multipart-post (>= 1.2, < 3)
63
+ fssm (0.2.10)
64
+ gherkin (2.12.2)
65
+ multi_json (~> 1.3)
66
+ git (1.2.6)
67
+ haml (3.1.8)
68
+ highline (1.6.20)
69
+ hirb (0.7.1)
70
+ hoe (3.7.1)
71
+ rake (>= 0.8, < 11.0)
72
+ iconv (1.0.4)
73
+ jeweler (1.8.4)
74
+ bundler (~> 1.0)
75
+ git (>= 1.2.5)
76
+ rake
77
+ rdoc
78
+ json (1.8.1)
79
+ jwt (0.1.11)
80
+ multi_json (>= 1.5)
81
+ libv8 (3.16.14.3)
82
+ maxcdn (0.1.4)
83
+ curb-fu
84
+ json
85
+ signet
86
+ method_source (0.8.2)
87
+ mime-types (1.25.1)
88
+ multi_json (1.8.4)
89
+ multi_test (0.1.1)
90
+ multipart-post (2.0.0)
91
+ mysql (2.8.1)
92
+ nokogiri (1.5.10)
93
+ pry (0.9.12)
94
+ coderay (~> 1.0.5)
95
+ method_source (~> 0.8)
96
+ slop (~> 3.4)
97
+ rack (1.1.6)
98
+ rack-cache (1.2)
99
+ rack (>= 0.4)
100
+ rack-test (0.6.2)
101
+ rack (>= 1.0)
102
+ radiant (1.1.4)
103
+ RedCloth (~> 4.2.0)
104
+ acts_as_tree (~> 0.1.1)
105
+ bundler (>= 1.0.0)
106
+ compass (~> 0.12.2)
107
+ compass-rails (~> 1.0.3)
108
+ delocalize (~> 0.2.3)
109
+ haml (~> 3.1.1)
110
+ highline (~> 1.6.10)
111
+ rack (~> 1.1.6)
112
+ rack-cache (~> 1.2)
113
+ radius (~> 0.7.3)
114
+ rails (~> 2.3.18)
115
+ rake (>= 0.8.7)
116
+ rdoc (>= 3.9.2)
117
+ stringex (~> 1.3.0)
118
+ tzinfo (~> 0.3.31)
119
+ will_paginate (~> 2.3.11)
120
+ radiant-archive-extension (1.0.7)
121
+ radiant-banner_rotator-extension (1.0.3)
122
+ radiant (>= 0.9.1)
123
+ radiant-cache_by_page-extension (1.0.3)
124
+ radiant (>= 0.9.1)
125
+ radiant-concurrent_draft-extension (1.0.11)
126
+ radiant (>= 1.0.0.rc2)
127
+ radiant-copy_move-extension (2.4.5)
128
+ radiant (>= 1.0.0.rc2)
129
+ radiant-debug-extension (1.0.2)
130
+ radiant-exporter-extension (1.1.0)
131
+ radiant-help-extension (1.1.3)
132
+ radiant-import_export-extension (1.0.0)
133
+ radiant-language_redirect-extension (1.0.1)
134
+ radiant (>= 1.1.3)
135
+ radiant-mailer-extension (1.0.6)
136
+ radiant-markdown_filter-extension (1.0.2)
137
+ bluecloth (~> 2.1.0)
138
+ radiant-page_group_permissions-extension (1.0.1)
139
+ radiant (>= 0.9.1)
140
+ radiant-page_list_view-extension (1.0.3)
141
+ radiant (>= 0.9.1)
142
+ radiant-rss_reader-extension (1.0.0)
143
+ ruby-feedparser (= 0.7.0)
144
+ radiant-settings-extension (1.1.2)
145
+ radiant (>= 0.9.1)
146
+ radiant-sheets-extension (1.1.0)
147
+ coffee-script (~> 2.2.0)
148
+ sass (~> 3.2.1)
149
+ radiant-site_templates-extension (1.0.6)
150
+ radiant-sitemap_search-extension (1.0.4)
151
+ radiant (>= 1.0.0.rc2)
152
+ radiant-smarty_pants_filter-extension (1.0.2)
153
+ rubypants (~> 0.2.0)
154
+ radiant-snippets-extension (1.1.3)
155
+ radiant-templates-extension (1.0.8)
156
+ radiant (>= 1.0.0.rc2)
157
+ radiant-textile_filter-extension (1.0.4)
158
+ RedCloth (~> 4.2.0)
159
+ radius (0.7.4)
160
+ rails (2.3.18)
161
+ actionmailer (= 2.3.18)
162
+ actionpack (= 2.3.18)
163
+ activerecord (= 2.3.18)
164
+ activeresource (= 2.3.18)
165
+ activesupport (= 2.3.18)
166
+ rake (>= 0.8.3)
167
+ rake (10.0.2)
168
+ rdoc (3.12.2)
169
+ json (~> 1.4)
170
+ rdoc-data (3.12)
171
+ rdoc (> 2.5, < 4.0)
172
+ ref (1.0.5)
173
+ rspec (1.3.2)
174
+ rspec-rails (1.3.4)
175
+ rack (>= 1.0.0)
176
+ rspec (~> 1.3.1)
177
+ ruby-feedparser (0.7)
178
+ ruby-oci8 (2.1.5)
179
+ ruby18_source_location (0.2)
180
+ rubypants (0.2.0)
181
+ sass (3.2.12)
182
+ signet (0.5.0)
183
+ addressable (>= 2.2.3)
184
+ faraday (>= 0.9.0.rc5)
185
+ jwt (>= 0.1.5)
186
+ multi_json (>= 1.0.0)
187
+ slop (3.4.4)
188
+ sqlite3 (1.3.8)
189
+ stringex (1.3.3)
190
+ syntax (1.0.0)
191
+ system_timer (1.2.4)
192
+ test-unit (1.2.3)
193
+ hoe (>= 1.5.1)
194
+ therubyracer (0.12.1)
195
+ libv8 (~> 3.16.14.0)
196
+ ref
197
+ tzinfo (0.3.38)
198
+ webrat (0.7.3)
199
+ nokogiri (>= 1.2.0)
200
+ rack (>= 1.0)
201
+ rack-test (>= 0.5.3)
202
+ will_paginate (2.3.16)
203
+ wirble (0.1.3)
204
+ yajl-ruby (1.2.0)
205
+
206
+ PLATFORMS
207
+ ruby
208
+
209
+ DEPENDENCIES
210
+ ZenTest (~> 4.6.2)
211
+ activerecord-oracle_enhanced-adapter
212
+ autotest (~> 4.4.5)
213
+ autotest-growl (~> 0.2.6)
214
+ autotest-rails (~> 4.1.0)
215
+ better_errors
216
+ binding_of_caller
217
+ compass-rails (~> 1.0.3)
218
+ cucumber-rails (~> 0.3.2)
219
+ curb
220
+ database_cleaner (~> 0.6.5)
221
+ hirb
222
+ iconv
223
+ jeweler
224
+ libv8 (~> 3.16.14.3)
225
+ maxcdn
226
+ mime-types (< 2.0)
227
+ mysql (~> 2.8.1)
228
+ pry
229
+ radiant (~> 1.1.4)
230
+ radiant-archive-extension (~> 1.0.7)
231
+ radiant-banner_rotator-extension
232
+ radiant-cache_by_page-extension
233
+ radiant-concurrent_draft-extension
234
+ radiant-copy_move-extension
235
+ radiant-debug-extension (~> 1.0.2)
236
+ radiant-exporter-extension (~> 1.1.0)
237
+ radiant-help-extension
238
+ radiant-import_export-extension
239
+ radiant-language_redirect-extension
240
+ radiant-mailer-extension
241
+ radiant-markdown_filter-extension (~> 1.0.2)
242
+ radiant-page_group_permissions-extension
243
+ radiant-page_list_view-extension
244
+ radiant-rss_reader-extension
245
+ radiant-settings-extension
246
+ radiant-sheets-extension (~> 1.1.0)
247
+ radiant-site_templates-extension (~> 1.0.6)
248
+ radiant-sitemap_search-extension
249
+ radiant-smarty_pants_filter-extension (~> 1.0.2)
250
+ radiant-snippets-extension (~> 1.1.2)
251
+ radiant-templates-extension
252
+ radiant-textile_filter-extension (~> 1.0.4)
253
+ rake (~> 10.0.2)
254
+ rdoc (~> 3.12.2)
255
+ rdoc-data (= 3.12)
256
+ rspec-rails (~> 1.3.3)
257
+ ruby-oci8
258
+ ruby18_source_location
259
+ sqlite3 (~> 1.3.4)
260
+ syntax (~> 1.0.0)
261
+ system_timer
262
+ test-unit (~> 1.2.3)
263
+ therubyracer (~> 0.12.1)
264
+ webrat (~> 0.7.3)
265
+ wirble
266
+ yajl-ruby
data/README.md CHANGED
@@ -62,7 +62,7 @@ You can sort items and group headers by date, title, content, creator, or link (
62
62
  * BJ Clark (bjclark@scidept.com, http://www.scidept.com/)
63
63
  * Loren Johnson (loren@fn-group.com, http://www.fn-group.com)
64
64
 
65
- #### Update to new Extension Architecture, Gemify:
65
+ #### Update to new Extension Architecture, Gemify, Add Tests
66
66
 
67
67
  * Andrew vonderLuft (avonderluft@avlux.net, https://avlux.net)
68
68
 
@@ -1,8 +1,8 @@
1
1
  module RadiantRssReaderExtension
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  SUMMARY = "RSS Reader for Radiant CMS"
4
4
  DESCRIPTION = "This extension uses the ruby-feedparser gem to read external RSS feeds, cache them, and easily display them in your pages."
5
5
  URL = "https://github.com/radiant/radiant-rss_reader-extension"
6
- AUTHORS = ["Andrew vonderLuft","Loren Johnson"]
7
- EMAIL = ["avonderluft@avlux.net","loren@hellovenado.com"]
6
+ AUTHORS = ["Andrew vonderLuft"]
7
+ EMAIL = ["avonderluft@avlux.net"]
8
8
  end
@@ -0,0 +1,44 @@
1
+ require 'uri'
2
+ require 'net/http'
3
+ require 'net/https'
4
+ require 'feedparser/feedparser'
5
+
6
+ module RssReader::PageExtensions
7
+
8
+ def fetch_rss(uri, cache_time)
9
+ c = File.join(ActionController::Base.page_cache_directory, uri.tr(':/','_'))
10
+ if (cached_feed = feed_for(IO.read(c)) rescue nil)
11
+ return cached_feed if File.mtime(c) > (Time.now - cache_time)
12
+ since = File.mtime(c).httpdate
13
+ else
14
+ since = "1970-01-01 00:00:00"
15
+ end
16
+ u = URI::parse(uri)
17
+ begin
18
+ http = Net::HTTP.new(u.host, u.port)
19
+ http.use_ssl = true if u.port == 443
20
+ answer = http.get("#{u.request_uri}", {"If-Modified-Since" => since, 'User-Agent' => "RadiantCMS rss_reader Extension #{RadiantRssReaderExtension::VERSION}"} )
21
+ feed = feed_for(answer.body)
22
+ rescue
23
+ return cached_feed
24
+ end
25
+ case answer.code
26
+ when '304'
27
+ return cached_feed
28
+ when '200'
29
+ File.open(c,'w+') { |fp| fp << answer.body }
30
+ return feed
31
+ else
32
+ raise StandardError, "#{answer.code} #{answer.message}"
33
+ end
34
+ end
35
+
36
+ def feed_for(str)
37
+ FeedParser::Feed.new(str)
38
+ end
39
+
40
+ def cache?
41
+ false
42
+ end
43
+
44
+ end
@@ -1,52 +1,10 @@
1
- require 'uri'
2
- require 'net/http'
3
- require 'net/https'
4
- require 'feedparser/feedparser'
5
-
6
- module RssReader
1
+ module RssReader::Tags
7
2
  include Radiant::Taggable
8
3
 
9
- def fetch_rss(uri, cache_time)
10
- c = File.join(ActionController::Base.page_cache_directory, uri.tr(':/','_'))
11
- if (cached_feed = feed_for(IO.read(c)) rescue nil)
12
- return cached_feed if File.mtime(c) > (Time.now - cache_time)
13
- since = File.mtime(c).httpdate
14
- else
15
- since = "1970-01-01 00:00:00"
16
- end
17
- u = URI::parse(uri)
18
- begin
19
- http = Net::HTTP.new(u.host, u.port)
20
- http.use_ssl = true if u.port == 443
21
- answer = http.get("#{u.request_uri}", {"If-Modified-Since" => since, 'User-Agent' => "RadiantCMS rss_reader Extension #{RadiantRssReaderExtension::VERSION}"} )
22
- feed = feed_for(answer.body)
23
- rescue
24
- return cached_feed
25
- end
26
- case answer.code
27
- when '304'
28
- return cached_feed
29
- when '200'
30
- File.open(c,'w+') { |fp| fp << answer.body }
31
- return feed
32
- else
33
- raise StandardError, "#{answer.code} #{answer.message}"
34
- end
35
- end
36
-
37
- def feed_for(str)
38
- FeedParser::Feed.new(str)
39
- end
40
-
41
- def cache?
42
- false
43
- end
44
-
45
4
  tag "feed" do |tag|
46
5
  tag.expand
47
6
  end
48
7
 
49
-
50
8
  desc %{
51
9
  Iterates through items in an rss feed provided as an absolute url to the @url@ attribute.
52
10
 
@@ -55,10 +13,14 @@ module RssReader
55
13
  * @cache_time@: length of time to cache the feed before seeing if it's been updated
56
14
  * @order@: works just like SQL 'ORDER BY' clauses, e.g. order='creator date desc' orders first by creator ascending, then date descending
57
15
  * @limit@: only return the first x items (after any ordering)
16
+ * @if_title_contains@: only return items whose title contains search term
17
+ * @unless_title_contains@: only return items whose title does not contain search term
18
+ * @if_content_contains@: only return items whose content contains search term
19
+ * @unless_content_contains@: only return items whose content does not contain search term
58
20
 
59
21
  *Usage:*
60
22
 
61
- <pre><code><r:find:items url="http://somefeed.com/rss" [cache_time="3600"] [order="creator date desc"] [limit="5"]>...</r:feed:items></code></pre>
23
+ <pre><code><r:feed:items url="http://somefeed.com/rss" [cache_time="3600"] [order="creator date desc"] [limit="5"] [if_title_contains="include text"] [unless_title_contains="exclude text"] [if_content_contains="include text"] [unless_content_contains="exclude text"]>...</r:feed:items></code></pre>
62
24
  }
63
25
  tag "feed:items" do |tag|
64
26
  attr = tag.attr.symbolize_keys
@@ -76,6 +38,18 @@ module RssReader
76
38
  end
77
39
  end
78
40
  end
41
+ if attr[:if_title_contains]
42
+ items = items.select { |item| item.title.downcase.include?(attr[:if_title_contains].downcase) }
43
+ end
44
+ if attr[:unless_title_contains]
45
+ items = items.select { |item| ! item.title.downcase.include?(attr[:unless_title_contains].downcase) }
46
+ end
47
+ if attr[:if_content_contains]
48
+ items = items.select { |item| item.content.downcase.include?(attr[:if_content_contains].downcase) }
49
+ end
50
+ if attr[:unless_content_contains]
51
+ items = items.select { |item| ! item.content.downcase.include?(attr[:unless_content_contains].downcase) }
52
+ end
79
53
  if attr[:limit]
80
54
  items = items.slice(0,attr[:limit].to_i)
81
55
  end
@@ -186,5 +160,4 @@ module RssReader
186
160
  tag.locals.item.creator
187
161
  end
188
162
 
189
- end
190
-
163
+ end
@@ -8,6 +8,7 @@ class RssReaderExtension < Radiant::Extension
8
8
  def activate
9
9
  cache_dir = ActionController::Base.page_cache_directory
10
10
  Dir.mkdir(cache_dir) unless File.exist?(cache_dir)
11
- Page.send :include, RssReader
11
+ Page.send :include, RssReader::PageExtensions
12
+ Page.send :include, RssReader::Tags
12
13
  end
13
14
  end
@@ -0,0 +1,85 @@
1
+ require 'spec_helper'
2
+ include Webrat::Matchers
3
+
4
+ describe SiteController do
5
+ dataset :rss_reader_pages
6
+
7
+ it "should read RSS feed generated by Radiant" do
8
+ get :show_page, :url => 'news-feed'
9
+ response.should be_success
10
+ response.body.should include('http://www.example.com/news/article-3/')
11
+ end
12
+
13
+ describe "fetching and formatting feeds" do
14
+
15
+ begin
16
+ pages = Page.find_by_slug('news-feed-pages').children
17
+ rescue NoMethodError => error_msg
18
+ puts "\n<h1>Unable to access pages - feed pages depend on viable internet connection.</h1>\n\n"
19
+ end
20
+
21
+ pages.each do |page|
22
+
23
+ describe "on #{page.title}" do
24
+
25
+ before :each do
26
+ get :show_page, :url => "news-feed-pages/#{page.slug}"
27
+ end
28
+ it "should render page from external feed" do
29
+ response.should be_success
30
+ end
31
+ it "should have the usual feed parts" do
32
+ [:title, :uri, :link, :content].each do |attr|
33
+ response.body.should have_selector('div', :class => "#{attr}") do |att|
34
+ att.should_not be_blank
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+
42
+ describe "fetching, formatting and filtering feeds" do
43
+
44
+ term = 'extension'
45
+
46
+ [1,2,3].each do |num|
47
+ it "should limit to #{num} feed item with attribute 'limit=\"#{num}\"'" do
48
+ get :show_page, :url => "news-feed-page-limit-#{num}"
49
+ response.should be_success
50
+ response.body.should have_selector('div', :class => "title", :count => num)
51
+ response.body.should have_selector('div', :class => "content", :count => num)
52
+ end
53
+ end
54
+ it "should retrieve only items with '#{term}' in the title" do
55
+ get :show_page, :url => "news-feed-page-by-words-in-title"
56
+ response.should be_success
57
+ response.body.should have_selector('div', :class => "title") do |title|
58
+ title.should contain("#{term}")
59
+ end
60
+ end
61
+ it "should retrieve only items without '#{term}' in the title" do
62
+ get :show_page, :url => "news-feed-page-by-words-not-in-title"
63
+ response.should be_success
64
+ response.body.should have_selector('div', :class => "title") do |title|
65
+ title.should_not contain("#{term}")
66
+ end
67
+ end
68
+ it "should retrieve only items with '#{term}' in the content" do
69
+ get :show_page, :url => "news-feed-page-by-words-in-content"
70
+ response.should be_success
71
+ response.body.should have_selector('div', :class => "content") do |content|
72
+ content.should contain("#{term}")
73
+ end
74
+ end
75
+ it "should retrieve only items without '#{term}' in the content" do
76
+ get :show_page, :url => "news-feed-page-by-words-not-in-content"
77
+ response.should be_success
78
+ response.body.should have_selector('div', :class => "content") do |content|
79
+ content.should_not contain("#{term}")
80
+ end
81
+ end
82
+
83
+ end
84
+
85
+ end
@@ -0,0 +1,100 @@
1
+ class RssReaderPagesDataset < Dataset::Base
2
+ uses :pages
3
+
4
+ def load
5
+
6
+ create_page "News Feed", :body => <<-CONTENT
7
+ <?xml version="1.0" encoding="UTF-8"?>
8
+ <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
9
+ <channel>
10
+ <title>Current News</title>
11
+ <link>http://www.example.com<r:url /></link>
12
+ <language>en-us</language>
13
+ <ttl>120</ttl>
14
+ <description>News Articles</description>
15
+ <r:find url="/news/">
16
+ <r:children:each limit="10" order="desc">
17
+ <item>
18
+ <title><r:title /></title>
19
+ <description><r:escape_html><r:content part="main_content" /></r:escape_html></description>
20
+ <pubDate><r:rfc1123_date /></pubDate>
21
+ <guid>http://www.example.com<r:url /></guid>
22
+ <link>http://www.example.com<r:url /></link>
23
+ </item>
24
+ </r:children:each>
25
+ </r:find>
26
+ </channel>
27
+ </rss>
28
+ CONTENT
29
+
30
+ feed_urls = []
31
+ feed_urls << "https://github.com/radiant/radiant-rss_reader-extension/commits/master.atom"
32
+ feed_urls << "http://rubygems.org/gems/radiant-rss_reader-extension/versions.atom"
33
+ feed_urls << "http://radiantcms.org/rss.xml"
34
+
35
+ create_page "News Feed Pages" do
36
+ feed_urls.each do |feed_url|
37
+ create_page "News Feed Page #{feed_urls.index(feed_url).to_s}", :body => <<-CONTENT
38
+ <r:feed:items url="#{feed_url}" order="date desc">
39
+ <div class="title"><r:feed:title /></div>
40
+ <div class="uri"><r:feed:uri /></div>
41
+ <div class="link"><r:feed:link /></div>
42
+ <div class="content"><r:feed:content/></div>
43
+ </r:feed:items>
44
+ CONTENT
45
+ end
46
+ end
47
+
48
+ feed_url = feed_urls.last
49
+
50
+ create_page "News Feed Page Limit 1", :body => <<-CONTENT
51
+ <r:feed:items url="#{feed_url}" order="date desc" limit="1">
52
+ <div class="title"><r:feed:title /></div>
53
+ <div class="content"><r:feed:content/></div>
54
+ </r:feed:items>
55
+ CONTENT
56
+
57
+ create_page "News Feed Page Limit 2", :body => <<-CONTENT
58
+ <r:feed:items url="#{feed_url}" order="date desc" limit="2">
59
+ <div class="title"><r:feed:title /></div>
60
+ <div class="content"><r:feed:content/></div>
61
+ </r:feed:items>
62
+ CONTENT
63
+
64
+ create_page "News Feed Page Limit 3", :body => <<-CONTENT
65
+ <r:feed:items url="#{feed_url}" order="date desc" limit="3">
66
+ <div class="title"><r:feed:title /></div>
67
+ <div class="content"><r:feed:content/></div>
68
+ </r:feed:items>
69
+ CONTENT
70
+
71
+ create_page "News Feed Page By Words in Title", :body => <<-CONTENT
72
+ <r:feed:items url="#{feed_url}" order="date desc" if_title_contains="extension">
73
+ <div class="title"><r:feed:title /></div>
74
+ <div class="content"><r:feed:content/></div>
75
+ </r:feed:items>
76
+ CONTENT
77
+
78
+ create_page "News Feed Page By Words not in Title", :body => <<-CONTENT
79
+ <r:feed:items url="#{feed_url}" order="date desc" unless_title_contains="extension">
80
+ <div class="title"><r:feed:title /></div>
81
+ <div class="content"><r:feed:content/></div>
82
+ </r:feed:items>
83
+ CONTENT
84
+
85
+ create_page "News Feed Page By Words in Content", :body => <<-CONTENT
86
+ <r:feed:items url="#{feed_url}" order="date desc" if_content_contains="extension">
87
+ <div class="title"><r:feed:title /></div>
88
+ <div class="content"><r:feed:content/></div>
89
+ </r:feed:items>
90
+ CONTENT
91
+
92
+ create_page "News Feed Page By Words not in Content", :body => <<-CONTENT
93
+ <r:feed:items url="#{feed_url}" order="date desc" unless_content_contains="extension">
94
+ <div class="title"><r:feed:title /></div>
95
+ <div class="content"><r:feed:content/></div>
96
+ </r:feed:items>
97
+ CONTENT
98
+
99
+ end
100
+ end
@@ -0,0 +1,66 @@
1
+ require 'spec_helper'
2
+
3
+ describe "RssReader::PageExtensions" do
4
+ dataset :rss_reader_pages
5
+
6
+ describe "Feed Page" do
7
+ before :all do
8
+ @page = pages(:news_feed)
9
+ end
10
+ it "should be valid" do
11
+ @page.should be_valid
12
+ @page.published?.should be_true
13
+ end
14
+ it "should have 1 page part" do
15
+ @page.parts.count.should == 1
16
+ end
17
+ it "should have XML content" do
18
+ @page.parts[0].content.should include('<?xml version="1.0" encoding="UTF-8"?>')
19
+ end
20
+ end
21
+
22
+ feeds = {}
23
+ feeds['atom'] = "http://rubygems.org/gems/radiant-rss_reader-extension/versions.atom"
24
+ feeds['rss'] = "http://radiantcms.org/rss.xml"
25
+
26
+ feeds.each_pair do |feed_type,feed_url|
27
+
28
+ describe "#{feed_type.capitalize} Feed" do
29
+ before :all do
30
+ @page = pages(:home)
31
+ @feed = @page.fetch_rss("#{feed_url}", 900)
32
+ end
33
+ [:title, :encoding, :xml].each do |attr|
34
+ it "should have #{attr}" do
35
+ @feed.send("#{attr}").should_not be_blank
36
+ end
37
+ end
38
+ it "should have correct type" do
39
+ @feed.type.should == feed_type
40
+ end
41
+ it "should have at least one item" do
42
+ @feed.items.count.should > 0
43
+ end
44
+ describe "First Item" do
45
+ before :all do
46
+ @item = @feed.items[0]
47
+ end
48
+ [:title, :xml, :content, :link].each do |attr|
49
+ it "should have #{attr}" do
50
+ @item.send("#{attr}").should_not be_blank
51
+ end
52
+ end
53
+ it "should have a valid date" do
54
+ ParseDate.parsedate("#{@item.date}")[0].should_not be_nil
55
+ end
56
+ it "should have at least 1 creator" do
57
+ @item.creators.count.should > 0
58
+ end
59
+ it "should have a valid link" do
60
+ @item.link.should include(feed_url[0..10])
61
+ end
62
+ end
63
+ end
64
+ end
65
+
66
+ end
metadata CHANGED
@@ -1,24 +1,24 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radiant-rss_reader-extension
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 0
10
- version: 1.0.0
9
+ - 1
10
+ version: 1.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andrew vonderLuft
14
- - Loren Johnson
15
14
  autorequire:
16
15
  bindir: bin
17
16
  cert_chain: []
18
17
 
19
- date: 2014-07-31 00:00:00 Z
18
+ date: 2014-08-09 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
21
+ prerelease: false
22
22
  type: :runtime
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
24
  none: false
@@ -32,12 +32,10 @@ dependencies:
32
32
  - 0
33
33
  version: 0.7.0
34
34
  version_requirements: *id001
35
- prerelease: false
36
35
  name: ruby-feedparser
37
36
  description: This extension uses the ruby-feedparser gem to read external RSS feeds, cache them, and easily display them in your pages.
38
37
  email:
39
38
  - avonderluft@avlux.net
40
- - loren@hellovenado.com
41
39
  executables: []
42
40
 
43
41
  extensions: []
@@ -51,13 +49,19 @@ files:
51
49
  - cucumber.yml
52
50
  - features/support/env.rb
53
51
  - features/support/paths.rb
52
+ - Gemfile
53
+ - Gemfile.lock
54
54
  - lib/radiant-rss_reader-extension.rb
55
- - lib/rss_reader.rb
55
+ - lib/rss_reader/page_extensions.rb
56
+ - lib/rss_reader/tags.rb
56
57
  - lib/tasks/rss_reader_extension_tasks.rake
57
58
  - radiant-rss_reader-extension.gemspec
58
59
  - Rakefile
59
60
  - README.md
60
61
  - rss_reader_extension.rb
62
+ - spec/controllers/site_controller_spec.rb
63
+ - spec/datasets/rss_reader_pages_dataset.rb
64
+ - spec/models/page_extensions_spec.rb
61
65
  - spec/spec.opts
62
66
  - spec/spec_helper.rb
63
67
  homepage: https://github.com/radiant/radiant-rss_reader-extension
@@ -89,11 +93,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
93
  requirements: []
90
94
 
91
95
  rubyforge_project:
92
- rubygems_version: 1.8.25
96
+ rubygems_version: 1.8.24
93
97
  signing_key:
94
98
  specification_version: 3
95
99
  summary: RSS Reader for Radiant CMS
96
100
  test_files:
101
+ - spec/controllers/site_controller_spec.rb
102
+ - spec/datasets/rss_reader_pages_dataset.rb
103
+ - spec/models/page_extensions_spec.rb
97
104
  - spec/spec.opts
98
105
  - spec/spec_helper.rb
99
106
  - features/support/env.rb