refinerycms-blog 1.6.1 → 1.6.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -41,4 +41,15 @@ module BlogPostsHelper
41
41
  def next_or_previous?(post)
42
42
  post.next.present? or post.prev.present?
43
43
  end
44
+
45
+ def blog_post_teaser(post)
46
+ if post.respond_to?(:custom_teaser) && post.custom_teaser.present?
47
+ post.custom_teaser.html_safe
48
+ else
49
+ truncate(post.body, {
50
+ :length => RefinerySetting.find_or_set(:blog_post_teaser_length, 250),
51
+ :preserve_html_tags => true
52
+ }).html_safe
53
+ end
54
+ end
44
55
  end
@@ -26,7 +26,7 @@ class BlogPost < ActiveRecord::Base
26
26
  :approximate_ascii => RefinerySetting.find_or_set(:approximate_ascii, false, :scoping => 'blog'),
27
27
  :strip_non_ascii => RefinerySetting.find_or_set(:strip_non_ascii, false, :scoping => 'blog')
28
28
 
29
- attr_accessible :title, :body, :tag_list, :draft, :published_at, :browser_title, :meta_keywords, :meta_description, :user_id, :category_ids, :custom_url
29
+ attr_accessible :title, :body, :tag_list, :draft, :published_at, :browser_title, :meta_keywords, :meta_description, :user_id, :category_ids, :custom_url, :custom_teaser
30
30
 
31
31
  scope :by_archive, lambda { |archive_date|
32
32
  where(['published_at between ? and ?', archive_date.beginning_of_month, archive_date.end_of_month])
@@ -4,4 +4,12 @@
4
4
  margin: 0px;
5
5
  padding: 0px;
6
6
  }
7
+ a#copy_body_link {
8
+ background: url("/images/refinery/icons/add.png") no-repeat scroll 0 6px transparent;
9
+ border-bottom: 0 none;
10
+ display: inline;
11
+ line-height: 29px;
12
+ margin-top: 0;
13
+ padding-left: 20px;
14
+ }
7
15
  </style>
@@ -13,9 +13,12 @@
13
13
  <div class='field'>
14
14
  <div id='page-tabs' class='clearfix ui-tabs ui-widget ui-widget-content ui-corner-all'>
15
15
  <ul id='page_parts'>
16
- <li class='ui-state-default'>
16
+ <li class='ui-state-default ui-state-active'>
17
17
  <%= link_to "Body", "#page_part_body" %>
18
18
  </li>
19
+ <li class='ui-state-default'>
20
+ <%= link_to "Teaser", "#page_part_teaser" %>
21
+ </li>
19
22
  <% Refinery::Blog.tabs.each_with_index do |tab, tab_index| %>
20
23
  <li class='ui-state-default' id="custom_<%= tab.name %>_tab">
21
24
  <%= link_to tab.name.titleize, "#custom_tab_#{tab_index}" %>
@@ -31,6 +34,11 @@
31
34
  :f => f,
32
35
  :part_index => (part_index += 1),
33
36
  } -%>
37
+ <%= render :partial => 'teaser_part',
38
+ :locals => {
39
+ :f => f,
40
+ :part_index => (part_index += 1),
41
+ } if f.object.respond_to?(:custom_teaser) -%>
34
42
  <% Refinery::Blog.tabs.each_with_index do |tab, tab_index| %>
35
43
  <div class='page_part' id='<%= "custom_tab_#{tab_index}" %>'>
36
44
  <%= render :partial => tab.partial, :locals => {:f => f} %>
@@ -1,5 +1,23 @@
1
1
  <script>
2
2
  (function($) {
3
- $('#page-tabs').tabs();
3
+ $(function() {
4
+ $('#page-tabs').tabs();
5
+ $('#copy_body_link').click(function(event) {
6
+ // Find the WYMEditor that maps to the custom_teaser field
7
+ var teaserTextArea = $('#blog_post_custom_teaser')[0];
8
+ var teaserEditor = null;
9
+ $.each(WYMeditor.INSTANCES, function(index, editor) {
10
+ if (editor._element[0] == teaserTextArea) {
11
+ teaserEditor = editor;
12
+ }
13
+ });
14
+
15
+ if (teaserEditor) {
16
+ teaserEditor.html($('#blog_post_body').attr('value'));
17
+ }
18
+
19
+ event.preventDefault();
20
+ });
21
+ });
4
22
  })(jQuery);
5
23
  </script>
@@ -0,0 +1,11 @@
1
+ <div class='page_part' id='page_part_teaser'>
2
+ <%= f.text_area :custom_teaser, :rows => 20, :class => 'wymeditor widest' -%>
3
+ <p>
4
+ <span class='clearfix label_inline_with_link'>
5
+ <%= link_to t('admin.blog.posts.form.copy_body'), "#",
6
+ :id => 'copy_body_link',
7
+ :title => t('admin.blog.posts.form.copy_body_help') %>
8
+ </span>
9
+ </p>
10
+ </div>
11
+
@@ -12,7 +12,7 @@
12
12
  <%=raw categories.collect { |category| link_to category.title, blog_category_url(category) }.to_sentence %>
13
13
  </aside>
14
14
  <% end %>
