tb_blog 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/Readme.md +39 -25
  3. data/app/assets/images/spud/admin/news_thumb.png +0 -0
  4. data/app/controllers/admin/news_posts_controller.rb +9 -7
  5. data/app/controllers/admin/post_categories_controller.rb +3 -3
  6. data/app/controllers/admin/posts_controller.rb +9 -5
  7. data/app/controllers/blog/sitemaps_controller.rb +1 -1
  8. data/app/controllers/blog_controller.rb +7 -8
  9. data/app/controllers/news_controller.rb +17 -12
  10. data/app/helpers/blog_helper.rb +1 -1
  11. data/app/models/spud/spud_post_model.rb +193 -0
  12. data/app/models/spud_post.rb +2 -185
  13. data/app/models/spud_post_category.rb +4 -47
  14. data/app/views/admin/post_categories/_form.html.erb +0 -9
  15. data/app/views/admin/post_categories/index.html.erb +1 -1
  16. data/app/views/admin/posts/_category.html.erb +1 -6
  17. data/app/views/admin/posts/_custom_fields.html.erb +9 -0
  18. data/app/views/admin/posts/_form.html.erb +3 -8
  19. data/app/views/blog/index.rss.builder +1 -1
  20. data/app/views/news/index.rss.builder +2 -2
  21. data/db/migrate/20140508200730_remove_awesome_nested_set_columns_from_spud_post_categories.rb +15 -0
  22. data/lib/spud_blog/configuration.rb +3 -1
  23. data/lib/spud_blog/engine.rb +0 -5
  24. data/lib/spud_blog/version.rb +1 -1
  25. data/spec/controllers/blog_controller_spec.rb +15 -2
  26. data/spec/dummy/app/controllers/application_controller.rb +1 -1
  27. data/spec/dummy/db/migrate/20140730131549_add_primary_key_to_spud_post_categories_posts.tb_blog.rb +6 -0
  28. data/spec/dummy/db/migrate/20140730131550_remove_awesome_nested_set_columns_from_spud_post_categories.tb_blog.rb +16 -0
  29. data/spec/dummy/db/schema.rb +2 -7
  30. metadata +9 -17
  31. data/app/assets/images/spud/admin/news_thumb@2x.png +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ecb52356b1361df2ea2c5b8515243e4d0d18ae05
4
- data.tar.gz: a829255d1eee53d9fbb9a45fa9b2777e9037b144
3
+ metadata.gz: 6985b911d99d89f62668336b020afd530179731b
4
+ data.tar.gz: a6670c45aae3e10bc112844326cc78ef64310003
5
5
  SHA512:
6
- metadata.gz: 65552c98ad3fc18794c29b3670d7d70d2d4d4b3886fddaff570dbef7befd9a7f9c815b3df5f8b23a49ddd1f8af435e63db6ce5a13762240a69aba861a23ea846
7
- data.tar.gz: 46262bed323d60ec7084cecded595c9b91461d85f462bf55c731f68142d0e79a01cdb679d3b4e3bff91462dd0bb13a0838de32297c8a50b7273d3d8291a9baa8
6
+ metadata.gz: 51fe31feee68e1f6191a5ac9eaa80a6d00454ada4b96089c3c8aee56d5a6550acf17405758ba8234de8c11f14af9735fd5aa4046c3ee6c60661029ee6bedce7e
7
+ data.tar.gz: 96ae50f8a8e5393e3c03194e6e4b41302ee2bb3efc3c5509d6159fe447dce89c02646302cf3067658a9271d5bd89e937236e8a7b905a8bed38c8731f0d680e8b
data/Readme.md CHANGED
@@ -28,9 +28,6 @@ TB Blog current accepts the following configuration options.
28
28
  config.blog_path = 'blog'
29
29
  config.news_path = 'news'
30
30
  config.posts_per_page = 5
31
- config.has_custom_fields = true
32
- config.caching_enabled = true
33
- config.caching_expires_in = 1.hour
34
31
  config.default_comment_approval = true
35
32
  end
36
33
 
@@ -48,46 +45,63 @@ TB Blog includes a small, unobtrusive javascript driver that adds functionality
48
45
 
49
46
  <%= javascript_include_tag 'spud/blog' %>
50
47
 
48
+ ## Access Control
49
+
50
+ TB Blog offers a mechanism for limitting who can see what posts. Supply a lambda to the `query_for_user` config, which takes a single `user` argument. The value you return will be supplied directly to the `where()` query used to find posts.
51
+
52
+ The example below is from an application that allows subscribers to view subscriber-only content.
53
+
54
+ Spud::Blog.query_for_user = ->(user){
55
+ if user.present? && user.has_paid_subscription?
56
+ {}
57
+ else
58
+ {:requires_subscription => false}
59
+ end
60
+ }
61
+
62
+ *See the section on Custom Fields to see how you might go about adding such a field to your model.*
63
+
51
64
  ## Custom Fields
52
65
 
53
66
  You may find that your blog requires a field that isn't included in the default `spud_post` model. Adding custom fields is easy.
54
67
 
55
- 1. Set `has_custom_fields` to true in your TB Blog configuration
56
- 2. Create a migration adding the necessary column(s) to your database
68
+ 1. Create a migration adding the necessary column(s) to your database
57
69
 
58
70
  class AddCaptionToPosts < ActiveRecord::Migration
59
71
  def change
60
- add_column :spud_posts, :caption, :string
72
+ add_column :spud_posts, :requires_subscription, :boolean, :default => false
61
73
  end
62
74
  end
63
75
 
64
- 3. Save a view partial at `app/views/spud/admin/posts/_custom_fields.html.erb` with the desired inputs
76
+ 2. Save a view partial at `app/views/admin/posts/_custom_fields.html.erb` with the desired inputs
65
77
 
78
+ <h4>My Custom Fields</h4>
79
+ <div class="spud_post_form_row">
80
+ <%= f.label :requires_subscription, 'Require subscription' %>
81
+ <%= f.check_box :requires_subscription %>
82
+ </div>
66
83
 
