public
Description: This contains various plugins for Feather
Clone URL: git://github.com/eldiablo/feather-plugins.git
Search Repo:
Click here to lend your support to: feather-plugins and make a donation at www.pledgie.com !
added feed settings, allowing the user to specify the amount of articles 
in the RSS feed (and the amount of comments in the comment RSS feed, if 
the comments plugin is also present and active), and also allows the user 
to specify an external feed for the html links (such as for FeedBurner 
feeds)
eldiablo (author)
Fri Apr 11 17:09:22 -0700 2008
commit  7854b3d7a0d1dbe70962dd784177303d817f1f31
tree    fd06e5ab58a825950e12fe53150f2dc5f4596cd1
parent  55a3157915dd2bb13e25cc0b5c61db7e16984792
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
0
@@ -1 +1,25 @@
0
+module Admin
0
+ class FeedSettings < Base
0
+ include_plugin_views __FILE__
0
+
0
+ def show
0
+ @feed_setting = FeedSetting.current
0
+ display @feed_setting
0
+ end
0
+
0
+ def edit
0
+ @feed_setting = FeedSetting.current
0
+ display @feed_setting
0
+ end
0
+
0
+ def update(feed_setting)
0
+ @feed_setting = FeedSetting.current
0
+ if @feed_setting.update_attributes(feed_setting)
0
+ redirect url(:admin_feed_settings, @feed_setting)
0
+ else
0
+ render :edit
0
+ end
0
+ end
0
+ end
0
+end
...
1
2
3
 
4
5
6
...
26
27
28
29
 
30
31
32
...
1
2
 
3
4
5
6
...
26
27
28
 
29
30
31
32
0
@@ -1,6 +1,6 @@
0
 class Feeds < Application
0
   def articles
0
- @articles = Article.all(:published => true, :limit => 15, :order => "published_at DESC")
0
+ @articles = Article.all(:published => true, :limit => FeedSetting.current.article_count, :order => "published_at DESC")
0
     rss = ""
0
     xml = Builder::XmlMarkup.new(:target => rss)
0
     xml.instruct!
0
@@ -26,7 +26,7 @@
0
   end
0
   
0
   def comments
0
- @comments = (defined?(Comment) && is_plugin_active("feather-comments")) ? Comment.all(:limit => 15, :order => "created_at DESC") : []
0
+ @comments = (defined?(Comment) && is_plugin_active("feather-comments")) ? Comment.all(:limit => FeedSetting.current.comment_count, :order => "created_at DESC") : []
0
     rss = ""
0
     xml = Builder::XmlMarkup.new(:target => rss)
0
     xml.instruct!
...
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
0
@@ -1 +1,9 @@
0
+module Merb
0
+ module GlobalHelpers
0
+ def feed_url
0
+ feed_settings = FeedSetting.current
0
+ (feed_settings.external_feed_url.nil? || feed_settings.external_feed_url == "") ? "http://#{request.env['HTTP_HOST']}/articles.rss" : feed_settings.external_feed_url
0
+ end
0
+ end
0
+end
...
1
2
3
 
 
 
4
5
6
7
8
 
 
 
9
10
11
12
13
 
 
 
 
14
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
0
@@ -1,15 +1,25 @@
0
 gem "builder"
0
 require "builder"
0
 require File.join(File.join(File.dirname(__FILE__), "controllers"), "feeds")
0
+require File.join(File.join(File.dirname(__FILE__), "controllers"), "feed_settings")
0
+require File.join(File.join(File.dirname(__FILE__), "helpers"), "global_helpers")
0
+require File.join(File.join(File.dirname(__FILE__), "models"), "feed_setting")
0
 
0
 Merb::Router.prepend do |r|
0
   r.match("/articles.rss").to(:controller => "Feeds", :action => "articles")
0
   r.match("/rss").to(:controller => "Feeds", :action => "articles")
0
   r.match("/comments.rss").to(:controller => "Feeds", :action => "comments")
0
+ r.namespace :admin do |admin|
0
+ admin.resource :feed_settings
0
+ end
0
 end
0
 
0
 Hooks::View.register_view do
0
   [{ :name => "head", :partial => "feed_link" },
0
   { :name => "sidebar", :partial => "feed_link" }]
0
+end
0
+
0
+Hooks::Menu.add_menu_item do
0
+ {:text => "Feed Settings", :url => "/admin/feed_settings" }
0
 end
...
 
...
1
0
@@ -1 +1,2 @@
0
+Database::migrate(FeedSetting)
...
7
8
9
 
10
11
12
 
 
 
 
 
 
 
13
14
 
 
 
 
 
 
15
16
17
...
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
0
@@ -7,11 +7,25 @@
0
     contents:
0
         .:
0
             - init.rb
0
+ - install.rb
0
         controllers:
0
             .:
0
                 - feeds.rb
