tylerrick-bcms_blog 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +25 -19
- data/app/models/blog.posts_finder.rb +155 -0
- data/app/models/blog.rb +43 -26
- data/app/models/blog_post.rb +12 -0
- data/app/portlets/blog_post_portlet.rb +2 -2
- data/app/portlets/blog_posts_portlet.rb +50 -0
- data/app/views/portlets/blog_post/_form.html.erb +1 -1
- data/app/views/portlets/blog_posts/_form.html.erb +13 -0
- data/app/views/portlets/blog_posts/render.html.haml +9 -0
- data/doc/migrate_to_20100427.rb +9 -0
- metadata +28 -5
data/README.markdown
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Blog Module for BrowserCMS
|
2
2
|
|
3
|
-
A simple blog module that lets you create one or more blogs. It features:
|
3
|
+
A simple blog module that lets you create one or more blogs and integrate them into your site. It features:
|
4
4
|
|
5
5
|
* Blog posts can be tagged and categorized
|
6
6
|
* The ability for users to leave comments on a blog post (stores the user name, email, url and comment)
|
@@ -16,9 +16,9 @@ This assumes you have the latest copy of the code from github on your machine.
|
|
16
16
|
gem build bcms_blog.gemspec
|
17
17
|
sudo gem install bcms_blog-1.x.x.gem
|
18
18
|
|
19
|
-
At this point, the
|
19
|
+
At this point, the BrowserCMS Blog gem should be installed as a gem on your system, and can be added to your projects.
|
20
20
|
|
21
|
-
### B. Adding the
|
21
|
+
### B. Adding the module to your project
|
22
22
|
In your BrowserCMS application, do the following steps.
|
23
23
|
|
24
24
|
#### 1. Edit the confing/environment.rb file
|
@@ -26,12 +26,12 @@ In your BrowserCMS application, do the following steps.
|
|
26
26
|
config.gem 'browsercms'
|
27
27
|
|
28
28
|
# Add this next line after the browsercms gem
|
29
|
-
config.gem "
|
29
|
+
config.gem "bcms_blog"
|
30
30
|
|
31
31
|
#### 2. Edit the routes.rb file
|
32
32
|
|
33
33
|
# Add this route. It must be before the core browser_cms route.
|
34
|
-
map.
|
34
|
+
map.routes_for_bcms_blog
|
35
35
|
map.routes_for_browser_cms
|
36
36
|
|
37
37
|
#### 3. Install the new module code
|
@@ -47,17 +47,23 @@ Modules will often add new data types, like content blocks, so you need to run t
|
|
47
47
|
rake db:migrate
|
48
48
|
script/server
|
49
49
|
|
50
|
-
#### 5. Create a
|
51
|
-
* Open your browser to localhost:3000/cms/
|
52
|
-
* Click 'Add New Content', and
|
53
|
-
*
|
54
|
-
* Now go to
|
55
|
-
*
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
50
|
+
#### 5. Create a Blog content block and embed it into your templates
|
51
|
+
* Open your browser to http://localhost:3000/cms/blogs and log in
|
52
|
+
* Click 'Add New Content', choose a name for your blog (for example, "Blog"), and click Save and Publish
|
53
|
+
* This will automatically create a new page named after the name of your blog and add your blog to it (you can delete this new page and add your Blog block to an existing page if you would rather)
|
54
|
+
* Now go to Blog Post, click 'Add New Content', and fill out the other fields to create your first post for your new blog.
|
55
|
+
* Don't forget that your new blog page won't appear in the menus until you publish the page. If you go to the Dashboard and look under Page Drafts, you will see that you can publish your new page there.
|
56
|
+
* You can navigate to your blog page using your site's main navigation menu (if you have one) or by going to the Sitemap and looking for a page with the name that you selected for your blog.
|
57
|
+
|
58
|
+
## Customization
|
59
|
+
|
60
|
+
### blog_post partial
|
61
|
+
|
62
|
+
* If you want to customize the way your blog posts are displayed, you can override the partial by copying this file from the gem to your application's directory and making changes to it: app/views/partials/_blog_post.html.haml or app/views/partials/_blog_post.html.erb (depending on if you prefer haml or erb)
|
63
|
+
* (You can run `gem which bcms_blog` to figure out where the bcms_blog files are located on your system.)
|
64
|
+
`app/views/partials/_blog_post.html.haml` or `app/views/partials/_blog_post.html.erb` (depending on if you prefer haml or erb templates)
|
65
|
+
* Example:
|
66
|
+
# cp /var/lib/gems/1.9.1/gems/bcms_blog-1.0.5/app/views/partials/_blog_post.html.erb app/views/partials/
|
67
|
+
* Keep in mind that the same partial is used both on the main blog page (which lists all posts) and on the blog post page (that shows a single post)
|
68
|
+
* If you want something to only show up on the blog post page, you can enclose your markup within a `if showing_individual_post`
|
69
|
+
* If you want something to only show up on the main blog page, you can enclose your markup within a `if !showing_individual_post`
|
@@ -0,0 +1,155 @@
|
|
1
|
+
class Blog < ActiveRecord::Base
|
2
|
+
acts_as_content_block
|
3
|
+
has_many :posts, :class_name => "BlogPost", :conditions => { :published => true }, :order => "published_at desc"
|
4
|
+
|
5
|
+
has_many :blog_group_memberships
|
6
|
+
has_many :groups, :through => :blog_group_memberships
|
7
|
+
|
8
|
+
validates_presence_of :name
|
9
|
+
validates_uniqueness_of :name
|
10
|
+
|
11
|
+
named_scope :editable_by, lambda { |user|
|
12
|
+
if user.able_to?(:administrate)
|
13
|
+
{ }
|
14
|
+
else
|
15
|
+
{ :include => :groups, :conditions => ["groups.id IN (?)", user.group_ids.join(",")] }
|
16
|
+
end
|
17
|
+
}
|
18
|
+
|
19
|
+
def self.default_template
|
20
|
+
template_file = ActionController::Base.view_paths.map do |vp|
|
21
|
+
path = vp.to_s.first == "/" ? vp.to_s : File.join(Rails.root, vp.to_s)
|
22
|
+
File.join(path, "cms/blogs/render.html.erb")
|
23
|
+
end.detect{|f| File.exists? f }
|
24
|
+
template_file ? open(template_file){|f| f.read } : ""
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.posts_finder(options)
|
28
|
+
finder = @blog.posts.published
|
29
|
+
|
30
|
+
if params[:category]
|
31
|
+
@category_type = CategoryType.named("Blog Post").first
|
32
|
+
@category = @category_type.categories.named(params[:category]).first
|
33
|
+
finder = finder.in_category(@category)
|
34
|
+
elsif params[:tag]
|
35
|
+
finder = finder.tagged_with(params[:tag])
|
36
|
+
elsif params[:year] && params[:month] && params[:day]
|
37
|
+
@date = Date.new(params[:year].to_i, params[:month].to_i, params[:day].to_i)
|
38
|
+
finder = posts.published_between(@date, @date + 1.day)
|
39
|
+
elsif params[:year] && params[:month]
|
40
|
+
@date = Date.new(params[:year].to_i, params[:month].to_i)
|
41
|
+
finder = posts.published_between(@date, @date + 1.month)
|
42
|
+
elsif params[:year]
|
43
|
+
@date = Date.new(params[:year].to_i)
|
44
|
+
finder = posts.published_between(@date, @date + 1.year)
|
45
|
+
end
|
46
|
+
|
47
|
+
finder
|
48
|
+
end
|
49
|
+
|
50
|
+
def render
|
51
|
+
@blog = self
|
52
|
+
finder = Blog.posts_finder(params)
|
53
|
+
|
54
|
+
@blog_posts = finder.all(:limit => 25, :order => "published_at desc")
|
55
|
+
raise ActiveRecord::RecordNotFound.new("No posts found") if @blog_posts.empty?
|
56
|
+
|
57
|
+
if params[:category]
|
58
|
+
@page_title = "#{params[:category]}"
|
59
|
+
elsif params[:tag]
|
60
|
+
@page_title = "Posts tagged with #{params[:tag]}"
|
61
|
+
elsif params[:year] && params[:month] && params[:day]
|
62
|
+
@page_title = "Posts from #{@date.to_s(:long)}"
|
63
|
+
elsif params[:year] && params[:month]
|
64
|
+
@page_title = "Posts from #{Date::MONTHNAMES[@date.month]} #{@date.year}"
|
65
|
+
elsif params[:year]
|
66
|
+
@page_title = "Posts from #{@date.year}"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def inline_options
|
71
|
+
{:inline => self.template}
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.default_order
|
75
|
+
"name"
|
76
|
+
end
|
77
|
+
|
78
|
+
def editable_by?(user)
|
79
|
+
user.able_to?(:administrate) || !(group_ids & user.group_ids).empty?
|
80
|
+
end
|
81
|
+
|
82
|
+
def potential_authors
|
83
|
+
groups.map(&:users).flatten.uniq
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
#-------------------------------------------------------------------------------------------------
|
88
|
+
|
89
|
+
def name_for_path
|
90
|
+
name.to_slug.gsub('-', '_')
|
91
|
+
end
|
92
|
+
|
93
|
+
protected
|
94
|
+
def after_create
|
95
|
+
section = Section.find_by_name(name) || (
|
96
|
+
section = Section.create!(
|
97
|
+
:name => name,
|
98
|
+
:path => "/#{name_for_path}",
|
99
|
+
:parent_id => 1
|
100
|
+
)
|
101
|
+
section.groups << Group.find_by_code("cms-admin")
|
102
|
+
section.groups << Group.find_by_code("guest")
|
103
|
+
section.groups << Group.find_by_code("content-editor")
|
104
|
+
section.save!
|
105
|
+
section
|
106
|
+
)
|
107
|
+
|
108
|
+
page = Page.find_by_name(name) || Page.create!(
|
109
|
+
:name => name,
|
110
|
+
:path => "/#{name_for_path}",
|
111
|
+
:section => section,
|
112
|
+
:template_file_name => "default.html.erb",
|
113
|
+
:hidden => true
|
114
|
+
)
|
115
|
+
page.create_connector(self, 'main')
|
116
|
+
create_route(page, "#{name}: Posts In Day", "/#{name_for_path}/:year/:month/:day")
|
117
|
+
create_route(page, "#{name}: Posts In Month", "/#{name_for_path}/:year/:month")
|
118
|
+
create_route(page, "#{name}: Posts In Year", "/#{name_for_path}/:year")
|
119
|
+
create_route(page, "#{name}: Posts With Tag", "/#{name_for_path}/tag/:tag")
|
120
|
+
create_route(page, "#{name}: Posts In Category", "/#{name_for_path}/category/:category")
|
121
|
+
|
122
|
+
page = Page.find_by_name(portlet_name = "#{name}: Post") || Page.create!(
|
123
|
+
:name => portlet_name,
|
124
|
+
:path => "/#{name_for_path}/post",
|
125
|
+
:section => section,
|
126
|
+
:template_file_name => "default.html.erb",
|
127
|
+
:hidden => true)
|
128
|
+
page.publish
|
129
|
+
create_route( page, portlet_name, "/#{name_for_path}/:year/:month/:day/:slug")
|
130
|
+
create_portlet(page, portlet_name, BlogPostPortlet)
|
131
|
+
|
132
|
+
# FIXME: This takes about 5 seconds to run, which is probably too long.
|
133
|
+
# Solution: Disable PageRoute's after_save :reload_routes and add this to the end here:
|
134
|
+
# ActionController::Routing::Routes.load!
|
135
|
+
end
|
136
|
+
|
137
|
+
def create_route(page, name, pattern)
|
138
|
+
route = page.page_routes.build(:name => name, :pattern => pattern, :code => "")
|
139
|
+
route.add_condition(:method, "get")
|
140
|
+
route.add_requirement(:year, '\d{4,}') if pattern.include?(":year")
|
141
|
+
route.add_requirement(:month, '\d{2,}') if pattern.include?(":month")
|
142
|
+
route.add_requirement(:day, '\d{2,}') if pattern.include?(":day")
|
143
|
+
route.save!
|
144
|
+
end
|
145
|
+
|
146
|
+
def create_portlet(page, name, portlet_class)
|
147
|
+
portlet_class.create!(
|
148
|
+
:name => "#{name} Portlet",
|
149
|
+
:blog_id => self.id,
|
150
|
+
:template => portlet_class.default_template,
|
151
|
+
:connect_to_page_id => page.id,
|
152
|
+
:connect_to_container => "main",
|
153
|
+
:publish_on_save => true)
|
154
|
+
end
|
155
|
+
end
|
data/app/models/blog.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
class Blog < ActiveRecord::Base
|
2
2
|
acts_as_content_block
|
3
3
|
has_many :posts, :class_name => "BlogPost", :conditions => { :published => true }, :order => "published_at desc"
|
4
|
-
|
4
|
+
|
5
5
|
has_many :blog_group_memberships
|
6
6
|
has_many :groups, :through => :blog_group_memberships
|
7
|
-
|
7
|
+
|
8
8
|
validates_presence_of :name
|
9
9
|
validates_uniqueness_of :name
|
10
|
-
|
10
|
+
|
11
11
|
named_scope :editable_by, lambda { |user|
|
12
12
|
if user.able_to?(:administrate)
|
13
13
|
{ }
|
@@ -15,64 +15,82 @@ class Blog < ActiveRecord::Base
|
|
15
15
|
{ :include => :groups, :conditions => ["groups.id IN (?)", user.group_ids.join(",")] }
|
16
16
|
end
|
17
17
|
}
|
18
|
-
|
18
|
+
|
19
19
|
def self.default_template
|
20
|
-
template_file = ActionController::Base.view_paths.map do |vp|
|
20
|
+
template_file = ActionController::Base.view_paths.map do |vp|
|
21
21
|
path = vp.to_s.first == "/" ? vp.to_s : File.join(Rails.root, vp.to_s)
|
22
22
|
File.join(path, "cms/blogs/render.html.erb")
|
23
23
|
end.detect{|f| File.exists? f }
|
24
24
|
template_file ? open(template_file){|f| f.read } : ""
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
|
+
def self.posts_finder(finder, options)
|
28
|
+
if options[:tags]
|
29
|
+
finder = finder.tagged_with(options[:tags])
|
30
|
+
end
|
31
|
+
if options[:exclude_tags]
|
32
|
+
finder = finder.not_tagged_with(options[:exclude_tags])
|
33
|
+
end
|
34
|
+
if options[:category] || options[:category_id]
|
35
|
+
category_type = CategoryType.named("Blog Post").first
|
36
|
+
category = category_type.categories.named(options[:category]).first if options[:category]
|
37
|
+
category = category_type.categories. find(options[:category_id]) if options[:category_id]
|
38
|
+
finder = finder.in_category(category)
|
39
|
+
end
|
40
|
+
finder
|
41
|
+
end
|
42
|
+
|
27
43
|
def render
|
28
44
|
@blog = self
|
29
45
|
finder = @blog.posts.published
|
46
|
+
finder = Blog.posts_finder(finder, params)
|
30
47
|
|
31
|
-
if params[:
|
32
|
-
@category_type = CategoryType.named("Blog Post").first
|
33
|
-
@category = @category_type.categories.named(params[:category]).first
|
34
|
-
finder = finder.in_category(@category)
|
35
|
-
@page_title = "Posts in category #{params[:category]}"
|
36
|
-
elsif params[:tag]
|
37
|
-
finder = finder.tagged_with(params[:tag])
|
38
|
-
@page_title = "Posts tagged with #{params[:tag]}"
|
39
|
-
elsif params[:year] && params[:month] && params[:day]
|
48
|
+
if params[:year] && params[:month] && params[:day]
|
40
49
|
@date = Date.new(params[:year].to_i, params[:month].to_i, params[:day].to_i)
|
41
50
|
finder = posts.published_between(@date, @date + 1.day)
|
42
|
-
@page_title = "Blog posts from #{@date.to_s(:long)}"
|
43
51
|
elsif params[:year] && params[:month]
|
44
52
|
@date = Date.new(params[:year].to_i, params[:month].to_i)
|
45
53
|
finder = posts.published_between(@date, @date + 1.month)
|
46
|
-
@page_title = "Blog posts from #{Date::MONTHNAMES[@date.month]} #{@date.year}"
|
47
54
|
elsif params[:year]
|
48
55
|
@date = Date.new(params[:year].to_i)
|
49
56
|
finder = posts.published_between(@date, @date + 1.year)
|
50
|
-
@page_title = "Blog posts from #{@date.year}"
|
51
57
|
end
|
52
58
|
|
53
|
-
@blog_posts = finder.all(:limit => 25, :order => "published_at desc")
|
59
|
+
@blog_posts = finder.all(:limit => 25, :order => "published_at desc")
|
54
60
|
raise ActiveRecord::RecordNotFound.new("No posts found") if @blog_posts.empty?
|
61
|
+
|
62
|
+
if params[:category]
|
63
|
+
@page_title = "#{params[:category]}"
|
64
|
+
elsif params[:tag]
|
65
|
+
@page_title = "Posts tagged with #{params[:tag]}"
|
66
|
+
elsif params[:year] && params[:month] && params[:day]
|
67
|
+
@page_title = "Posts from #{@date.to_s(:long)}"
|
68
|
+
elsif params[:year] && params[:month]
|
69
|
+
@page_title = "Posts from #{Date::MONTHNAMES[@date.month]} #{@date.year}"
|
70
|
+
elsif params[:year]
|
71
|
+
@page_title = "Posts from #{@date.year}"
|
72
|
+
end
|
55
73
|
end
|
56
|
-
|
74
|
+
|
57
75
|
def inline_options
|
58
76
|
{:inline => self.template}
|
59
77
|
end
|
60
|
-
|
78
|
+
|
61
79
|
def self.default_order
|
62
80
|
"name"
|
63
81
|
end
|
64
|
-
|
82
|
+
|
65
83
|
def editable_by?(user)
|
66
84
|
user.able_to?(:administrate) || !(group_ids & user.group_ids).empty?
|
67
85
|
end
|
68
|
-
|
86
|
+
|
69
87
|
def potential_authors
|
70
88
|
groups.map(&:users).flatten.uniq
|
71
89
|
end
|
72
|
-
|
90
|
+
|
73
91
|
|
74
92
|
#-------------------------------------------------------------------------------------------------
|
75
|
-
|
93
|
+
|
76
94
|
def name_for_path
|
77
95
|
name.to_slug.gsub('-', '_')
|
78
96
|
end
|
@@ -139,5 +157,4 @@ protected
|
|
139
157
|
:connect_to_container => "main",
|
140
158
|
:publish_on_save => true)
|
141
159
|
end
|
142
|
-
|
143
160
|
end
|
data/app/models/blog_post.rb
CHANGED
@@ -32,6 +32,18 @@ class BlogPost < ActiveRecord::Base
|
|
32
32
|
start, finish ] }
|
33
33
|
}
|
34
34
|
|
35
|
+
named_scope :not_tagged_with, lambda { |tag| {
|
36
|
+
:conditions => [
|
37
|
+
"blog_posts.id not in (
|
38
|
+
SELECT taggings.taggable_id FROM taggings
|
39
|
+
JOIN tags ON tags.id = taggings.tag_id
|
40
|
+
WHERE taggings.taggable_type = 'BlogPost'
|
41
|
+
AND (tags.name = ?)
|
42
|
+
)",
|
43
|
+
tag
|
44
|
+
]
|
45
|
+
} }
|
46
|
+
|
35
47
|
INCORRECT_PARAMETERS = "Incorrect parameters. This is probably because you are trying to view the " +
|
36
48
|
"portlet through the CMS interface, and so we have no way of knowing what " +
|
37
49
|
"post(s) to show"
|
@@ -0,0 +1,50 @@
|
|
1
|
+
class BlogPostsPortlet < Portlet
|
2
|
+
def after_initialize
|
3
|
+
self.render_blog_post_code ||= 'truncate(blog_post.name, 30)'
|
4
|
+
end
|
5
|
+
|
6
|
+
# Mark this as 'true' to allow the portlet's template to be editable via the CMS admin UI.
|
7
|
+
enable_template_editor false
|
8
|
+
|
9
|
+
def render(_options = {})
|
10
|
+
# Since we can't pass any options to render_portlet, you can use $blog_posts_portlet_options if you want to pass in/override some options
|
11
|
+
# This is an ugly workaround for https://browsermedia.lighthouseapp.com/projects/28481-browsercms-30/tickets/350-make-it-possible-to-pass-options-to-render_portletrender_connectable in case we want to call render_portlet with some options
|
12
|
+
_options = $blog_posts_portlet_options || {}
|
13
|
+
_options.symbolize_keys!
|
14
|
+
|
15
|
+
portlet_attributes = self.portlet_attributes.inject({}) {|hash, a| hash[a.name] = a.value; hash}.reject {|k,v| v.blank?}.symbolize_keys
|
16
|
+
|
17
|
+
#options.reverse_merge!(params.slice(:tags)).symbolize_keys!
|
18
|
+
@options = portlet_attributes.merge(_options)
|
19
|
+
Rails.logger.debug "... BlogPostsPortlet#render(options=#{@options.inspect} #{@options.class})"
|
20
|
+
|
21
|
+
if @options[:blog_id]
|
22
|
+
finder = Blog.find(@options[:blog_id]).posts
|
23
|
+
elsif @options[:blog_name]
|
24
|
+
finder = Blog.find_by_name(@options[:blog_name]).posts
|
25
|
+
else
|
26
|
+
finder = BlogPost
|
27
|
+
end
|
28
|
+
|
29
|
+
if @options[:tags].is_a?(Array) && @options[:tags].size > 1
|
30
|
+
other_tags = @options[:tags][1..-1]
|
31
|
+
@options[:tags] = @options[:tags][0]
|
32
|
+
end
|
33
|
+
|
34
|
+
finder = finder.published
|
35
|
+
finder = Blog.posts_finder(finder, @options)
|
36
|
+
|
37
|
+
@blog_posts = finder.all(
|
38
|
+
:limit => @options[:limit] || 25,
|
39
|
+
:order => "published_at desc"
|
40
|
+
)
|
41
|
+
|
42
|
+
if other_tags
|
43
|
+
@blog_posts.select! {|p| (p.tags.map(&:name).map(&:downcase) & other_tags.map(&:downcase)).size == other_tags.size }
|
44
|
+
end
|
45
|
+
|
46
|
+
raise ActiveRecord::RecordNotFound.new("No articles found") if @blog_posts.empty?
|
47
|
+
|
48
|
+
@portlet = self
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<%= f.cms_text_field :name, :label => 'Portlet Name', :instructions => 'Since we may have many Articles portlets, each with different parameters, give each portlet a descriptive name.' %>
|
2
|
+
|
3
|
+
<%= f.cms_drop_down :blog_id, Blog.all.map{|b| [b.name, b.id.to_s]}, :include_blank => true, :label => "Show posts from", :instructions => 'Leave blank to include posts from all blogs' %>
|
4
|
+
<%# f.cms_drop_down :show_posts_as, [['First post as full post, the rest as Summary + Read More link', 'first_full_post_others_summary'], ['Summary + Read More link', 'summary'], ['Full post', 'full_post'], ['Title (links to post)', 'link']] %>
|
5
|
+
<%= f.cms_drop_down :show_posts_as, [['Title (links to post)', 'link'], ['Post', 'post']] %>
|
6
|
+
<%= f.cms_check_box :show_full_posts %>
|
7
|
+
<%= f.cms_drop_down :category_id, categories_for('Blog Post').map{|c| [c.path, c.id]}, :include_blank => true, :label => "Only posts in category" %>
|
8
|
+
<%= f.cms_tag_list :label => "Only posts with tags", :instructions => 'Separate tags with spaces' %>
|
9
|
+
<%= f.cms_text_field :exclude_tags, :label => 'Exclude posts with tags' %>
|
10
|
+
<%= f.cms_text_field :limit, :label => 'Limit' %>
|
11
|
+
<%= f.cms_text_area :render_blog_post_code, :label => 'Code to turn blog_post into link text' %>
|
12
|
+
|
13
|
+
<%= f.cms_template_editor :template %>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
- if @portlet.show_posts_as == 'post'
|
2
|
+
= render :partial => '/partials/blog_post', :collection => @blog_posts, :locals => {:show_full_posts => @options[:show_full_posts]}
|
3
|
+
- elsif @portlet.show_posts_as == 'link'
|
4
|
+
%ul.blog_posts
|
5
|
+
- for blog_post in @blog_posts
|
6
|
+
- text = @portlet.render_blog_post_code.present? ? eval(@portlet.render_blog_post_code) : text = truncate(blog_post.name, 30)
|
7
|
+
%li= link_to text, _blog_post_path(blog_post)
|
8
|
+
- else
|
9
|
+
Unrecognized option '#{@portlet.show_posts_as}' for @portlet.show_posts_as
|
data/doc/migrate_to_20100427.rb
CHANGED
@@ -34,6 +34,14 @@ class PageRoute
|
|
34
34
|
has_many :conditions, :class_name => "PageRouteCondition", :dependent => :destroy
|
35
35
|
end
|
36
36
|
|
37
|
+
# Added these here because these classes will be removed by the next commit, so if anyone tried to run this script in future versions it would have a missing constant error unless we keep these class definitions around
|
38
|
+
class BlogPostsInCategoryPortlet < Portlet; end
|
39
|
+
class BlogPostsWithTagPortlet < Portlet; end
|
40
|
+
class BlogPostPortlet < Portlet; end
|
41
|
+
class BlogPostsInDayPortlet < Portlet; end
|
42
|
+
class BlogPostsInMonthPortlet < Portlet; end
|
43
|
+
class BlogPostsInYearPortlet < Portlet; end
|
44
|
+
|
37
45
|
class MigrateTo20100427 < ActiveRecord::Migration
|
38
46
|
def self.up
|
39
47
|
drop_table :blog_group_membership_versions
|
@@ -45,6 +53,7 @@ class MigrateTo20100427 < ActiveRecord::Migration
|
|
45
53
|
portlets = [BlogPostPortlet, BlogPostsInCategoryPortlet, BlogPostsWithTagPortlet, BlogPostsInDayPortlet, BlogPostsInMonthPortlet, BlogPostsInYearPortlet]
|
46
54
|
#pp portlets.map(&:all).flatten.map(&:connected_pages).flatten.map(&:page_routes).flatten.each(&:destroy)
|
47
55
|
pp portlets.map(&:all).flatten.map(&:connected_pages).flatten.each(&:destroy)
|
56
|
+
pp portlets.map(&:all).flatten.each(&:destroy)
|
48
57
|
|
49
58
|
# Something like this might not work if they have moved their Blog page to a different section or to no section, so we better let users resolve this manually...
|
50
59
|
#Blog.all.map(&:connected_pages).flatten.each do |page|
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tylerrick-bcms_blog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 0
|
8
|
+
- 6
|
9
|
+
version: 1.0.6
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- BrowserMedia
|
@@ -9,7 +14,7 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date: 2010-
|
17
|
+
date: 2010-05-18 00:00:00 -07:00
|
13
18
|
default_executable:
|
14
19
|
dependencies: []
|
15
20
|
|
@@ -28,11 +33,13 @@ files:
|
|
28
33
|
- app/controllers/cms/blogs_controller.rb
|
29
34
|
- app/helpers/application_helper.rb
|
30
35
|
- app/helpers/cms/blog_helper.rb
|
36
|
+
- app/models/blog.posts_finder.rb
|
31
37
|
- app/models/blog.rb
|
32
38
|
- app/models/blog_comment.rb
|
33
39
|
- app/models/blog_group_membership.rb
|
34
40
|
- app/models/blog_post.rb
|
35
41
|
- app/portlets/blog_post_portlet.rb
|
42
|
+
- app/portlets/blog_posts_portlet.rb
|
36
43
|
- app/views/cms/blog_comments/_form.html.erb
|
37
44
|
- app/views/cms/blog_comments/render.html.erb
|
38
45
|
- app/views/cms/blog_posts/_form.html.erb
|
@@ -45,6 +52,8 @@ files:
|
|
45
52
|
- app/views/partials/_blog_post.html.haml
|
46
53
|
- app/views/portlets/blog_post/_form.html.erb
|
47
54
|
- app/views/portlets/blog_post/render.html.erb
|
55
|
+
- app/views/portlets/blog_posts/_form.html.erb
|
56
|
+
- app/views/portlets/blog_posts/render.html.haml
|
48
57
|
- db/migrate/20090415000000_create_blogs.rb
|
49
58
|
- db/migrate/20090415000001_create_blog_posts.rb
|
50
59
|
- db/migrate/20090415000002_create_blog_comments.rb
|
@@ -55,6 +64,16 @@ files:
|
|
55
64
|
- lib/bcms_blog/routes.rb
|
56
65
|
- rails/init.rb
|
57
66
|
- README.markdown
|
67
|
+
- test/test_helper.rb
|
68
|
+
- test/factories.rb
|
69
|
+
- test/test_logging.rb
|
70
|
+
- test/performance/browsing_test.rb
|
71
|
+
- test/unit/blog_post_test.rb
|
72
|
+
- test/unit/blog_test.rb
|
73
|
+
- test/functional/blog_post_test.rb
|
74
|
+
- test/functional/blog_test.rb
|
75
|
+
- test/functional/cms/blogs_controller_test.rb
|
76
|
+
- test/functional/cms/blog_posts_controller_test.rb
|
58
77
|
has_rdoc: true
|
59
78
|
homepage: http://browsercms.org
|
60
79
|
licenses: []
|
@@ -65,21 +84,25 @@ rdoc_options:
|
|
65
84
|
require_paths:
|
66
85
|
- lib
|
67
86
|
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
68
88
|
requirements:
|
69
89
|
- - ">="
|
70
90
|
- !ruby/object:Gem::Version
|
91
|
+
segments:
|
92
|
+
- 0
|
71
93
|
version: "0"
|
72
|
-
version:
|
73
94
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
74
96
|
requirements:
|
75
97
|
- - ">="
|
76
98
|
- !ruby/object:Gem::Version
|
99
|
+
segments:
|
100
|
+
- 0
|
77
101
|
version: "0"
|
78
|
-
version:
|
79
102
|
requirements: []
|
80
103
|
|
81
104
|
rubyforge_project: browsercms
|
82
|
-
rubygems_version: 1.3.
|
105
|
+
rubygems_version: 1.3.7
|
83
106
|
signing_key:
|
84
107
|
specification_version: 3
|
85
108
|
summary: The Blog Module for BrowserCMS
|