bcms_news 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.markdown +34 -0
- data/app/models/news_article.rb +3 -3
- data/app/portlets/news_archive_portlet.rb +3 -0
- data/app/portlets/news_article_portlet.rb +3 -0
- data/app/portlets/recent_news_portlet.rb +3 -0
- data/app/views/cms/news_articles/render.html.erb +1 -1
- data/app/views/portlets/news_archive/_form.html.erb +1 -1
- data/app/views/portlets/news_archive/render.html.erb +1 -1
- data/app/views/portlets/news_article/_form.html.erb +1 -1
- data/app/views/portlets/recent_news/_form.html.erb +1 -1
- data/app/views/portlets/recent_news/render.html.erb +1 -1
- data/db/migrate/20090410193313_create_news_articles.rb +1 -1
- data/lib/bcms_news/engine.rb +7 -0
- data/lib/bcms_news/routes.rb +8 -10
- data/lib/bcms_news.rb +3 -1
- data/lib/generators/bcms_news/install/USAGE +10 -0
- data/lib/generators/bcms_news/install/install_generator.rb +8 -0
- data/test/integration/news_articles_test.rb +12 -0
- data/test/performance/browsing_test.rb +2 -2
- data/test/test_helper.rb +2 -27
- data/test/unit/news_article_test.rb +1 -1
- data/test/unit/recent_news_portlet_test.rb +1 -1
- metadata +70 -16
- data/README +0 -4
- data/rails/init.rb +0 -3
- data/test/functional/news_articles_controller_test.rb +0 -13
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
|
+
|
data/app/models/news_article.rb
CHANGED
@@ -8,10 +8,10 @@ class NewsArticle < ActiveRecord::Base
|
|
8
8
|
|
9
9
|
before_validation :set_slug
|
10
10
|
|
11
|
-
|
11
|
+
scope :released, :conditions =>
|
12
12
|
["news_articles.published = ? and news_articles.release_date <= ?", true, Time.now]
|
13
13
|
|
14
|
-
|
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
|
-
|
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,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.
|
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.
|
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.
|
7
|
+
<%= f.cms_template_editor :template %>
|
@@ -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",
|
data/lib/bcms_news/routes.rb
CHANGED
@@ -1,13 +1,11 @@
|
|
1
|
-
module Cms
|
2
|
-
|
1
|
+
module Cms
|
2
|
+
module Routes
|
3
|
+
def routes_for_bcms_news
|
3
4
|
|
4
|
-
|
5
|
-
:
|
6
|
-
|
7
|
-
|
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,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 <
|
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(
|
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
|
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
|
-
|
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:
|
13
|
-
|
14
|
-
|
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
|
-
-
|
88
|
+
- lib/generators/bcms_news/install/USAGE
|
89
|
+
- lib/generators/bcms_news/install/install_generator.rb
|
45
90
|
- LICENSE.txt
|
46
|
-
- README
|
47
|
-
|
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
|
-
|
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.
|
123
|
+
rubygems_version: 1.7.2
|
70
124
|
signing_key:
|
71
|
-
specification_version:
|
125
|
+
specification_version: 3
|
72
126
|
summary: The News Module for BrowserCMS
|
73
127
|
test_files:
|
74
|
-
- test/
|
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
data/rails/init.rb
DELETED
@@ -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
|