67
- <div class="control-group">
68
- <%= f.label :caption, 'Caption',:class => "control-label" %>
69
- <div class="controls">
70
- <%= f.text_field :caption %>
71
- </div>
72
- </div>
84
+ 3. Finally, add the field to your `permitted_attributes` array. This is to satisfy the [Strong Parameters](http://guides.rubyonrails.org/action_controller_overview.html#strong-parameters) in the admin controller.
85
+
86
+ Spud::Blog.configure do |config|
87
+ config.permitted_attributes = [:requires_subscription]
88
+ end
73
89
 
74
90
  ## Extending the Post Model
75
91
 
76
- Rails engines allow you to extend or even completely override classes by adding them to your local application. Source files found in your local app's path will take precedence over those found within the TB Blog gem. Lets say you wanted to extend the SpudPost model.
92
+ You might want to add custom methods or attributes to the Post model. Create a file at `app/models/spud_post.rb` and add the following code:
77
93
 
78
- 1. Create a file at `app/models/spud_post.rb`
79
- 2. Add the following code:
94
+ class SpudPost < Spud::SpudPostModel
95
+ # custom methods here!
96
+ def hello_world
97
+ return "Hello, World!"
98
+ end
99
+ end
80
100
 
81
- # Use this helper method to pull in the SpudPost source code from the engine
82
- Spud::Blog::Engine.require_model('spud_post')
101
+ That's it! You may now begin customizing the post class.
83
102
 
84
- # Add your own methods to SpudPost
85
- class SpudPost
86
- attr_accessible :caption
87
- def byline
88
- return "'#{self.title}' was posted by #{self.author.full_name} on #{self.display_date}"
89
- end
90
- end
103
+ p = SpudPost.first
104
+ puts p.hello_world # outputs "Hello, World!"
91
105
 
92
106
  ## Akismet Support
93
107
 
@@ -11,12 +11,12 @@ class Admin::NewsPostsController < Admin::ApplicationController
11
11
  end
12
12
 
13
13
  def edit
14
- @categories = SpudPostCategory.grouped
14
+ @categories = SpudPostCategory.ordered
15
15
  respond_with @post
16
16
  end
17
17
 
18
18
  def update
19
- @categories = SpudPostCategory.grouped
19
+ @categories = SpudPostCategory.ordered
20
20
  params[:spud_post][:spud_site_ids] ||= []
21
21
  if @post.update_attributes(post_params)
22
22
  flash[:notice] = 'News Post was successfully updated.'
@@ -25,13 +25,13 @@ class Admin::NewsPostsController < Admin::ApplicationController
25
25
  end
26
26
 
27
27
  def new
28
- @categories = SpudPostCategory.grouped
28
+ @categories = SpudPostCategory.ordered
29
29
  @post = SpudPost.new(:published_at => Time.zone.now, :spud_user_id => current_user.id, :is_news => true, :comments_enabled => false, :spud_site_ids => [current_site_id])
30
30
  respond_with @post
31
31
  end
32
32
 
33
33
  def create
34
- @categories = SpudPostCategory.grouped
34
+ @categories = SpudPostCategory.ordered
35
35
  params[:spud_post][:spud_site_ids] ||= []
36
36
  @post = SpudPost.new(post_params)
37
37
  @post.is_news = true
@@ -59,9 +59,11 @@ private
59
59
  end
60
60
 
61
61
  def post_params
62
- params.require(:spud_post).permit(:published_at, :title, :content, :spud_user_id, :url_name, :visible, :comments_enabled, :meta_keywords, :meta_description, :content_format,
63
- :category_ids => [], :spud_site_ids => []
64
- )
62
+ permitted = [:published_at, :title, :content, :spud_user_id, :url_name, :visible, :comments_enabled, :meta_keywords, :meta_description, :content_format, :category_ids => [], :spud_site_ids => []]
63
+ if Spud::Blog.permitted_attributes.present?
64
+ permitted = permitted + Spud::Blog.permitted_attributes
65
+ end
66
+ params.require(:spud_post).permit(permitted)
65
67
  end
66
68
 
67
69
  end
@@ -6,7 +6,7 @@ class Admin::PostCategoriesController < Admin::ApplicationController
6
6
  before_filter :find_category, :only => [:show, :edit, :update, :destroy]
7
7
 
8
8
  def index
9
- @post_categories = SpudPostCategory.grouped
9
+ @post_categories = SpudPostCategory.ordered
10
10
  respond_with @post_categories
11
11
  end
12
12
 
@@ -41,7 +41,7 @@ class Admin::PostCategoriesController < Admin::ApplicationController
41
41
  def destroy
42
42
  if @post_category.destroy
43
43
  flash[:notice] = 'Post Category was successfully deleted'
44
- @post_categories = SpudPostCategory.grouped
44
+ @post_categories = SpudPostCategory.ordered
45
45
  render 'index'
46
46
  else
47
47
  respond_with @post_category, :location => admin_post_categories_path
@@ -55,7 +55,7 @@ class Admin::PostCategoriesController < Admin::ApplicationController
55
55
  end
56
56
 
57
57
  def category_params
58
- params.require(:spud_post_category).permit(:name, :parent_id)
58
+ params.require(:spud_post_category).permit(:name)
59
59
  end
60
60
 
61
61
  end
@@ -11,12 +11,12 @@ class Admin::PostsController < Admin::ApplicationController
11
11
  end
12
12
 
13
13
  def edit
14
- @categories = SpudPostCategory.grouped
14
+ @categories = SpudPostCategory.ordered
15
15
  respond_with @post
16
16
  end
17
17
 
18
18
  def update
19
- @categories = SpudPostCategory.grouped
19
+ @categories = SpudPostCategory.ordered
20
20
  params[:spud_post][:spud_site_ids] ||= []
21
21
  params[:spud_post][:updated_at] = Time.now()
22
22
  if @post.update_attributes(post_params)
@@ -26,13 +26,13 @@ class Admin::PostsController < Admin::ApplicationController
26
26
  end
27
27
 
28
28
  def new
29
- @categories = SpudPostCategory.grouped
29
+ @categories = SpudPostCategory.ordered
30
30
  @post = SpudPost.new(:published_at => Time.zone.now, :spud_user_id => current_user.id, :spud_site_ids => [session[:admin_site] || 0])
31
31
  respond_with @post
32
32
  end
33
33
 
34
34
  def create
35
- @categories = SpudPostCategory.grouped
35
+ @categories = SpudPostCategory.ordered
36
36
  params[:spud_post][:spud_site_ids] ||= []
37
37
  @post = SpudPost.new(post_params)
38
38
  if @post.save
@@ -59,7 +59,11 @@ private
59
59
  end
60
60
 
61
61
  def post_params
62
- params.require(:spud_post).permit(:published_at, :title, :content, :spud_user_id, :url_name, :visible, :comments_enabled, :meta_keywords, :meta_description, :content_format, :category_ids => [], :spud_site_ids => [])
62
+ permitted = [:published_at, :title, :content, :spud_user_id, :url_name, :visible, :comments_enabled, :meta_keywords, :meta_description, :content_format, :category_ids => [], :spud_site_ids => []]
63
+ if Spud::Blog.permitted_attributes.present?
64
+ permitted = permitted + Spud::Blog.permitted_attributes
65
+ end
66
+ params.require(:spud_post).permit(permitted)
63
67
  end
64
68
 
65
69
  end
@@ -3,7 +3,7 @@ class Blog::SitemapsController < Spud::ApplicationController
3
3
  respond_to :xml
4
4
 
5
5
  def show
6
- @posts = SpudPost.publicly.all
6
+ @posts = SpudPost.visible.ordered.all
7
7
  respond_with @pages
8
8
  end
9
9
 
@@ -6,7 +6,7 @@ class BlogController < ApplicationController
6
6
  before_filter :find_post, :only => [:show, :create_comment]
7
7
 
8
8
  def index
9
- @posts = SpudPost.visible.blog_posts.ordered.paginate(:page => get_page_number, :per_page => Spud::Blog.config.posts_per_page)
9
+ @posts = SpudPost.for_user(current_user).visible.blog_posts.ordered.paginate(:page => get_page_number, :per_page => Spud::Blog.config.posts_per_page)
10
10
  if Spud::Core.config.multisite_mode_enabled
11
11
  @posts = @posts.for_spud_site(current_site_id)
12
12
  end
@@ -41,9 +41,9 @@ class BlogController < ApplicationController
41
41
 
42
42
  if @post_category = SpudPostCategory.find_by_url_name(params[:category_url_name])
43
43
  if Spud::Core.config.multisite_mode_enabled
44
- @posts = @post_category.posts_with_children.visible.blog_posts.for_spud_site(current_site_id).from_archive(params[:archive_date]).paginate(:page => page, :per_page => Spud::Blog.config.posts_per_page)
44
+ @posts = @post_category.posts.for_user(current_user).visible.blog_posts.for_spud_site(current_site_id).from_archive(params[:archive_date]).paginate(:page => page, :per_page => Spud::Blog.config.posts_per_page)
45
45
  else
46
- @posts = @post_category.posts_with_children.visible.blog_posts.from_archive(params[:archive_date]).paginate(:page => page, :per_page => Spud::Blog.config.posts_per_page)
46
+ @posts = @post_category.posts.for_user(current_user).visible.blog_posts.from_archive(params[:archive_date]).paginate(:page => page, :per_page => Spud::Blog.config.posts_per_page)
47
47
  end
48
48
  else
49
49
  redirect_to blog_path
@@ -56,9 +56,9 @@ class BlogController < ApplicationController
56
56
 
57
57
  def archive
58
58
  if Spud::Core.config.multisite_mode_enabled
59
- @posts = SpudPost.visible.blog_posts.from_archive(params[:archive_date]).for_spud_site(current_site_id).paginate(:page => get_page_number, :per_page => Spud::Blog.config.posts_per_page)
59
+ @posts = SpudPost.for_user(current_user).visible.blog_posts.from_archive(params[:archive_date]).for_spud_site(current_site_id).paginate(:page => get_page_number, :per_page => Spud::Blog.config.posts_per_page)
60
60
  else
61
- @posts = SpudPost.visible.blog_posts.from_archive(params[:archive_date]).paginate(:page => get_page_number, :per_page => Spud::Blog.config.posts_per_page)
61
+ @posts = SpudPost.for_user(current_user).visible.blog_posts.from_archive(params[:archive_date]).paginate(:page => get_page_number, :per_page => Spud::Blog.config.posts_per_page)
62
62
  end
63
63
  respond_with @posts do |format|
64
64
  format.html { render 'index' }
@@ -101,10 +101,9 @@ class BlogController < ApplicationController
101
101
  private
102
102
 
103
103
  def find_post
104
- @post = SpudPost.find_by_url_name(params[:id])
104
+ @post = SpudPost.for_user(current_user).where(:url_name => params[:id]).first
105
105
  if @post.blank? || @post.is_private? || (Spud::Core.config.multisite_mode_enabled && !@post.spud_site_ids.include?(current_site_id))
106
- flash[:error] = "Post not found!"
107
- redirect_to blog_path and return false
106
+ raise Spud::NotFoundError.new(:item => 'post')
108
107
  end
109
108
  end
110
109
 
@@ -3,8 +3,10 @@ class NewsController < ApplicationController
3
3
  respond_to :html, :xml, :json, :rss
4
4
  layout Spud::Blog.news_layout
5
5
 
6
+ before_filter :find_post, :only => [:show]
7
+
6
8
  def index
7
- @posts = SpudPost.visible.news_posts.ordered.paginate(:page => params[:page], :per_page => Spud::Blog.config.posts_per_page)
9
+ @posts = SpudPost.for_user(current_user).visible.news_posts.ordered.paginate(:page => params[:page], :per_page => Spud::Blog.config.posts_per_page)
8
10
  if Spud::Core.config.multisite_mode_enabled
9
11
  @posts = @posts.for_spud_site(current_site_id)
10
12
  end
@@ -27,9 +29,9 @@ class NewsController < ApplicationController
27
29
  def category
28
30
  if @post_category = SpudPostCategory.find_by_url_name(params[:category_url_name])
29
31
  if Spud::Core.config.multisite_mode_enabled
30
- @posts = @post_category.posts_with_children.visible.news_posts.for_spud_site(current_site_id).from_archive(params[:archive_date]).paginate(:page => params[:page], :per_page => Spud::Blog.config.posts_per_page)
32
+ @posts = @post_category.posts.for_user(current_user).visible.news_posts.for_spud_site(current_site_id).from_archive(params[:archive_date]).paginate(:page => params[:page], :per_page => Spud::Blog.config.posts_per_page)
31
33
  else
32
- @posts = @post_category.posts_with_children.visible.news_posts.from_archive(params[:archive_date]).paginate(:page => params[:page], :per_page => Spud::Blog.config.posts_per_page)
34
+ @posts = @post_category.posts.for_user(current_user).visible.news_posts.from_archive(params[:archive_date]).paginate(:page => params[:page], :per_page => Spud::Blog.config.posts_per_page)
33
35
  end
34
36
  else
35
37
  redirect_to news_path
@@ -42,9 +44,9 @@ class NewsController < ApplicationController
42
44
 
43
45
  def archive
44
46
  if Spud::Core.config.multisite_mode_enabled
45
- @posts = SpudPost.visible.news_posts.for_spud_site(current_site_id).from_archive(params[:archive_date]).paginate(:page => params[:page], :per_page => Spud::Blog.config.posts_per_page)
47
+ @posts = SpudPost.for_user(current_user).visible.news_posts.for_spud_site(current_site_id).from_archive(params[:archive_date]).paginate(:page => params[:page], :per_page => Spud::Blog.config.posts_per_page)
46
48
  else
47
- @posts = SpudPost.visible.news_posts.from_archive(params[:archive_date]).paginate(:page => params[:page], :per_page => Spud::Blog.config.posts_per_page)
49
+ @posts = SpudPost.for_user(current_user).visible.news_posts.from_archive(params[:archive_date]).paginate(:page => params[:page], :per_page => Spud::Blog.config.posts_per_page)
48
50
  end
49
51
  respond_with @posts do |format|
50
52
  format.html { render 'index' }
@@ -52,13 +54,16 @@ class NewsController < ApplicationController
52
54
  end
53
55
 
54
56
  def show
55
- @post = SpudPost.find_by_url_name(params[:id])
56
- if @post.blank? || @post.is_private? || (Spud::Core.config.multisite_mode_enabled && !@post.spud_site_ids.include?(current_site_id))
57
- flash[:error] = "Post not found!"
58
- redirect_to news_path and return false
59
- else
60
- respond_with @post
61
- end
57
+ respond_with @post
58
+ end
59
+
60
+ private
61
+
62
+ def find_post
63
+ @post = SpudPost.for_user(current_user).where(:url_name => params[:id]).first
64
+ if @post.blank? || @post.is_private? || (Spud::Core.config.multisite_mode_enabled && !@post.spud_site_ids.include?(current_site_id))
65
+ raise Spud::NotFoundError.new(:item => 'post')
66
+ end
62
67
  end
63
68
 
64
69
  end
@@ -2,7 +2,7 @@ module BlogHelper
2
2
 
3
3
  def spud_post_category_select
4
4
  return select_tag 'category_url_name',
5
- options_for_select(SpudPostCategory.options_for_categories(:value => :url_name), params[:category_url_name]),
5
+ options_for_select(SpudPostCategory.options_for_categories(), params[:category_url_name]),
6
6
  :include_blank => true,
7
7
  :rel => 'category'
8
8
  end
@@ -0,0 +1,193 @@
1
+ class Spud::SpudPostModel < ActiveRecord::Base
2
+ self.table_name = 'spud_posts'
3
+
4
+ spud_searchable
5
+
6
+ has_many :spud_post_categories_posts, :foreign_key => 'spud_post_id'
7
+ has_many :categories,
8
+ :class_name => 'SpudPostCategory',
9
+ :through => :spud_post_categories_posts,
10
+ :source => :spud_post_category
11
+
12
+ belongs_to :author, :class_name => 'SpudUser', :foreign_key => 'spud_user_id'
13
+ has_many :comments, :class_name => 'SpudPostComment', :inverse_of => :post, :foreign_key => 'spud_post_id'
14
+ has_many :pending_comments, ->{ where(:spam => [nil, false], :approved => false) }, :class_name => "SpudPostComment", :foreign_key => 'spud_post_id'
15
+ has_many :visible_comments, ->{ where(:spam => [nil,false], :approved => true) }, :class_name => 'SpudPostComment', :foreign_key => 'spud_post_id'
16
+ has_many :spam_comments, ->{ where(:spam => true) }, :class_name => "SpudPostComment", :foreign_key => 'spud_post_id'
17
+ has_many :spud_permalinks,:as => :attachment
18
+ has_many :spud_post_sites, :dependent => :destroy
19
+
20
+ scope :blog_posts, ->{ where(:is_news => false) }
21
+ scope :news_posts, ->{ where(:is_news => true) }
22
+ scope :visible, ->{ where('visible = true AND published_at <= ?', Time.now.utc) }
23
+ scope :ordered, ->{ order('published_at desc') }
24
+
25
+ scope :for_user, ->(user){
26
+ if Spud::Blog.query_for_user.present?
27
+ where(Spud::Blog.query_for_user.call(user))
28
+ else
29
+ where({})
30
+ end
31
+ }
32
+
33
+ validates_presence_of :title, :content, :published_at, :spud_user_id, :url_name
34
+ validates_uniqueness_of :url_name
35
+ before_validation :set_url_name
36
+ after_save :set_spud_site_ids
37
+
38
+ acts_as_spud_liquid_content
39
+
40
+ attr_accessor :spud_site_ids
41
+
42
+ def self.for_spud_site(spud_site_id)
43
+ return joins(:spud_post_sites).where(:spud_post_sites => {:spud_site_id => spud_site_id})
44
+ end
45
+
46
+ def self.public_posts(page, per_page)
47
+ ActiveSupport::Deprecation.warn "SpudPost.public_posts is deprecated. Please the :visible, and :ordered scopes instead.", caller
48
+ return where('visible = ? AND published_at <= ?', true,Time.now.utc).order('published_at desc').paginate(:page => page, :per_page => per_page)
49
+ end
50
+
51
+ def self.public_blog_posts(page, per_page)
52
+ ActiveSupport::Deprecation.warn "SpudPost.public_blog_posts is deprecated. Please the :blog_posts, :visible, and :ordered scopes instead.", caller
53
+ return self.public_posts(page, per_page).where(:is_news => false)
54
+ end
55
+
56
+ def self.public_news_posts(page, per_page)
57
+ ActiveSupport::Deprecation.warn "SpudPost.public_news_posts is deprecated. Please the :news_posts, :visible, and :ordered scopes instead.", caller
58
+ return self.public_posts(page, per_page).where(:is_news => true)
59
+ end
60
+
61
+ def self.recent_posts(limit=5)
62
+ return where('visible = ? AND published_at <= ?', true, Time.now.utc).order('published_at desc').limit(limit)
63
+ end
64
+
65
+ def self.recent_blog_posts(limit=5)
66
+ return self.blog_posts.recent_posts(limit)
67
+ end
68
+
69
+ def self.recent_news_posts(limit=5)
70
+ return self.news_posts.recent_posts(limit)
71
+ end
72
+
73
+ def self.from_archive(date_string)
74
+ begin
75
+ date = Date.strptime(date_string, "%Y-%b")
76
+ return where(:published_at => date..date.end_of_month)
77
+ rescue
78
+ return all
79
+ end
80
+ end
81
+
82
+ #def self.posts_for_category_archive(category, )
83
+
84
+ # Returns an array of Date objects for months with public posts
85
+ def self.months_with_public_posts
86
+ # Select
87
+ # Month(published_at) as published_month,
88
+ # Year(published_at) as published_year
89
+ # From spud_posts
90
+ # Where visible = 1
91
+ # And published_at < '2012-01-30'
92
+ # Group By published_month, published_year
93
+ # Order By published_year desc, published_month desc
94
+ records = SpudPost.select('Extract(Month from published_at) as published_month, Extract(Year from published_at) as published_year').where('visible = ? AND published_at < ?', true, DateTime.now).group('published_month, published_year').order('published_year desc, published_month desc')
95
+ begin
96
+ return records.collect{ |r| Date.new(r[:published_year].to_i, r[:published_month].to_i) }
97
+ rescue Exception => e
98
+ logger.fatal "Exception occurred while fetching post archive dates:\n #{e.to_s}"
99
+ return []
100
+ end
101
+ end
102
+
103
+ def self.months_with_public_news_posts
104
+ records = SpudPost.select('Extract(Month from published_at) as published_month, Extract(Year from published_at) as published_year').where('visible = ? AND published_at < ? AND is_news = ?', true, DateTime.now, true).group('published_month, published_year').order('published_year desc, published_month desc')
105
+ begin
106
+ return records.collect{ |r| Date.new(r[:published_year].to_i, r[:published_month].to_i) }
107
+ rescue Exception => e
108
+ logger.fatal "Exception occurred while fetching post archive dates:\n #{e.to_s}"
109
+ end
110
+ end
111
+
112
+ def self.months_with_public_blog_posts
113
+ records = SpudPost.select('Extract(Month from published_at) as published_month, Extract(Year from published_at) as published_year').where('visible = ? AND published_at < ? AND is_news = ?', true, DateTime.now, false).group('published_month, published_year').order('published_year desc, published_month desc')
114
+ begin
115
+ return records.collect{ |r| Date.new(r[:published_year].to_i, r[:published_month].to_i) }
116
+ rescue Exception => e
117
+ logger.fatal "Exception occurred while fetching post archive dates:\n #{e.to_s}"
118
+ end
119
+ end
120
+
121
+ def postprocess_content
122
+ # if self.content_format == 'Markdown'
123
+ # require 'redcarpet'
124
+ # renderer = Redcarpet::Render::HTML.new
125
+ # extensions = {fenced_code_blocks: true}
126
+ # redcarpet = Redcarpet::Markdown.new(renderer, extensions)
127
+ # self.content_processed = redcarpet.render self.content
128
+ # else
129
+ template = Liquid::Template.parse(self.content)
130
+ self.content_processed = template.render()
131
+ # end
132
+ end
133
+
134
+ def content_processed
135
+ if read_attribute(:content_processed).blank?
136
+ postprocess_content
137
+ end
138
+ read_attribute(:content_processed)
139
+ end
140
+
141
+ def content_processed=(content)
142
+ write_attribute(:content_processed,content)
143
+ end
144
+
145
+ def display_date
146
+ return published_at.strftime("%b %d, %Y")
147
+ end
148
+
149
+ def is_public?
150
+ return (published_at < DateTime.now) && visible
151
+ end
152
+
153
+ def is_private?
154
+ return !is_public?
155
+ end
156
+
157
+ def category_names
158
+ return self.categories.collect{ |c| c.name }.join(', ')
159
+ end
160
+
161
+ # Spud site ids getter
162
+ def spud_site_ids
163
+ if @spud_site_ids.nil?
164
+ @spud_site_ids = spud_post_sites.collect{ |site| site.spud_site_id }
165
+ end
166
+ return @spud_site_ids
167
+ end
168
+
169
+ # Spud site ids setter
170
+ def spud_site_ids=(site_ids)
171
+ if site_ids.is_a?(Array)
172
+ @spud_site_ids = site_ids.collect{ |id| id.to_i }
173
+ else
174
+ raise 'Site ids must be an Array'
175
+ end
176
+ end
177
+
178
+ private
179
+
180
+ def set_url_name
181
+ self.url_name = "#{self.published_at.strftime('%Y-%m-%d')}-#{self.title.parameterize}"
182
+ end
183
+
184
+ def set_spud_site_ids
185
+ if Spud::Core.multisite_mode_enabled
186
+ _spud_post_sites = []
187
+ self.spud_site_ids.each do |site_id|
188
+ _spud_post_sites << SpudPostSite.new(:spud_post_id => id, :spud_site_id => site_id)
189
+ end
190
+ self.spud_post_sites = _spud_post_sites
191
+ end
192
+ end
193
+ end
@@ -1,186 +1,3 @@
1
- class SpudPost < ActiveRecord::Base
2
- spud_searchable
3
-
4
- has_many :spud_post_categories_posts
5
- has_many :categories,
6
- :class_name => 'SpudPostCategory',
7
- :through => :spud_post_categories_posts,
8
- :source => :spud_post_category
9
-
10
- belongs_to :author, :class_name => 'SpudUser', :foreign_key => 'spud_user_id'
11
- has_many :comments, :class_name => 'SpudPostComment', :inverse_of => :post
12
- has_many :pending_comments, ->{ where(:spam => [nil, false], :approved => false) }, :class_name => "SpudPostComment"
13
- has_many :visible_comments, ->{ where(:spam => [nil,false], :approved => true) }, :class_name => 'SpudPostComment'
14
- has_many :spam_comments, ->{ where(:spam => true) }, :class_name => "SpudPostComment"
15
- has_many :spud_permalinks,:as => :attachment
16
- has_many :spud_post_sites, :dependent => :destroy
17
-
18
- scope :publicly, ->{ where('visible = true AND published_at <= ?', Time.now.utc).order('published_at desc') }
19
- scope :future_posts, ->{ where('visible = true AND published_at > ?', Time.now.utc) }
20
-
21
- scope :blog_posts, ->{ where(:is_news => false) }
22
- scope :news_posts, ->{ where(:is_news => true) }
23
- scope :visible, ->{ where('visible = true AND published_at <= ?', Time.now.utc) }
24
- scope :ordered, ->{ order('published_at desc') }
25
-
26
- validates_presence_of :title, :content, :published_at, :spud_user_id, :url_name
27
- validates_uniqueness_of :url_name
28
- before_validation :set_url_name
29
- after_save :set_spud_site_ids
30
-
31
- acts_as_spud_liquid_content
32
-
33
- attr_accessor :spud_site_ids
34
-
35
- def self.for_spud_site(spud_site_id)
36
- return joins(:spud_post_sites).where(:spud_post_sites => {:spud_site_id => spud_site_id})
37
- end
38
-
39
- def self.public_posts(page, per_page)
40
- ActiveSupport::Deprecation.warn "SpudPost.public_posts is deprecated. Please the :visible, and :ordered scopes instead.", caller
41
- return where('visible = ? AND published_at <= ?', true,Time.now.utc).order('published_at desc').paginate(:page => page, :per_page => per_page)
42
- end
43
-
44
- def self.public_blog_posts(page, per_page)
45
- ActiveSupport::Deprecation.warn "SpudPost.public_blog_posts is deprecated. Please the :blog_posts, :visible, and :ordered scopes instead.", caller
46
- return self.public_posts(page, per_page).where(:is_news => false)
47
- end
48
-
49
- def self.public_news_posts(page, per_page)
50
- ActiveSupport::Deprecation.warn "SpudPost.public_news_posts is deprecated. Please the :news_posts, :visible, and :ordered scopes instead.", caller
51
- return self.public_posts(page, per_page).where(:is_news => true)
52
- end
53
-
54
- def self.recent_posts(limit=5)
55
- return where('visible = ? AND published_at <= ?', true, Time.now.utc).order('published_at desc').limit(limit)
56
- end
57
-
58
- def self.recent_blog_posts(limit=5)
59
- return self.blog_posts.recent_posts(limit)
60
- end
61
-
62
- def self.recent_news_posts(limit=5)
63
- return self.news_posts.recent_posts(limit)
64
- end
65
-
66
- def self.from_archive(date_string)
67
- begin
68
- date = Date.strptime(date_string, "%Y-%b")
69
- return where(:published_at => date..date.end_of_month)
70
- rescue
71
- return all
72
- end
73
- end
74
-
75
- #def self.posts_for_category_archive(category, )
76
-
77
- # Returns an array of Date objects for months with public posts
78
- def self.months_with_public_posts
79
- # Select
80
- # Month(published_at) as published_month,
81
- # Year(published_at) as published_year
82
- # From spud_posts
83
- # Where visible = 1
84
- # And published_at < '2012-01-30'
85
- # Group By published_month, published_year
86
- # Order By published_year desc, published_month desc
87
- records = SpudPost.select('Extract(Month from published_at) as published_month, Extract(Year from published_at) as published_year').where('visible = ? AND published_at < ?', true, DateTime.now).group('published_month, published_year').order('published_year desc, published_month desc')
88
- begin
89
- return records.collect{ |r| Date.new(r[:published_year].to_i, r[:published_month].to_i) }
90
- rescue Exception => e
91
- logger.fatal "Exception occurred while fetching post archive dates:\n #{e.to_s}"
92
- return []
93
- end
94
- end
95
-
96
- def self.months_with_public_news_posts
97
- records = SpudPost.select('Extract(Month from published_at) as published_month, Extract(Year from published_at) as published_year').where('visible = ? AND published_at < ? AND is_news = ?', true, DateTime.now, true).group('published_month, published_year').order('published_year desc, published_month desc')
98
- begin
99
- return records.collect{ |r| Date.new(r[:published_year].to_i, r[:published_month].to_i) }
100
- rescue Exception => e
101
- logger.fatal "Exception occurred while fetching post archive dates:\n #{e.to_s}"
102
- end
103
- end
104
-
105
- def self.months_with_public_blog_posts
106
- records = SpudPost.select('Extract(Month from published_at) as published_month, Extract(Year from published_at) as published_year').where('visible = ? AND published_at < ? AND is_news = ?', true, DateTime.now, false).group('published_month, published_year').order('published_year desc, published_month desc')
107
- begin
108
- return records.collect{ |r| Date.new(r[:published_year].to_i, r[:published_month].to_i) }
109
- rescue Exception => e
110
- logger.fatal "Exception occurred while fetching post archive dates:\n #{e.to_s}"
111
- end
112
- end
113
-
114
- def postprocess_content
115
- # if self.content_format == 'Markdown'
116
- # require 'redcarpet'
117
- # renderer = Redcarpet::Render::HTML.new
118
- # extensions = {fenced_code_blocks: true}
119
- # redcarpet = Redcarpet::Markdown.new(renderer, extensions)
120
- # self.content_processed = redcarpet.render self.content
121
- # else
122
- template = Liquid::Template.parse(self.content)
123
- self.content_processed = template.render()
124
- # end
125
- end
126
-
127
- def content_processed
128
- if read_attribute(:content_processed).blank?
129
- postprocess_content
130
- end
131
- read_attribute(:content_processed)
132
- end
133
-
134
- def content_processed=(content)
135
- write_attribute(:content_processed,content)
136
- end
137
-
138
- def display_date
139
- return published_at.strftime("%b %d, %Y")
140
- end
141
-
142
- def is_public?
143
- return (published_at < DateTime.now) && visible
144
- end
145
-
146
- def is_private?
147
- return !is_public?
148
- end
149
-
150
- def category_names
151
- return self.categories.collect{ |c| c.name }.join(', ')
152
- end
153
-
154
- # Spud site ids getter
155
- def spud_site_ids
156
- if @spud_site_ids.nil?
157
- @spud_site_ids = spud_post_sites.collect{ |site| site.spud_site_id }
158
- end
159
- return @spud_site_ids
160
- end
161
-
162
- # Spud site ids setter
163
- def spud_site_ids=(site_ids)
164
- if site_ids.is_a?(Array)
165
- @spud_site_ids = site_ids.collect{ |id| id.to_i }
166
- else
167
- raise 'Site ids must be an Array'
168
- end
169
- end
170
-
171
- private
172
-
173
- def set_url_name
174
- self.url_name = "#{self.published_at.strftime('%Y-%m-%d')}-#{self.title.parameterize}"
175
- end
176
-
177
- def set_spud_site_ids
178
- if Spud::Core.multisite_mode_enabled
179
- _spud_post_sites = []
180
- self.spud_site_ids.each do |site_id|
181
- _spud_post_sites << SpudPostSite.new(:spud_post_id => id, :spud_site_id => site_id)
182
- end
183
- self.spud_post_sites = _spud_post_sites
184
- end
185
- end
1
+ class SpudPost < Spud::SpudPostModel
2
+ # Copy this file to your app to extend the base SpudPost model
186
3
  end
@@ -1,6 +1,5 @@
1
1
  class SpudPostCategory < ActiveRecord::Base
2
2
  spud_searchable
3
- acts_as_nested_set
4
3
 
5
4
  has_and_belongs_to_many :posts,
6
5
  :class_name => 'SpudPost',
@@ -11,63 +10,21 @@ class SpudPostCategory < ActiveRecord::Base
11
10
  validates_uniqueness_of :name, :url_name
12
11
  before_validation :set_url_name
13
12
 
14
- before_destroy :update_child_categories
15
13
  after_update :touch_posts
16
14
  after_destroy :touch_posts
17
15
 
18
- # tell awesome_nested_set not to destroy descendants
19
- def skip_before_destroy
20
- return true
21
- end
22
-
23
- def self.grouped
24
- return all.group_by(&:parent_id)
25
- end
26
-
27
- # Returns an array of categories in order of heirarchy
28
- # :fitler Filters out a category by ID, and all of its children
29
- # :value Pick an attribute to be used in the value field, defaults to ID
30
- def self.options_for_categories(config={})
31
- collection = config[:collection] || self.grouped
32
- level = config[:level] || 0
33
- parent_id = config[:parent_id] || nil
34
- filter = config[:filter] || nil
35
- value = config[:value] || :id
36
- list = []
37
- if collection[parent_id]
38
- collection[parent_id].each do |c|
39
- if c.id != filter
40
- list << [level.times.collect{ '- ' }.join('') + c.name, c[value]]
41
- list += self.options_for_categories({:collection => collection, :parent_id => c.id, :level => level+1, :filter => filter, :value => value})
42
- end
43
- end
44
- end
45
- return list
46
- end
16
+ scope :ordered, ->{ order('name asc') }
47
17
 
48
- def posts_with_children
49
- category_ids = self.self_and_ancestors.collect{ |category| category.id }
50
- post_ids = SpudPostCategoriesPost.where(:spud_post_category_id => category_ids).collect{ |it| it.spud_post_id }
51
- return SpudPost.where(:id => post_ids)
18
+ def self.options_for_categories()
19
+ return ordered.select(:name, :url_name).collect{ |c| [c.name, c.url_name] }
52
20
  end
53
21
 
54
- private
22
+ private
55
23
 
56
24
  def set_url_name
57
25
  self.url_name = self.name.parameterize
58
26
  end
59
27
 
60
- def parent_is_valid
61
- if parent_id == self.id
62
- errors.add :base, 'Category cannot be its own parent'
63
- end
64
- end
65
-
66
- def update_child_categories
67
- self.children.update_all(:parent_id => self.parent_id)
68
- self.class.rebuild!
69
- end
70
-
71
28
  def touch_posts
72
29
  if self.name_changed?
73
30
  self.posts.update_all(:updated_at => Time.now)
@@ -9,15 +9,6 @@
9
9
  <%= f.text_field :name %>
10
10
  </div>
11
11
  </div>
12
- <div class="control-group">
13
- <%= label_tag :parent,'Parent',:class => "control-label" %>
14
- <div class="controls">
15
- <select name="spud_post_category[parent_id]">
16
- <option value="">No Parent</option>
17
- <%= options_for_select(SpudPostCategory.options_for_categories(:filter => @post_category.id), @post_category.parent_id) %>
18
- </select>
19
- </div>
20
- </div>
21
12
  </fieldset>
22
13
 
23
14
  <% end %>
@@ -4,6 +4,6 @@
4
4
  <% if @post_categories.length == 0 %>
5
5
  <li class="spud_blog_category_manager_empty">You do not have any Post Categories at this time.</li>
6
6
  <% end %>
7
- <%= render :partial => 'category', :collection => @post_categories[nil] %>
7
+ <%= render :partial => 'category', :collection => @post_categories %>
8
8
  </ul>
9
9
  </div>
@@ -1,9 +1,4 @@
1
1
  <%= content_tag :li, :class => 'spud_post_form_category', 'data-id' => category.id do %>
2
2
  <%= check_box_tag 'spud_post[category_ids][]', category.id, @post.category_ids.include?(category.id), :id => "spud_post_category_#{category.id}" %>
3
3
  <%= label_tag "spud_post_category_#{category.id}", category.name %>
4
- <ul>
5
- <% if @categories[category.id] %>
6
- <%= render :partial => '/admin/posts/category', :collection => @categories[category.id] %>
7
- <% end %>
8
- </ul>
9
- <% end %>
4
+ <% end %>
@@ -0,0 +1,9 @@
1
+ <!--
2
+ override me to supply custom form fields!
3
+ app/views/admin/posts/_custom_fields.html.erb
4
+
5
+ <h4>My Fields</h4>
6
+ <div class="spud_post_form_row">
7
+ ...etc
8
+ </div>
9
+ -->
@@ -17,17 +17,12 @@
17
17
  <%= f.text_area :content,:style => "width:100%;", :class => 'tinymce full-width', "data-format" => f.object.content_format%>
18
18
  </div>
19
19
 
20
- <% if Spud::Blog.config.has_custom_fields %>
21
- <fieldset>
22
- <legend>Custom Fields</legend>
23
- <%= render :partial => '/admin/posts/custom_fields', :locals => {:f => f} %>
24
- </fieldset>
25
- <% end %>
26
-
27
20
  <fieldset class="spud_post_form_fieldset">
28
21
  <legend>Advanced</legend>
29
22
 
30
23
  <div class="spud_post_form_col">
24
+ <%= render :partial => '/admin/posts/custom_fields', :locals => {:f => f} %>
25
+
31
26
  <h4>Meta Data</h4>
32
27
 
33
28
  <div class="spud_post_form_row">
@@ -101,7 +96,7 @@
101
96
  <%= link_to 'Add Category', new_admin_post_category_path, :class => 'btn btn-mini spud_post_add_category' %>
102
97
  <input type="hidden" name="spud_post[category_ids][]" value="" />
103
98
  <ul class="spud_post_categories_form">
104
- <%= render :partial => '/admin/posts/category', :collection => @categories[nil] %>
99
+ <%= render :partial => '/admin/posts/category', :collection => @categories %>
105
100
  </ul>
106
101
  </div>
107
102
 
@@ -8,7 +8,7 @@ xml.rss :version => "2.0" do
8
8
  for article in @posts
9
9
  xml.item do
10
10
  xml.title article.title
11
- xml.description article.content_processed
11
+ xml.description strip_tags(article.content_truncated).truncate(250)
12
12
  xml.pubDate article.created_at.to_s(:rfc822)
13
13
  xml.link blog_post_url(article.url_name)
14
14
  xml.guid blog_post_url(article.url_name)
@@ -8,11 +8,11 @@ xml.rss :version => "2.0" do
8
8
  for article in @posts
9
9
  xml.item do
10
10
  xml.title article.title
11
- xml.description article.content
11
+ xml.description strip_tags(article.content_processed).truncate(250)
12
12
  xml.pubDate article.created_at.to_s(:rfc822)
13
13
  xml.link news_post_url(article.url_name)
14
14
  xml.guid news_post_url(article.url_name)
15
15
  end
16
16
  end
17
17
  end
18
- end
18
+ end
@@ -0,0 +1,15 @@
1
+ class RemoveAwesomeNestedSetColumnsFromSpudPostCategories < ActiveRecord::Migration
2
+ def up
3
+ change_table :spud_post_categories do |t|
4
+ t.remove :lft, :rgt, :depth, :parent_id
5
+ end
6
+ end
7
+ def down
8
+ change_table :spud_post_categories do |t|
9
+ t.integer :lft
10
+ t.integer :rgt
11
+ t.integer :depth
12
+ t.inreger :parent_id
13
+ end
14
+ end
15
+ end
@@ -5,7 +5,7 @@ module Spud
5
5
  :base_layout, :news_layout, :blog_enabled,
6
6
  :news_enabled, :posts_per_page, :blog_path,
7
7
  :news_path, :enable_sitemap, :has_custom_fields,
8
- :cache_mode,
8
+ :cache_mode, :permitted_attributes, :query_for_user,
9
9
  :enable_rakismet, :enable_markdown, :default_comment_approval
10
10
  )
