tb_blog 1.3.2 → 1.3.3

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.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/Readme.md +1 -15
  3. data/app/controllers/admin/posts_controller.rb +26 -2
  4. data/app/controllers/concerns/blog_url_helpers.rb +1 -10
  5. data/app/controllers/posts_controller.rb +0 -31
  6. data/app/helpers/admin/posts_helper.rb +12 -1
  7. data/app/helpers/blog_helper.rb +5 -0
  8. data/app/models/spud/spud_post_model.rb +18 -5
  9. data/app/views/admin/posts/_form.html.erb +6 -1
  10. data/app/views/admin/posts/index.html.erb +15 -7
  11. data/app/views/posts/_disqus.html.erb +18 -0
  12. data/app/views/posts/index.html.erb +8 -1
  13. data/app/views/posts/show.html.erb +4 -18
  14. data/config/routes.rb +1 -11
  15. data/db/migrate/20151015151133_add_custom_author_to_post.rb +5 -0
  16. data/db/migrate/20160216144708_add_identifier_to_spud_posts.rb +6 -0
  17. data/db/optional/20160216153113_drop_spud_post_comments.rb +29 -0
  18. data/lib/spud_blog/configuration.rb +3 -6
  19. data/lib/spud_blog/engine.rb +4 -12
  20. data/lib/spud_blog/version.rb +1 -1
  21. data/spec/controllers/admin/posts_controller_spec.rb +23 -1
  22. data/spec/controllers/posts_controller_spec.rb +0 -26
  23. data/spec/dummy/config/application.rb +5 -0
  24. data/spec/dummy/db/migrate/20151015154040_add_custom_author_to_post.tb_blog.rb +6 -0
  25. data/spec/dummy/db/migrate/20160215174632_add_requires_password_change_to_spud_users.tb_core.rb +6 -0
  26. data/spec/dummy/db/migrate/20160215174633_create_tb_redirects.tb_redirects.rb +15 -0
  27. data/spec/dummy/db/migrate/20160216150847_add_identifier_to_spud_posts.tb_blog.rb +7 -0
  28. data/spec/dummy/db/migrate/20160216153113_drop_spud_post_comments.rb +29 -0
  29. data/spec/dummy/db/schema.rb +37 -40
  30. data/spec/helpers/admin/posts_helper_spec.rb +15 -0
  31. data/spec/helpers/blog_helper_spec.rb +13 -0
  32. data/spec/models/spud_post_spec.rb +19 -0
  33. data/spec/rails_helper.rb +1 -1
  34. metadata +33 -25
  35. data/app/assets/javascripts/admin/blog/post_comments.js +0 -37
  36. data/app/controllers/admin/post_comments_controller.rb +0 -80
  37. data/app/helpers/admin/post_comments_helper.rb +0 -3
  38. data/app/models/spud_post_comment.rb +0 -42
  39. data/app/views/admin/post_comments/index.html.erb +0 -60
  40. data/db/migrate/20120125181359_create_spud_post_comments.rb +0 -13
  41. data/db/migrate/20120413020437_add_comments_counter_to_spud_posts.rb +0 -12
  42. data/db/migrate/20120825142547_add_spam_fields_to_spud_post_comments.rb +0 -8
  43. data/db/migrate/20120825144506_add_permalink_to_spud_post_comments.rb +0 -5
  44. data/db/migrate/20140811152252_add_blog_key_to_spud_post_comments.rb +0 -6
  45. data/spec/factories/spud_user_factories.rb +0 -31
  46. /data/app/assets/images/{spud/admin → admin}/news_thumb.png +0 -0
  47. /data/app/assets/images/{spud/admin → admin}/posts_thumb.png +0 -0
