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.
- data/app/assets/stylesheets/spud/blog/validity.css +3 -0
- data/app/controllers/blog_controller.rb +7 -3
- data/app/models/spud_post.rb +6 -5
- data/app/models/spud_post_comment.rb +15 -3
- data/app/views/blog/_comment_form.html.erb +5 -2
- data/app/views/blog/show.html.erb +2 -2
- data/db/migrate/20120825142547_add_spam_fields_to_spud_post_comments.rb +8 -0
- data/db/migrate/20120825144506_add_permalink_to_spud_post_comments.rb +5 -0
- data/lib/spud_blog/configuration.rb +8 -7
- data/lib/spud_blog/engine.rb +8 -2
- data/lib/spud_blog/version.rb +1 -1
- data/test/dummy/log/development.log +36 -0
- metadata +9 -4
@@ -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
|
data/app/models/spud_post.rb
CHANGED
@@ -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
|
-
|
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
|
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
|
-
|
17
|
+
|
18
|
+
<% end %>
|
19
|
+
<%= stylesheet_link_tag "spud/blog/validity.css", :media => "all" %>
|
20
|
+
|
@@ -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
|
@@ -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
|
data/lib/spud_blog/engine.rb
CHANGED
@@ -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
|
data/lib/spud_blog/version.rb
CHANGED
@@ -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
|
+
[1m[36m (153.8ms)[0m [1mCREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB[0m
|
5
|
+
[1m[35m (287.7ms)[0m CREATE UNIQUE INDEX `unique_schema_migrations` ON `schema_migrations` (`version`)
|
6
|
+
[1m[36m (0.2ms)[0m [1mSELECT `schema_migrations`.`version` FROM `schema_migrations` [0m
|
7
|
+
Migrating to CreateSpudPosts (20120125180945)
|
8
|
+
[1m[35m (163.8ms)[0m 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
|
+
[1m[36m (225.6ms)[0m [1mCREATE INDEX `index_spud_posts_on_spud_user_id` ON `spud_posts` (`spud_user_id`)[0m
|
10
|
+
[1m[35m (178.6ms)[0m CREATE INDEX `index_spud_posts_on_visible` ON `spud_posts` (`visible`)
|
11
|
+
[1m[36m (0.5ms)[0m [1mINSERT INTO `schema_migrations` (`version`) VALUES ('20120125180945')[0m
|
12
|
+
Migrating to CreateSpudPostCategories (20120125181022)
|
13
|
+
[1m[35m (214.2ms)[0m 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
|
+
[1m[36m (209.6ms)[0m [1mCREATE TABLE `spud_post_categories_posts` (`spud_post_id` int(11), `spud_post_category_id` int(11)) ENGINE=InnoDB[0m
|
15
|
+
[1m[35m (182.2ms)[0m CREATE INDEX `index_spud_post_categories_posts_on_spud_post_category_id` ON `spud_post_categories_posts` (`spud_post_category_id`)
|
16
|
+
[1m[36m (0.6ms)[0m [1mINSERT INTO `schema_migrations` (`version`) VALUES ('20120125181022')[0m
|
17
|
+
Migrating to CreateSpudPostComments (20120125181359)
|
18
|
+
[1m[35m (171.4ms)[0m 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
|
+
[1m[36m (237.9ms)[0m [1mCREATE INDEX `index_spud_post_comments_on_spud_post_id` ON `spud_post_comments` (`spud_post_id`)[0m
|
20
|
+
[1m[35m (227.0ms)[0m CREATE INDEX `index_spud_post_comments_on_approved` ON `spud_post_comments` (`approved`)
|
21
|
+
[1m[36m (0.5ms)[0m [1mINSERT INTO `schema_migrations` (`version`) VALUES ('20120125181359')[0m
|
22
|
+
Migrating to AddUrlToSpudPosts (20120127143054)
|
23
|
+
[1m[35m (239.3ms)[0m ALTER TABLE `spud_posts` ADD `url_name` varchar(255)
|
24
|
+
[1m[36m (234.5ms)[0m [1mCREATE INDEX `index_spud_posts_on_url_name` ON `spud_posts` (`url_name`)[0m
|
25
|
+
[1m[35m (0.6ms)[0m INSERT INTO `schema_migrations` (`version`) VALUES ('20120127143054')
|
26
|
+
Migrating to AddUrlToSpudPostCategories (20120127144942)
|
27
|
+
[1m[36m (196.9ms)[0m [1mALTER TABLE `spud_post_categories` ADD `parent_id` int(11) DEFAULT 0[0m
|
28
|
+
[1m[35m (220.7ms)[0m ALTER TABLE `spud_post_categories` ADD `url_name` varchar(255)
|
29
|
+
[1m[36m (179.0ms)[0m [1mCREATE INDEX `index_spud_post_categories_on_parent_id` ON `spud_post_categories` (`parent_id`)[0m
|
30
|
+
[1m[35m (178.4ms)[0m CREATE INDEX `index_spud_post_categories_on_url_name` ON `spud_post_categories` (`url_name`)
|
31
|
+
[1m[36m (0.6ms)[0m [1mINSERT INTO `schema_migrations` (`version`) VALUES ('20120127144942')[0m
|
32
|
+
Migrating to AddIsNewsToSpudPosts (20120210165540)
|
33
|
+
[1m[35m (207.1ms)[0m ALTER TABLE `spud_posts` ADD `is_news` tinyint(1) DEFAULT 0
|
34
|
+
[1m[36m (212.3ms)[0m [1mCREATE INDEX `index_spud_posts_on_is_news` ON `spud_posts` (`is_news`)[0m
|
35
|
+
[1m[35m (0.8ms)[0m INSERT INTO `schema_migrations` (`version`) VALUES ('20120210165540')
|
36
|
+
[1m[36m (0.2ms)[0m [1mSELECT `schema_migrations`.`version` FROM `schema_migrations` [0m
|
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.
|
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-
|
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:
|
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:
|
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
|