radiant-rss_reader-extension 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +81 -0
- data/Rakefile +110 -0
- data/config/initializers/radiant_config.rb +3 -0
- data/config/locales/en.yml +3 -0
- data/config/routes.rb +5 -0
- data/cucumber.yml +1 -0
- data/features/support/env.rb +11 -0
- data/features/support/paths.rb +22 -0
- data/lib/radiant-rss_reader-extension.rb +8 -0
- data/lib/rss_reader.rb +190 -0
- data/lib/tasks/rss_reader_extension_tasks.rake +47 -0
- data/radiant-rss_reader-extension.gemspec +28 -0
- data/rss_reader_extension.rb +13 -0
- data/spec/spec.opts +6 -0
- data/spec/spec_helper.rb +42 -0
- metadata +100 -0
data/README.md
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
# Radiant RSS Reader Extension
|
2
|
+
|
3
|
+
This is a RadiantCMS extension (originally a behavior by Alessandro Preite Martinez) that adds some tags to fetch and display RSS feeds. It uses the'ruby-feedparser' module, and it is able to cache the raw feed data and to only fetch the new feed if it has been modified (using the If-Modified-Since HTTP header).
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add `gem "radiant-rss_reader-extension", "~> 1.0.0"` to your Gemfile and run `bundle install`
|
8
|
+
|
9
|
+
|
10
|
+
## Usage
|
11
|
+
|
12
|
+
Use it in your page like this (just an example):
|
13
|
+
|
14
|
+
<dl>
|
15
|
+
<r:feed:items url="http://www.somefeed.com/rss" limit="5">
|
16
|
+
<dt><r:feed:link /> - by <r:feed:creator />, <r:feed:date format="%b %d"/></dt>
|
17
|
+
<dd><r:feed:content /></dd>
|
18
|
+
</r:feed:items>
|
19
|
+
</dl>
|
20
|
+
|
21
|
+
You can also order by some feed entry attribute other than the date:
|
22
|
+
|
23
|
+
<ul>
|
24
|
+
|
25
|
+
<r:feed:items
|
26
|
+
url="http://feeds.boingboing.net/boingboing/iBag"
|
27
|
+
order="creator ASC">
|
28
|
+
|
29
|
+
<li><r:feed:link /></li>
|
30
|
+
|
31
|
+
</r:feed:items>
|
32
|
+
|
33
|
+
</ul>
|
34
|
+
|
35
|
+
And you can do headers to mark off sections:
|
36
|
+
|
37
|
+
<ul>
|
38
|
+
|
39
|
+
<r:feed:items
|
40
|
+
url="http://feeds.boingboing.net/boingboing/iBag"
|
41
|
+
order="creator ASC">
|
42
|
+
|
43
|
+
<r:feed:header for="creator">
|
44
|
+
<h2><r:feed:creator /></h2>
|
45
|
+
</r:feed:header>
|
46
|
+
|
47
|
+
<li><r:feed:link /></li>
|
48
|
+
|
49
|
+
</r:feed:items>
|
50
|
+
|
51
|
+
</ul>
|
52
|
+
|
53
|
+
You can sort items and group headers by date, title, content, creator, or link (i.e. the URL of the item). There are more things you can do, which are documented in `rss_reader.rb`.
|
54
|
+
|
55
|
+
## [Contributors](https://github.com/radiant/radiant-rss_reader-extension/graphs/contributors)
|
56
|
+
|
57
|
+
#### Original Author:
|
58
|
+
* Alessandro Preite Martinez (ale@incal.net)
|
59
|
+
|
60
|
+
#### Port to Extension:
|
61
|
+
|
62
|
+
* BJ Clark (bjclark@scidept.com, http://www.scidept.com/)
|
63
|
+
* Loren Johnson (loren@fn-group.com, http://www.fn-group.com)
|
64
|
+
|
65
|
+
#### Update to new Extension Architecture, Gemify:
|
66
|
+
|
67
|
+
* Andrew vonderLuft (avonderluft@avlux.net, https://avlux.net)
|
68
|
+
|
69
|
+
#### Modifications:
|
70
|
+
|
71
|
+
* James MacAulay (jmacaulay@gmail.com, http://jmacaulay.net/)
|
72
|
+
* Michael Hale (mikehale@gmail.com, http://michaelahale.com/)
|
73
|
+
* Bryan Liles (iam@smartic.us, http://smartic.us/)
|
74
|
+
|
75
|
+
## [History](https://github.com/radiant/radiant-rss_reader-extension/commits/master)
|
76
|
+
|
77
|
+
## License
|
78
|
+
|
79
|
+
Creative Commons Attribution-Share Alike 2.5 License
|
80
|
+
|
81
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
# Determine where the RSpec plugin is by loading the boot
|
2
|
+
unless defined? RADIANT_ROOT
|
3
|
+
ENV["RAILS_ENV"] = "test"
|
4
|
+
case
|
5
|
+
when ENV["RADIANT_ENV_FILE"]
|
6
|
+
require File.dirname(ENV["RADIANT_ENV_FILE"]) + "/boot"
|
7
|
+
when File.dirname(__FILE__) =~ %r{vendor/radiant/vendor/extensions}
|
8
|
+
require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../")}/config/boot"
|
9
|
+
else
|
10
|
+
require "#{File.expand_path(File.dirname(__FILE__) + "/../../../")}/config/boot"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
require 'rake'
|
15
|
+
require 'rdoc/task'
|
16
|
+
require 'rake/testtask'
|
17
|
+
require 'bundler/gem_tasks'
|
18
|
+
|
19
|
+
rspec_base = File.expand_path(RADIANT_ROOT + '/vendor/plugins/rspec/lib')
|
20
|
+
$LOAD_PATH.unshift(rspec_base) if File.exist?(rspec_base)
|
21
|
+
require 'spec/rake/spectask'
|
22
|
+
require 'cucumber'
|
23
|
+
require 'cucumber/rake/task'
|
24
|
+
|
25
|
+
# Cleanup the RADIANT_ROOT constant so specs will load the environment
|
26
|
+
Object.send(:remove_const, :RADIANT_ROOT)
|
27
|
+
|
28
|
+
extension_root = File.expand_path(File.dirname(__FILE__))
|
29
|
+
|
30
|
+
task :default => [:spec, :features]
|
31
|
+
task :stats => "spec:statsetup"
|
32
|
+
|
33
|
+
desc "Run all specs in spec directory"
|
34
|
+
Spec::Rake::SpecTask.new(:spec) do |t|
|
35
|
+
t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
|
36
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
37
|
+
end
|
38
|
+
|
39
|
+
task :features => 'spec:integration'
|
40
|
+
|
41
|
+
namespace :spec do
|
42
|
+
desc "Run all specs in spec directory with RCov"
|
43
|
+
Spec::Rake::SpecTask.new(:rcov) do |t|
|
44
|
+
t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
|
45
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
46
|
+
t.rcov = true
|
47
|
+
t.rcov_opts = ['--exclude', 'spec', '--rails']
|
48
|
+
end
|
49
|
+
|
50
|
+
desc "Print Specdoc for all specs"
|
51
|
+
Spec::Rake::SpecTask.new(:doc) do |t|
|
52
|
+
t.spec_opts = ["--format", "specdoc", "--dry-run"]
|
53
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
54
|
+
end
|
55
|
+
|
56
|
+
[:models, :controllers, :views, :helpers].each do |sub|
|
57
|
+
desc "Run the specs under spec/#{sub}"
|
58
|
+
Spec::Rake::SpecTask.new(sub) do |t|
|
59
|
+
t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
|
60
|
+
t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
desc "Run the Cucumber features"
|
65
|
+
Cucumber::Rake::Task.new(:integration) do |t|
|
66
|
+
t.fork = true
|
67
|
+
t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'pretty')]
|
68
|
+
# t.feature_pattern = "#{extension_root}/features/**/*.feature"
|
69
|
+
t.profile = "default"
|
70
|
+
end
|
71
|
+
|
72
|
+
# Setup specs for stats
|
73
|
+
task :statsetup do
|
74
|
+
require 'code_statistics'
|
75
|
+
::STATS_DIRECTORIES << %w(Model\ specs spec/models)
|
76
|
+
::STATS_DIRECTORIES << %w(View\ specs spec/views)
|
77
|
+
::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers)
|
78
|
+
::STATS_DIRECTORIES << %w(Helper\ specs spec/views)
|
79
|
+
::CodeStatistics::TEST_TYPES << "Model specs"
|
80
|
+
::CodeStatistics::TEST_TYPES << "View specs"
|
81
|
+
::CodeStatistics::TEST_TYPES << "Controller specs"
|
82
|
+
::CodeStatistics::TEST_TYPES << "Helper specs"
|
83
|
+
::STATS_DIRECTORIES.delete_if {|a| a[0] =~ /test/}
|
84
|
+
end
|
85
|
+
|
86
|
+
namespace :db do
|
87
|
+
namespace :fixtures do
|
88
|
+
desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y"
|
89
|
+
task :load => :environment do
|
90
|
+
require 'active_record/fixtures'
|
91
|
+
ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
|
92
|
+
(ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'spec', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
|
93
|
+
Fixtures.create_fixtures('spec/fixtures', File.basename(fixture_file, '.*'))
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
desc 'Generate documentation for the rss_reader extension.'
|
101
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
102
|
+
rdoc.rdoc_dir = 'rdoc'
|
103
|
+
rdoc.title = 'RssReaderExtension'
|
104
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
105
|
+
rdoc.rdoc_files.include('README')
|
106
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
107
|
+
end
|
108
|
+
|
109
|
+
# Load any custom rakefiles for extension
|
110
|
+
Dir[File.dirname(__FILE__) + '/tasks/*.rake'].sort.each { |f| require f }
|
data/config/routes.rb
ADDED
data/cucumber.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
default: --format progress features --tags ~@proposed,~@in_progress
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Sets up the Rails environment for Cucumber
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
# Extension root
|
4
|
+
extension_env = File.expand_path(File.dirname(__FILE__) + '/../../../../../config/environment')
|
5
|
+
require extension_env+'.rb'
|
6
|
+
|
7
|
+
Dir.glob(File.join(RADIANT_ROOT, "features", "**", "*.rb")).each {|step| require step unless step =~ /datasets_loader\.rb$/}
|
8
|
+
|
9
|
+
Cucumber::Rails::World.class_eval do
|
10
|
+
dataset :rss_reader
|
11
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module NavigationHelpers
|
2
|
+
|
3
|
+
# Extend the standard PathMatchers with your own paths
|
4
|
+
# to be used in your features.
|
5
|
+
#
|
6
|
+
# The keys and values here may be used in your standard web steps
|
7
|
+
# Using:
|
8
|
+
#
|
9
|
+
# When I go to the "rss_reader" admin page
|
10
|
+
#
|
11
|
+
# would direct the request to the path you provide in the value:
|
12
|
+
#
|
13
|
+
# admin_rss_reader_path
|
14
|
+
#
|
15
|
+
PathMatchers = {} unless defined?(PathMatchers)
|
16
|
+
PathMatchers.merge!({
|
17
|
+
# /rss_reader/i => 'admin_rss_reader_path'
|
18
|
+
})
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
World(NavigationHelpers)
|
@@ -0,0 +1,8 @@
|
|
1
|
+
module RadiantRssReaderExtension
|
2
|
+
VERSION = "1.0.0"
|
3
|
+
SUMMARY = "RSS Reader for Radiant CMS"
|
4
|
+
DESCRIPTION = "This extension uses the ruby-feedparser gem to read external RSS feeds, cache them, and easily display them in your pages."
|
5
|
+
URL = "https://github.com/radiant/radiant-rss_reader-extension"
|
6
|
+
AUTHORS = ["Andrew vonderLuft","Loren Johnson"]
|
7
|
+
EMAIL = ["avonderluft@avlux.net","loren@hellovenado.com"]
|
8
|
+
end
|
data/lib/rss_reader.rb
ADDED
@@ -0,0 +1,190 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'net/http'
|
3
|
+
require 'net/https'
|
4
|
+
require 'feedparser/feedparser'
|
5
|
+
|
6
|
+
module RssReader
|
7
|
+
include Radiant::Taggable
|
8
|
+
|
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
|
+
tag "feed" do |tag|
|
46
|
+
tag.expand
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
desc %{
|
51
|
+
Iterates through items in an rss feed provided as an absolute url to the @url@ attribute.
|
52
|
+
|
53
|
+
Optional attributes:
|
54
|
+
|
55
|
+
* @cache_time@: length of time to cache the feed before seeing if it's been updated
|
56
|
+
* @order@: works just like SQL 'ORDER BY' clauses, e.g. order='creator date desc' orders first by creator ascending, then date descending
|
57
|
+
* @limit@: only return the first x items (after any ordering)
|
58
|
+
|
59
|
+
*Usage:*
|
60
|
+
|
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>
|
62
|
+
}
|
63
|
+
tag "feed:items" do |tag|
|
64
|
+
attr = tag.attr.symbolize_keys
|
65
|
+
result = []
|
66
|
+
begin
|
67
|
+
items = fetch_rss(attr[:url], attr[:cache_time].to_i || 900).items
|
68
|
+
rescue
|
69
|
+
return "<!-- RssReader error: #{$!} -->"
|
70
|
+
end
|
71
|
+
if attr[:order]
|
72
|
+
(tokens = attr[:order].split.map {|t| t.downcase}.reverse).each_index do |i|
|
73
|
+
t = tokens[i]
|
74
|
+
if ['title','link','content','date','creator'].include? t
|
75
|
+
items.sort! {|x,y| (tokens[i-1] == 'desc') ? (y.send(t) <=> x.send(t)) : (x.send(t) <=> y.send(t)) }
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
if attr[:limit]
|
80
|
+
items = items.slice(0,attr[:limit].to_i)
|
81
|
+
end
|
82
|
+
items.each_index do |i|
|
83
|
+
tag.locals.item = items[i]
|
84
|
+
tag.locals.last_item = items[i-1] if i > 0
|
85
|
+
result << tag.expand
|
86
|
+
end
|
87
|
+
result
|
88
|
+
end
|
89
|
+
|
90
|
+
desc %{
|
91
|
+
Used when the @feed:items@ tag uses the @order@ attribute. Will enter this block each time the value of the @for@ attribute is different from the previous feed item. Note: Using "date" as the @for@ attribute group by day
|
92
|
+
|
93
|
+
*Usage:*
|
94
|
+
|
95
|
+
<pre><code><r:feed:header for="{creator|title|link|content|date}">...</r:feed:header></code></pre>
|
96
|
+
}
|
97
|
+
|
98
|
+
tag "feed:header" do |tag|
|
99
|
+
attr = tag.attr.symbolize_keys
|
100
|
+
grouping = attr[:for] || 'date'
|
101
|
+
unless tag.locals.last_item
|
102
|
+
tag.expand
|
103
|
+
else
|
104
|
+
if ['title','link','content','creator'].include? grouping
|
105
|
+
tag.expand if tag.locals.item.send(grouping) != tag.locals.last_item.send(grouping)
|
106
|
+
elsif grouping == 'date'
|
107
|
+
tag.expand if tag.locals.item.send(grouping).strftime("%j%Y") != tag.locals.last_item.send(grouping).strftime("%j%Y")
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
tag "feed:title" do |tag|
|
113
|
+
tag.locals.item.title
|
114
|
+
end
|
115
|
+
|
116
|
+
tag "feed:link" do |tag|
|
117
|
+
options = tag.attr.dup
|
118
|
+
attributes = options.inject('') { |s, (k, v)| s << %{#{k.downcase}="#{v}" } }.strip
|
119
|
+
attributes = " #{attributes}" unless attributes.empty?
|
120
|
+
href = tag.locals.item.link
|
121
|
+
text = tag.double? ? tag.expand : tag.locals.item.title
|
122
|
+
%{<a href="#{href}"#{attributes}>#{text}</a>}
|
123
|
+
end
|
124
|
+
|
125
|
+
tag "feed:uri" do |tag|
|
126
|
+
tag.locals.item.link
|
127
|
+
end
|
128
|
+
|
129
|
+
desc %{
|
130
|
+
Display the contents of the rss feed item
|
131
|
+
|
132
|
+
Optional attributes:
|
133
|
+
|
134
|
+
* @max_length@: no-nonsense truncation
|
135
|
+
* @no_p@: takes out just the enclosing paragraph tags that FeedParser puts in
|
136
|
+
* @no_html@: takes out *all* html
|
137
|
+
|
138
|
+
*Usage:*
|
139
|
+
|
140
|
+
<pre><code><r:feed:content [max_length="140"] [no_p="true"] [no_html="true"]/></code></pre>
|
141
|
+
}
|
142
|
+
|
143
|
+
tag "feed:content" do |tag|
|
144
|
+
attr = tag.attr.symbolize_keys
|
145
|
+
result = tag.locals.item.content
|
146
|
+
if attr[:max_length]
|
147
|
+
l = tag.locals.item.content.size()
|
148
|
+
maxl = attr[:max_length].to_i
|
149
|
+
if l > maxl
|
150
|
+
result = tag.locals.item.content[0..maxl] + ' ...'
|
151
|
+
end
|
152
|
+
end
|
153
|
+
if result
|
154
|
+
result = result.gsub(/\A<p>(.*)<\/p>\z/m,'\1') if attr[:no_p]
|
155
|
+
result = result.gsub(/<[^>]+>/, '') if attr[:no_html]
|
156
|
+
end
|
157
|
+
result
|
158
|
+
end
|
159
|
+
|
160
|
+
desc %{
|
161
|
+
Display the date of the rss feed item
|
162
|
+
|
163
|
+
Optional attributes:
|
164
|
+
|
165
|
+
* @format@: Default is "%A, %B %d, %Y" can be changed to "%b %d"
|
166
|
+
|
167
|
+
*Usage:*
|
168
|
+
|
169
|
+
<pre><code><r:feed:date [format="%b %d"]/></code></pre>
|
170
|
+
}
|
171
|
+
tag "feed:date" do |tag|
|
172
|
+
format = (tag.attr['format'] || '%A, %B %d, %Y')
|
173
|
+
if date = tag.locals.item.date
|
174
|
+
date.strftime(format)
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
desc %{
|
179
|
+
Display the creator of the rss feed item
|
180
|
+
|
181
|
+
*Usage:*
|
182
|
+
|
183
|
+
<pre><code><r:feed:creator/></code></pre>
|
184
|
+
}
|
185
|
+
tag "feed:creator" do |tag|
|
186
|
+
tag.locals.item.creator
|
187
|
+
end
|
188
|
+
|
189
|
+
end
|
190
|
+
|
@@ -0,0 +1,47 @@
|
|
1
|
+
namespace :radiant do
|
2
|
+
namespace :extensions do
|
3
|
+
namespace :rss_reader do
|
4
|
+
|
5
|
+
desc "Runs the migration of the Rss Reader extension"
|
6
|
+
task :migrate => :environment do
|
7
|
+
require 'radiant/extension_migrator'
|
8
|
+
if ENV["VERSION"]
|
9
|
+
RssReaderExtension.migrator.migrate(ENV["VERSION"].to_i)
|
10
|
+
Rake::Task['db:schema:dump'].invoke
|
11
|
+
else
|
12
|
+
RssReaderExtension.migrator.migrate
|
13
|
+
Rake::Task['db:schema:dump'].invoke
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Copies public assets of the Rss Reader to the instance public/ directory."
|
18
|
+
task :update => :environment do
|
19
|
+
is_svn_or_dir = proc {|path| path =~ /\.svn/ || File.directory?(path) }
|
20
|
+
puts "Copying assets from RssReaderExtension"
|
21
|
+
Dir[RssReaderExtension.root + "/public/**/*"].reject(&is_svn_or_dir).each do |file|
|
22
|
+
path = file.sub(RssReaderExtension.root, '')
|
23
|
+
directory = File.dirname(path)
|
24
|
+
mkdir_p RAILS_ROOT + directory, :verbose => false
|
25
|
+
cp file, RAILS_ROOT + path, :verbose => false
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "Syncs all available translations for this ext to the English ext master"
|
30
|
+
task :sync => :environment do
|
31
|
+
# The main translation root, basically where English is kept
|
32
|
+
language_root = RssReaderExtension.root + "/config/locales"
|
33
|
+
words = TranslationSupport.get_translation_keys(language_root)
|
34
|
+
|
35
|
+
Dir["#{language_root}/*.yml"].each do |filename|
|
36
|
+
next if filename.match('_available_tags')
|
37
|
+
basename = File.basename(filename, '.yml')
|
38
|
+
puts "Syncing #{basename}"
|
39
|
+
(comments, other) = TranslationSupport.read_file(filename, basename)
|
40
|
+
words.each { |k,v| other[k] ||= words[k] } # Initializing hash variable as empty if it does not exist
|
41
|
+
other.delete_if { |k,v| !words[k] } # Remove if not defined in en.yml
|
42
|
+
TranslationSupport.write_file(filename, basename, comments, other)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "radiant-rss_reader-extension"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "radiant-rss_reader-extension"
|
7
|
+
s.version = RadiantRssReaderExtension::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = RadiantRssReaderExtension::AUTHORS
|
10
|
+
s.email = RadiantRssReaderExtension::EMAIL
|
11
|
+
s.homepage = RadiantRssReaderExtension::URL
|
12
|
+
s.summary = RadiantRssReaderExtension::SUMMARY
|
13
|
+
s.description = RadiantRssReaderExtension::DESCRIPTION
|
14
|
+
|
15
|
+
# Define gem dependencies here.
|
16
|
+
# Don't include a dependency on radiant itself: it causes problems when radiant is in vendor/radiant.
|
17
|
+
s.add_dependency "ruby-feedparser", "0.7.0"
|
18
|
+
|
19
|
+
ignores = if File.exist?('.gitignore')
|
20
|
+
File.read('.gitignore').split("\n").inject([]) {|a,p| a + Dir[p] }
|
21
|
+
else
|
22
|
+
[]
|
23
|
+
end
|
24
|
+
s.files = Dir['**/*'] - ignores
|
25
|
+
s.test_files = Dir['test/**/*','spec/**/*','features/**/*'] - ignores
|
26
|
+
# s.executables = Dir['bin/*'] - ignores
|
27
|
+
s.require_paths = ["lib"]
|
28
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "radiant-rss_reader-extension"
|
2
|
+
|
3
|
+
class RssReaderExtension < Radiant::Extension
|
4
|
+
version RadiantRssReaderExtension::VERSION
|
5
|
+
description RadiantRssReaderExtension::DESCRIPTION
|
6
|
+
url RadiantRssReaderExtension::URL
|
7
|
+
|
8
|
+
def activate
|
9
|
+
cache_dir = ActionController::Base.page_cache_directory
|
10
|
+
Dir.mkdir(cache_dir) unless File.exist?(cache_dir)
|
11
|
+
Page.send :include, RssReader
|
12
|
+
end
|
13
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
unless defined? RADIANT_ROOT
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
case
|
4
|
+
when ENV["RADIANT_ENV_FILE"]
|
5
|
+
require ENV["RADIANT_ENV_FILE"]
|
6
|
+
when File.dirname(__FILE__) =~ %r{vendor/radiant/vendor/extensions}
|
7
|
+
require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../../")}/config/environment"
|
8
|
+
else
|
9
|
+
require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../")}/config/environment"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
require "#{RADIANT_ROOT}/spec/spec_helper"
|
13
|
+
|
14
|
+
Dataset::Resolver.default << (File.dirname(__FILE__) + "/datasets")
|
15
|
+
# Include any datasets from loaded extensions
|
16
|
+
Radiant::Extension.descendants.each do |extension|
|
17
|
+
if File.directory?(extension.root + "/spec/datasets")
|
18
|
+
Dataset::Resolver.default << (extension.root + "/spec/datasets")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
if File.directory?(File.dirname(__FILE__) + "/matchers")
|
23
|
+
Dir[File.dirname(__FILE__) + "/matchers/*.rb"].each {|file| require file }
|
24
|
+
end
|
25
|
+
|
26
|
+
Spec::Runner.configure do |config|
|
27
|
+
# config.use_transactional_fixtures = true
|
28
|
+
# config.use_instantiated_fixtures = false
|
29
|
+
# config.fixture_path = RAILS_ROOT + '/spec/fixtures'
|
30
|
+
|
31
|
+
# You can declare fixtures for each behaviour like this:
|
32
|
+
# describe "...." do
|
33
|
+
# fixtures :table_a, :table_b
|
34
|
+
#
|
35
|
+
# Alternatively, if you prefer to declare them only once, you can
|
36
|
+
# do so here, like so ...
|
37
|
+
#
|
38
|
+
# config.global_fixtures = :table_a, :table_b
|
39
|
+
#
|
40
|
+
# If you declare global fixtures, be aware that they will be declared
|
41
|
+
# for all of your examples, even those that don't use them.
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: radiant-rss_reader-extension
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 1.0.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Andrew vonderLuft
|
14
|
+
- Loren Johnson
|
15
|
+
autorequire:
|
16
|
+
bindir: bin
|
17
|
+
cert_chain: []
|
18
|
+
|
19
|
+
date: 2014-07-31 00:00:00 Z
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
type: :runtime
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - "="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
- 7
|
32
|
+
- 0
|
33
|
+
version: 0.7.0
|
34
|
+
version_requirements: *id001
|
35
|
+
prerelease: false
|
36
|
+
name: ruby-feedparser
|
37
|
+
description: This extension uses the ruby-feedparser gem to read external RSS feeds, cache them, and easily display them in your pages.
|
38
|
+
email:
|
39
|
+
- avonderluft@avlux.net
|
40
|
+
- loren@hellovenado.com
|
41
|
+
executables: []
|
42
|
+
|
43
|
+
extensions: []
|
44
|
+
|
45
|
+
extra_rdoc_files: []
|
46
|
+
|
47
|
+
files:
|
48
|
+
- config/initializers/radiant_config.rb
|
49
|
+
- config/locales/en.yml
|
50
|
+
- config/routes.rb
|
51
|
+
- cucumber.yml
|
52
|
+
- features/support/env.rb
|
53
|
+
- features/support/paths.rb
|
54
|
+
- lib/radiant-rss_reader-extension.rb
|
55
|
+
- lib/rss_reader.rb
|
56
|
+
- lib/tasks/rss_reader_extension_tasks.rake
|
57
|
+
- radiant-rss_reader-extension.gemspec
|
58
|
+
- Rakefile
|
59
|
+
- README.md
|
60
|
+
- rss_reader_extension.rb
|
61
|
+
- spec/spec.opts
|
62
|
+
- spec/spec_helper.rb
|
63
|
+
homepage: https://github.com/radiant/radiant-rss_reader-extension
|
64
|
+
licenses: []
|
65
|
+
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
hash: 3
|
77
|
+
segments:
|
78
|
+
- 0
|
79
|
+
version: "0"
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
hash: 3
|
86
|
+
segments:
|
87
|
+
- 0
|
88
|
+
version: "0"
|
89
|
+
requirements: []
|
90
|
+
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 1.8.25
|
93
|
+
signing_key:
|
94
|
+
specification_version: 3
|
95
|
+
summary: RSS Reader for Radiant CMS
|
96
|
+
test_files:
|
97
|
+
- spec/spec.opts
|
98
|
+
- spec/spec_helper.rb
|
99
|
+
- features/support/env.rb
|
100
|
+
- features/support/paths.rb
|