11
11
  self.base_layout = 'application'
@@ -21,5 +21,7 @@ module Spud
21
21
  self.enable_rakismet = false
22
22
  self.enable_markdown = false
23
23
  self.default_comment_approval = true
24
+ self.permitted_attributes = []
25
+ self.query_for_user = nil
24
26
  end
25
27
  end
@@ -1,17 +1,12 @@
1
1
  require 'tb_core'
2
2
  require 'tb_permalinks'
3
3
  require 'tb_liquid'
4
- require 'awesome_nested_set'
5
4
  require 'truncate_html'
6
5
 
7
6
  module Spud
8
7
  module Blog
9
8
  class Engine < Rails::Engine
10
9
 
11
- def self.require_model(model_name)
12
- require "#{root}/app/models/#{model_name}"
13
- end
14
-
15
10
  def self.require_controller(controller_name)
16
11
  require "#{root}/app/controllers/#{controller_name}"
17
12
  end
@@ -1,5 +1,5 @@
1
1
  module Spud
2
2
  module Blog
3
- VERSION = "1.1.2"
3
+ VERSION = "1.1.3"
4
4
  end
5
5
  end
@@ -2,8 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  describe BlogController, :type => :controller do
4
4
 
5
- before(:all) do
6
-
5
+ before(:each) do
6
+ activate_authlogic
7
7
  end
