Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Feeds work

  • Loading branch information...
commit dc928d414ecdaeae3c514da44ec2a531a2d48100 1 parent f49374e
@peakpg peakpg authored
View
2  README.markdown
@@ -105,6 +105,4 @@ Special thanks to some amazing folks from the BrowserCMS community for their wor
## 3.5.x Todo
-* Need to verify RSS Feeds work
-* Verify we can edit/add comments through the admin
* Test and release
View
10 app/controllers/bcms_blog/feeds_controller.rb
@@ -0,0 +1,10 @@
+module BcmsBlog
+ class FeedsController < ApplicationController
+
+ def index
+ @blog = Blog.find(params[:blog_id])
+ @blog_posts = @blog.posts.published.all(:limit => 10, :order => "published_at DESC")
+ end
+
+ end
+end
View
8 app/controllers/feeds_controller.rb
@@ -1,8 +0,0 @@
-class FeedsController < ApplicationController
-
- def index
- @blog = Blog.find(params[:blog_id])
- @blog_posts = @blog.posts.published.all(:limit => 10, :order => "published_at DESC")
- end
-
-end
View
2  app/helpers/bcms_blog/blog_helper.rb
@@ -11,7 +11,7 @@ def _blog_post_path(blog_post)
def feeds_link_tag_for(name)
blog = Blog.find_by_name(name)
- auto_discovery_link_tag(:rss, blog_feeds_url(:blog_id => blog), :title => "#{blog.name}")
+ auto_discovery_link_tag(:rss, main_app.blog_feeds_url(:blog_id => blog), :title => "#{blog.name}")
end
def new_comment_params(portlet)
View
6 app/views/feeds/index.rss.builder → app/views/bcms_blog/feeds/index.rss.builder
@@ -2,7 +2,7 @@ xml.instruct! :xml, :version=>"1.0"
xml.rss(:version=>"2.0") do
xml.channel do
xml.title("#{@blog.name} Posts Feed")
- xml.link(blog_feeds_url(:id => @blog.id, :format => "rss"))
+ xml.link(main_app.blog_feeds_url(:id => @blog.id, :format => "rss"))
xml.description("")
xml.language('en-us')
for post in @blog_posts
@@ -10,8 +10,8 @@ xml.rss(:version=>"2.0") do
xml.title(post.name)
xml.description(post.summary) unless post.summary.blank?
xml.pubDate(post.published_at.strftime("%a, %d %b %Y %H:%M:%S %z")) unless post.published_at.blank?
- xml.link(send("#{@blog.name_for_path}_post_url", post.route_params))
- xml.guid(send("#{@blog.name_for_path}_post_url", post.route_params))
+ xml.link(main_app.send("#{@blog.name_for_path}_post_url", post.route_params))
+ xml.guid(main_app.send("#{@blog.name_for_path}_post_url", post.route_params))
end
end
end
View
11 lib/bcms_blog/engine.rb
@@ -1,4 +1,5 @@
require 'browsercms'
+require 'bcms_blog/route_extensions'
module BcmsBlog
class Engine < Rails::Engine
@@ -9,6 +10,16 @@ class Engine < Rails::Engine
config.to_prepare do
Cms::ViewContext.send(:include, BcmsBlog::BlogHelper)
+ ApplicationHelper.send(:include, BcmsBlog::BlogHelper)
+ end
+
+ initializer 'bcms_blog.route_extensions', :after => 'action_dispatch.prepare_dispatcher' do |app|
+ ActionDispatch::Routing::Mapper.send :include, BcmsBlog::RouteExtensions
+ end
+
+ config.before_configuration do |app|
+ # Used by blog_feed_url to determine the host
+ Rails.application.routes.default_url_options[:host]= config.cms.site_domain
end
end
end
View
8 lib/bcms_blog/route_extensions.rb
@@ -0,0 +1,8 @@
+module BcmsBlog::RouteExtensions
+ def mount_bcms_blog
+ mount BcmsBlog::Engine => "/bcms_blog"
+ match '/blog/feeds', :to=>"bcms_blog/feeds#index", :defaults=>{:format => "rss"}, :as=>'blog_feeds'
+ end
+
+ alias :routes_for_bcms_blog :mount_bcms_blog
+end
View
8 lib/bcms_blog/routes.rb
@@ -1,8 +0,0 @@
-module Cms::Routes
- def mount_bcms_blog
- mount BcmsBlog::Engine => "/bcms_blog"
- match '/blog/feeds', :to=>"feeds#index", :defaults=>{:format => "rss"}, :as=>'blog_feeds'
- end
-
- alias :routes_for_bcms_blog :mount_bcms_blog
-end
View
2  test/dummy/app/views/layouts/templates/default.html.erb
@@ -4,6 +4,8 @@
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title><%= page_title %></title>
<%= yield :html_head %>
+ <%= feeds_link_tag_for "Patricks Blog" %>
+
</head>
<body style="margin: 0; padding: 0; text-align: center;">
<%= cms_toolbar %>
View
2  test/dummy/config/routes.rb
@@ -1,5 +1,5 @@
Rails.application.routes.draw do
- mount BcmsBlog::Engine => "/bcms_blog"
+ mount_bcms_blog
mount_browsercms
end
Please sign in to comment.
Something went wrong with that request. Please try again.