spud_blog 0.8.14 → 0.8.15

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.
@@ -0,0 +1,3 @@
1
+ .comment_validity {
2
+ display:none;
3
+ }
@@ -25,7 +25,7 @@ class BlogController < ApplicationController
25
25
  @posts = SpudPost.public_blog_posts(params[:page], Spud::Blog.config.posts_per_page)
26
26
  if Spud::Core.config.multisite_mode_enabled
27
27
  @posts = @posts.for_spud_site(current_site_id)
28
- end
28
+ end
29
29
  respond_with @posts
30
30
  end
31
31
 
@@ -87,12 +87,16 @@ class BlogController < ApplicationController
87
87
  redirect_to blog_path and return false
88
88
  end
89
89
  @comment = @post.comments.new(params[:spud_post_comment])
90
+ @comment.user_agent = request.env["HTTP_USER_AGENT"]
91
+ @comment.user_ip = request.remote_ip
92
+ @comment.referrer = request.referrer
90
93
  @comment.approved = true
94
+ @comment.permalink = blog_post_url(@post.url_name)
91
95
  flash[:notice] = 'Your comment has been posted.' if @comment.save
92
96
  respond_with @comment do |format|
93
97
  format.html { redirect_to blog_post_path(@post.url_name, :anchor => 'spud_post_comment_form') }
94
98
  end
95
- end
99
+ end
96
100
 
97
101
  private
98
102
 
@@ -104,4 +108,4 @@ class BlogController < ApplicationController
104
108
  end
105
109
  end
106
110
 
107
- end
111
+ end
@@ -1,12 +1,13 @@
1
1
  class SpudPost < ActiveRecord::Base
2
2
  searchable
3
3
 
4
- has_and_belongs_to_many :categories,
4
+ has_and_belongs_to_many :categories,
5
5
  :class_name => 'SpudPostCategory',
6
- :join_table => 'spud_post_categories_posts',
6
+ :join_table => 'spud_post_categories_posts',
7
7
  :foreign_key => 'spud_post_id'
8
8
  belongs_to :author, :class_name => 'SpudUser', :foreign_key => 'spud_user_id'
9
9
  has_many :comments, :class_name => 'SpudPostComment'
10
+ has_many :visible_comments, :class_name => 'SpudPostComment',:conditions => {:spam => [nil,false]}
10
11
  has_many :spud_permalinks,:as => :attachment
11
12
  has_many :spud_post_sites, :dependent => :destroy
12
13
 
@@ -15,7 +16,7 @@ class SpudPost < ActiveRecord::Base
15
16
  validates_presence_of :title, :content, :published_at, :spud_user_id, :url_name
16
17
  validates_uniqueness_of :url_name
17
18
  before_validation :set_url_name
18
-
19
+
19
20
  after_save :set_spud_site_ids
20
21
 
21
22
  attr_accessible :is_news,:published_at,:title,:content,:spud_user_id,:url_name,:visible,:comments_enabled,:meta_keywords,:meta_description,:category_ids, :spud_site_ids
@@ -62,7 +63,7 @@ class SpudPost < ActiveRecord::Base
62
63
 
63
64
  # Returns an array of Date objects for months with public posts
64
65
  def self.months_with_public_posts
65
- # Select
66
+ # Select
66
67
  # Month(published_at) as published_month,
67
68
  # Year(published_at) as published_year
68
69
  # From spud_posts
@@ -140,4 +141,4 @@ class SpudPost < ActiveRecord::Base
140
141
  self.spud_post_sites = _spud_post_sites
141
142
  end
142
143
  end
143
- end
144
+ end
@@ -1,7 +1,19 @@
1
1
  class SpudPostComment < ActiveRecord::Base
2
+ if Spud::Blog.enable_rakismet
3
+ include Rakismet::Model
4
+ before_save :rakismet_check_for_spam
5
+ end
6
+
2
7
 
3
8
  validates_presence_of :author, :content
4
9
  belongs_to :post, :class_name => 'SpudPost', :foreign_key => 'spud_post_id', :counter_cache => :comments_count
5
-
6
- attr_accessible :author,:content,:spud_post_id
7
- end
10
+
11
+ attr_accessible :author,:content,:spud_post_id,:referrer,:spam,:user_agent,:user_ip,:permalink
12
+
13
+
14
+ def rakismet_check_for_spam
15
+ self.spam = self.spam?
16
+ return true
17
+ end
18
+
19
+ end
@@ -7,11 +7,14 @@
7
7
  <%= f.label :content %>
8
8
  <%= f.text_area :content %>
9
9
  </div>
10
- <div style="display:none;">
10
+ <div class="comment_validity">
11
11
  <%= label_tag 'Comment Validation' %>
12
12
  <%= text_field_tag 'comment_validation' %>
13
13
  </div>
14
14
  <div>
15
15
  <%= f.submit 'Post Comment' %>
16
16
  </div>
17
- <% end %>
17
+
18
+ <% end %>
19
+ <%= stylesheet_link_tag "spud/blog/validity.css", :media => "all" %>
20
+
@@ -32,6 +32,6 @@
32
32
  <%= render 'comment_form' %>