8
8
 
9
9
  describe :index do
@@ -12,6 +12,19 @@ describe BlogController, :type => :controller do
12
12
  get :index
13
13
  assigns(:posts).count.should be > 1
14
14
  end
15
+
16
+ it "should not display any posts" do
17
+ Spud::Blog.config.query_for_user = ->(user){
18
+ if user.blank?
19
+ '1=0'
20
+ else
21
+ {}
22
+ end
23
+ }
24
+ get :index
25
+ assigns(:posts).count.should be 0
26
+ Spud::Blog.config.query_for_user = nil
27
+ end
15
28
  end
16
29
 
17
30
  describe :create_comment do
@@ -1,3 +1,3 @@
1
- class ApplicationController < ActionController::Base
1
+ class ApplicationController < Spud::ApplicationController
2
2
  protect_from_forgery
3
3
  end
@@ -0,0 +1,6 @@
1
+ # This migration comes from tb_blog (originally 20140406182651)
2
+ class AddPrimaryKeyToSpudPostCategoriesPosts < ActiveRecord::Migration
3
+ def change
4
+ add_column :spud_post_categories_posts, :id, :primary_key
5
+ end
6
+ end
@@ -0,0 +1,16 @@
1
+ # This migration comes from tb_blog (originally 20140508200730)
2
+ class RemoveAwesomeNestedSetColumnsFromSpudPostCategories < ActiveRecord::Migration
3
+ def up
4
+ change_table :spud_post_categories do |t|
5
+ t.remove :lft, :rgt, :depth, :parent_id
6
+ end
7
+ end
8
+ def down
9
+ change_table :spud_post_categories do |t|
10
+ t.integer :lft
11
+ t.integer :rgt
12
+ t.integer :depth
13
+ t.inreger :parent_id
14
+ end
15
+ end
16
+ end
@@ -11,7 +11,7 @@
11
11
  #
