fullstack-rss 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.
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'rails'
4
+
5
+ group :development do
6
+ gem "bundler"
7
+ gem "jeweler", "~> 1.8.4"
8
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,94 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ actionmailer (3.2.11)
5
+ actionpack (= 3.2.11)
6
+ mail (~> 2.4.4)
7
+ actionpack (3.2.11)
8
+ activemodel (= 3.2.11)
9
+ activesupport (= 3.2.11)
10
+ builder (~> 3.0.0)
11
+ erubis (~> 2.7.0)
12
+ journey (~> 1.0.4)
13
+ rack (~> 1.4.0)
14
+ rack-cache (~> 1.2)
15
+ rack-test (~> 0.6.1)
16
+ sprockets (~> 2.2.1)
17
+ activemodel (3.2.11)
18
+ activesupport (= 3.2.11)
19
+ builder (~> 3.0.0)
20
+ activerecord (3.2.11)
21
+ activemodel (= 3.2.11)
22
+ activesupport (= 3.2.11)
23
+ arel (~> 3.0.2)
24
+ tzinfo (~> 0.3.29)
25
+ activeresource (3.2.11)
26
+ activemodel (= 3.2.11)
27
+ activesupport (= 3.2.11)
28
+ activesupport (3.2.11)
29
+ i18n (~> 0.6)
30
+ multi_json (~> 1.0)
31
+ arel (3.0.2)
32
+ builder (3.0.4)
33
+ erubis (2.7.0)
34
+ git (1.2.5)
35
+ hike (1.2.1)
36
+ i18n (0.6.1)
37
+ jeweler (1.8.4)
38
+ bundler (~> 1.0)
39
+ git (>= 1.2.5)
40
+ rake
41
+ rdoc
42
+ journey (1.0.4)
43
+ json (1.7.6)
44
+ mail (2.4.4)
45
+ i18n (>= 0.4.0)
46
+ mime-types (~> 1.16)
47
+ treetop (~> 1.4.8)
48
+ mime-types (1.19)
49
+ multi_json (1.5.0)
50
+ polyglot (0.3.3)
51
+ rack (1.4.3)
52
+ rack-cache (1.2)
53
+ rack (>= 0.4)
54
+ rack-ssl (1.3.2)
55
+ rack
56
+ rack-test (0.6.2)
57
+ rack (>= 1.0)
58
+ rails (3.2.11)
59
+ actionmailer (= 3.2.11)
60
+ actionpack (= 3.2.11)
61
+ activerecord (= 3.2.11)
62
+ activeresource (= 3.2.11)
63
+ activesupport (= 3.2.11)
64
+ bundler (~> 1.0)
65
+ railties (= 3.2.11)
66
+ railties (3.2.11)
67
+ actionpack (= 3.2.11)
68
+ activesupport (= 3.2.11)
69
+ rack-ssl (~> 1.3.2)
70
+ rake (>= 0.8.7)
71
+ rdoc (~> 3.4)
72
+ thor (>= 0.14.6, < 2.0)
73
+ rake (10.0.3)
74
+ rdoc (3.12)
75
+ json (~> 1.4)
76
+ sprockets (2.2.2)
77
+ hike (~> 1.2)
78
+ multi_json (~> 1.0)
79
+ rack (~> 1.0)
80
+ tilt (~> 1.1, != 1.3.0)
81
+ thor (0.16.0)
82
+ tilt (1.3.3)
83
+ treetop (1.4.12)
84
+ polyglot
85
+ polyglot (>= 0.3.1)
86
+ tzinfo (0.3.35)
87
+
88
+ PLATFORMS
89
+ ruby
90
+
91
+ DEPENDENCIES
92
+ bundler
93
+ jeweler (~> 1.8.4)
94
+ rails
data/README.md ADDED
@@ -0,0 +1,105 @@
1
+ # Fullstack-rss
2
+
3
+ RSS Feed Gem for fullstack-cms
4
+
5
+ ## Installation
6
+
7
+ ``` rb
8
+ gem 'fullstack-rss'
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ First of all any item shoud respond at least to `:title`, `:link`, `:pubdate`, `:category` and `:description`, `:guid` and `:guid_is_permalink?`.
14
+
15
+ The simplest way to achieve that is use a decorator:
16
+
17
+ ``` rb
18
+ class PostRssItem < Fullstack::Rss::Item
19
+
20
+ # ============
21
+ # = Required =
22
+ # ============
23
+
24
+ def title
25
+ cdata(object.title)
26
+ end
27
+
28
+ def link
29
+ site_post_url(object)
30
+ end
31
+
32
+ def pubdate
33
+ object.created_at.xmlschema
34
+ end
35
+
36
+ def category
37
+ cdata(object.category.title) # cdata helper is provided by Fullstack::Rss::ItemDecorator
38
+ end
39
+
40
+ def description
41
+ cdata(object.intro.html_safe)
42
+ end
43
+
44
+ # ============
45
+ # = Optional =
46
+ # ============
47
+
48
+ def guid
49
+ link # this is the default
50
+ end
51
+
52
+ def guid_is_permalink?
53
+ false # this is also the default
54
+ end
55
+
56
+ end
57
+ ```
58
+
59
+ Then you can build a feed like that
60
+
61
+ ``` rb
62
+ class Site::SiteController < Site::BaseController
63
+
64
+ include Fullstack::Rss::Helpers
65
+
66
+ # ...
67
+
68
+ action :feed, :path => "/feed", :format => "xml"
69
+ @items = Post.all.map { |post| PostRssItem.new(post) }
70
+ render_feed @items
71
+ end
72
+
73
+ end
74
+ ```
75
+
76
+ And link it in your views with `rss_feed_link`
77
+
78
+ ``` rhtml
79
+ <%= rss_feed_link site_feed_url %>
80
+ ```
81
+
82
+ ---
83
+
84
+ Copyright (c) 2012 mcasimir
85
+
86
+ MIT License
87
+
88
+ Permission is hereby granted, free of charge, to any person obtaining
89
+ a copy of this software and associated documentation files (the
90
+ "Software"), to deal in the Software without restriction, including
91
+ without limitation the rights to use, copy, modify, merge, publish,
92
+ distribute, sublicense, and/or sell copies of the Software, and to
93
+ permit persons to whom the Software is furnished to do so, subject to
94
+ the following conditions:
95
+
96
+ The above copyright notice and this permission notice shall be
97
+ included in all copies or substantial portions of the Software.
98
+
99
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
100
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
101
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
102
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
103
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
104
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
105
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "fullstack-rss"
18
+ gem.homepage = "http://github.com/mcasimir/kaminari-bootstrap"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{RSS Feed Gem for fullstack-cms}
21
+ gem.description = %Q{RSS Feed Gem for fullstack-cms}
22
+ gem.email = "maurizio.cas@gmail.com"
23
+ gem.authors = ["mcasimir"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+
29
+ task :push do
30
+ message = ENV["message"] || "commit #{Time.now}"
31
+ `git add . && git commit -a -m '#{message}' && git push`
32
+ end
33
+
34
+ task "release:patch" do
35
+ Rake::Task["gemspec"].invoke
36
+ Rake::Task["version:bump:patch"]
37
+ Rake::Task["push"].invoke
38
+ Rake::Task["release"].invoke
39
+ end
40
+
41
+ task "release:minor" do
42
+ Rake::Task["gemspec"].invoke
43
+ Rake::Task["version:bump:minor"]
44
+ Rake::Task["push"].invoke
45
+ Rake::Task["release"].invoke
46
+ end
47
+
48
+ task "release:major" do
49
+ Rake::Task["gemspec"].invoke
50
+ Rake::Task["version:bump:major"]
51
+ Rake::Task["push"].invoke
52
+ Rake::Task["release"].invoke
53
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.1
@@ -0,0 +1,25 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <rss version="2.0"
3
+ xmlns:atom="http://www.w3.org/2005/Atom">
4
+
5
+ <channel>
6
+ <title><%= options[:title] %></title>
7
+ <atom:link href="<%= request.url %>" rel="self" type="application/rss+xml" />
8
+ <link><%= options[:link] %></link>
9
+ <description><%= options[:description] %></description>
10
+ <lastBuildDate><%= Time.now.xmlschema %></lastBuildDate>
11
+ <language><%= options[:language] || I18n.default_locale.to_s %></language>
12
+
13
+ <% items.each do |item| %>
14
+ <item>
15
+ <title><%= item.title %></title>
16
+ <link><%= item.link %></link>
17
+ <pubDate><%= item.pubdate %></pubDate>
18
+ <category><%= item.category %></category>
19
+ <guid isPermaLink="<%= item.guid_is_permalink? %>"><%= item.guid %></guid>
20
+ <description><%= item.description %></description>
21
+ </item>
22
+ <% end -%>
23
+
24
+ </channel>
25
+ </rss>
@@ -0,0 +1,56 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "fullstack-rss"
8
+ s.version = "0.1.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["mcasimir"]
12
+ s.date = "2013-01-09"
13
+ s.description = "RSS Feed Gem for fullstack-cms"
14
+ s.email = "maurizio.cas@gmail.com"
15
+ s.extra_rdoc_files = [
16
+ "README.md"
17
+ ]
18
+ s.files = [
19
+ "Gemfile",
20
+ "Gemfile.lock",
21
+ "README.md",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "app/views/fullstack/rss/feed.xml.erb",
25
+ "fullstack-rss.gemspec",
26
+ "lib/fullstack-rss.rb",
27
+ "lib/fullstack/rss.rb",
28
+ "lib/fullstack/rss/engine.rb",
29
+ "lib/fullstack/rss/helpers.rb",
30
+ "lib/fullstack/rss/item.rb"
31
+ ]
32
+ s.homepage = "http://github.com/mcasimir/kaminari-bootstrap"
33
+ s.licenses = ["MIT"]
34
+ s.require_paths = ["lib"]
35
+ s.rubygems_version = "1.8.24"
36
+ s.summary = "RSS Feed Gem for fullstack-cms"
37
+
38
+ if s.respond_to? :specification_version then
39
+ s.specification_version = 3
40
+
41
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
42
+ s.add_runtime_dependency(%q<rails>, [">= 0"])
43
+ s.add_development_dependency(%q<bundler>, [">= 0"])
44
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
45
+ else
46
+ s.add_dependency(%q<rails>, [">= 0"])
47
+ s.add_dependency(%q<bundler>, [">= 0"])
48
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
49
+ end
50
+ else
51
+ s.add_dependency(%q<rails>, [">= 0"])
52
+ s.add_dependency(%q<bundler>, [">= 0"])
53
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
54
+ end
55
+ end
56
+
@@ -0,0 +1,9 @@
1
+ require 'rails'
2
+
3
+ module Fullstack
4
+ module Rss
5
+ class Engine < ::Rails::Engine
6
+
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,41 @@
1
+ module Fullstack
2
+ module Rss
3
+ module Helpers
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ helper_method :rss_feed_link
8
+ end
9
+
10
+ # eg.
11
+ # render_feed( @items,
12
+ # title: @feed_title,
13
+ # link: root_url,
14
+ # description: "This is a great feed.",
15
+ # language: "en"
16
+ # )
17
+
18
+ def render_feed(items, options = {})
19
+ render :template => "fullstack/rss/feed.xml.erb", :locals => { :items => items, :options => options }
20
+ end
21
+
22
+ protected
23
+
24
+ # This is just a little helper to link feeds.
25
+ #
26
+ # usage:
27
+ # <%= rss_feed_link site_feed_path, :title => "Intresting stuffs from my blog" %>
28
+ #
29
+
30
+ def rss_feed_link(url, options = {})
31
+ title = options.delete(:title)
32
+ raise ":title option is required" if !title
33
+ title = view_context.h(title)
34
+
35
+ "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"#{title}\" href=\"#{url}\" />"
36
+ end
37
+
38
+
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,68 @@
1
+ # Any item shoud respond at least to :title, :link, :pubdate, :category, :guid, :description, :guid_is_permalink.
2
+ #
3
+ # The simplest way to achieve that is use a decorator:
4
+ #
5
+ # class PostRssItem < Fullstack::Rss::Item
6
+ #
7
+ # # ============
8
+ # # = Required =
9
+ # # ============
10
+ #
11
+ # delegate :title, :to => :object
12
+ #
13
+ # def link
14
+ # site_post_url(object)
15
+ # end
16
+ #
17
+ # def pubdate
18
+ # object.created_at.xmlschema
19
+ # end
20
+ #
21
+ # def category
22
+ # cdata(object.category.title) # cdata helper is provided by Fullstack::Rss::ItemDecorator
23
+ # end
24
+ #
25
+ # def description
26
+ # cdata(object.intro.html_safe)
27
+ # end
28
+ #
29
+ # # ============
30
+ # # = Optional =
31
+ # # ============
32
+ #
33
+ # def guid
34
+ # link # this is the default
35
+ # end
36
+ #
37
+ # def guid_is_permalink?
38
+ # false # this is also the default
39
+ # end
40
+ #
41
+ # end
42
+
43
+ module Fullstack
44
+ module Rss
45
+ class Item
46
+
47
+ attr_accessor :object
48
+ def initialize(object)
49
+ @object = object
50
+ end
51
+
52
+ def guid
53
+ link
54
+ end
55
+
56
+ def guid_is_permalink?
57
+ false
58
+ end
59
+
60
+ protected
61
+
62
+ def cdata(text)
63
+ "<![#{text}]]>".html_safe
64
+ end
65
+
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,92 @@
1
+ # Author:: Maurizio Casimirri (mailto:maurizio.cas@gmail.com)
2
+ # Copyright:: Copyright (c) 2012 Maurizio Casimirri
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+
23
+
24
+ # =========
25
+ # = Usage =
26
+ # =========
27
+ #
28
+ # # site_controller.rb
29
+ #
30
+ # include Fullstack::Rss::Helpers
31
+ #
32
+ # action :feed, :path => "/feed", :format => "xml"
33
+ # @items = Post.all.map { |post| PostRssItem.new(post) }
34
+ # render_feed @items
35
+ # end
36
+ #
37
+ # # _head.html.erb
38
+ #
39
+ # <%= rss_feed_link site_feed_url %>
40
+ #
41
+ # Any item shoud respond at least to :title, :link, :pubdate, :category, :guid, :description, :guid_is_permalink.
42
+ #
43
+ # The simplest way to achieve that is use a decorator:
44
+ #
45
+ # class PostRssItem < Fullstack::Rss::Item
46
+ #
47
+ # # ============
48
+ # # = Required =
49
+ # # ============
50
+ #
51
+ # delegate :title, :to => :object
52
+ #
53
+ # def link
54
+ # site_post_url(object)
55
+ # end
56
+ #
57
+ # def pubdate
58
+ # object.created_at.xmlschema
59
+ # end
60
+ #
61
+ # def category
62
+ # cdata(object.category.title) # cdata helper is provided by Fullstack::Rss::ItemDecorator
63
+ # end
64
+ #
65
+ # def description
66
+ # cdata(object.intro.html_safe)
67
+ # end
68
+ #
69
+ # # ============
70
+ # # = Optional =
71
+ # # ============
72
+ #
73
+ # def guid
74
+ # link # this is the default
75
+ # end
76
+ #
77
+ # def guid_is_permalink?
78
+ # false # this is also the default
79
+ # end
80
+ #
81
+ # end
82
+
83
+
84
+ require 'fullstack/rss/engine'
85
+ require 'fullstack/rss/helpers'
86
+
87
+ module Fullstack
88
+ module Rss
89
+
90
+ end
91
+ end
92
+
@@ -0,0 +1,3 @@
1
+ require 'fullstack-rss/engine'
2
+
3
+ require "fullstack/rss"
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fullstack-rss
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - mcasimir
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: bundler
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: jeweler
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 1.8.4
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.8.4
62
+ description: RSS Feed Gem for fullstack-cms
63
+ email: maurizio.cas@gmail.com
64
+ executables: []
65
+ extensions: []
66
+ extra_rdoc_files:
67
+ - README.md
68
+ files:
69
+ - Gemfile
70
+ - Gemfile.lock
71
+ - README.md
72
+ - Rakefile
73
+ - VERSION
74
+ - app/views/fullstack/rss/feed.xml.erb
75
+ - fullstack-rss.gemspec
76
+ - lib/fullstack-rss.rb
77
+ - lib/fullstack/rss.rb
78
+ - lib/fullstack/rss/engine.rb
79
+ - lib/fullstack/rss/helpers.rb
80
+ - lib/fullstack/rss/item.rb
81
+ homepage: http://github.com/mcasimir/kaminari-bootstrap
82
+ licenses:
83
+ - MIT
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ segments:
95
+ - 0
96
+ hash: 4068807422851151234
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 1.8.24
106
+ signing_key:
107
+ specification_version: 3
108
+ summary: RSS Feed Gem for fullstack-cms
109
+ test_files: []