refinerycms-blog 1.0.rc10 → 1.0.rc11
Sign up to get free protection for your applications and to get access to all the features.
- data/app/models/blog_category.rb +12 -1
- data/app/models/blog_post.rb +7 -3
- data/app/views/admin/blog/posts/_form.html.erb +2 -0
- data/app/views/blog/shared/_categories.html.erb +1 -1
- data/app/views/blog/shared/_post.html.erb +23 -21
- data/config/locales/en.yml +1 -0
- data/generators/refinery_blog/refinery_blog_generator.rb +1 -0
- data/lib/refinerycms-blog.rb +1 -1
- metadata +4 -4
data/app/models/blog_category.rb
CHANGED
@@ -8,5 +8,16 @@ class BlogCategory < ActiveRecord::Base
|
|
8
8
|
validates_uniqueness_of :title
|
9
9
|
|
10
10
|
has_friendly_id :title, :use_slug => true
|
11
|
-
|
11
|
+
|
12
|
+
# this might be able to be optimised a little more
|
13
|
+
def post_count
|
14
|
+
count = 0
|
15
|
+
|
16
|
+
self.posts.each do |p|
|
17
|
+
count += 1 if p.live?
|
18
|
+
end
|
19
|
+
|
20
|
+
count
|
21
|
+
end
|
22
|
+
|
12
23
|
end
|
data/app/models/blog_post.rb
CHANGED
@@ -13,11 +13,15 @@ class BlogPost < ActiveRecord::Base
|
|
13
13
|
default_scope :order => "created_at DESC"
|
14
14
|
|
15
15
|
if Rails.version < '3.0.0'
|
16
|
-
named_scope :live, :conditions =>
|
16
|
+
named_scope :live, lambda { {:conditions => ["published_at < ? and draft = ?", Time.now, false]} }
|
17
17
|
else
|
18
|
-
scope :live,
|
18
|
+
scope :live, lambda { where( "published_at < ? and draft = ?", Time.now, false) }
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
|
+
def live?
|
22
|
+
!draft and published_at <= Time.now
|
23
|
+
end
|
24
|
+
|
21
25
|
def category_ids=(ids)
|
22
26
|
self.categories = ids.reject{|id| id.blank?}.collect {|c_id|
|
23
27
|
BlogCategory.find(c_id.to_i) rescue nil
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<ul id='categories'>
|
3
3
|
<% @blog_categories.each do |category| %>
|
4
4
|
<li<%= " class='selected'" if @category.present? and @category.id == category.id %>>
|
5
|
-
<%= link_to "#{category.title} (#{category.
|
5
|
+
<%= link_to "#{category.title} (#{category.post_count})", blog_category_url(category) %>
|
6
6
|
</li>
|
7
7
|
<% end %>
|
8
8
|
</ul>
|
@@ -1,22 +1,24 @@
|
|
1
|
-
|
2
|
-
<
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
1
|
+
<% if post.live? %>
|
2
|
+
<li>
|
3
|
+
<h2><%= link_to post.title, blog_post_url(post) %></h2>
|
4
|
+
<p class='posted_at'>
|
5
|
+
<%= t('blog.shared.posts.created_at', :when => post.published_at.strftime('%d %B %Y')) %>
|
6
|
+
</p>
|
7
|
+
<div clas='clearfix'>
|
8
|
+
<%= truncate(post.body,
|
9
|
+
:length => RefinerySetting.find_or_set(:blog_post_teaser_length, 250),
|
10
|
+
:preserve_html_tags => true) %>
|
11
|
+
</div>
|
12
|
+
<p>
|
13
|
+
<%= link_to t('blog.shared.posts.read_more'), blog_post_url(post) %>
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
</li>
|
15
|
+
<span class='comment_count'>
|
16
|
+
<% if post.comments.any? %>
|
17
|
+
(<%= pluralize(post.comments.count, t('blog.shared.comments.singular')) %>)
|
18
|
+
<% else %>
|
19
|
+
(<%= t('blog.shared.comments.none') %>)
|
20
|
+
<% end %>
|
21
|
+
</span>
|
22
|
+
</p>
|
23
|
+
</li>
|
24
|
+
<% end %>
|
data/config/locales/en.yml
CHANGED
@@ -37,6 +37,7 @@ en:
|
|
37
37
|
advanced_options: Advanced Options
|
38
38
|
toggle_advanced_options: Click to access meta tag settings and menu options
|
39
39
|
save_as_draft: Save as Draft
|
40
|
+
published_at: Publish Date
|
40
41
|
index:
|
41
42
|
no_items_yet: 'There are no Blog Posts yet. Click "{{create}}" to add your first blog post.'
|
42
43
|
post:
|
@@ -38,6 +38,7 @@ class RefineryBlogGenerator < Rails::Generator::NamedBase
|
|
38
38
|
Rails::Generator::GeneratedAttribute.new('title', 'string'),
|
39
39
|
Rails::Generator::GeneratedAttribute.new('body', 'text'),
|
40
40
|
Rails::Generator::GeneratedAttribute.new('draft', 'boolean')
|
41
|
+
Rails::Generator::GeneratedAttribute.new('published_at', 'datetime')
|
41
42
|
], :id => true
|
42
43
|
},{
|
43
44
|
:table_name => 'blog_comments',
|
data/lib/refinerycms-blog.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: refinerycms-blog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: -
|
4
|
+
hash: -398340060
|
5
5
|
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- rc11
|
10
|
+
version: 1.0.rc11
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Resolve Digital
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-09-
|
19
|
+
date: 2010-09-21 00:00:00 +12:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|