0
+ - feed_settings.rb
0
+ helpers:
0
+ .:
0
+ - global_helpers.rb
0
+ models:
0
+ .:
0
+ - feed_setting.rb
0
         views:
0
             .:
0
+ admin:
0
+ .:
0
+ feed_settings:
0
+ .:
0
+ - edit.html.erb
0
+ - show.html.erb
0
                 head:
0
                     .:
0
                         - _feed_link.html.erb
...
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
0
@@ -1 +1,14 @@
0
+class FeedSetting < DataMapper::Base
0
+ property :article_count, :integer
0
+ property :comment_count, :integer
0
+ property :external_feed_url, :string, :length => 255
0
+
0
+ ##
0
+ # This returns the current settings, creating them if they aren't found
0
+ def self.current
0
+ feed_settings = FeedSetting.first
0
+ feed_settings = FeedSetting.create(:article_count => 15, :comment_count => 15, :external_feed_url => nil) if feed_settings.nil?
0
+ feed_settings
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
0
@@ -1 +1,29 @@
0
+<% throw_content :right do %>
0
+ <h4>Feed Settings</h4>
0
+ Update the feed settings for this blog.
0
+<% end %>
0
+
0
+<%= error_messages_for @feed_setting %>
0
+<h1>Edit feed settings</h1>
0
+
0
+<% form_for :feed_setting, :action => url(:admin_feed_settings, @feed_setting), :method => :put do %>
0
+ <p>
0
+ <span class="mock_label">Article Count</span>
0
+ <%= text_control :article_count, :value => @feed_setting.article_count %>
0
+ </p>
0
+
0
+ <% if defined?(Comment) && is_plugin_active("feather-comments") %>
0
+ <p>
0
+ <span class="mock_label">Comment Count</span>
0
+ <%= text_control :comment_count, :value => @feed_setting.comment_count %>
0
+ </p>
0
+ <% end %>
0
+
0
+ <p>
0
+ <span class="mock_label">External Feed Url</span>
0
+ <%= text_control :external_feed_url, :value => @feed_setting.external_feed_url %>
0
+ </p>
0
+
0
+ <%= submit_button 'Save Settings' %> or <%= link_to 'Cancel', url(:admin_feed_settings) %>
0
+<% end %>
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
0
@@ -1 +1,28 @@
0
+<% throw_content :right do %>
0
+ <h4>View Feed Settings</h4>
0
+ <p>
0
+ Here you can view feed settings.
0
+ </p>
0
+<% end %>
0
+
0
+<h1>View Feed Settings</h1>
0
+
0
+<p>
0
+ Article count within feed:
0
+ <%= @feed_setting.article_count %>
0
+</p>
0
+
0
+<% if defined?(Comment) && is_plugin_active("feather-comments") %>
0
+<p>
0
+ Comment count within feed:
0
+ <%= @feed_setting.comment_count %>
0
+</p>
0
+<% end %>
0
+
0
+<p>
0
+ External Feed Url:
0
+ <%= (@feed_setting.external_feed_url.nil? || @feed_setting.external_feed_url == "") ? "Not set" : @feed_setting.external_feed_url %>
0
+</p>
0
+
0
+<%= link_to "Edit feed settings", url(:edit_admin_feed_settings, @feed_setting) %>
...
1
 
...
 
1
0
@@ -1,2 +1,2 @@
0
-<link rel="alternate" type="application/rss+xml" title="<%= Configuration.first.title %>" href="http://<%= request.env['HTTP_HOST'] %>/articles.rss" />
0
+<link rel="alternate" type="application/rss+xml" title="<%= Configuration.first.title %>" href="<%= feed_url %>"/>
...
1
2
3
4
 
5
6
7
...
1
2
3
 
4
5
6
7
0
@@ -1,7 +1,7 @@
0
 <div id="feed-link">
0
   <h3>Syndicate</h3>
0
   <!-- <= image_tag 'feed_icon.png' > -->
0
- <a href="http://<%= request.env['HTTP_HOST'] %>/articles.rss">Articles</a>
0
+ <a href="http://<%= feed_url %>">Articles</a>
0
   <br />
0
   <% if defined?(Comment) && is_plugin_active("feather-comments") %>
0
     <a href="http://<%= request.env['HTTP_HOST'] %>/comments.rss">Comments</a>
...
1
2
 
3
4
5
...
1
 
2
3
4
5
0
@@ -1,5 +1,5 @@
0
 module Admin
0
- class PingLogs < Base
0
+ class PingLogs < Base
0
     include_plugin_views __FILE__
0
 
0
     def index
...
1
2
 
3
4
5
...
1
 
2
3
4
5
0
@@ -1,5 +1,5 @@
0
 module Admin
0
- class PingServices < Base
0
+ class PingServices < Base
0
     include_plugin_views __FILE__
0
 
0
     before :find_ping_service, :only => %w(edit update delete show)

Comments

    No one has commented yet.