@@ -0,0 +1,29 @@
1
+ # This migration will drop spud_post_comments from your database. It has been excluded
2
+ # from the migrations directory to avoid accidential data loss on upgrading.
3
+ #
4
+ # If you wish to completely remove spud_post_comments from your app, simply copy this file
5
+ # into your db/migrations directory and run db:migrate.
6
+ #
7
+
8
+ class DropSpudPostComments < ActiveRecord::Migration
9
+ def up
10
+ drop_table :spud_post_comments
11
+ remove_column :spud_posts, :comments_count
12
+ end
13
+ def down
14
+ create_table :spud_post_comments do |t|
15
+ t.integer :spud_post_id
16
+ t.string :author
17
+ t.text :content
18
+ t.boolean :approved, :default => false
19
+ t.boolean :spam
20
+ t.string :user_ip
21
+ t.string :user_agent
22
+ t.string :referrer
23
+ t.string :permalink
24
+ t.string :blog_key
25
+ t.timestamps
26
+ end
27
+ add_column :spud_posts, :comments_count, :integer
28
+ end
29
+ 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: 20150116195007) do
14
+ ActiveRecord::Schema.define(version: 20160216153113) do
15
15
 
16
16
  create_table "spud_liquid_tags", force: :cascade do |t|
17
17
  t.integer "attachment_id", limit: 4
@@ -61,45 +61,28 @@ ActiveRecord::Schema.define(version: 20150116195007) do
61
61
 
62
62
  add_index "spud_post_categories_posts", ["spud_post_category_id"], name: "index_spud_post_categories_posts_on_spud_post_category_id", using: :btree
63
63
 
64
- create_table "spud_post_comments", force: :cascade do |t|
65
- t.integer "spud_post_id", limit: 4
66
- t.string "author", limit: 255
67
- t.text "content", limit: 65535
68
- t.boolean "approved", limit: 1, default: false
69
- t.datetime "created_at"
70
- t.datetime "updated_at"
71
- t.boolean "spam", limit: 1
72
- t.string "user_ip", limit: 255
73
- t.string "user_agent", limit: 255
74
- t.string "referrer", limit: 255
75
- t.string "permalink", limit: 255
76
- t.string "blog_key", limit: 255
77
- end
78
-
79
- add_index "spud_post_comments", ["approved"], name: "index_spud_post_comments_on_approved", using: :btree
80
- add_index "spud_post_comments", ["blog_key"], name: "index_spud_post_comments_on_blog_key", using: :btree
81
- add_index "spud_post_comments", ["spud_post_id"], name: "index_spud_post_comments_on_spud_post_id", using: :btree
82
-
83
64
  create_table "spud_posts", force: :cascade do |t|
84
65
  t.integer "spud_user_id", limit: 4
85
66
  t.string "title", limit: 255
86
67
  t.text "content", limit: 65535
87
- t.boolean "comments_enabled", limit: 1, default: false
88
- t.boolean "visible", limit: 1, default: true
68
+ t.boolean "comments_enabled", default: false
69
+ t.boolean "visible", default: true
89
70
  t.datetime "published_at"
90
71
  t.datetime "created_at"
91
72
  t.datetime "updated_at"
92
73
  t.string "url_name", limit: 255
93
- t.boolean "is_news", limit: 1, default: false
74
+ t.boolean "is_news", default: false
94
75
  t.string "meta_keywords", limit: 255
95
76
  t.text "meta_description", limit: 65535
96
- t.integer "comments_count", limit: 4, default: 0
97
77
  t.string "content_format", limit: 255, default: "HTML"
98
78
  t.text "content_processed", limit: 65535
99
79
  t.string "blog_key", limit: 255
80
+ t.string "custom_author", limit: 255
81
+ t.string "identifier", limit: 255
100
82
  end
101
83
 
102
84
  add_index "spud_posts", ["blog_key"], name: "index_spud_posts_on_blog_key", using: :btree
85
+ add_index "spud_posts", ["identifier"], name: "index_spud_posts_on_identifier", unique: true, using: :btree
103
86
  add_index "spud_posts", ["is_news"], name: "index_spud_posts_on_is_news", using: :btree