12
12
  # It's strongly recommended that you check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(version: 20140113162805) do
14
+ ActiveRecord::Schema.define(version: 20140730131550) do
15
15
 
16
16
  create_table "spud_liquid_tags", force: true do |t|
17
17
  t.integer "attachment_id"
@@ -49,17 +49,12 @@ ActiveRecord::Schema.define(version: 20140113162805) do
49
49
  t.string "name"
50
50
  t.datetime "created_at"
51
51
  t.datetime "updated_at"
52
- t.integer "parent_id", default: 0
53
52
  t.string "url_name"
54
- t.integer "lft"
55
- t.integer "rgt"
56
- t.integer "depth"
57
53
  end
58
54
 
59
- add_index "spud_post_categories", ["parent_id"], name: "index_spud_post_categories_on_parent_id", using: :btree
60
55
  add_index "spud_post_categories", ["url_name"], name: "index_spud_post_categories_on_url_name", using: :btree
61
56
 
62
- create_table "spud_post_categories_posts", id: false, force: true do |t|
57
+ create_table "spud_post_categories_posts", force: true do |t|
63
58
  t.integer "spud_post_id"
64
59
  t.integer "spud_post_category_id"
65
60
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tb_blog
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Westlake Design
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-08 00:00:00.000000000 Z
11
+ date: 2014-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -80,20 +80,6 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: awesome_nested_set
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - '='
88
- - !ruby/object:Gem::Version
89
- version: 3.0.0.rc.3
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - '='
95
- - !ruby/object:Gem::Version
96
- version: 3.0.0.rc.3
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: mysql2
99
85
  requirement: !ruby/object:Gem::Requirement
