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 comment feeds to feeds plugin, with checks to ensure it only shows 
up if the comments plugin is installed, available and active; also changed 
the import plugin to do the same checks before showing the comment import 
textbox
eldiablo (author)
Tue Apr 08 15:09:24 -0700 2008
commit  6b1c7ab9250b5de387edfcdccbb1db5a853290f3
tree    1537c7ad78a8e1127c831e7fd62ca6b0ce8ffd10
parent  f3d0c61d8a30358513f68611f2e2652dbe0534e4
...
1
2
 
3
4
5
...
18
19
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
22
23
...
1
 
2
3
4
5
...
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
0
@@ -1,5 +1,5 @@
0
 class Feeds < Application
0
- def rss
0
+ def articles
0
     @articles = Article.all(:published => true, :limit => 15, :order => "published_at DESC")
0
     rss = ""
0
     xml = Builder::XmlMarkup.new(:target => rss)
0
@@ -18,6 +18,35 @@
0
             xml.pubDate rfc822(article.published_at)
0
             xml.guid "http://#{request.env['HTTP_HOST']}#{article.permalink}"
0
             xml.author article.user.login
0
+ end
0
+ end
0
+ end
0
+ end
0
+ rss
0
+ end
0
+
0
+ def comments
0
+ @comments = (defined?(Comment) && is_plugin_active("feather-comments")) ? Comment.all(:limit => 15, :order => "created_at DESC") : []
0
+ rss = ""
0
+ xml = Builder::XmlMarkup.new(:target => rss)
0
+ xml.instruct!
0
+ xml.rss "version" => "2.0" do
0
+ xml.channel do
0
+ xml.title "#{Configuration.first.title}: comments"
0
+ xml.link "http://#{request.env['HTTP_HOST']}#{request.uri}"
0
+ xml.pubDate rfc822(@comments.first.created_at) if @comments.length > 0
0
+ xml.description Configuration.first.tag_line
0
+ @comments.each do |comment|
0
+ article = Article[comment.article_id]
0
+ if article
0
+ xml.item do
0
+ xml.title "Re: #{article.title}"
0
+ xml.link "http://#{request.env['HTTP_HOST']}#{article.permalink}##{comment.id}"
0
+ xml.description RedCloth.new(comment.comment).to_html
0
+ xml.pubDate rfc822(comment.created_at)
0
+ xml.guid "http://#{request.env['HTTP_HOST']}#{article.permalink}##{comment.id}"
0
+ xml.author comment.name
0
+ end
0
           end
0
         end
0
       end
...
1
2
3
4
5
 
 
 
 
6
7
8
9
 
10
11
12
...
15
16
17
18
 
...
1
2
3
 
 
4
5
6
7
8
9
10
 
11
12
13
14
...
17
18
19
 
20
0
@@ -1,12 +1,14 @@
0
 require File.join(File.join(File.dirname(__FILE__), "controllers"), "feeds")
0
 require "builder"
0
 
0
-Hooks::Routing.add_route do
0
- {:url => "/rss", :controller => "Feeds", :action => "rss" }
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
 end
0
 
0
 Hooks::Menu.add_menu_item do
0
- {:text => "Feed", :url => "/rss" }
0
+ {:text => "Feed", :url => "articles.rss" }
0
 end
0
 
0
 Hooks::View.register_view do
0
@@ -15,5 +17,5 @@
0
 
0
 Hooks::View.register_view do
0
   { :name => "sidebar", :partial => "feed_link" }
0
-end
0
+end
...
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'] %>/rss" />
0
+<link rel="alternate" type="application/rss+xml" title="<%= Configuration.first.title %>" href="http://<%= request.env['HTTP_HOST'] %>/articles.rss" />
...
1
2
3
4
 
 
 
 
 
 
5
...
1
2
3
 
4
5
6
7
8
9
10
0
@@ -1,6 +1,11 @@
0
 <div id="feed-link">
0
   <h3>Syndicate</h3>
0
   <!-- <= image_tag 'feed_icon.png' > -->
0
- <a href="http://<%= request.env['HTTP_HOST'] %>/rss">Articles</a>
0
+ <a href="http://<%= request.env['HTTP_HOST'] %>/articles.rss">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>
0
+  <br />
0
+ <% end %>
0
 </div>
...
10
11
12
13
 
14
15
16
...
10
11
12
 
13
14
15
16
0
@@ -10,7 +10,7 @@
0
       # Process the article feed if specified
0
       @articles = process_articles(params[:articles_url]) if params[:articles_url] && params[:articles_url] != ""
0
       # Process the comment feed if specified
0
- @comments = process_comments(params[:comments_url]) if params[:comments_url] && params[:comments_url] != ""
0
+ @comments = process_comments(params[:comments_url]) if params[:comments_url] && params[:comments_url] != "" && (defined?(Comment) && is_plugin_active("feather-comments"))
0
       # Render the results
0
       render
0
     end
...
2
3
4
5
 
6
7
8
...
2
3
4
 
5
6
7
8
0
@@ -2,7 +2,7 @@
0
 
0
 <% form_tag(:action => url(:admin_importer)) do %>
0
   <%= text_field :name => "articles_url", :label => "Articles Feed" %><br />
0
-  <% if defined?(Comment) %>
0
+  <% if defined?(Comment) && is_plugin_active("feather-comments") %>
0
     <%= text_field :name => "comments_url", :label => "Comments Feed" %><br />
0
   <% end %>
0
   <%= submit_button "Import" %>

Comments

    No one has commented yet.