104
87
  add_index "spud_posts", ["spud_user_id"], name: "index_spud_posts_on_spud_user_id", using: :btree
105
88
  add_index "spud_posts", ["url_name"], name: "index_spud_posts_on_url_name", using: :btree
@@ -130,31 +113,45 @@ ActiveRecord::Schema.define(version: 20150116195007) do
130
113
  end
131
114
 
132
115
  create_table "spud_users", force: :cascade do |t|
133
- t.string "first_name", limit: 255
134
- t.string "last_name", limit: 255
135
- t.boolean "super_admin", limit: 1
136
- t.string "login", limit: 255, null: false
137
- t.string "email", limit: 255, null: false
138
- t.string "crypted_password", limit: 255, null: false
139
- t.string "password_salt", limit: 255, null: false
140
- t.string "persistence_token", limit: 255, null: false
141
- t.string "single_access_token", limit: 255, null: false
142
- t.string "perishable_token", limit: 255, null: false
143
- t.integer "login_count", limit: 4, default: 0, null: false
144
- t.integer "failed_login_count", limit: 4, default: 0, null: false
116
+ t.string "first_name", limit: 255
117
+ t.string "last_name", limit: 255
118
+ t.boolean "super_admin"
119
+ t.string "login", limit: 255, null: false
120
+ t.string "email", limit: 255, null: false
121
+ t.string "crypted_password", limit: 255, null: false
122
+ t.string "password_salt", limit: 255, null: false
123
+ t.string "persistence_token", limit: 255, null: false
124
+ t.string "single_access_token", limit: 255, null: false
125
+ t.string "perishable_token", limit: 255, null: false
126
+ t.integer "login_count", limit: 4, default: 0, null: false
127
+ t.integer "failed_login_count", limit: 4, default: 0, null: false
145
128
  t.datetime "last_request_at"
146
129
  t.datetime "current_login_at"
147
130
  t.datetime "last_login_at"
148
- t.string "current_login_ip", limit: 255
149
- t.string "last_login_ip", limit: 255
131
+ t.string "current_login_ip", limit: 255
132
+ t.string "last_login_ip", limit: 255
150
133
  t.datetime "created_at"
151
134
  t.datetime "updated_at"
152
- t.string "time_zone", limit: 255
153
- t.integer "spud_role_id", limit: 4
135
+ t.string "time_zone", limit: 255
136
+ t.integer "spud_role_id", limit: 4
137
+ t.boolean "requires_password_change", default: false
154
138
  end
155
139
 
156
140
  add_index "spud_users", ["email"], name: "index_spud_users_on_email", using: :btree
157
141
  add_index "spud_users", ["login"], name: "index_spud_users_on_login", using: :btree
158
142
  add_index "spud_users", ["spud_role_id"], name: "index_spud_users_on_spud_role_id", using: :btree
159
143
 
144
+ create_table "tb_redirects", force: :cascade do |t|
145
+ t.string "owner_type", limit: 255
146
+ t.integer "owner_id", limit: 4
147
+ t.string "source", limit: 255, null: false
148
+ t.string "destination", limit: 255, null: false
149
+ t.string "created_by", limit: 255
150
+ t.datetime "created_at", null: false
151
+ t.datetime "updated_at", null: false
152
+ end
153
+
154
+ add_index "tb_redirects", ["owner_type", "owner_id"], name: "index_tb_redirects_on_owner_type_and_owner_id", using: :btree
155
+ add_index "tb_redirects", ["source"], name: "index_tb_redirects_on_source", unique: true, using: :btree
156
+
160
157
  end