15
- <% if (tags = post.tag_list).any? %>
15
+ <% if (tags = post.tags).any? %>
16
16
  <aside class='tagged'>
17
17
  <%= t('tagged', :scope => 'blog.posts.show') %>
18
18
  <%=raw tags.collect { |tag| link_to tag, tagged_posts_path(tag.id, tag.name.parameterize) }.to_sentence %>
@@ -21,9 +21,7 @@
21
21
  </section>
22
22
  </header>
23
23
  <section class='clearfix'>
24
- <%= truncate(post.body,
25
- :length => RefinerySetting.find_or_set(:blog_post_teaser_length, 250),
26
- :preserve_html_tags => true) %>
24
+ <%= blog_post_teaser(post) %>
27
25
  </section>
28
26
  <footer>
29
27
  <p>
data/changelog.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 1.7 [UNRELEASED]
2
+ * Custom teaser field to overwrite the automatic truncation of the body [wikyd](https://github.com/wikyd)
3
+ * Tagging URL strategy updated again [joemsak](https://github.com/joemsak)
4
+
5
+ ## 1.6.2 [UNRELEASED]
6
+ * Tagging bug fixed [ruprict](https://github.com/ruprict)
7
+
1
8
  ## 1.6.1 [21 June 2011]
2
9
  * Tagging URL strategy updated for reliability /blog/posts/tagged/ID-name-parameterized [joemsak](https://github.com/joemsak)
3
10
  * Heroku/PostgreSQL support for autocomplete tags [joemsak](https://github.com/joemsak)
@@ -40,6 +40,8 @@ en:
40
40
  published_at: Publish Date
41
41
  custom_url: Custom Url
42
42
  custom_url_help: Generate the url for the blog post from this text instead of the title.
43
+ copy_body: Copy Post Body to Teaser
44
+ copy_body_help: Copies the post body to the teaser. Leave teaser blank to let Refinery automatically make the teaser.
43
45
  index:
44
46
  no_items_yet: 'There are no Blog Posts yet. Click "%{create}" to add your first blog post.'
45
47
  uncategorized:
data/config/routes.rb CHANGED
@@ -6,7 +6,7 @@
6
6
  match 'categories/:id', :to => 'categories#show', :as => 'blog_category'
7
7
  match ':id/comments', :to => 'posts#comment', :as => 'blog_post_blog_comments'
8
8
  get 'archive/:year(/:month)', :to => 'posts#archive', :as => 'archive_blog_posts'
9
- get 'tagged/:tag_id-:tag_name' => 'posts#tagged', :as => 'tagged_posts'
9
+ get 'tagged/:tag_id/:tag_name' => 'posts#tagged', :as => 'tagged_posts'
10
10
  end
11
11
 
12
12
  scope(:path => 'refinery', :as => 'admin', :module => 'admin') do
@@ -0,0 +1,10 @@
1
+ class AddCustomTeaserFieldToBlogPosts < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :blog_posts, :custom_teaser, :text
4
+ end
5
+
6
+ def self.down
7
+ remove_column :blog_posts, :custom_teaser
8
+ end
9
+ end
10
+
@@ -19,5 +19,5 @@ Feature: Blog Post Categories
19
19
  And I press "Save"
20
20
 
21
21
  Then there should be 1 blog post
22
- And the blog post should have "1" category
22
+ And the blog post should have 1 category
23
23
  And the blog post should have the category "Videos"
@@ -4,5 +4,5 @@ Factory.define(:blog_comment) do |f|
4
4
  f.name "Joe Commenter"
5
5
  f.sequence(:email) { |n| "person#{n}@example.com" }
6
6
  f.body "Which one is the best for picking up new shoes?"
7
- f.association :post
7
+ f.association :post, :factory => :blog_post
8
8
  end
@@ -1,6 +1,6 @@
1
1
  require 'factory_girl'
2
2
 
3
- Factory.define(:post, :class => BlogPost) do |f|
3
+ Factory.define(:blog_post, :class => BlogPost) do |f|
4
4
  f.sequence(:title) { |n| "Top #{n} Shopping Centers in Chicago" }
5
5
  f.body "These are the top ten shopping centers in Chicago. You're going to read a long blog post about them. Come to peace with it."
6
6
  f.draft false
@@ -1,11 +1,11 @@
1
1
  Given /^there is a category titled "([^"]*)"$/ do |title|
2
- @category = Factory(:blog_category, :title => title)
2
+ @category = Factory.create(:blog_category, :title => title)
3
3
  end
4
4
 
5
- Then /^the blog post should have "([^"]*)" category$/ do |num_category|
6
- BlogPost.last.categories.count.should == num_category
5
+ Then /^the blog post should have ([\d]*) categor[yies]{1,3}$/ do |num_category|
6
+ BlogPost.last.categories.count.should == num_category.to_i
7
7
  end
8
8
 
9
- Then /^the blog post should have the category "([^"]*)"$/ do |category|
9
+ Then /^the blog post should have the category "([^"]*)"$/ do |category|
10
10
  BlogPost.last.categories.first.title.should == category
11
11
  end
