Permalink
Browse files

Adding feedburner support

  • Loading branch information...
1 parent bc9a9f1 commit 58fc900d97faa0c3e3d692c0e0e17f1ec97f1128 @fdv fdv committed Mar 1, 2009
Showing with 22 additions and 3 deletions.
  1. +16 −3 app/controllers/articles_controller.rb
  2. +1 −0 app/models/blog.rb
  3. +5 −0 app/views/admin/settings/read.html.erb
@@ -34,11 +34,10 @@ def index
respond_to do |format|
format.html { render_paginated_index }
format.atom do
- render :partial => 'articles/atom_feed', :object => @articles
+ send_feed('atom')
end
format.rss do
- auto_discovery_feed(:only_path => false)
- render :partial => 'articles/rss20_feed', :object => @articles
+ send_feed('rss20')
end
end
end
@@ -107,6 +106,14 @@ def verify_config
end
end
+ def send_feed(format)
+ if this_blog.feedburner_url.empty? or request.env["HTTP_USER_AGENT"][/Feedburner/]
+ render :partial => "articles/#{format}_feed", :object => @articles
+ else
+ redirect_to "http://feeds2.feedburner.com/#{this_blog.feedburner_url}"
+ end
+ end
+
alias_method :rescue_action_in_public, :error
def render_error(object = '', status = 500)
@@ -119,6 +126,12 @@ def set_headers
def render_paginated_index(on_empty = _("No posts found..."))
return error(on_empty, :status => 200) if @articles.empty?
+ if this_blog.feedburner_url.empty?
+ auto_discovery_feed(:only_path => false)
+ else
+ @auto_discovery_url_rss = "http://feeds2.feedburner.com/#{this_blog.feedburner_url}"
+ @auto_discovery_url_atom = "http://feeds2.feedburner.com/#{this_blog.feedburner_url}"
+ end
render :action => 'index'
end
View
@@ -76,6 +76,7 @@ class Blog < CachedModel
setting :meta_description, :string, ''
setting :meta_keywords, :string, ''
setting :google_analytics, :string, ''
+ setting :feedburner_url, :string, ''
setting :rss_description, :boolean, false
setting :permalink_format, :string, '/%year%/%month%/%day%/%title%'
setting :robots, :string, ''
@@ -20,6 +20,11 @@
<input name="setting[show_extended_on_rss]" id="show_extended_on_rss" type="checkbox" value="1" <%= 'checked="checked"' if this_blog.show_extended_on_rss%> />
<input name="setting[show_extended_on_rss]" type="hidden" value="0" />
</li>
+ <li>
+ <label class="float" for="feedburner_url"><%= _("Feedburner ID")%>:</label>
+ <input name="setting[feedburner_url]" id="feedburner_url" type="text" value="<%=h this_blog.feedburner_url %>" class="medium" />
+ <span class="float">You can use your Google Feedburner account instead of Typo feed URL. To enable this, fill this form with your Feedburner ID.</span>
+ </li>
</ul>
</fieldset>
<%= hidden_field_tag 'from', 'read' %>

0 comments on commit 58fc900

Please sign in to comment.