@@ -0,0 +1,15 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe Admin::PostsHelper, type: :helper do
4
+
5
+ describe '#link_to_disqus_comment_count' do
6
+ it 'should return a link with the disqus identifier' do
7
+ post = FactoryGirl.create(:spud_post)
8
+ result = helper.link_to_disqus_comment_count(post)
9
+
10
+ expect(result).to include("data-disqus-identifier=\"#{post.identifier}\"")
11
+ expect(result).to include("testblog.disqus.com")
12
+ end
13
+ end
14
+
15
+ end
@@ -0,0 +1,13 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe BlogHelper, type: :helper do
4
+
5
+ describe '#disqus_comment_count_for_post' do
6
+ it 'should return a tag with the disqus identifier' do
7
+ post = FactoryGirl.create(:spud_post)
8
+ result = helper.disqus_comment_count_for_post(post)
9
+ expect(result).to include("data-disqus-identifier=\"#{post.identifier}\"")
10
+ end
11
+ end
12
+
13
+ end
@@ -0,0 +1,19 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe SpudPost, :type => :model do
4
+
5
+ describe '#display_date' do
6
+ it 'should return a date string' do
7
+ post = FactoryGirl.create(:spud_post)
8
+ expect(post.display_date).to eq(post.published_at.strftime("%b %d, %Y"))
9
+ end
10
+ end
11
+
12
+ describe '#set_identifier' do
13
+ it 'should set a random identifier' do
14
+ post = FactoryGirl.create(:spud_post, :identifier => nil)
15
+ expect(post.identifier).to be_a(String)
16
+ end
17
+ end
18
+
19
+ end
data/spec/rails_helper.rb CHANGED
@@ -3,11 +3,11 @@ ENV["RAILS_ENV"] ||= 'test'
3
3
 
4
4
  require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
5
  require 'spec_helper'
6
- require 'authlogic_helper'
7
6
  require 'rspec/rails'
8
7
  require 'database_cleaner'
9
8
  require 'simplecov'
10
9
  require 'factory_girl_rails'
10
+ require 'tb_core/test_helper'
11
11
 
12
12
  SimpleCov.start 'rails'
13
13
 
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.3.2
4
+ version: 1.3.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: 2015-10-12 00:00:00.000000000 Z
11
+ date: 2016-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '4.0'
19
+ version: 4.2.5
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '4.0'
26
+ version: 4.2.5
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: tb_core
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.2'
33
+ version: 1.3.7
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.2'
40
+ version: 1.3.7
41
41
  - !ruby/object:Gem::Dependency
42
- name: tb_permalinks
42
+ name: tb_redirects
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '1.0'
47
+ version: 0.0.1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '1.0'
54
+ version: 0.0.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: tb_liquid
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 3.1.0
103
+ version: 3.4.2
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 3.1.0
110
+ version: 3.4.2
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: factory_girl_rails
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -160,21 +160,18 @@ files:
160
160
  - MIT-LICENSE
161
161
  - Rakefile
162
162
  - Readme.md
163
- - app/assets/images/spud/admin/news_thumb.png
164
- - app/assets/images/spud/admin/posts_thumb.png
163
+ - app/assets/images/admin/news_thumb.png
164
+ - app/assets/images/admin/posts_thumb.png
165
165
  - app/assets/javascripts/admin/blog/application.js
166
166
  - app/assets/javascripts/admin/blog/post_categories.js
167
- - app/assets/javascripts/admin/blog/post_comments.js
168
167
  - app/assets/javascripts/admin/blog/posts.js
169
168
  - app/assets/stylesheets/admin/blog/application.css.scss
170
169
  - app/controllers/admin/post_categories_controller.rb
171
- - app/controllers/admin/post_comments_controller.rb
172
170
  - app/controllers/admin/posts_controller.rb
173
171
  - app/controllers/concerns/blog_url_helpers.rb
174
172
  - app/controllers/posts_controller.rb
175
173
  - app/helpers/admin/news_posts_helper.rb
176
174
  - app/helpers/admin/post_categories_helper.rb
177
- - app/helpers/admin/post_comments_helper.rb
178
175
  - app/helpers/admin/posts_helper.rb
179
176
  - app/helpers/blog/sitemaps_helper.rb