@@ -1,8 +1,10 @@
1
1
  Given /^there is a blog post titled "([^"]*)" and tagged "([^"]*)"$/ do |title, tag_name|
2
- @blog_post = Factory(:post, :title => title, :tag_list => tag_name)
2
+ @blog_post = Factory.create(:blog_post, :title => title, :tag_list => tag_name)
3
3
  end
4
4
 
5
5
  When /^I visit the tagged posts page for "([^"]*)"$/ do |tag_name|
6
+ @blog_post ||= Factory.create(:blog_post, :tag_list => tag_name)
7
+ tag = BlogPost.tag_counts_on(:tags).first
6
8
  visit tagged_posts_path(tag.id, tag_name.parameterize)
7
9
  end
8
10
 
data/lib/gemspec.rb CHANGED
@@ -2,9 +2,7 @@
2
2
  require File.expand_path('../refinery/blog/version', __FILE__)
3
3
  version = ::Refinery::Blog::Version.to_s
4
4
  raise "Could not get version so gemspec can not be built" if version.nil?
5
- files = Dir.glob("**/*").flatten.reject do |file|
6
- file =~ /\.gem(spec)?$/
7
- end
5
+ files = Dir.glob("**/*").flatten.reject{|f| f =~ %r{.gem$}}
8
6
 
9
7
  gemspec = <<EOF
10
8
  Gem::Specification.new do |s|
@@ -19,7 +17,7 @@ Gem::Specification.new do |s|
19
17
  s.require_paths = %w(lib)
20
18
 
21
19
  # Runtime dependencies
22
- s.add_dependency 'refinerycms-core', '~> 1.0.0'
20
+ s.add_dependency 'refinerycms-core', '~> 1.0.3'
23
21
  s.add_dependency 'filters_spam', '~> 0.2'
24
22
  s.add_dependency 'acts-as-taggable-on'
25
23
  s.add_dependency 'seo_meta', '~> 1.1.0'
@@ -3,7 +3,7 @@ module Refinery
3
3
  class Version
4
4
  @major = 1
5
5
  @minor = 6
6
- @tiny = 1
6
+ @tiny = 2
7
7
 
8
8
  class << self
9
9
  attr_reader :major, :minor, :tiny
data/readme.md CHANGED
@@ -17,7 +17,7 @@ Refinery CMS version 1.0.0 or above.
17
17
 
18
18
  Open up your ``Gemfile`` and add at the bottom this line:
19
19
 
20
- gem 'refinerycms-blog', '~> 1.5'
20
+ gem 'refinerycms-blog', '~> 1.6.1'
21
21
 
22
22
  Now, run ``bundle install``
23
23
 
