bcms_news 1.0.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown ADDED
@@ -0,0 +1,34 @@
1
+ # News Module for BrowserCMS
2
+
3
+ A module to create and display News Items or Press Releases content.
4
+
5
+ ## Features
6
+
7
+ * *News Articles* - Contributors can create News Articles with attributes like release date, title, summary, body and an attachment.
8
+ * *Friendly URLs* - Each news article will have its own unique path created automatically based on its name. Published article can be accessed via these paths.
9
+ * *RSS - Visitors* can subscribe to an RSS feed that displays the most recent 15 News Articles.
10
+ * *Recent News* - Contributors can show the most recent few articles (via a Portlet) on any page. The exact # of articles shown can be configured.
11
+ * *Archive* - Visitors can browse all past articles. By default, the portlet will display articles in reverse chronological order, grouped by month.
12
+ * *Categorized* - Uses the core Category module to allow each News Article to marked for a particular Category. Both the _Recent News_ and _Archive_ can be configured to show articles only in a particular category.
13
+ * *Configurable Views* - Each portlet's view can be edited via the CMS UI to be tweaked for any site design.
14
+ * *News Section* - A top level 'News' section will be created along with several pages designed to handle the above features will be created.
15
+
16
+ ## News Articles
17
+ The News Module defines a new content type, "News Article" which comes with the following fields.
18
+
19
+ * Name (Textfield)
20
+ * Release Date (Date Picker)
21
+ * Category (Select one)
22
+ * Summary (Textarea) - Appears in summarized lists (like 'Recent News')
23
+ * Body (HTML Editor) - Appears when individual news articles are viewed.
24
+ * File (File Upload) - Allows files attachments like PDF attachments to be added
25
+ * Tags (Free Form Tagging) - Allows multiple free form tags to be applied to any article.
26
+
27
+ ## Installation
28
+
29
+ The news module uses the standard BrowserCMS module instructions as detailed here: http://guides.browsercms.org/installing_modules.html
30
+
31
+ ### After Installation
32
+
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.
34
+
@@ -8,10 +8,10 @@ class NewsArticle < ActiveRecord::Base
8
8
 
9
9
  before_validation :set_slug
10
10
 
11
- named_scope :released, :conditions =>
11
+ scope :released, :conditions =>
12
12
  ["news_articles.published = ? and news_articles.release_date <= ?", true, Time.now]
13
13
 
14
- named_scope :released_on, lambda {|date|
14
+ scope :released_on, lambda {|date|
15
15
  d = if date.kind_of?(Hash)
16
16
  Date.new(date[:year].to_i, date[:month].to_i, date[:day].to_i)
17
17
  else
@@ -25,7 +25,7 @@ class NewsArticle < ActiveRecord::Base
25
25
  ]}
26
26
  }
27
27
 
28
- named_scope :with_slug, lambda{|slug| {:conditions => ["news_articles.slug = ?",slug]}}
28
+ scope :with_slug, lambda{|slug| {:conditions => ["news_articles.slug = ?",slug]}}
29
29
 
30
30
  def category_name
31
31
  category ? category.name : nil
@@ -1,5 +1,8 @@
1
1
  class NewsArchivePortlet < Portlet
2
2
 
3
+ # Mark this as 'true' to allow the portlet's template to be editable via the CMS admin UI.
4
+ enable_template_editor false
5
+
3
6
  def render
4
7
  if self.category_id.blank?
5
8
  @articles = NewsArticle.all(:order => "release_date desc", :limit => self.limit)
@@ -1,4 +1,7 @@
1
1
  class NewsArticlePortlet < Portlet
2
+
3
+ # Mark this as 'true' to allow the portlet's template to be editable via the CMS admin UI.
4
+ enable_template_editor false
2
5
 
3
6
  def render
4
7
  # @news_article should already be set by the page route
@@ -1,4 +1,7 @@
1
1
  class RecentNewsPortlet < Portlet
2
+
3
+ # Mark this as 'true' to allow the portlet's template to be editable via the CMS admin UI.
4
+ enable_template_editor false
2
5
 