180
177
  - app/helpers/blog_helper.rb
@@ -184,14 +181,12 @@ files:
184
181
  - app/models/spud_post.rb
185
182
  - app/models/spud_post_categories_post.rb
186
183
  - app/models/spud_post_category.rb
187
- - app/models/spud_post_comment.rb
188
184
  - app/models/spud_post_site.rb
189
185
  - app/views/admin/post_categories/_category.html.erb
190
186
  - app/views/admin/post_categories/_form.html.erb
191
187
  - app/views/admin/post_categories/edit.html.erb
192
188
  - app/views/admin/post_categories/index.html.erb
193
189
  - app/views/admin/post_categories/new.html.erb
194
- - app/views/admin/post_comments/index.html.erb
195
190
  - app/views/admin/posts/_category.html.erb
196
191
  - app/views/admin/posts/_custom_fields.html.erb
197
192
  - app/views/admin/posts/_form.html.erb
@@ -199,6 +194,7 @@ files:
199
194
  - app/views/admin/posts/index.html.erb
200
195
  - app/views/admin/posts/new.html.erb
201
196
  - app/views/posts/_comment_form.html.erb
197
+ - app/views/posts/_disqus.html.erb
202
198
  - app/views/posts/index.html.erb
203
199
  - app/views/posts/index.rss.builder
204
200
  - app/views/posts/show.html.erb
@@ -206,23 +202,21 @@ files:
206
202
  - config/routes.rb
207
203
  - db/migrate/20120125180945_create_spud_posts.rb
208
204
  - db/migrate/20120125181022_create_spud_post_categories.rb
209
- - db/migrate/20120125181359_create_spud_post_comments.rb
210
205
  - db/migrate/20120127143054_add_url_to_spud_posts.rb
211
206
  - db/migrate/20120127144942_add_url_to_spud_post_categories.rb
212
207
  - db/migrate/20120210165540_add_is_news_to_spud_posts.rb
213
208
  - db/migrate/20120309181917_add_meta_to_posts.rb
214
- - db/migrate/20120413020437_add_comments_counter_to_spud_posts.rb
215
209
  - db/migrate/20120713150446_create_spud_post_sites.rb
216
- - db/migrate/20120825142547_add_spam_fields_to_spud_post_comments.rb
217
- - db/migrate/20120825144506_add_permalink_to_spud_post_comments.rb
218
210
  - db/migrate/20121113135812_add_nested_set_to_post_categories.rb
219
211
  - db/migrate/20130120151857_add_content_format_to_spud_posts.rb
220
212
  - db/migrate/20130121130612_add_content_processed_to_spud_post.rb
221
213
  - db/migrate/20140406182651_add_primary_key_to_spud_post_categories_posts.rb
222
214
  - db/migrate/20140508200730_remove_awesome_nested_set_columns_from_spud_post_categories.rb
223
215
  - db/migrate/20140808132950_add_blog_key_to_spud_posts.rb
224
- - db/migrate/20140811152252_add_blog_key_to_spud_post_comments.rb
225
216
  - db/migrate/20150116194722_drop_spud_post_sites.rb
217
+ - db/migrate/20151015151133_add_custom_author_to_post.rb
218
+ - db/migrate/20160216144708_add_identifier_to_spud_posts.rb
219
+ - db/optional/20160216153113_drop_spud_post_comments.rb
226
220
  - lib/generators/spud/blog/blog_generator.rb
227
221
  - lib/generators/spud/blog/random_posts_generator.rb
228
222
  - lib/generators/spud/blog/views_generator.rb
@@ -289,6 +283,11 @@ files:
289
283
  - spec/dummy/db/migrate/20140811161502_add_blog_key_to_spud_posts.tb_blog.rb
290
284
  - spec/dummy/db/migrate/20140811161503_add_blog_key_to_spud_post_comments.tb_blog.rb
291
285
  - spec/dummy/db/migrate/20150116195007_drop_spud_post_sites.tb_blog.rb
