pluto 0.8.4 → 0.8.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,13 +20,22 @@ class Feed < ActiveRecord::Base
20
20
  order( "coalesce(latest_published_at,'1911-01-01') desc" )
21
21
  end
22
22
 
23
+ ##################################
24
+ # attribute reader aliases
25
+ def name() title; end # alias for title
26
+ def description() summary; end # alias for summary -- also add descr shortcut??
27
+ def link() url; end # alias for url
28
+ def feed() feed_url; end # alias for feed_url
29
+
23
30
 
24
31
  def url?() read_attribute(:url).present?; end
25
32
  def title?() read_attribute(:title).present?; end
33
+ def title2?() read_attribute(:title2).present?; end
26
34
  def feed_url?() read_attribute(:feed_url).present?; end
27
35
 
28
36
  def url() read_attribute_w_fallbacks( :url, :auto_url ); end
29
37
  def title() read_attribute_w_fallbacks( :title, :auto_title ); end
38
+ def title2() read_attribute_w_fallbacks( :title2, :auto_title2 ); end
30
39
  def feed_url() read_attribute_w_fallbacks( :feed_url, :auto_feed_url ); end
31
40
 
32
41
 
@@ -7,7 +7,14 @@ class Item < ActiveRecord::Base
7
7
  include Pluto::ActiveRecordMethods # e.g. read_attribute_w_fallbacks
8
8
 
9
9
  belongs_to :feed
10
-
10
+
11
+ ##################################
12
+ # attribute reader aliases
13
+ def name() title; end # alias for title
14
+ def description() summary; end # alias for summary -- also add descr shortcut??
15
+ def link() url; end # alias for url
16
+
17
+
11
18
  def self.latest
12
19
  # note: order by first non-null datetime field
13
20
  # coalesce - supported by sqlite (yes), postgres (yes)
@@ -6,6 +6,12 @@ class Site < ActiveRecord::Base
6
6
 
7
7
  has_many :subscriptions
8
8
  has_many :feeds, :through => :subscriptions
9
+ has_many :items, :through => :feeds
10
+
11
+ ##################################
12
+ # attribute reader aliases
13
+ def name() title; end # alias for title
14
+
9
15
  end
10
16
 
11
17
  end # module Models
@@ -60,7 +60,11 @@ class Refresher
60
60
  touched_at: feed.updated? ? feed.updated : nil,
61
61
  built_at: feed.built? ? feed.built : nil,
62
62
  summary: feed.summary? ? feed.summary : nil,
63
- title2: feed.title2? ? feed.title2 : nil,
63
+ ### todo/fix: add/use
64
+ # auto_title: ???,
65
+ # auto_url: ???,
66
+ # auto_feed_url: ???,
67
+ auto_title2: feed.title2? ? feed.title2 : nil,
64
68
  generator: feed.generator
65
69
  }
66
70
 
data/lib/pluto/schema.rb CHANGED
@@ -19,16 +19,18 @@ class CreateDb < ActiveRecord::Migration
19
19
  end
20
20
 
21
21
  create_table :feeds do |t|
22
- t.string :title # user supplied titled
22
+ t.string :title # user supplied title
23
23
  t.string :auto_title # "fallback" - auto(fill) title from feed
24
24
 
25
+ t.string :title2 # user supplied title2
26
+ t.string :auto_title2 # "fallback" - auto(fill) title2 from feed e.g. subtitle (atom)
27
+
25
28
  t.string :url # user supplied site url
26
29
  t.string :auto_url # "fallback" - auto(fill) url from feed
27
30
 
28
31
  t.string :feed_url # user supplied feed url
29
32
  t.string :auto_feed_url # "fallback" - auto discovery feed url from (site) url
30
33
 
31
- t.string :title2 # e.g. subtitle (atom)
32
34
  t.text :summary # e.g. description (rss)
33
35
 
34
36
  t.string :generator # feed generator (e.g. wordpress, etc.) from feed
@@ -34,10 +34,17 @@ class Subscriber
34
34
  # -- log update action
35
35
  Action.create!( title: 'update subscriptions' )
36
36
 
37
+ # clean out subscriptions and add again
38
+ logger.debug "before site.subscriptions.delete_all - count: #{site_rec.subscriptions.count}"
39
+ site_rec.subscriptions.destroy_all # note: use destroy_all NOT delete_all (delete_all tries by default only nullify)
40
+ logger.debug "after site.subscriptions.delete_all - count: #{site_rec.subscriptions.count}"
37
41
 
38
42
  config.each do |key, value|