3
6
  def render
4
7
  order = "release_date DESC"
@@ -1,2 +1,2 @@
1
1
  <h2><%=h @content_block.name %></h2>
2
- <p><%= @content_block.body %></p>
2
+ <p><%= @content_block.body.html_safe %></p>
@@ -1,3 +1,3 @@
1
1
  <%= f.cms_text_field :name %>
2
2
  <%= f.cms_drop_down :category_id, categories_for('News Article').map{|c| [c.path, c.id]}, { :selected=>f.object.category_id.to_i, :include_blank=>"Show News Articles in any Category", :instructions=>"Select a category to show News Articles from only that category." } %>
3
- <%= f.cms_text_area :template, :default_value => @block.class.default_template %>
3
+ <%= f.cms_template_editor :template %>
@@ -1,5 +1,5 @@
1
1
  <% content_for :html_head do %>
2
- <%= auto_discovery_link_tag :rss, news_articles_url, "RSS Feed for News Articles" %>
2
+ <%= auto_discovery_link_tag( :rss, news_articles_url, {:title => "RSS Feed for News Articles"}) %>
3
3
  <% end %>
4
4
  <div>
5
5
  <% @articles.group_by(&:year).sort_by(&:first).reverse.each do |year, year_articles| %>
@@ -1,2 +1,2 @@
1
1
  <%= f.cms_text_field :name %>
2
- <%= f.cms_text_area :template, :default_value => @block.class.default_template %>
2
+ <%= f.cms_template_editor :template %>
@@ -4,4 +4,4 @@
4
4
  <%= f.cms_drop_down :sort_order, %w(asc desc).collect { |field| ["#{field.titleize}ending", field.upcase] } %>
5
5
  <%= f.cms_drop_down :category_id, categories_for('News Article').map{|c| [c.path, c.id]}, {:selected=>f.object.category_id.to_i, :include_blank=>"Show News Articles in any Category", :instructions=>"Select a category to show News Articles from only that category." } %>
6
6
  <%= f.cms_text_field :more_link %>
7
- <%= f.cms_text_area :template, :default_value => @block.class.default_template %>
7
+ <%= f.cms_template_editor :template %>
@@ -1,5 +1,5 @@
1
1
  <% content_for :html_head do %>
2
- <%= auto_discovery_link_tag :rss, news_articles_url, "RSS Feed for News Articles" %>
2
+ <%= auto_discovery_link_tag( :rss, news_articles_url, {:title => "RSS Feed for News Articles" }) %>
3
3
  <% end %>
4
4
  <b>Latest News</b>
5
5
  <br/>
@@ -17,7 +17,7 @@ class CreateNewsArticles < ActiveRecord::Migration
17
17
  news = Section.create!(:name => "News",
18
18
  :path => "/news",
19
19
  :parent => Section.root.first,
20
- :group_ids => Group.all(&:id))
20
+ :group_ids => Group.all.map(&:id))
21
21
 
22
22
  # Create the page to display the recent news
