Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[#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...
commit 41ae2a6e03dd9427efc4ad0bf822276cb57520d7 1 parent 5b4334b
peakpg peakpg authored
1  .rvmrc
... ... @@ -0,0 +1 @@
  1 +rvm --create 1.9.2@rails3.0
15 README.markdown
Source Rendered
@@ -26,9 +26,20 @@ The News Module defines a new content type, "News Article" which comes with the
26 26
27 27 ## Installation
28 28
  29 +### 1. Install Module
  30 +
29 31 The news module uses the standard BrowserCMS module instructions as detailed here: http://guides.browsercms.org/installing_modules.html
30 32
31   -### After Installation
  33 +### 2. Configure RSS Feeds
  34 +
  35 +To have autodiscovery links to the News RSS feed, add the following to your project page templates in the <head> element.
  36 +
  37 +```
  38 +<%= auto_discovery_link_tag( :rss, news_articles_url, {:title => "RSS Feed for News Articles"}) %>
  39 +```
  40 +
  41 +### 3. Publish Pages
32 42
33   -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.
  43 +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.
34 44
  45 +You will also likely want to mark the 'Article' page as hidden from menus.
1  app/views/layouts/templates/default.html.erb
@@ -4,6 +4,7 @@
4 4 <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
5 5 <title><%= page_title %></title>
6 6 <%= yield :html_head %>
  7 + <%= auto_discovery_link_tag( :rss, news_articles_url, {:title => "RSS Feed for News Articles"}) %>
7 8 </head>
8 9 <body style="margin: 0; padding: 0; text-align: center;">
9 10 <%= cms_toolbar %>
3  app/views/portlets/news_archive/render.html.erb
... ... @@ -1,6 +1,3 @@
1   -<% content_for :html_head do %>
2   - <%= auto_discovery_link_tag( :rss, news_articles_url, {:title => "RSS Feed for News Articles"}) %>
3   -<% end %>
4 1 <div>
5 2 <% @articles.group_by(&:year).sort_by(&:first).reverse.each do |year, year_articles| %>
6 3 <!-- <%= year %> -->
3  app/views/portlets/recent_news/render.html.erb
... ... @@ -1,6 +1,3 @@
1   -<% content_for :html_head do %>
2   - <%= auto_discovery_link_tag( :rss, news_articles_url, {:title => "RSS Feed for News Articles" }) %>
3   -<% end %>
4 1 <b>Latest News</b>
5 2 <br/>
6 3 <br/>
51 db/bcms_news.seeds.rb
... ... @@ -0,0 +1,51 @@
  1 +# Create the content type, category type and section for news
  2 +ContentType.create!(:name => "NewsArticle", :group_name => "News")
  3 +CategoryType.create!(:name => "News Article")
  4 +news = Section.create!(:name => "News",
  5 + :path => "/news",
  6 + :parent => Section.root.first,
  7 + :group_ids => Group.all.map(&:id))
  8 +
  9 +# Create the page to display the recent news
  10 +overview = Page.create!(:name => "Overview",
  11 + :path => "/news/articles",
  12 + :section => news,
  13 + :template_file_name => "default.html.erb")
  14 +RecentNewsPortlet.create!(:name => "Recent News Portlet",
  15 + :limit => 5,
  16 + :more_link => "/news/archive",
  17 + :template => RecentNewsPortlet.default_template,
  18 + :connect_to_page_id => overview.id,
  19 + :connect_to_container => "main")
  20 +
  21 +
  22 +# Create the page to display the news archives
  23 +archives = Page.create!(:name => "Archive",
  24 + :path => "/news/archive",
  25 + :section => news,
  26 + :template_file_name => "default.html.erb")
  27 +NewsArchivePortlet.create!(:name => "News Archive Portlet",
  28 + :template => NewsArchivePortlet.default_template,
  29 + :connect_to_page_id => archives.id,
  30 + :connect_to_container => "main")
  31 +
  32 +# Create the page to display a given news article
  33 +article = Page.create!(:name => "Article",
  34 + :path => "/news/article",
  35 + :section => news,
  36 + :template_file_name => "default.html.erb")
  37 +NewsArticlePortlet.create!(:name => "News Article Portlet",
  38 + :template => NewsArticlePortlet.default_template,
  39 + :connect_to_page_id => article.id,
  40 + :connect_to_container => "main")
  41 +
  42 +# Create Page Route to article page
  43 +route = article.page_routes.build(
  44 + :name => "News Article",
  45 + :pattern => "/news/articles/:year/:month/:day/:slug",
  46 + :code => "@news_article = NewsArticle.released_on(params).with_slug(params[:slug]).first")
  47 +route.add_condition(:method, "get")
  48 +route.add_requirement(:year, '\d{4,}')
  49 +route.add_requirement(:month, '\d{2,}')
  50 +route.add_requirement(:day, '\d{2,}')
  51 +route.save!
52 db/migrate/20090410193313_create_news_articles.rb
@@ -10,58 +10,6 @@ def self.up
10 10 t.text :summary
11 11 t.text :body, :size => (64.kilobytes + 1)
12 12 end
13   -
14   - # Create the content type, category type and section for news
15   - ContentType.create!(:name => "NewsArticle", :group_name => "News")
16   - CategoryType.create!(:name => "News Article")
17   - news = Section.create!(:name => "News",
18   - :path => "/news",
19   - :parent => Section.root.first,
20   - :group_ids => Group.all.map(&:id))
21   -
22   - # Create the page to display the recent news
23   - overview = Page.create!(:name => "Overview",
24   - :path => "/news/articles",
25   - :section => news,
26   - :template_file_name => "default.html.erb")
27   - RecentNewsPortlet.create!(:name => "Recent News Portlet",
28   - :limit => 5,
29   - :more_link => "/news/archive",
30   - :template => RecentNewsPortlet.default_template,
31   - :connect_to_page_id => overview.id,
32   - :connect_to_container => "main")
33   -
34   -
35   - # Create the page to display the news archives
36   - archives = Page.create!(:name => "Archive",
37   - :path => "/news/archive",
38   - :section => news,
39   - :template_file_name => "default.html.erb")
40   - NewsArchivePortlet.create!(:name => "News Archive Portlet",
41   - :template => NewsArchivePortlet.default_template,
42   - :connect_to_page_id => archives.id,
43   - :connect_to_container => "main")
44   -
45   - # Create the page to display a given news article
46   - article = Page.create!(:name => "Article",
47   - :path => "/news/article",
48   - :section => news,
49   - :template_file_name => "default.html.erb")
50   - NewsArticlePortlet.create!(:name => "News Article Portlet",
51   - :template => NewsArticlePortlet.default_template,
52   - :connect_to_page_id => article.id,
53   - :connect_to_container => "main")
54   -
55   - # Create Page Route to article page
56   - route = article.page_routes.build(
57   - :name => "News Article",
58   - :pattern => "/news/articles/:year/:month/:day/:slug",
59   - :code => "@news_article = NewsArticle.released_on(params).with_slug(params[:slug]).first")
60   - route.add_condition(:method, "get")
61   - route.add_requirement(:year, '\d{4,}')
62   - route.add_requirement(:month, '\d{2,}')
63   - route.add_requirement(:day, '\d{2,}')
64   - route.save!
65 13 end
66 14
67 15 def self.down
2  db/seeds.rb
@@ -56,3 +56,5 @@
56 56 puts "* YOUR CMS username/password is: cmsadmin/#{pwd}"
57 57 puts "*************************************************"
58 58
  59 +load File.expand_path('../bcms_news.seeds.rb', __FILE__)
  60 +

0 comments on commit 41ae2a6

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