pluto-models 1.2.3 → 1.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 655a0dd8f07d85aca47f4e60daf6fd994b089ef6
4
- data.tar.gz: 2babdba51c354d42457844f4ff34d0cde087baba
3
+ metadata.gz: 0f17253773a7629dbd311e1d3aecb9babfbf50cd
4
+ data.tar.gz: 57f21b6e70a575e104bbf9d8fbf57cde52148d92
5
5
  SHA512:
6
- metadata.gz: e24ff26b7b9cfc8d851159c7aa7348be236e5790747ab6e251ca7131179c7893e359372d36441bfe291f92741d3facf15b48f5b9d575e1b3731b8260bed11c58
7
- data.tar.gz: 0e84028a50c42762f7cc5968c12940821132591a96edb12045b2cfd3a8c3b0ae8288ba931f360bc7b5a862c9fc7e163890b13acdaecaf9321ab7d798cf02af55
6
+ metadata.gz: e56ba1c10d02aeec5807a7cc5527711729b74300d4d0b11d472dfc710d5d0338a7d1c2deb348dee41bdcffe7a33f267515aa76b2170b46a83a01580e8af6ef4e
7
+ data.tar.gz: d3372c8160a1401ae7da82c739348e672aa138a99d1d2b69bdf7374f7c0691dbae7b583fc0a6d6b35f3175055bc0193121018f4bcf0c49c580d85c79cfa3dcc7
@@ -12,6 +12,11 @@ class Feed < ActiveRecord::Base
12
12
  has_many :sites, :through => :subscriptions
13
13
 
14
14
 
15
+ ## todo/fix:
16
+ ## use a module ref or something; do NOT include all methods - why? why not?
17
+ include TextUtils::HypertextHelper ## e.g. lets us use strip_tags( ht )
18
+
19
+
15
20
  def self.latest
16
21
  # note: order by first non-null datetime field
17
22
  # coalesce - supported by sqlite (yes), postgres (yes)
@@ -95,6 +100,17 @@ class Feed < ActiveRecord::Base
95
100
  generator_full = nil
96
101
  end
97
102
 
103
+ ##
104
+ # todo:
105
+ ## strip all tags from title2
106
+ ## limit to 255 chars
107
+ ## e.g. title2 such as this exist
108
+ ## This is a low-traffic announce-only list for people interested
109
+ ## in hearing news about Polymer (<a href="http://polymer-project.org">http://polymer-project.org</a>).
110
+ ## The higher-traffic mailing list for all kinds of discussion is
111
+ ## <a href="https://groups.google.com/group/polymer-dev">https://groups.google.com/group/polymer-dev</a>
112
+
113
+
98
114
  feed_attribs = {
99
115
  format: data.format,
100
116
  published: data.published,
@@ -105,7 +121,7 @@ class Feed < ActiveRecord::Base
105
121
  # auto_title: ???,
106
122
  # auto_url: ???,
107
123
  # auto_feed_url: ???,
108
- auto_title2: data.title2,
124
+ auto_title2: data.title2 ? strip_tags(data.title2)[0...255] : data.title2, # limit to 255 chars; strip tags
109
125
  generator: generator_full
110
126
  }
111
127
 
@@ -8,6 +8,11 @@ class Item < ActiveRecord::Base
8
8
 
9
9
  belongs_to :feed
10
10
 
11
+ ## todo/fix:
12
+ ## use a module ref or something; do NOT include all methods - why? why not?
13
+ include TextUtils::HypertextHelper ## e.g. lets us use strip_tags( ht )
14
+
15
+
11
16
  ##################################
12
17
  # attribute reader aliases
13
18
  def name() title; end # alias for title
@@ -45,7 +50,7 @@ class Item < ActiveRecord::Base
45
50
 
46
51
  item_attribs = {
47
52
  guid: data.guid, # todo: only add for new records???
48
- title: data.title,
53
+ title: data.title ? strip_tags(data.title)[0...255] : data.title, ## limit to 255 chars; strip tags
49
54
  url: data.url,
50
55
  summary: data.summary,
51
56
  content: data.content,
data/lib/pluto/schema.rb CHANGED
@@ -109,13 +109,15 @@ class CreateDb < ActiveRecord::Migration
109
109
  t.string :guid
110
110
  t.string :url
111
111
 
112
- ## note: title may contain more than 255 chars!! use text for sure!
112
+ ## note: title may contain more than 255 chars!!
113
113
  ## e.g. Rails Girls blog has massive titles in feed
114
-
115
- t.text :title # todo: add some :null => false ??
114
+ ## cut-off/limit to 255
115
+ ## also strip tags in titles - why? why not?? - see feed.title2/auto_title2
116
+
117
+ t.string :title # todo: add some :null => false ??
116
118
  t.text :summary # e.g. description (rss), summary (atom)
117
119
  t.text :content
118
-
120
+
119
121
  t.datetime :published # from feed (published) + pubDate(rss)
120
122
  t.datetime :touched # from feed updated (atom)
121
123
 
data/lib/pluto/version.rb CHANGED
@@ -4,7 +4,7 @@ module Pluto
4
4
 
5
5
  MAJOR = 1
6
6
  MINOR = 2
7
- PATCH = 3
7
+ PATCH = 4
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
10
10
  def self.version
data/test/test_helpers.rb CHANGED
@@ -34,4 +34,21 @@ class TestHelper < MiniTest::Test
34
34
  assert true ## if we get here it should workd
35
35
  end
36
36
 
37
+
38
+ include TextUtils::HypertextHelper ## e.g. lets us use strip_tags( ht )
39
+
40
+ def test_feed_title2_sanitize
41
+ ##
42
+ # todo:
43
+ ## strip all tags from title2
44
+ ## limit to 255 chars
45
+ ## e.g. title2 such as this exist
46
+
47
+ title2_in = %Q{This is a low-traffic announce-only list for people interested in hearing news about Polymer (<a href="http://polymer-project.org">http://polymer-project.org</a>). The higher-traffic mailing list for all kinds of discussion is <a href="https://groups.google.com/group/polymer-dev">https://groups.google.com/group/polymer-dev</a>}
48
+ title2_out = %Q{This is a low-traffic announce-only list for people interested in hearing news about Polymer (http://polymer-project.org). The higher-traffic mailing list for all kinds of discussion is https://groups.google.com/group/polymer-dev}
49
+
50
+ assert_equal title2_out, strip_tags( title2_in )
51
+ assert_equal 229, strip_tags( title2_in )[0...255].length
52
+ end
53
+
37
54
  end # class TestHelper
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pluto-models
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-13 00:00:00.000000000 Z
11
+ date: 2014-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: props