23
23
  overview = Page.create!(:name => "Overview",
@@ -0,0 +1,7 @@
1
+ require 'browsercms'
2
+
3
+ module BcmsNews
4
+ class Engine < Rails::Engine
5
+ include Cms::Module
6
+ end
7
+ end
@@ -1,13 +1,11 @@
1
- module Cms::Routes
2
- def routes_for_bcms_news
1
+ module Cms
2
+ module Routes
3
+ def routes_for_bcms_news
3
4
 
4
- news_articles '/news/articles.rss',
5
- :controller => "news_articles",
6
- :conditions => {:method => :get},
7
- :format => "rss"
8
-
9
- namespace(:cms) do |cms|
10
- cms.content_blocks :news_articles
11
- end
5
+ match '/news/articles.rss', :to=>"news_articles#index", :as=>'news_articles', :method=>:get, :defaults => { :format => 'rss' }
6
+ namespace(:cms) do
7
+ content_blocks :news_articles
8
+ end
9
+ end
12
10
  end
13
11
  end
data/lib/bcms_news.rb CHANGED
@@ -1 +1,3 @@
1
- require 'bcms_news/routes'
1
+ require 'bcms_news/routes'
2
+ require 'bcms_news/engine'
3
+
@@ -0,0 +1,10 @@
1
+ Description:
2
+ Installs the bcms_news module.
3
+
4
+ Example:
5
+ rails generate bcms_news:install
6
+
7
+ This will:
8
+ Copy the migrations from the gem into the project.
9
+ Add the routes to the config/routes.rb
10
+
@@ -0,0 +1,8 @@
1
+ require 'cms/module_installation'
2
+
3
+ class BcmsNews::InstallGenerator < Cms::ModuleInstallation
4
+ add_migrations_directory_to_source_root __FILE__
5
+
6
+ copy_migration_file '20090410193313_create_news_articles.rb'
7
+
8
+ end
@@ -0,0 +1,12 @@
1
+ require 'test_helper'
2
+ class NewsArticlesTest < ActionController::IntegrationTest
3
+
4
+ test "login and browse site" do
5
+ get "/news/articles.rss"
6
+
7
+ assert_response :success
8
+ assert_select "rss"
9
+ end
10
+
11
+
12
+ end
@@ -1,8 +1,8 @@
1
1
  require 'test_helper'
2
- require 'performance_test_help'
2
+ require 'rails/performance_test_help'
3
3
 
4
4
  # Profiling results for each test method are written to tmp/performance.
5
- class BrowsingTest < ActionController::PerformanceTest
5
+ class BrowsingTest < ActionDispatch::PerformanceTest
6
6
  def test_homepage
7
7
  get '/'
8
8
  end
data/test/test_helper.rb CHANGED
@@ -1,33 +1,8 @@
1
1
  ENV["RAILS_ENV"] = "test"
2
- require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
3
- require 'test_help'
2
+ require File.expand_path('../../config/environment', __FILE__)
3
+ require 'rails/test_help'
4
4
 
5
5
  class ActiveSupport::TestCase
6
- # Transactional fixtures accelerate your tests by wrapping each test method
7
- # in a transaction that's rolled back on completion. This ensures that the
8
- # test database remains unchanged so your fixtures don't have to be reloaded
9
- # between every test method. Fewer database queries means faster tests.
10
- #
11
- # Read Mike Clark's excellent walkthrough at
12
- # http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
13
- #
14
- # Every Active Record database supports transactions except MyISAM tables
15
- # in MySQL. Turn off transactional fixtures in this case; however, if you
16
- # don't care one way or the other, switching from MyISAM to InnoDB tables
17
- # is recommended.
18
- #
19
- # The only drawback to using transactional fixtures is when you actually
20
- # need to test transactions. Since your test is bracketed by a transaction,
21
- # any transactions started in your code will be automatically rolled back.
22
- self.use_transactional_fixtures = true
23
-
24
- # Instantiated fixtures are slow, but give you @david where otherwise you
25
- # would need people(:david). If you don't want to migrate your existing
26
- # test cases which use the @david style and don't mind the speed hit (each
27
- # instantiated fixtures translates to a database query per test method),
28
- # then set this back to true.
29
- self.use_instantiated_fixtures = false
30
-
31
6
  # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
32
7
  #
33
8
  # Note: You'll currently still have to declare fixtures explicitly in integration tests
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), '/../test_helper')
1
+ require 'test_helper'
2
2
 
3
3
  class NewsArticleTest < ActiveSupport::TestCase
4
4
 
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), '/../test_helper')
1
+ require 'test_helper'
2
2
 
3
3
  class RecentNewsArticleTest < ActiveSupport::TestCase
4
4
 
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bcms_news
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ prerelease:
5
+ version: 1.2.0
5
6
  platform: ruby
6
7
  authors:
7
8
  - BrowserMedia
@@ -9,10 +10,52 @@ autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
12
 