286
+ - spec/dummy/db/migrate/20151015154040_add_custom_author_to_post.tb_blog.rb
287
+ - spec/dummy/db/migrate/20160215174632_add_requires_password_change_to_spud_users.tb_core.rb
288
+ - spec/dummy/db/migrate/20160215174633_create_tb_redirects.tb_redirects.rb
289
+ - spec/dummy/db/migrate/20160216150847_add_identifier_to_spud_posts.tb_blog.rb
290
+ - spec/dummy/db/migrate/20160216153113_drop_spud_post_comments.rb
292
291
  - spec/dummy/db/schema.rb
293
292
  - spec/dummy/public/404.html
294
293
  - spec/dummy/public/422.html
@@ -296,7 +295,9 @@ files:
296
295
  - spec/dummy/public/favicon.ico
297
296
  - spec/dummy/script/rails
298
297
  - spec/factories/spud_post_factories.rb
299
- - spec/factories/spud_user_factories.rb
298
+ - spec/helpers/admin/posts_helper_spec.rb
299
+ - spec/helpers/blog_helper_spec.rb
300
+ - spec/models/spud_post_spec.rb
300
301
  - spec/rails_helper.rb
301
302
  - spec/spec_helper.rb
302
303
  homepage: http://bitbucket.org/westlakedesign/tb_blog
@@ -379,6 +380,11 @@ test_files:
379
380
  - spec/dummy/db/migrate/20140811161502_add_blog_key_to_spud_posts.tb_blog.rb
380
381
  - spec/dummy/db/migrate/20140811161503_add_blog_key_to_spud_post_comments.tb_blog.rb
381
382
  - spec/dummy/db/migrate/20150116195007_drop_spud_post_sites.tb_blog.rb
383
+ - spec/dummy/db/migrate/20151015154040_add_custom_author_to_post.tb_blog.rb
384
+ - spec/dummy/db/migrate/20160215174632_add_requires_password_change_to_spud_users.tb_core.rb
385
+ - spec/dummy/db/migrate/20160215174633_create_tb_redirects.tb_redirects.rb
386
+ - spec/dummy/db/migrate/20160216150847_add_identifier_to_spud_posts.tb_blog.rb
387
+ - spec/dummy/db/migrate/20160216153113_drop_spud_post_comments.rb
382
388
  - spec/dummy/db/schema.rb
383
389
  - spec/dummy/public/404.html
384
390
  - spec/dummy/public/422.html
@@ -388,6 +394,8 @@ test_files:
388
394
  - spec/dummy/README.rdoc
389
395
  - spec/dummy/script/rails
390
396
  - spec/factories/spud_post_factories.rb
391
- - spec/factories/spud_user_factories.rb
397
+ - spec/helpers/admin/posts_helper_spec.rb
398
+ - spec/helpers/blog_helper_spec.rb
399
+ - spec/models/spud_post_spec.rb
392
400
  - spec/rails_helper.rb
393
401
  - spec/spec_helper.rb