@@ -0,0 +1,202 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = %q{refinerycms-blog}
3
+ s.version = %q{1.6.2}
4
+ s.description = %q{A really straightforward open source Ruby on Rails blog engine designed for integration with RefineryCMS.}
5
+ s.date = %q{2011-06-29}
6
+ s.summary = %q{Ruby on Rails blogging engine for RefineryCMS.}
7
+ s.email = %q{info@refinerycms.com}
8
+ s.homepage = %q{http://refinerycms.com/blog}
9
+ s.authors = ['Resolve Digital', 'Neoteric Design']
10
+ s.require_paths = %w(lib)
11
+
12
+ # Runtime dependencies
13
+ s.add_dependency 'refinerycms-core', '~> 1.0.3'
14
+ s.add_dependency 'filters_spam', '~> 0.2'
15
+ s.add_dependency 'acts-as-taggable-on'
16
+ s.add_dependency 'seo_meta', '~> 1.1.0'
17
+
18
+ # Development dependencies
19
+ s.add_development_dependency 'factory_girl'
20
+
21
+ s.files = %w(
22
+ app
23
+ app/controllers
24
+ app/controllers/admin
25
+ app/controllers/admin/blog
26
+ app/controllers/admin/blog/categories_controller.rb
27
+ app/controllers/admin/blog/comments_controller.rb
28
+ app/controllers/admin/blog/posts_controller.rb
29
+ app/controllers/admin/blog/settings_controller.rb
30
+ app/controllers/blog
31
+ app/controllers/blog/categories_controller.rb
32
+ app/controllers/blog/posts_controller.rb
33
+ app/controllers/blog_controller.rb
34
+ app/helpers
35
+ app/helpers/blog_posts_helper.rb
36
+ app/mailers
37
+ app/mailers/blog
38
+ app/mailers/blog/comment_mailer.rb
39
+ app/models
40
+ app/models/blog
41
+ app/models/blog/comment_mailer.rb
42
+ app/models/blog_category.rb
43
+ app/models/blog_comment.rb
44
+ app/models/blog_post.rb
45
+ app/models/categorization.rb
46
+ app/views
47
+ app/views/admin
48
+ app/views/admin/blog
49
+ app/views/admin/blog/_submenu.html.erb
50
+ app/views/admin/blog/categories
51
+ app/views/admin/blog/categories/_category.html.erb
52
+ app/views/admin/blog/categories/_form.html.erb
53
+ app/views/admin/blog/categories/_sortable_list.html.erb
54
+ app/views/admin/blog/categories/edit.html.erb
55
+ app/views/admin/blog/categories/index.html.erb
56
+ app/views/admin/blog/categories/new.html.erb
57
+ app/views/admin/blog/comments
58
+ app/views/admin/blog/comments/_comment.html.erb
59
+ app/views/admin/blog/comments/_sortable_list.html.erb
60
+ app/views/admin/blog/comments/index.html.erb
61
+ app/views/admin/blog/comments/show.html.erb
62
+ app/views/admin/blog/posts
63
+ app/views/admin/blog/posts/_form.css.erb
64
+ app/views/admin/blog/posts/_form.html.erb
65
+ app/views/admin/blog/posts/_form.js.erb
66
+ app/views/admin/blog/posts/_form_part.html.erb
67
+ app/views/admin/blog/posts/_post.html.erb
68
+ app/views/admin/blog/posts/_sortable_list.html.erb
69
+ app/views/admin/blog/posts/_teaser_part.html.erb
70
+ app/views/admin/blog/posts/edit.html.erb
71
+ app/views/admin/blog/posts/index.html.erb
72
+ app/views/admin/blog/posts/new.html.erb
73
+ app/views/admin/blog/posts/uncategorized.html.erb
74
+ app/views/admin/blog/settings
75
+ app/views/admin/blog/settings/notification_recipients.html.erb
76
+ app/views/blog
77
+ app/views/blog/categories
78
+ app/views/blog/categories/show.html.erb
79
+ app/views/blog/comment_mailer
80
+ app/views/blog/comment_mailer/notification.html.erb
81
+ app/views/blog/posts
82
+ app/views/blog/posts/_comment.html.erb
83
+ app/views/blog/posts/_nav.html.erb
84
+ app/views/blog/posts/_post.html.erb
85
+ app/views/blog/posts/archive.html.erb
86
+ app/views/blog/posts/index.html.erb
87
+ app/views/blog/posts/index.rss.builder
88
+ app/views/blog/posts/show.html.erb
89
+ app/views/blog/posts/tagged.html.erb
90
+ app/views/blog/shared
91
+ app/views/blog/shared/_categories.html.erb
92
+ app/views/blog/shared/_post.html.erb
93
+ app/views/blog/shared/_posts.html.erb
94
+ app/views/blog/shared/_rss_feed.html.erb
95
+ app/views/blog/shared/_tags.html.erb
96
+ app/views/shared
97
+ app/views/shared/admin
98
+ app/views/shared/admin/_autocomplete.html.erb
99
+ changelog.md
100
+ config
101
+ config/locales
102
+ config/locales/cs.yml
103
+ config/locales/de.yml
104
+ config/locales/en.yml
105
+ config/locales/es.yml
106
+ config/locales/fr.yml
107
+ config/locales/it.yml
108
+ config/locales/nb.yml
109
+ config/locales/nl.yml
110
+ config/locales/pl.yml
111
+ config/locales/pt-BR.yml
112
+ config/locales/ru.yml
113
+ config/locales/sk.yml
114
+ config/locales/zh-CN.yml
115
+ config/routes.rb
116
+ db
117
+ db/migrate
118
+ db/migrate/1_create_blog_structure.rb
119
+ db/migrate/2_add_user_id_to_blog_posts.rb
120
+ db/migrate/3_acts_as_taggable_on_migration.rb
121
+ db/migrate/4_create_seo_meta_for_blog.rb
122
+ db/migrate/5_add_cached_slugs.rb
123
+ db/migrate/6_add_custom_url_field_to_blog_posts.rb
124
+ db/migrate/7_add_custom_teaser_field_to_blog_posts.rb
125
+ db/seeds
126
+ db/seeds/refinerycms_blog.rb
127
+ features
128
+ features/authors.feature
129
+ features/category.feature
130
+ features/support
131
+ features/support/factories
132
+ features/support/factories/blog_categories.rb
133
+ features/support/factories/blog_comments.rb
134
+ features/support/factories/blog_posts.rb
135
+ features/support/paths.rb
136
+ features/support/step_definitions
137
+ features/support/step_definitions/authors_steps.rb
138
+ features/support/step_definitions/category_steps.rb
139
+ features/support/step_definitions/tags_steps.rb
140
+ features/tags.feature
141
+ lib
142
+ lib/gemspec.rb
143
+ lib/generators
144
+ lib/generators/refinerycms_blog_generator.rb
145
+ lib/refinery
146
+ lib/refinery/blog
147
+ lib/refinery/blog/tabs.rb
148
+ lib/refinery/blog/version.rb
149
+ lib/refinerycms-blog.rb
150
+ public
151
+ public/images
152
+ public/images/refinerycms-blog
153
+ public/images/refinerycms-blog/icons
154
+ public/images/refinerycms-blog/icons/cog.png
155
+ public/images/refinerycms-blog/icons/comment.png
156
+ public/images/refinerycms-blog/icons/comment_cross.png
157
+ public/images/refinerycms-blog/icons/comment_tick.png
158
+ public/images/refinerycms-blog/icons/comments.png
159
+ public/images/refinerycms-blog/icons/down.gif
160
+ public/images/refinerycms-blog/icons/folder.png
161
+ public/images/refinerycms-blog/icons/folder_add.png
162
+ public/images/refinerycms-blog/icons/folder_edit.png
163
+ public/images/refinerycms-blog/icons/page.png
164
+ public/images/refinerycms-blog/icons/page_add.png
165
+ public/images/refinerycms-blog/icons/page_copy.png
166
+ public/images/refinerycms-blog/icons/up.gif
167
+ public/images/refinerycms-blog/rss-feed.png
168
+ public/javascripts
169
+ public/javascripts/refinery
170
+ public/javascripts/refinery/refinerycms-blog.js
171
+ public/javascripts/refinerycms-blog.js
172
+ public/stylesheets
173
+ public/stylesheets/refinery
174
+ public/stylesheets/refinery/refinerycms-blog.css
175
+ public/stylesheets/refinerycms-blog.css
176
+ public/stylesheets/ui-lightness
177
+ public/stylesheets/ui-lightness/images
178
+ public/stylesheets/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png
179
+ public/stylesheets/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png
180
+ public/stylesheets/ui-lightness/images/ui-bg_flat_10_000000_40x100.png
181
+ public/stylesheets/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png
182
+ public/stylesheets/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png
183
+ public/stylesheets/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png
184
+ public/stylesheets/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png
185
+ public/stylesheets/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png
186
+ public/stylesheets/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png
187
+ public/stylesheets/ui-lightness/images/ui-icons_222222_256x240.png
188
+ public/stylesheets/ui-lightness/images/ui-icons_228ef1_256x240.png
189
+ public/stylesheets/ui-lightness/images/ui-icons_ef8c08_256x240.png
190
+ public/stylesheets/ui-lightness/images/ui-icons_ffd27a_256x240.png
191
+ public/stylesheets/ui-lightness/images/ui-icons_ffffff_256x240.png
192
+ public/stylesheets/ui-lightness/jquery-ui-1.8.13.custom.css
193
+ readme.md
194
+ refinerycms-blog.gemspec
195
+ spec
196
+ spec/models
197
+ spec/models/blog_category_spec.rb
198
+ spec/models/blog_comment_spec.rb
199
+ spec/models/blog_post_spec.rb
200
+ )
201
+
202
+ end
@@ -3,7 +3,7 @@ Dir[File.expand_path('../../../features/support/factories/*.rb', __FILE__)].each
3
3
 
4
4
  describe BlogCategory do
5
5
  before(:each) do
6
- @blog_category = Factory(:blog_category)
6
+ @blog_category = Factory.create(:blog_category)
7
7
  end
8
8
 
9
9
  describe "validations" do
@@ -20,20 +20,20 @@ describe BlogCategory do
20
20
  it "has a posts attribute" do
21
21
  @blog_category.should respond_to(:posts)
22
22
  end
23
-
23
+
24
24
  it "returns posts by published_at date in descending order" do
25
25
  first_post = @blog_category.posts.create!({ :title => "Breaking News: Joe Sak is hot stuff you guys!!", :body => "True story.", :published_at => Time.now.yesterday })
26
- latest_post = @blog_category.posts.create!({ :title => "parndt is p. okay", :body => "For a kiwi.", :published_at => Time.now })
26
+ latest_post = @blog_category.posts.create!({ :title => "parndt is p. okay", :body => "For a Kiwi.", :published_at => Time.now })
27
27
 
28
28
  @blog_category.posts.first.should == latest_post
29
29
  end
30
-
30
+
31
31
  end
32
32
 
33
33
  describe "#post_count" do
34
34
  it "returns post count in category" do
35
35
  2.times do
36
- @blog_category.posts << Factory(:post)
36
+ @blog_category.posts << Factory.create(:blog_post)
37
37
  end
38
38
  @blog_category.post_count.should == 2
39
39
  end
@@ -6,7 +6,7 @@ describe BlogComment do
6
6
  context "wiring up" do
7
7
 
8
8
  before(:each) do
9
- @comment = Factory(:blog_comment)
9
+ @comment = Factory.create(:blog_comment)
10
10
  end
11
11
 
12
12
  it "saves" do
@@ -2,19 +2,19 @@ require 'spec_helper'
2
2
  Dir[File.expand_path('../../../features/support/factories/*.rb', __FILE__)].each{|factory| require factory}
3
3
 
4
4
  describe BlogPost do
5
- let(:blog_post ) { Factory :post }
6
-
5
+ let(:blog_post ) { Factory.create(:blog_post) }
6
+
7
7
  describe "validations" do
8
8
  it "requires title" do
9
- Factory.build(:post, :title => "").should_not be_valid
9
+ Factory.build(:blog_post, :title => "").should_not be_valid
10
10
  end
11
11
 
12
12
  it "won't allow duplicate titles" do
13
- Factory.build(:post, :title => blog_post.title).should_not be_valid
13
+ Factory.build(:blog_post, :title => blog_post.title).should_not be_valid
14
14
  end
15
15
 
16
16
  it "requires body" do
17
- Factory.build(:post, :body => nil).should_not be_valid
17
+ Factory.build(:blog_post, :body => nil).should_not be_valid
18
18
  end
19
19
  end
20
20
 
@@ -25,7 +25,7 @@ describe BlogPost do
25
25
  end
26
26
 
27
27
  it "destroys associated comments" do
28
- Factory(:blog_comment, :blog_post_id => blog_post.id)
28
+ Factory.create(:blog_comment, :blog_post_id => blog_post.id)
29
29
  blog_post.destroy
30
30
  BlogComment.find_by_blog_post_id(blog_post.id).should == nil
31
31
  end
@@ -36,16 +36,16 @@ describe BlogPost do
36
36
  blog_post.should respond_to(:categories)
37
37
  end
38
38
  end
39
-
39
+
40
40
  describe "tags" do
41
41
  it "acts as taggable" do
42
42
  blog_post.should respond_to(:tag_list)
43
-
43
+
44
44
  #the factory has default tags, including 'chicago'
45
45
  blog_post.tag_list.should include("chicago")
46
46
  end
47
47
  end
48
-
48
+
49
49
  describe "authors" do
50
50
  it "are authored" do
51
51
  BlogPost.instance_methods.map(&:to_sym).should include(:author)
@@ -54,54 +54,54 @@ describe BlogPost do
54
54
 
55
55
  describe "by_archive scope" do
56
56
  before do
57
- @blog_post1 = Factory(:post, :published_at => Date.new(2011, 3, 11))
58
- @blog_post2 = Factory(:post, :published_at => Date.new(2011, 3, 12))
59
-
57
+ @blog_post1 = Factory.create(:blog_post, :published_at => Date.new(2011, 3, 11))
58
+ @blog_post2 = Factory.create(:blog_post, :published_at => Date.new(2011, 3, 12))
59
+
60
60
  #2 months before
61
- Factory(:post, :published_at => Date.new(2011, 1, 10))
61
+ Factory.create(:blog_post, :published_at => Date.new(2011, 1, 10))
62
62
  end
63
63
 
64
64
  it "returns all posts from specified month" do
65
65
  #check for this month
66
66
  date = "03/2011"
67
- BlogPost.by_archive(Time.parse(date)).count.should == 2
67
+ BlogPost.by_archive(Time.parse(date)).count.should be == 2
68
68
  BlogPost.by_archive(Time.parse(date)).should == [@blog_post2, @blog_post1]
69
69
  end
70
70
  end
71
71
 
72
72
  describe "all_previous scope" do
73
73
  before do
74
- @blog_post1 = Factory(:post, :published_at => Time.now - 2.months)
75
- @blog_post2 = Factory(:post, :published_at => Time.now - 1.month)
76
- Factory :post, :published_at => Time.now
74
+ @blog_post1 = Factory.create(:blog_post, :published_at => Time.now - 2.months)
75
+ @blog_post2 = Factory.create(:blog_post, :published_at => Time.now - 1.month)
76
+ Factory.create(:blog_post, :published_at => Time.now)
77
77
  end
78
78
 
79
79
  it "returns all posts from previous months" do
80
- BlogPost.all_previous.count.should == 2
80
+ BlogPost.all_previous.count.should be == 2
81
81
  BlogPost.all_previous.should == [@blog_post2, @blog_post1]
82
82
  end
83
83
  end
84
84
 
85
85
  describe "live scope" do
86
86
  before do
87
- @blog_post1 = Factory(:post, :published_at => Time.now.advance(:minutes => -2))
88
- @blog_post2 = Factory(:post, :published_at => Time.now.advance(:minutes => -1))
89
- Factory(:post, :draft => true)
90
- Factory(:post, :published_at => Time.now + 1.minute)
87
+ @blog_post1 = Factory.create(:blog_post, :published_at => Time.now.advance(:minutes => -2))
88
+ @blog_post2 = Factory.create(:blog_post, :published_at => Time.now.advance(:minutes => -1))
89
+ Factory.create(:blog_post, :draft => true)
90
+ Factory.create(:blog_post, :published_at => Time.now + 1.minute)
91
91
  end
92
92
 
93
93
  it "returns all posts which aren't in draft and pub date isn't in future" do
94
- BlogPost.live.count.should == 2
94
+ BlogPost.live.count.should be == 2
95
95
  BlogPost.live.should == [@blog_post2, @blog_post1]
96
96
  end
97
97
  end
98
98
 
99
99
  describe "uncategorized scope" do
100
100
  before do
101
- @uncategorized_blog_post = Factory(:post)
102
- @categorized_blog_post = Factory(:post)
101
+ @uncategorized_blog_post = Factory.create(:blog_post)
102
+ @categorized_blog_post = Factory.create(:blog_post)
103
103
 
104
- @categorized_blog_post.categories << Factory(:blog_category)
104
+ @categorized_blog_post.categories << Factory.create(:blog_category)
105
105
  end
106
106
 
107
107
  it "returns uncategorized posts if they exist" do
@@ -112,22 +112,22 @@ describe BlogPost do
112
112
 
113
113
  describe "#live?" do
114
114
  it "returns true if post is not in draft and it's published" do
115
- Factory(:post).live?.should be_true
115
+ Factory.create(:blog_post).live?.should be_true
116
116
  end
117
117
 
118
118
  it "returns false if post is in draft" do
119
- Factory(:post, :draft => true).live?.should be_false
119
+ Factory.create(:blog_post, :draft => true).live?.should be_false
120
120
  end
121
121
 
122
122
  it "returns false if post pub date is in future" do
123
- Factory(:post, :published_at => Time.now.advance(:minutes => 1)).live?.should be_false
123
+ Factory.create(:blog_post, :published_at => Time.now.advance(:minutes => 1)).live?.should be_false
124
124
  end
125
125
  end
126
126
 
127
127
  describe "#next" do
128
128
  before do
129
- Factory(:post, :published_at => Time.now.advance(:minutes => -1))
130
- @blog_post = Factory(:post)
129
+ Factory.create(:blog_post, :published_at => Time.now.advance(:minutes => -1))
130
+ @blog_post = Factory.create(:blog_post)
131
131
  end
132
132
 
133
133
  it "returns next article when called on current article" do
@@ -137,8 +137,8 @@ describe BlogPost do
137
137
 
138
138
  describe "#prev" do
139
139
  before do
140
- Factory(:post)
141
- @blog_post = Factory(:post, :published_at => Time.now.advance(:minutes => -1))
140
+ Factory.create(:blog_post)
141
+ @blog_post = Factory.create(:blog_post, :published_at => Time.now.advance(:minutes => -1))
142
142
  end
143
143
 
144
144
  it "returns previous article when called on current article" do
@@ -148,9 +148,9 @@ describe BlogPost do
148
148
 
149
149
  describe "#category_ids=" do
150
150
  before do
151
- @cat1 = Factory(:blog_category, :id => 1)
152
- @cat2 = Factory(:blog_category, :id => 2)
153
- @cat3 = Factory(:blog_category, :id => 3)
151
+ @cat1 = Factory.create(:blog_category, :id => 1)
152
+ @cat2 = Factory.create(:blog_category, :id => 2)
153
+ @cat3 = Factory.create(:blog_category, :id => 3)
154
154
  blog_post.category_ids = [1,2,"","",3]
155
155
  end
156
156
 
@@ -168,7 +168,7 @@ describe BlogPost do
168
168
  before do
169
169
  RefinerySetting.set(:comments_allowed, { :scoping => 'blog', :value => true })
170
170
  end
171
-
171
+
172
172
  it "should be true" do
173
173
  BlogPost.comments_allowed?.should be_true
174
174
  end
@@ -178,10 +178,16 @@ describe BlogPost do
178
178
  before do
179
179
  RefinerySetting.set(:comments_allowed, { :scoping => 'blog', :value => false })
180
180
  end
181
-
181
+
182
182
  it "should be false" do
183
183
  BlogPost.comments_allowed?.should be_false
184
184
  end
185
185
  end
186
186
  end
187
+
188
+ describe "custom teasers" do
189
+ it "should allow a custom teaser" do
190
+ Factory.create(:blog_post, :custom_teaser => 'This is some custom content').should be_valid
191
+ end
192
+ end
187
193
  end
metadata CHANGED
@@ -1,80 +1,108 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: refinerycms-blog
3
- version: !ruby/object:Gem::Version
4
- version: 1.6.1
3
+ version: !ruby/object:Gem::Version
4
+ hash: 11
5
5
  prerelease:
6
+ segments:
7
+ - 1
8
+ - 6
9
+ - 2
10
+ version: 1.6.2
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Resolve Digital
9
14
  - Neoteric Design
10
15
  autorequire:
11
16
  bindir: bin
12
17
  cert_chain: []
13
- date: 2011-06-22 00:00:00.000000000 +12:00
18
+
19
+ date: 2011-06-29 00:00:00 +12:00
14
20
  default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
17
23
  name: refinerycms-core
18
- requirement: &2152867900 !ruby/object:Gem::Requirement
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
19
26
  none: false
20
- requirements:
27
+ requirements:
21
28
  - - ~>
22
- - !ruby/object:Gem::Version
23
- version: 1.0.0
29
+ - !ruby/object:Gem::Version
30
+ hash: 17
31
+ segments:
32
+ - 1
33
+ - 0
34
+ - 3
35
+ version: 1.0.3
24
36
  type: :runtime
25
- prerelease: false
26
- version_requirements: *2152867900
27
- - !ruby/object:Gem::Dependency
37
+ version_requirements: *id001
38
+ - !ruby/object:Gem::Dependency
28
39
  name: filters_spam
29
- requirement: &2152866060 !ruby/object:Gem::Requirement
40
+ prerelease: false
41
+ requirement: &id002 !ruby/object:Gem::Requirement
30
42
  none: false
31
- requirements:
43
+ requirements:
32
44
  - - ~>
33
- - !ruby/object:Gem::Version
34
- version: '0.2'
45
+ - !ruby/object:Gem::Version
46
+ hash: 15
47
+ segments:
48
+ - 0
49
+ - 2
50
+ version: "0.2"
35
51
  type: :runtime
36
- prerelease: false
37
- version_requirements: *2152866060
38
- - !ruby/object:Gem::Dependency
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
39
54
  name: acts-as-taggable-on
40
- requirement: &2152861900 !ruby/object:Gem::Requirement
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
41
57
  none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ hash: 3
62
+ segments:
63
+ - 0
64
+ version: "0"
46
65
  type: :runtime
47
- prerelease: false
48
- version_requirements: *2152861900
49
- - !ruby/object:Gem::Dependency
66
+ version_requirements: *id003
67
+ - !ruby/object:Gem::Dependency
50
68
  name: seo_meta
51
- requirement: &2152850340 !ruby/object:Gem::Requirement
69
+ prerelease: false
70
+ requirement: &id004 !ruby/object:Gem::Requirement
52
71
  none: false
53
- requirements:
72
+ requirements:
54
73
  - - ~>
55
- - !ruby/object:Gem::Version
74
+ - !ruby/object:Gem::Version
75
+ hash: 19
76
+ segments:
77
+ - 1
78
+ - 1
79
+ - 0
56
80
  version: 1.1.0
57
81
  type: :runtime
58
- prerelease: false
59
- version_requirements: *2152850340
60
- - !ruby/object:Gem::Dependency
82
+ version_requirements: *id004
83
+ - !ruby/object:Gem::Dependency
61
84
  name: factory_girl
62
- requirement: &2152849200 !ruby/object:Gem::Requirement
85
+ prerelease: false
86
+ requirement: &id005 !ruby/object:Gem::Requirement
63
87
  none: false
64
- requirements:
65
- - - ! '>='
66
- - !ruby/object:Gem::Version
67
- version: '0'
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ hash: 3
92
+ segments:
93
+ - 0
94
+ version: "0"
68
95
  type: :development
69
- prerelease: false
70
- version_requirements: *2152849200
71
- description: A really straightforward open source Ruby on Rails blog engine designed
72
- for integration with RefineryCMS.
96
+ version_requirements: *id005
97
+ description: A really straightforward open source Ruby on Rails blog engine designed for integration with RefineryCMS.
73
98
  email: info@refinerycms.com
74
99
  executables: []
100
+
75
101
  extensions: []
102
+
76
103
  extra_rdoc_files: []
77
- files:
104
+
105
+ files:
78
106
  - app/controllers/admin/blog/categories_controller.rb
79
107
  - app/controllers/admin/blog/comments_controller.rb
80
108
  - app/controllers/admin/blog/posts_controller.rb
@@ -106,6 +134,7 @@ files:
106
134
  - app/views/admin/blog/posts/_form_part.html.erb
107
135
  - app/views/admin/blog/posts/_post.html.erb
108
136
  - app/views/admin/blog/posts/_sortable_list.html.erb
137
+ - app/views/admin/blog/posts/_teaser_part.html.erb
109
138
  - app/views/admin/blog/posts/edit.html.erb
110
139
  - app/views/admin/blog/posts/index.html.erb
111
140
  - app/views/admin/blog/posts/new.html.erb
@@ -148,6 +177,7 @@ files:
148
177
  - db/migrate/4_create_seo_meta_for_blog.rb
149
178
  - db/migrate/5_add_cached_slugs.rb
150
179
  - db/migrate/6_add_custom_url_field_to_blog_posts.rb
180
+ - db/migrate/7_add_custom_teaser_field_to_blog_posts.rb
151
181
  - db/seeds/refinerycms_blog.rb
152
182
  - features/authors.feature
153
183
  - features/category.feature
@@ -198,32 +228,43 @@ files:
198
228
  - public/stylesheets/ui-lightness/images/ui-icons_ffffff_256x240.png
199
229
  - public/stylesheets/ui-lightness/jquery-ui-1.8.13.custom.css
200
230
  - readme.md
231
+ - refinerycms-blog.gemspec
201
232
  - spec/models/blog_category_spec.rb
202
233
  - spec/models/blog_comment_spec.rb
203
234
  - spec/models/blog_post_spec.rb
204
235
  has_rdoc: true
205
236
  homepage: http://refinerycms.com/blog
206
237
  licenses: []
238
+
207
239
  post_install_message:
208
240
  rdoc_options: []
209
- require_paths:
241
+
242
+ require_paths:
210
243
  - lib
211
- required_ruby_version: !ruby/object:Gem::Requirement
244
+ required_ruby_version: !ruby/object:Gem::Requirement
212
245
  none: false
213
- requirements:
214
- - - ! '>='
215
- - !ruby/object:Gem::Version
216
- version: '0'
217
- required_rubygems_version: !ruby/object:Gem::Requirement
246
+ requirements:
247
+ - - ">="
248
+ - !ruby/object:Gem::Version
249
+ hash: 3
250
+ segments:
251
+ - 0
252
+ version: "0"
253
+ required_rubygems_version: !ruby/object:Gem::Requirement
218
254
  none: false
219
- requirements:
220
- - - ! '>='
221
- - !ruby/object:Gem::Version
222
- version: '0'
255
+ requirements:
256
+ - - ">="
257
+ - !ruby/object:Gem::Version
258
+ hash: 3
259
+ segments:
260
+ - 0
261
+ version: "0"
223
262
  requirements: []
263
+
224
264
  rubyforge_project:
225
265
  rubygems_version: 1.6.2
226
266
  signing_key:
227
267
  specification_version: 3
228
268
  summary: Ruby on Rails blogging engine for RefineryCMS.
229
269
  test_files: []
270
+