12
- date: 2009-07-02 00:00:00 -04:00
13
- default_executable:
14
- dependencies: []
15
-
13
+ date: 2011-05-23 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rails
17
+ requirement: &id001 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - "="
21
+ - !ruby/object:Gem::Version
22
+ version: 3.0.3
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: browsercms
28
+ requirement: &id002 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - "="
32
+ - !ruby/object:Gem::Version
33
+ version: 3.3.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
38
+ name: mysql
39
+ requirement: &id003 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: "0"
45
+ type: :development
46
+ prerelease: false
47
+ version_requirements: *id003
48
+ - !ruby/object:Gem::Dependency
49
+ name: jeweler
50
+ requirement: &id004 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: "0"
56
+ type: :development
57
+ prerelease: false
58
+ version_requirements: *id004
16
59
  description: The News Module for BrowserCMS
17
60
  email: github@browsermedia.com
18
61
  executables: []
@@ -21,7 +64,7 @@ extensions: []
21
64
 
22
65
  extra_rdoc_files:
23
66
  - LICENSE.txt
24
- - README
67
+ - README.markdown
25
68
  files:
26
69
  - app/controllers/cms/news_articles_controller.rb
27
70
  - app/controllers/news_articles_controller.rb
@@ -40,38 +83,49 @@ files:
40
83
  - app/views/portlets/recent_news/render.html.erb
41
84
  - db/migrate/20090410193313_create_news_articles.rb
42
85
  - lib/bcms_news.rb
86
+ - lib/bcms_news/engine.rb
43
87
  - lib/bcms_news/routes.rb
44
- - rails/init.rb
88
+ - lib/generators/bcms_news/install/USAGE
89
+ - lib/generators/bcms_news/install/install_generator.rb
45
90
  - LICENSE.txt
46
- - README
47
- has_rdoc: true
91
+ - README.markdown
92
+ - test/integration/news_articles_test.rb
93
+ - test/performance/browsing_test.rb
94
+ - test/test_helper.rb
95
+ - test/unit/news_article_test.rb
96
+ - test/unit/recent_news_portlet_test.rb
48
97
  homepage: http://browsercms.org
98
+ licenses: []
99
+
49
100
  post_install_message:
50
- rdoc_options:
51
- - --charset=UTF-8
101
+ rdoc_options: []
102
+
52
103
  require_paths:
53
104
  - lib
54
105
  required_ruby_version: !ruby/object:Gem::Requirement
106
+ none: false
55
107
  requirements:
56
108
  - - ">="
57
109
  - !ruby/object:Gem::Version
110
+ hash: 546851667
111
+ segments:
112
+ - 0
58
113
  version: "0"
59
- version:
60
114
  required_rubygems_version: !ruby/object:Gem::Requirement
115
+ none: false
61
116
  requirements:
62
117
  - - ">="
63
118
  - !ruby/object:Gem::Version
64
119
  version: "0"
65
- version:
66
120
  requirements: []
67
121
 
68
122
  rubyforge_project: browsercms
69
- rubygems_version: 1.3.1
123
+ rubygems_version: 1.7.2
70
124
  signing_key:
71
- specification_version: 2
125
+ specification_version: 3
72
126
  summary: The News Module for BrowserCMS
73
127
  test_files:
74
- - test/functional/news_articles_controller_test.rb
128
+ - test/integration/news_articles_test.rb
75
129
  - test/performance/browsing_test.rb
76
130
  - test/test_helper.rb
77
131
  - test/unit/news_article_test.rb
data/README DELETED
@@ -1,4 +0,0 @@
1
- BrowserCMS News Module
2
- ======================
3
-
4
- This is the BrowserCMS News Module. This includes...
data/rails/init.rb DELETED
@@ -1,3 +0,0 @@
1
- gem_root = File.expand_path(File.join(File.dirname(__FILE__), ".."))
2
- Cms.add_to_rails_paths gem_root
3
- Cms.add_generator_paths gem_root, "db/migrate/[0-9]*_*.rb"
@@ -1,13 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '/../test_helper')
2
-
3
- class NewsArticlesControllerTest < ActionController::TestCase
4
-
5
- test "User can call RSS Feed" do
6
- get :index, {:format => "rss"}
7
- assert :success
8
- assert_select "rss"
9
-
10
- end
11
-
12
-
13
- end