33
33
  </div>
34
34
  <ul id="spud_blog_post_comments">
35
- <%= render :partial => 'comment', :collection => @post.comments %>
35
+ <%= render :partial => 'comment', :collection => @post.visible_comments %>
36
36
  </ul>
37
- <% end %>
37
+ <% end %>
@@ -0,0 +1,8 @@
1
+ class AddSpamFieldsToSpudPostComments < ActiveRecord::Migration
2
+ def change
3
+ add_column :spud_post_comments, :spam, :boolean
4
+ add_column :spud_post_comments, :user_ip, :string
5
+ add_column :spud_post_comments, :user_agent, :string
6
+ add_column :spud_post_comments, :referrer, :string
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ class AddPermalinkToSpudPostComments < ActiveRecord::Migration
2
+ def change
3
+ add_column :spud_post_comments, :permalink, :string
4
+ end
5
+ end
@@ -1,12 +1,12 @@
1
1
  module Spud
2
2
  module Blog
3
3
  include ActiveSupport::Configurable
4
- config_accessor(
5
- :base_layout, :news_layout, :blog_enabled,
6
- :news_enabled, :posts_per_page, :blog_path,
7
- :news_path, :enable_sitemap, :has_custom_fields,
8
- :enable_action_caching, :action_caching_duration,
9
- :enable_full_page_caching
4
+ config_accessor(
5
+ :base_layout, :news_layout, :blog_enabled,
6
+ :news_enabled, :posts_per_page, :blog_path,
7
+ :news_path, :enable_sitemap, :has_custom_fields,
8
+ :enable_action_caching, :action_caching_duration,
9
+ :enable_full_page_caching,:enable_rakismet
10
10
  )
11
11
  self.base_layout = 'application'
12
12
  self.news_layout = nil
@@ -20,5 +20,6 @@ module Spud
20
20
  self.enable_action_caching = false
21
21
  self.action_caching_duration = 3600
22
22
  self.enable_full_page_caching = false
23
+ self.enable_rakismet = false
23
24
  end
24
- end
25
+ end
@@ -24,7 +24,7 @@ module Spud
24
24
  end
25
25
  if Spud::Blog.config.blog_enabled
26
26
  Spud::Core.config.admin_applications += [{
27
- :name => 'Blog Posts',
27
+ :name => 'Blog Posts',
28
28
  :thumbnail => 'spud/admin/posts_thumb.png',
29
29
  :url => '/spud/admin/posts',
30
30
  :order => 1
@@ -40,7 +40,7 @@ module Spud
40
40
  end
41
41
  end
42
42
  initializer :assets do
43
- Rails.application.config.assets.precompile += ['spud/admin/posts.css']
43
+ Rails.application.config.assets.precompile += ['spud/admin/posts.css','spud/blog/validity.css']
44
44
  end
45
45
  initializer :associations do
46
46
  SpudUser.class_eval do
@@ -52,6 +52,12 @@ module Spud
52
52
  Spud::Core.config.news_layout = Spud::Core.config.base_layout
53
53
  end
54
54
  end
55
+
56
+ initializer :rakismet do
57
+ if Spud::Blog.enable_rakismet
58
+ require 'rakismet'
59
+ end
60
+ end
55
61
  end
56
62
  end
57
63
  end
@@ -1,5 +1,5 @@
1
1
  module Spud
2
2
  module Blog
3
- VERSION = "0.8.14"
3
+ VERSION = "0.8.15"
4
4
  end
5
5
  end
@@ -0,0 +1,36 @@
1
+ Mysql2::Error: Table 'spud_blog_development.spud_users' doesn't exist: SHOW FULL FIELDS FROM `spud_users`
2
+ Mysql2::Error: Table 'spud_blog_development.spud_users' doesn't exist: SHOW FULL FIELDS FROM `spud_users`
3
+ Mysql2::Error: Table 'spud_blog_development.spud_users' doesn't exist: SHOW FULL FIELDS FROM `spud_users`
4
+  (153.8ms) CREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB
5
+  (287.7ms) CREATE UNIQUE INDEX `unique_schema_migrations` ON `schema_migrations` (`version`)
6
+  (0.2ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` 
7
+ Migrating to CreateSpudPosts (20120125180945)
8
+  (163.8ms) CREATE TABLE `spud_posts` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `spud_user_id` int(11), `title` varchar(255), `content` text, `comments_enabled` tinyint(1) DEFAULT 0, `visible` tinyint(1) DEFAULT 1, `published_at` datetime, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
9
+  (225.6ms) CREATE INDEX `index_spud_posts_on_spud_user_id` ON `spud_posts` (`spud_user_id`)
10
+  (178.6ms) CREATE INDEX `index_spud_posts_on_visible` ON `spud_posts` (`visible`)
11
+  (0.5ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20120125180945')
12
+ Migrating to CreateSpudPostCategories (20120125181022)
13
+  (214.2ms) CREATE TABLE `spud_post_categories` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `name` varchar(255), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
14
+  (209.6ms) CREATE TABLE `spud_post_categories_posts` (`spud_post_id` int(11), `spud_post_category_id` int(11)) ENGINE=InnoDB
15
+  (182.2ms) CREATE INDEX `index_spud_post_categories_posts_on_spud_post_category_id` ON `spud_post_categories_posts` (`spud_post_category_id`)
16
+  (0.6ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20120125181022')
17
+ Migrating to CreateSpudPostComments (20120125181359)
18
+  (171.4ms) CREATE TABLE `spud_post_comments` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `spud_post_id` int(11), `author` varchar(255), `content` text, `approved` tinyint(1) DEFAULT 0, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
19
+  (237.9ms) CREATE INDEX `index_spud_post_comments_on_spud_post_id` ON `spud_post_comments` (`spud_post_id`)
20
+  (227.0ms) CREATE INDEX `index_spud_post_comments_on_approved` ON `spud_post_comments` (`approved`)
21
+  (0.5ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20120125181359')
22
+ Migrating to AddUrlToSpudPosts (20120127143054)
23
+  (239.3ms) ALTER TABLE `spud_posts` ADD `url_name` varchar(255)
24
+  (234.5ms) CREATE INDEX `index_spud_posts_on_url_name` ON `spud_posts` (`url_name`)
25
+  (0.6ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20120127143054')
26
+ Migrating to AddUrlToSpudPostCategories (20120127144942)
27
+  (196.9ms) ALTER TABLE `spud_post_categories` ADD `parent_id` int(11) DEFAULT 0
28
+  (220.7ms) ALTER TABLE `spud_post_categories` ADD `url_name` varchar(255)
29
+  (179.0ms) CREATE INDEX `index_spud_post_categories_on_parent_id` ON `spud_post_categories` (`parent_id`)
30
+  (178.4ms) CREATE INDEX `index_spud_post_categories_on_url_name` ON `spud_post_categories` (`url_name`)
31
+  (0.6ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20120127144942')
32
+ Migrating to AddIsNewsToSpudPosts (20120210165540)
33
+  (207.1ms) ALTER TABLE `spud_posts` ADD `is_news` tinyint(1) DEFAULT 0
34
+  (212.3ms) CREATE INDEX `index_spud_posts_on_is_news` ON `spud_posts` (`is_news`)
35
+  (0.8ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20120210165540')
36
+  (0.2ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spud_blog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.14
4
+ version: 0.8.15
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-23 00:00:00.000000000 Z
12
+ date: 2012-08-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -214,6 +214,7 @@ files:
214
214
  - app/assets/stylesheets/spud/admin/post_comments.css
215
215
  - app/assets/stylesheets/spud/admin/posts.css
216
216
  - app/assets/stylesheets/spud/blog/sitemaps.css
217
+ - app/assets/stylesheets/spud/blog/validity.css
217
218
  - app/controllers/blog_controller.rb
218
219
  - app/controllers/news_controller.rb
219
220
  - app/controllers/spud/admin/news_posts_controller.rb
@@ -268,6 +269,8 @@ files:
268
269
  - db/migrate/20120309181917_add_meta_to_posts.rb
269
270
  - db/migrate/20120413020437_add_comments_counter_to_spud_posts.rb
270
271
  - db/migrate/20120713150446_create_spud_post_sites.rb
272
+ - db/migrate/20120825142547_add_spam_fields_to_spud_post_comments.rb
273
+ - db/migrate/20120825144506_add_permalink_to_spud_post_comments.rb
271
274
  - lib/generators/spud/blog/random_posts_generator.rb
272
275
  - lib/generators/spud/blog/views_generator.rb
273
276
  - lib/spud_blog/configuration.rb
@@ -278,6 +281,7 @@ files:
278
281
  - MIT-LICENSE
279
282
  - Rakefile
280
283
  - Readme.markdown
284
+ - test/dummy/log/development.log
281
285
  - test/fixtures/spud_post_sites.yml
282
286
  - test/unit/spud_post_site_test.rb
283
287
  homepage: http://github.com/davydotcom/spud_blog
@@ -294,7 +298,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
294
298
  version: '0'
295
299
  segments:
296
300
  - 0
297
- hash: -4202281715850105173
301
+ hash: 1089695411037407557
298
302
  required_rubygems_version: !ruby/object:Gem::Requirement
299
303
  none: false
300
304
  requirements:
@@ -303,7 +307,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
303
307
  version: '0'
304
308
  segments:
305
309
  - 0
306
- hash: -4202281715850105173
310
+ hash: 1089695411037407557
307
311
  requirements: []
308
312
  rubyforge_project:
309
313
  rubygems_version: 1.8.24
@@ -311,5 +315,6 @@ signing_key:
311
315
  specification_version: 3
312
316
  summary: Spud Blog Engine.
313
317
  test_files:
318
+ - test/dummy/log/development.log
314
319
  - test/fixtures/spud_post_sites.yml
315
320
  - test/unit/spud_post_site_test.rb