@@ -1,37 +0,0 @@
1
- (function(){
2
-
3
- spud.admin.post_comments = {
4
- index: function(){
5
-
6
- var maxChars = 100;
7
- $('.spud-post-comment-details-content').each(function(){
8
- var el = $(this);
9
- var fulltext = el.html();
10
- if(fulltext.length > maxChars){
11
- var shorttext = fulltext.substr(0, maxChars) + " (...)";
12
- el.data('fulltext', fulltext);
13
- el.data('shorttext', shorttext);
14
- el.data('shortened', true);
15
- el.html(shorttext);
16
- el.next('.blog-comment-content-toggle').show();
17
- }
18
- });
19
-
20
- $('body').on('click', '.blog-comment-content-toggle', clickedToggleCommentContent);
21
- }
22
- };
23
-
24
- var clickedToggleCommentContent = function(e){
25
- e.preventDefault();
26
- var el = $(this).prev('.spud-post-comment-details-content');
27
- if(el.data('shortened')){
28
- el.data('shortened', false);
29
- el.html(el.data('fulltext'));
30
- }
31
- else{
32
- el.data('shortened', true);
33
- el.html(el.data('shorttext'));
34
- }
35
- };
36
-
37
- })();
@@ -1,80 +0,0 @@
1
- class Admin::PostCommentsController < Admin::ApplicationController
2
- include BlogUrlHelpers
3
-
4
- respond_to :html, :xml, :json
5
- before_action :load_blog, :only => :index
6
- before_action :find_comment, :only => [:show, :edit, :update, :destroy, :approve, :spam]
7
-
8
- def index
9
- @page_name = "Comments"
10
- if params[:post_id]
11
- @post_comments = SpudPostComment.where(:spud_post_id => params[:post_id])
12
- else
13
- @post_comments = SpudPostComment.for_blog(params[:blog_key])
14
- end
15
- @post_comments = @post_comments.ordered.includes(:post).paginate(:page => params[:page], :per_page => 15)
16
- respond_with @post_comments
17
- end
18
-
19
- def show
20
- respond_with @post_comment
21
- end
22
-
23
- def edit
24
- respond_with @post_comment
25
- end
26
-
27
- def update
28
-
29
- end
30
-
31
- def create
32
-
33
- end
34
-
35
- def approve
36
- if Spud::Blog.enable_rakismet && @post_comment.spam
37
- @post_comment.ham!
38
- end
39
- @post_comment.spam = false
40
- @post_comment.approved = true
41
- @post_comment.save()
42
- redirect_to request.referer || admin_post_post_comments_path(@post_comment.post)
43
- end
44
-
45
- def spam
46
- if Spud::Blog.enable_rakismet && !@post_comment.spam
47
- @post_comment.spam!
48
- end
49
- @post_comment.spam = true
50
- @post_comment.approved = false
51
- @post_comment.save()
52
- redirect_to request.referer || admin_post_post_comments_path(@post_comment.post)
53
- end
54
-
55
- def destroy
56
- if !@post_comment.destroy
57
- flash[:error] = "Whoops! Something odd happened while trying to delete that comment. Thats not fun. please try again."
58
- end
59
- respond_with @post_comment, :location => request.referer || admin_post_post_comments_path(@post_comment.post)
60
- end
61
-
62
- private
63
-
64
- def find_comment
65
- @post_comment = SpudPostComment.find(params[:id])
66
- end
67
-
68
- def load_blog
69
- @config = SpudBlogConfig.find(params[:blog_key])
70
- if @config.blank?
71
- redirect_to admin_root_path
72
- return false
73
- else
74
- self.class.belongs_to_spud_app "#{@config.name} Posts".parameterize.underscore.to_sym
75
- add_breadcrumb "#{@config.name} Posts", admin_posts_path(blog_key: @config.key)
76
- add_breadcrumb "Comments", admin_post_comments_path(blog_key: @config.key)
77
- end
78
- end
79
-
80
- end
@@ -1,3 +0,0 @@
1
- module Admin::PostCommentsHelper
2
-
3
- end
@@ -1,42 +0,0 @@
1
- class SpudPostComment < ActiveRecord::Base
2
-
3
- if Spud::Blog.enable_rakismet
4
- include Rakismet::Model
5
- before_save :rakismet_check_for_spam
6
- end
7
-
8
- validates_presence_of :author, :content
9
- belongs_to :post, :class_name => 'SpudPost', :foreign_key => 'spud_post_id', :counter_cache => :comments_count, :inverse_of => :comments, :touch => true
10
-
11
- scope :for_blog, ->(key){ where(:blog_key => key) }
12
- scope :pending_approval, ->{ where(:approved => nil) }
13
- scope :ordered, ->{ order('created_at desc') }
14
-
15
- before_save :set_blog_key
16
-
17
- def visible?
18
- return approved && !spam
19
- end
20
-
21
- private
22
-
23
- def rakismet_check_for_spam
24
- if self.spam?
25
- self.spam = true
26
- self.approved = false
27
- else
28
- self.spam = true
29
- end
30
- return true
31
- end
32
-
33
- def set_blog_key
34
- self.blog_key = self.post.blog_key
35
- end
36
-
37
- end
38
-
39
- # To update current comments
40
- # SpudPostComment.all.each do |comment|
41
- # comment.update_column(:blog_key, comment.post.blog_key)
42
- # end
@@ -1,60 +0,0 @@
1
- <%= content_for :data_controls do %>
2
-
3
- <% end %>
4
-
5
- <%= content_for :detail do %>
6
- <table class="table table-striped">
7
- <thead>
8
- <tr>
9
- <th>Comment</th>
10
- <th>Status</th>
11
- <th>&nbsp;</th>
12
- </tr>
13
- </thead>
14
- <tbody>
15
- <% @post_comments.each do |comment| %>
16
- <tr>
17
- <td>
18
- <div class="spud-post-comment-details">
19
- <p>
20
- Posted by <span class="spud-post-comment-details-author"><%= comment.author %></span>
21
- <span class="spud-post-comment-details-timestamp"><%= timestamp(comment.created_at) %></span>
22
- </p>
23
- <p class="spud-post-comment-details-title">
24
- <%= link_to truncate(comment.post.title, {:length => 100}), post_path(comment.post.url_name), :target => :blank %>
25
- </p>
26
- <p>
27
- <span class="spud-post-comment-details-content"><%= comment.content %></span>
28
- <a href="#" class="blog-comment-content-toggle">Expand</a>
29
- </p>
30
- </div>
31
- </td>
32
- <td>
33
- <% if comment.spam %>
34
- <span class="label label-warning">Spam</span>
35
- <% elsif comment.approved %>
36
- <span class="label label-success">Approved</span>
37
- <% else %>
38
- <span class="label label-default">Pending</span>
39
- <% end %>
40
- </td>
41
- <td class="spud-post-comment-actions">
42
- <% if !comment.approved %>
43
- <%= link_to 'Approve', approve_admin_post_comment_path(comment), :class => 'btn btn-success btn-sm' %>
44
- <% end %>
45
- <% if !comment.spam %>
46
- <%= link_to 'Spam', spam_admin_post_comment_path(comment), :class => 'btn btn-warning btn-sm' %>
47
- <% end %>
48
- <%= link_to 'Delete', admin_post_comment_path(comment), :method => :delete, :data => {:confirm => 'Are you sure you want to delete this comment?'}, :class => 'btn btn-danger btn-sm' %>
49
- </td>
50
- </tr>
51
- <%end%>
52
- </tbody>
53
- </table>
54
- <%= will_paginate @post_comments, :renderer => BootstrapPagination::Rails %>
55
-
56
- <script>
57
- $(document).ready(spud.admin.post_comments.index);
58
- </script>
59
-
60
- <% end %>
@@ -1,13 +0,0 @@
1
- class CreateSpudPostComments < ActiveRecord::Migration
2
- def change
3
- create_table :spud_post_comments do |t|
4
- t.integer :spud_post_id
5
- t.string :author
6
- t.text :content
7
- t.boolean :approved, :default => false
8
- t.timestamps
9
- end
10
- add_index :spud_post_comments, :spud_post_id
11
- add_index :spud_post_comments, :approved
12
- end
13
- end
@@ -1,12 +0,0 @@
1
- class AddCommentsCounterToSpudPosts < ActiveRecord::Migration
2
- def self.up
3
- add_column :spud_posts, :comments_count, :integer, :default => 0
4
- SpudPost.find_each do |post|
5
- post.comments_count = post.comments.count
6
- post.save
7
- end
8
- end
9
- def self.down
10
- remove_column :spud_posts, :comments_count
11
- end
12
- end