39
-
40
- next if ['title','name','feeds'].include?( key ) # skip "top-level" feed keys e.g. title, etc.
43
+
44
+ ## todo: downcase key - why ??? why not???
45
+
46
+ # skip "top-level" feed keys e.g. title, etc. or planet planet sections (e.g. planet,defaults)
47
+ next if ['title','title2','name','feeds','planet','defaults'].include?( key )
41
48
 
42
49
  ### todo/check:
43
50
  ## check value - must be hash
@@ -50,8 +57,9 @@ class Subscriber
50
57
  # todo: use title from feed?
51
58
  feed_attribs = {
52
59
  feed_url: feed_hash[ 'feed' ] || feed_hash[ 'feed_url' ],
53
- url: feed_hash[ 'link' ] || feed_hash[ 'site' ] || feed_hash[ 'url' ],
54
- title: feed_hash[ 'title' ] || feed_hash[ 'name' ] || feed_hash[ 'author' ]
60
+ url: feed_hash[ 'link' ] || feed_hash[ 'url' ],
61
+ title: feed_hash[ 'title' ] || feed_hash[ 'name' ],
62
+ title2: feed_hash[ 'title2' ]
55
63
  }
56
64
 
57
65
  puts "Updating feed subscription >#{feed_key}< - >#{feed_attribs[:feed_url]}<..."
@@ -68,9 +76,10 @@ class Subscriber
68
76
  end
69
77
 
70
78
  feed_rec.update_attributes!( feed_attribs )
71
-
72
- ## todo:
73
- # add subscription records (feed,site) - how?
79
+
80
+ # add subscription record
81
+ # note: subscriptions get cleaned out on update first (see above)
82
+ site_rec.subscriptions.create!( feed_id: feed_rec.id )
74
83
  end
75
84
 
76
85
  end # method update_subscriptions
@@ -68,7 +68,7 @@ module TemplateHelper
68
68
  # rails style asset tag helpers and friends
69
69
 
70
70
  def stylesheet_link_tag( href )
71
- href = "#{href}.css" unless href.ends_with( '.css' ) # auto-add .css if not present
71
+ href = "#{href}.css" unless href.ends_with?( '.css' ) # auto-add .css if not present
72
72
  "<link rel='stylesheet' type='text/css' href='#{href}'>"
73
73
  end
74
74
 
data/lib/pluto/version.rb CHANGED
@@ -1,5 +1,4 @@
1
1
 
2
2
  module Pluto
3
- VERSION = '0.8.4'
3
+ VERSION = '0.8.5'
4
4
  end
5
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pluto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.4
4
+ version: 0.8.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-01 00:00:00.000000000 Z
12
+ date: 2013-10-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pakman
16
- requirement: &74627180 !ruby/object:Gem::Requirement
16
+ requirement: &80642240 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0.5'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *74627180
24
+ version_requirements: *80642240
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: fetcher
27
- requirement: &74626900 !ruby/object:Gem::Requirement
27
+ requirement: &80642000 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0.3'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *74626900
35
+ version_requirements: *80642000
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: logutils
38
- requirement: &74626660 !ruby/object:Gem::Requirement
38
+ requirement: &80641710 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0.6'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *74626660
46
+ version_requirements: *80641710
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: feedutils
49
- requirement: &74626360 !ruby/object:Gem::Requirement
49
+ requirement: &80641470 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 0.3.2
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *74626360
57
+ version_requirements: *80641470
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: props
60
- requirement: &74626110 !ruby/object:Gem::Requirement
60
+ requirement: &80641170 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.0.2
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *74626110
68
+ version_requirements: *80641170
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: textutils
71
- requirement: &74625810 !ruby/object:Gem::Requirement
71
+ requirement: &80640910 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 0.6.8
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *74625810
79
+ version_requirements: *80640910
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: gli
82
- requirement: &74625560 !ruby/object:Gem::Requirement
82
+ requirement: &80640610 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 2.5.6
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *74625560
90
+ version_requirements: *80640610
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rdoc
93
- requirement: &74641630 !ruby/object:Gem::Requirement
93
+ requirement: &80640330 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '3.10'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *74641630
101
+ version_requirements: *80640330
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: hoe
104
- requirement: &74641390 !ruby/object:Gem::Requirement
104
+ requirement: &80640060 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ~>
@@ -109,7 +109,7 @@ dependencies:
109
109
  version: '3.3'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *74641390
112
+ version_requirements: *80640060
113
113
  description: pluto - Another Planet Generator (Lets You Build Web Pages from Published
114
114
  Web Feeds)
115
115
  email: feedreader@googlegroups.com