@@ -217,7 +203,6 @@ files:
217
203
  - Rakefile
218
204
  - Readme.md
219
205
  - app/assets/images/spud/admin/news_thumb.png
220
- - app/assets/images/spud/admin/news_thumb@2x.png
221
206
  - app/assets/images/spud/admin/posts_thumb.png
222
207
  - app/assets/javascripts/admin/blog/application.js
223
208
  - app/assets/javascripts/admin/blog/post_categories.js
@@ -238,6 +223,7 @@ files:
238
223
  - app/helpers/blog/sitemaps_helper.rb
239
224
  - app/helpers/blog_helper.rb
240
225
  - app/helpers/news_helper.rb
226
+ - app/models/spud/spud_post_model.rb
241
227
  - app/models/spud_post.rb
242
228
  - app/models/spud_post_categories_post.rb
243
229
  - app/models/spud_post_category.rb
@@ -253,6 +239,7 @@ files:
253
239
  - app/views/admin/post_categories/new.html.erb
254
240
  - app/views/admin/post_comments/index.html.erb
255
241
  - app/views/admin/posts/_category.html.erb
242
+ - app/views/admin/posts/_custom_fields.html.erb
256
243
  - app/views/admin/posts/_form.html.erb
257
244
  - app/views/admin/posts/edit.html.erb
