refinerycms-blog 1.0.rc10 → 1.0.rc11

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.
@@ -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
@@ -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 => {:draft => false}
16
+ named_scope :live, lambda { {:conditions => ["published_at < ? and draft = ?", Time.now, false]} }
17
17
  else
18
- scope :live, :conditions => {:draft => false}
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
@@ -44,6 +44,8 @@
44
44
  </li>
45
45
  <% end %>
46
46
  </ul>
47
+ <h3><%= t('admin.blog.posts.form.published_at') %></h3>
48
+ <%= f.datetime_select :published_at %>
47
49
  </div>
48
50
  <div class='hemisquare right_side'>
49
51
  </div>
@@ -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.posts.count})", blog_category_url(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
- <li>
2
- <h2><%= link_to post.title, blog_post_url(post) %></h2>
3
- <p class='posted_at'>
4
- <%= t('blog.shared.posts.created_at', :when => post.created_at.strftime('%d %B %Y')) %>
5
- </p>
6
- <div clas='clearfix'>
7
- <%= truncate(post.body,
8
- :length => RefinerySetting.find_or_set(:blog_post_teaser_length, 250),
9
- :preserve_html_tags => true) %>
10
- </div>
11
- <p>
12
- <%= link_to t('blog.shared.posts.read_more'), blog_post_url(post) %>
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
- <span class='comment_count'>
15
- <% if post.comments.any? %>
16
- (<%= pluralize(post.comments.count, t('blog.shared.comments.singular')) %>)
17
- <% else %>
18
- (<%= t('blog.shared.comments.none') %>)
19
- <% end %>
20
- </span>
21
- </p>
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 %>
@@ -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',
@@ -42,7 +42,7 @@ module Refinery
42
42
 
43
43
  class << self
44
44
  def version
45
- %q{1.0.rc10}
45
+ %q{1.0.rc11}
46
46
  end
47
47
  end
48
48
  end
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: -398340057
4
+ hash: -398340060
5
5
  prerelease: true
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - rc10
10
- version: 1.0.rc10
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-14 00:00:00 +12:00
19
+ date: 2010-09-21 00:00:00 +12:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency