concerto_simple_rss 1.0 → 1.1
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
- data/app/models/simple_rss.rb +17 -17
- data/lib/concerto_simple_rss/engine.rb +2 -1
- data/lib/concerto_simple_rss/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b661b2dccddb96c606b34d1c63b15b014790c286
|
4
|
+
data.tar.gz: 8d6ecccd2b613b09e6905370bdc6a2cb36a591d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0645137debcd329c78c43bf57f2f64a00b1cefc34f8a477f4af494501058d75622c60b5b1454fd775d86cfd6b7d09eb6defe243692405647346c971bc18026d
|
7
|
+
data.tar.gz: 6e7785a2185ef61abc7e9601108e54ec9a985ae997914e613c0e02e7a0946bee601c84f9f237b573c6b57e05a5b1b4bdb32541fec2d04422ab9303151f9e5f36
|
data/app/models/simple_rss.rb
CHANGED
@@ -10,15 +10,15 @@ class SimpleRss < DynamicContent
|
|
10
10
|
# Called during `after_find`.
|
11
11
|
def load_config
|
12
12
|
j = JSON.load(self.data)
|
13
|
-
|
13
|
+
|
14
14
|
# decrypt fields
|
15
15
|
unless j.blank?
|
16
16
|
encrypted_userid = Base64.decode64(j['url_userid_enc']) unless j['url_userid_enc'].blank?
|
17
17
|
encrypted_password = Base64.decode64(j['url_password_enc']) unless j['url_password_enc'].blank?
|
18
18
|
|
19
|
-
j['url_userid'] = (encrypted_userid.blank? ? "" :
|
20
|
-
j['url_password'] = (encrypted_password.blank? ? "" :
|
21
|
-
end
|
19
|
+
j['url_userid'] = (encrypted_userid.blank? ? "" : Encryptor.decrypt(encrypted_userid))
|
20
|
+
j['url_password'] = (encrypted_password.blank? ? "" : Encryptor.decrypt(encrypted_password))
|
21
|
+
end
|
22
22
|
|
23
23
|
self.config = j
|
24
24
|
end
|
@@ -30,8 +30,8 @@ class SimpleRss < DynamicContent
|
|
30
30
|
j = self.config.deep_dup
|
31
31
|
|
32
32
|
# encrypt fields
|
33
|
-
j['url_userid_enc'] = (j['url_userid'].blank? ? "" : Base64.encode64(j['url_userid']
|
34
|
-
j['url_password_enc'] = (j['url_password'].blank? ? "" : Base64.encode64(j['url_password']
|
33
|
+
j['url_userid_enc'] = (j['url_userid'].blank? ? "" : Base64.encode64(Encryptor.encrypt(j['url_userid'])))
|
34
|
+
j['url_password_enc'] = (j['url_password'].blank? ? "" : Base64.encode64(Encryptor.encrypt(j['url_password'])))
|
35
35
|
j.delete 'url_userid'
|
36
36
|
j.delete 'url_password'
|
37
37
|
self.data = JSON.dump(j)
|
@@ -45,7 +45,7 @@ class SimpleRss < DynamicContent
|
|
45
45
|
url_userid = self.config['url_userid']
|
46
46
|
url_password = self.config['url_password']
|
47
47
|
type, feed_title, rss, raw = fetch_feed(url, url_userid, url_password)
|
48
|
-
|
48
|
+
|
49
49
|
if (["RSS", "ATOM"].include? type) && !feed_title.blank?
|
50
50
|
# it is a valid feed
|
51
51
|
if !self.config['reverse_order'].blank? && self.config['reverse_order'] == '1'
|
@@ -100,7 +100,7 @@ class SimpleRss < DynamicContent
|
|
100
100
|
|
101
101
|
# add a replace [gsub] function for more powerful transforms. You can use this in a transform
|
102
102
|
# by adding the bogus namespace http://concerto.functions
|
103
|
-
# A nodeset comes in as an array of REXML::Elements
|
103
|
+
# A nodeset comes in as an array of REXML::Elements
|
104
104
|
XML::XSLT.registerExtFunc("http://concerto.functions", "replace") do |nodes, pattern, replacement|
|
105
105
|
result = xslt_replace(nodes, pattern, replacement)
|
106
106
|
result
|
@@ -115,7 +115,7 @@ class SimpleRss < DynamicContent
|
|
115
115
|
# xslt.serve does always return a string with ASCII-8BIT encoding regardless of what the actual encoding is
|
116
116
|
data = data.force_encoding(xslt.xml.encoding) if data
|
117
117
|
|
118
|
-
# try to load the transformed data as an xml document so we can see if there are
|
118
|
+
# try to load the transformed data as an xml document so we can see if there are
|
119
119
|
# mulitple content-items that we need to parse out, if we cant then treat it as one content item
|
120
120
|
begin
|
121
121
|
data_xml = REXML::Document.new('<root>' + data + '</root>')
|
@@ -146,7 +146,7 @@ class SimpleRss < DynamicContent
|
|
146
146
|
data.split("</content-item>").each do |n|
|
147
147
|
htmltext = HtmlText.new()
|
148
148
|
htmltext.name = "#{feed_title}"
|
149
|
-
htmltext.data = sanitize(n.sub("<content-item>", ""))
|
149
|
+
htmltext.data = sanitize(n.sub("<content-item>", ""))
|
150
150
|
contents << htmltext if !htmltext.data.blank?
|
151
151
|
end
|
152
152
|
|
@@ -170,7 +170,7 @@ class SimpleRss < DynamicContent
|
|
170
170
|
raise "Unexpected feed format for #{url}."
|
171
171
|
end
|
172
172
|
end
|
173
|
-
|
173
|
+
|
174
174
|
return contents
|
175
175
|
end
|
176
176
|
|
@@ -198,7 +198,7 @@ class SimpleRss < DynamicContent
|
|
198
198
|
end
|
199
199
|
|
200
200
|
result
|
201
|
-
end
|
201
|
+
end
|
202
202
|
|
203
203
|
# fetch the feed, return the type, title, and contents (parsed) and raw feed (unparsed)
|
204
204
|
def fetch_feed(url, url_userid, url_password)
|
@@ -254,7 +254,7 @@ class SimpleRss < DynamicContent
|
|
254
254
|
when "ATOM"
|
255
255
|
title = item.title.content
|
256
256
|
|
257
|
-
# seems like the hard way, but the only way I could figure out to get the
|
257
|
+
# seems like the hard way, but the only way I could figure out to get the
|
258
258
|
# contents without it being html encoded. most likely a prime candidate for optimizing
|
259
259
|
require 'rexml/document'
|
260
260
|
entry_xml = REXML::Document.new(item.to_s)
|
@@ -271,7 +271,7 @@ class SimpleRss < DynamicContent
|
|
271
271
|
end
|
272
272
|
|
273
273
|
def items_to_html(items, type)
|
274
|
-
return items.collect {|item|
|
274
|
+
return items.collect {|item|
|
275
275
|
case type
|
276
276
|
when "RSS"
|
277
277
|
title = item.title
|
@@ -293,7 +293,7 @@ class SimpleRss < DynamicContent
|
|
293
293
|
url = self.config['url']
|
294
294
|
url_userid = self.config['url_userid']
|
295
295
|
url_password = self.config['url_password']
|
296
|
-
unless url.blank?
|
296
|
+
unless url.blank?
|
297
297
|
Rails.logger.debug("looking up feed title for #{url}")
|
298
298
|
|
299
299
|
type, title = fetch_feed(url, url_userid, url_password)
|
@@ -321,7 +321,7 @@ class SimpleRss < DynamicContent
|
|
321
321
|
url = self.config['url']
|
322
322
|
url_userid = self.config['url_userid']
|
323
323
|
url_password = self.config['url_password']
|
324
|
-
unless url.blank?
|
324
|
+
unless url.blank?
|
325
325
|
require 'rexml/document'
|
326
326
|
require 'xml/xslt'
|
327
327
|
|
@@ -365,7 +365,7 @@ class SimpleRss < DynamicContent
|
|
365
365
|
|
366
366
|
def sanitize(html)
|
367
367
|
if self.config.include?('sanitize_tags') and !self.config['sanitize_tags'].empty?
|
368
|
-
whitelist = ActionView::Base.sanitized_allowed_tags
|
368
|
+
whitelist = ActionView::Base.sanitized_allowed_tags
|
369
369
|
blacklist = self.config['sanitize_tags'].split(" ")
|
370
370
|
|
371
371
|
html = ActionController::Base.helpers.sanitize(html, :tags => (whitelist - blacklist))
|
@@ -1,13 +1,14 @@
|
|
1
1
|
module ConcertoSimpleRss
|
2
2
|
class Engine < ::Rails::Engine
|
3
3
|
require 'encryptor'
|
4
|
-
|
4
|
+
|
5
5
|
isolate_namespace ConcertoSimpleRss
|
6
6
|
|
7
7
|
initializer "register content type" do |app|
|
8
8
|
app.config.content_types << SimpleRss
|
9
9
|
|
10
10
|
Encryptor.default_options.merge!(key: ENV["SECRET_KEY_BASE"])
|
11
|
+
Encryptor.default_options.merge!(iv: ENV["SECRET_KEY_BASE"])
|
11
12
|
end
|
12
13
|
end
|
13
14
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: concerto_simple_rss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.1'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Michalski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: encryptor
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
33
|
+
version: '3.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
40
|
+
version: '3.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: ruby-xslt
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
128
|
version: '0'
|
129
129
|
requirements: []
|
130
130
|
rubyforge_project:
|
131
|
-
rubygems_version: 2.
|
131
|
+
rubygems_version: 2.5.2
|
132
132
|
signing_key:
|
133
133
|
specification_version: 4
|
134
134
|
summary: RSS Dynamic Concerto for Concerto 2.
|