258
245
  - app/views/admin/posts/index.html.erb
@@ -282,6 +269,7 @@ files:
282
269
  - db/migrate/20130120151857_add_content_format_to_spud_posts.rb
283
270
  - db/migrate/20130121130612_add_content_processed_to_spud_post.rb
284
271
  - db/migrate/20140406182651_add_primary_key_to_spud_post_categories_posts.rb
272
+ - db/migrate/20140508200730_remove_awesome_nested_set_columns_from_spud_post_categories.rb
285
273
  - lib/generators/spud/blog/random_posts_generator.rb
286
274
  - lib/generators/spud/blog/views_generator.rb
287
275
  - lib/spud_blog/configuration.rb
@@ -341,6 +329,8 @@ files:
341
329
  - spec/dummy/db/migrate/20140110180430_add_content_format_to_spud_posts.tb_blog.rb
342
330
  - spec/dummy/db/migrate/20140110180431_add_content_processed_to_spud_post.tb_blog.rb
343
331
  - spec/dummy/db/migrate/20140113162805_create_tb_liquid_spud_liquid_tags.tb_liquid.rb
332
+ - spec/dummy/db/migrate/20140730131549_add_primary_key_to_spud_post_categories_posts.tb_blog.rb
333
+ - spec/dummy/db/migrate/20140730131550_remove_awesome_nested_set_columns_from_spud_post_categories.tb_blog.rb
344
334
  - spec/dummy/db/schema.rb
345
335
  - spec/dummy/public/404.html
346
336
  - spec/dummy/public/422.html
@@ -425,6 +415,8 @@ test_files:
425
415
  - spec/dummy/db/migrate/20140110180430_add_content_format_to_spud_posts.tb_blog.rb
426
416
  - spec/dummy/db/migrate/20140110180431_add_content_processed_to_spud_post.tb_blog.rb
427
417
  - spec/dummy/db/migrate/20140113162805_create_tb_liquid_spud_liquid_tags.tb_liquid.rb
418
+ - spec/dummy/db/migrate/20140730131549_add_primary_key_to_spud_post_categories_posts.tb_blog.rb
419
+ - spec/dummy/db/migrate/20140730131550_remove_awesome_nested_set_columns_from_spud_post_categories.tb_blog.rb
428
420
  - spec/dummy/db/schema.rb
429
421
  - spec/dummy/public/404.html
430
422
  - spec/dummy/public/422.html