Skip to content
Browse files

[#2] Fix 'content_for' in portlets

* Remove auto_discovery_tag link from portlets.
* Add installation instructions for portlets.
* Split seed data into separate file so it will be run for new projects.
* Update installation instructions to remember to hide pages.
  • Loading branch information...
1 parent 5b4334b commit 41ae2a6e03dd9427efc4ad0bf822276cb57520d7 @peakpg peakpg committed Jan 13, 2012
View
1 .rvmrc
@@ -0,0 +1 @@
+rvm --create 1.9.2@rails3.0
View
15 README.markdown
@@ -26,9 +26,20 @@ The News Module defines a new content type, "News Article" which comes with the
## Installation
+### 1. Install Module
+
The news module uses the standard BrowserCMS module instructions as detailed here: http://guides.browsercms.org/installing_modules.html
-### After Installation
+### 2. Configure RSS Feeds
+
+To have autodiscovery links to the News RSS feed, add the following to your project page templates in the <head> element.
+
+```
+<%= auto_discovery_link_tag( :rss, news_articles_url, {:title => "RSS Feed for News Articles"}) %>
+```
+
+### 3. Publish Pages
-The news module will create several pages under a 'News' section in the root of the Sitemap. Contributors will need to publish these pages via the sitemap in order for them to display in the menus.
+The news module will create several pages under a 'News' section in the root of the Sitemap. You will need to publish these pages via the sitemap in order for them to display in the menus.
+You will also likely want to mark the 'Article' page as hidden from menus.
View
1 app/views/layouts/templates/default.html.erb
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title><%= page_title %></title>
<%= yield :html_head %>
+ <%= auto_discovery_link_tag( :rss, news_articles_url, {:title => "RSS Feed for News Articles"}) %>
</head>
<body style="margin: 0; padding: 0; text-align: center;">
<%= cms_toolbar %>
View
3 app/views/portlets/news_archive/render.html.erb
@@ -1,6 +1,3 @@
-<% content_for :html_head do %>
- <%= auto_discovery_link_tag( :rss, news_articles_url, {:title => "RSS Feed for News Articles"}) %>
-<% end %>
<div>
<% @articles.group_by(&:year).sort_by(&:first).reverse.each do |year, year_articles| %>
<!-- <%= year %> -->
View
3 app/views/portlets/recent_news/render.html.erb
@@ -1,6 +1,3 @@
-<% content_for :html_head do %>
- <%= auto_discovery_link_tag( :rss, news_articles_url, {:title => "RSS Feed for News Articles" }) %>
-<% end %>
<b>Latest News</b>
<br/>
<br/>
View
51 db/bcms_news.seeds.rb
@@ -0,0 +1,51 @@
+# Create the content type, category type and section for news
+ContentType.create!(:name => "NewsArticle", :group_name => "News")
+CategoryType.create!(:name => "News Article")
+news = Section.create!(:name => "News",
+ :path => "/news",
+ :parent => Section.root.first,
+ :group_ids => Group.all.map(&:id))
+
+# Create the page to display the recent news
+overview = Page.create!(:name => "Overview",
+ :path => "/news/articles",
+ :section => news,
+ :template_file_name => "default.html.erb")
+RecentNewsPortlet.create!(:name => "Recent News Portlet",
+ :limit => 5,
+ :more_link => "/news/archive",
+ :template => RecentNewsPortlet.default_template,
+ :connect_to_page_id => overview.id,
+ :connect_to_container => "main")
+
+
+# Create the page to display the news archives
+archives = Page.create!(:name => "Archive",
+ :path => "/news/archive",
+ :section => news,
+ :template_file_name => "default.html.erb")
+NewsArchivePortlet.create!(:name => "News Archive Portlet",
+ :template => NewsArchivePortlet.default_template,
+ :connect_to_page_id => archives.id,
+ :connect_to_container => "main")
+
+# Create the page to display a given news article
+article = Page.create!(:name => "Article",
+ :path => "/news/article",
+ :section => news,
+ :template_file_name => "default.html.erb")
+NewsArticlePortlet.create!(:name => "News Article Portlet",
+ :template => NewsArticlePortlet.default_template,
+ :connect_to_page_id => article.id,
+ :connect_to_container => "main")
+
+# Create Page Route to article page
+route = article.page_routes.build(
+ :name => "News Article",
+ :pattern => "/news/articles/:year/:month/:day/:slug",
+ :code => "@news_article = NewsArticle.released_on(params).with_slug(params[:slug]).first")
+route.add_condition(:method, "get")
+route.add_requirement(:year, '\d{4,}')
+route.add_requirement(:month, '\d{2,}')
+route.add_requirement(:day, '\d{2,}')
+route.save!
View
52 db/migrate/20090410193313_create_news_articles.rb
@@ -10,58 +10,6 @@ def self.up
t.text :summary
t.text :body, :size => (64.kilobytes + 1)
end
-
- # Create the content type, category type and section for news
- ContentType.create!(:name => "NewsArticle", :group_name => "News")
- CategoryType.create!(:name => "News Article")
- news = Section.create!(:name => "News",
- :path => "/news",
- :parent => Section.root.first,
- :group_ids => Group.all.map(&:id))
-
- # Create the page to display the recent news
- overview = Page.create!(:name => "Overview",
- :path => "/news/articles",
- :section => news,
- :template_file_name => "default.html.erb")
- RecentNewsPortlet.create!(:name => "Recent News Portlet",
- :limit => 5,
- :more_link => "/news/archive",
- :template => RecentNewsPortlet.default_template,
- :connect_to_page_id => overview.id,
- :connect_to_container => "main")
-
-
- # Create the page to display the news archives
- archives = Page.create!(:name => "Archive",
- :path => "/news/archive",
- :section => news,
- :template_file_name => "default.html.erb")
- NewsArchivePortlet.create!(:name => "News Archive Portlet",
- :template => NewsArchivePortlet.default_template,
- :connect_to_page_id => archives.id,
- :connect_to_container => "main")
-
- # Create the page to display a given news article
- article = Page.create!(:name => "Article",
- :path => "/news/article",
- :section => news,
- :template_file_name => "default.html.erb")
- NewsArticlePortlet.create!(:name => "News Article Portlet",
- :template => NewsArticlePortlet.default_template,
- :connect_to_page_id => article.id,
- :connect_to_container => "main")
-
- # Create Page Route to article page
- route = article.page_routes.build(
- :name => "News Article",
- :pattern => "/news/articles/:year/:month/:day/:slug",
- :code => "@news_article = NewsArticle.released_on(params).with_slug(params[:slug]).first")
- route.add_condition(:method, "get")
- route.add_requirement(:year, '\d{4,}')
- route.add_requirement(:month, '\d{2,}')
- route.add_requirement(:day, '\d{2,}')
- route.save!
end
def self.down
View
2 db/seeds.rb
@@ -56,3 +56,5 @@
puts "* YOUR CMS username/password is: cmsadmin/#{pwd}"
puts "*************************************************"
+load File.expand_path('../bcms_news.seeds.rb', __FILE__)
+

0 comments on commit 41ae2a6

Please sign in to comment.
Something went wrong with that request. Please try again.