workarea-blog 3.4.9 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/{.eslintrc → .eslintrc.json} +12 -1
  3. data/.github/workflows/ci.yml +6 -0
  4. data/CHANGELOG.md +18 -36
  5. data/Gemfile +3 -3
  6. data/app/controllers/workarea/storefront/application_controller.decorator +5 -0
  7. data/app/helpers/workarea/storefront/blogs_helper.rb +44 -0
  8. data/app/view_models/workarea/admin/blog_entry_view_model.rb +1 -1
  9. data/app/view_models/workarea/storefront/blog_entry_view_model.rb +1 -1
  10. data/app/view_models/workarea/storefront/blog_view_model.rb +3 -3
  11. data/app/views/workarea/admin/content_blog_comments/_summary.html.haml +21 -9
  12. data/app/views/workarea/admin/content_blog_comments/index.html.haml +8 -7
  13. data/app/views/workarea/admin/content_blog_entries/_cards.html.haml +1 -1
  14. data/app/views/workarea/admin/content_blog_entries/edit.html.haml +2 -1
  15. data/app/views/workarea/admin/content_blogs/edit.html.haml +2 -1
  16. data/app/views/workarea/storefront/blog_entries/_summary.html.haml +12 -11
  17. data/app/views/workarea/storefront/blog_entries/show.html.haml +20 -20
  18. data/app/views/workarea/storefront/blog_metadata/_publisher.html.haml +3 -2
  19. data/app/views/workarea/storefront/blogs/index.html.haml +4 -4
  20. data/app/views/workarea/storefront/blogs/show.html.haml +2 -2
  21. data/config/initializers/content_block_types.rb +1 -1
  22. data/config/initializers/fields.rb +9 -0
  23. data/config/initializers/rack_attack.rb +11 -0
  24. data/config/initializers/workarea.rb +0 -3
  25. data/config/locales/en.yml +2 -0
  26. data/lib/workarea/blog/import/wordpress/content_cleaner.rb +1 -1
  27. data/lib/workarea/blog/version.rb +1 -1
  28. data/package.json +9 -0
  29. data/test/dummy/config/initializers/session_store.rb +1 -1
  30. data/test/factories/wordpress_import.rb +8 -10
  31. data/test/integration/workarea/blog/rack_attack_integration_test.rb +50 -0
  32. data/test/system/workarea/admin/blog_user_comments_system_test.rb +41 -1
  33. data/test/view_models/workarea/storefront/blog_view_model_test.rb +8 -7
  34. data/workarea-blog.gemspec +3 -3
  35. metadata +14 -9
  36. data/.scss-lint.yml +0 -188
  37. data/.tailor +0 -180
@@ -1,7 +1,8 @@
1
+ -# TODO v4 remove
1
2
  %div{ itemprop: 'publisher', itemscope: 'itemscope', itemtype: 'https://schema.org/Organization'}
2
3
  %meta{ itemprop: 'url', content: root_url }
3
4
  %meta{ itemprop: 'name', content: Workarea.config.site_name }
4
- -# TODO: Add meta data for logo, this must include url, width, and height attributes
5
+ -# TODO: Add meta data for logo, this must include url, width, and height attributes
5
6
  -# This will require a helper method for site logo with something similar to dragonfly analyzers for width & height
6
7
  -# example: https://webmasters.stackexchange.com/questions/95957/how-to-specify-publisher-in-schema-orgs-article-structured-data
7
-
8
+
@@ -8,16 +8,16 @@
8
8
  - unless @blog_index.meta_description.blank?
9
9
  %meta{ name: :description, content: @blog_index.meta_description }
10
10
 
11
- .blog-index.view{ itemscope: true, itemtype: 'http://schema.org/Blog' }
11
+ .blog-index.view
12
12
 
13
13
  = render_content_blocks(@blog_index.content_blocks_for(:header_content))
14
14
 
15
- %h1.blog-entry-summary__title{ itemprop: 'name' }= t('workarea.storefront.blogs.name')
15
+ %h1.blog-entry-summary__title= t('workarea.storefront.blogs.name')
16
16
 
17
17
  - @blog_index.each do |blog|
18
18
  %section
19
- %h2.blog-index__title{ itemprop: 'name' }
20
- = link_to blog.name, blog_path(blog), itemprop: 'url'
19
+ %h2.blog-index__title
20
+ = link_to blog.name, blog_path(blog)
21
21
 
22
22
  .pagination-results
23
23
  .blog-entry-summary__entry-group
@@ -14,9 +14,9 @@
14
14
  - content_for :page_aside do
15
15
  = render 'workarea/storefront/blogs/blog_navigation', blog: @blog
16
16
 
17
- .blog-entry-summary.view{ itemscope: true, itemtype: 'http://schema.org/Blog', itemprop: '' }
17
+ .blog-entry-summary.view
18
18
 
19
- %h1.blog-entry-summary__title{ itemprop: 'name' }= @blog.name
19
+ %h1.blog-entry-summary__title= @blog.name
20
20
 
21
21
  - if @blog.content_blocks_for(:header_content).present?
22
22
  .blog-entry-summary__banner-content!= render_content_blocks(@blog.content_blocks_for(:header_content))
@@ -1,4 +1,4 @@
1
- Workarea::Content.define_block_types do
1
+ Workarea.define_content_block_types do
2
2
  block_type 'Blog Entry' do
3
3
  description 'Feature a blog entry as a content block'
4
4
  view_model 'Workarea::Storefront::ContentBlocks::BlogEntryContentBlockViewModel'
@@ -0,0 +1,9 @@
1
+ Workarea::Configuration.define_fields do
2
+ fieldset 'Content', namespaced: false do
3
+ field 'Blog Entry Index Display',
4
+ id: :blog_entries_on_index,
5
+ type: :integer,
6
+ default: 4,
7
+ description: 'The number of blog entries to display on the blog index page for each blog.'
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ class Rack::Attack
2
+ # Ban blog comment spammers for a day when more than 10 comments are
3
+ # posted in an hour.
4
+ blocklist('blog/comments') do |req|
5
+ key = [req.ip, req.cookies['user_id']].reject(&:blank?).join(':')
6
+
7
+ Rack::Attack::Allow2Ban.filter(key, maxretry: 10, findtime: 1.hour, bantime: 1.day) do
8
+ req.post? && req.path =~ %r{blog_entries/(.*)/comment}
9
+ end
10
+ end
11
+ end
@@ -1,7 +1,4 @@
1
1
  Workarea.configure do |config|
2
- # Number of articles to be displayed per blog on blog index page
3
- config.blog_entries_on_index ||= 4
4
-
5
2
  config.content_areas.merge!(
6
3
  'blog_entry' => %w[blog_content blog_header],
7
4
  'blog' => %w[header_content],
@@ -44,6 +44,8 @@ en:
44
44
  new_comment: New Comment
45
45
  comment_body: Comment Body
46
46
  create_comment: Create Comment
47
+ approve: Approve
48
+ deny: Deny
47
49
  content_blog_entries:
48
50
  fields:
49
51
  author: Author
@@ -31,7 +31,7 @@ module Workarea
31
31
 
32
32
  def find_asset(uri)
33
33
  name = uri.path.rpartition('.').first.split('/').join('-')
34
- Content::Asset.find_by(name: name) rescue Content::Asset.placeholder
34
+ Content::Asset.find_by(name: name) rescue Content::Asset.image_placeholder
35
35
  end
36
36
 
37
37
  def make_internal_links_relative
@@ -1,5 +1,5 @@
1
1
  module Workarea
2
2
  module Blog
3
- VERSION = '3.4.9'.freeze
3
+ VERSION = '3.5.0'.freeze
4
4
  end
5
5
  end
data/package.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "devDependencies": {
3
+ "eslint": "~5.16.0",
4
+ "eslint-config-recommended": "~4.0.0",
5
+ "stylelint": "~10.1.0",
6
+ "stylelint-config-recommended-scss": "~3.3.0",
7
+ "stylelint-scss": "~3.9.2"
8
+ }
9
+ }
@@ -1,3 +1,3 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
- Rails.application.config.session_store :cookie_store, key: '_dummy_session'
3
+ Rails.application.config.session_store :cookie_store, key: '_dummy_session', expire_after: 30.minutes
@@ -1,16 +1,14 @@
1
1
  module Workarea
2
- module Blog
3
- module Factoris
4
- module WordpressImport
5
- Factories.add(self)
2
+ module Factories
3
+ module WordpressImport
4
+ Factories.add(self)
6
5
 
7
- def wordpress_xml_path
8
- "#{Workarea::Blog.root}/test/fixtures/test_wordpress.xml"
9
- end
6
+ def wordpress_xml_path
7
+ "#{Workarea::Blog.root}/test/fixtures/test_wordpress.xml"
8
+ end
10
9
 
11
- def wordpress_xml
12
- File.open(wordpress_xml_path)
13
- end
10
+ def wordpress_xml
11
+ File.open(wordpress_xml_path)
14
12
  end
15
13
  end
16
14
  end
@@ -0,0 +1,50 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ class Blog::RackAttackIntegrationTest < Workarea::IntegrationTest
5
+ class AddEnvMiddleware
6
+ def initialize(app)
7
+ @app = app
8
+ end
9
+
10
+ def call(env)
11
+ env.merge!(Rails.application.env_config)
12
+ @app.call(env)
13
+ end
14
+ end
15
+
16
+ def test_prevent_comment_spam
17
+ ip = '192.168.1.1'
18
+ user = create_user
19
+ blog_entry = create_blog_entry(blog: create_blog)
20
+ key = [ip, user.id.to_s].reject(&:blank?).join(':')
21
+ env = { 'HTTP_COOKIE' => "user_id=#{user.id}", 'REMOTE_ADDR' => ip }
22
+
23
+ post "/blog_entries/#{blog_entry.slug}/comment", env: env
24
+
25
+ assert_response(:success)
26
+
27
+ Rack::Attack::Allow2Ban.stubs(:banned?).returns(false)
28
+ Rack::Attack::Allow2Ban.stubs(:banned?).with(key).returns(true)
29
+
30
+ post "/blog_entries/#{blog_entry.slug}/comment", env: env
31
+
32
+ assert_equal('blog/comments', request.env['rack.attack.matched'])
33
+ assert_equal(:blocklist, request.env['rack.attack.match_type'])
34
+ assert_response(:forbidden)
35
+ end
36
+
37
+ private
38
+
39
+ def app
40
+ @app ||= begin
41
+ Rack::Builder.new do
42
+ use AddEnvMiddleware
43
+ use Rack::Attack
44
+ use ActionDispatch::Cookies
45
+ run -> (*) { [ 200, {}, [] ] }
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -43,6 +43,46 @@ module Workarea
43
43
  assert(page.has_content?('blog comment'))
44
44
  end
45
45
 
46
+ def test_moderating_comments_from_index
47
+ pending = t('workarea.admin.content_blogs_comments.summary.pending')
48
+ blog_entry = blog.entries.first
49
+ bad_comment = create_blog_comment(
50
+ entry: blog_entry,
51
+ user_id: Workarea::User.first.id,
52
+ user_info: 'UC',
53
+ body: 'oh noes i said the bad word',
54
+ pending: true
55
+ )
56
+ good_comment = create_blog_comment(
57
+ entry: blog_entry,
58
+ user_id: Workarea::User.first.id,
59
+ user_info: 'UC',
60
+ body: 'test test test',
61
+ pending: true
62
+ )
63
+
64
+ visit admin.content_blog_user_comments_path
65
+
66
+ assert_text(good_comment.body)
67
+ assert_text(bad_comment.body)
68
+ assert_text(pending, count: 2)
69
+
70
+ within '.comments__comment:first-child' do
71
+ click_link t('workarea.admin.content_blogs_comments.index.approve')
72
+ end
73
+
74
+ assert_text(pending, count: 1)
75
+
76
+ within '.comments__comment:first-child' do
77
+ click_link t('workarea.admin.content_blogs_comments.index.deny')
78
+ end
79
+
80
+ refute_text(pending)
81
+
82
+ assert(good_comment.reload.approved)
83
+ refute(bad_comment.reload.approved)
84
+ end
85
+
46
86
  def test_deleting_a_comment
47
87
  blog_entry = blog.entries.first
48
88
  blog_entry.comments.create!(
@@ -56,7 +96,7 @@ module Workarea
56
96
  visit admin.content_blog_user_comments_path
57
97
 
58
98
  within '.comments__comment', match: :first do
59
- click_button('Delete')
99
+ click_link t('workarea.admin.actions.delete')
60
100
  end
61
101
 
62
102
  assert(page.has_content?(t('workarea.admin.content_blogs_comments.flash_messages.destroyed')))
@@ -133,15 +133,16 @@ module Workarea
133
133
  unpublished = view_model.entries.select { |entry| entry.name == 'Unpublished' }
134
134
 
135
135
  assert_equal(3, view_model.entries.count)
136
- assert unpublished.empty?
136
+ assert(unpublished.empty?)
137
+ assert(release.publish!)
137
138
 
138
- release.as_current do
139
- view_model = Workarea::Storefront::BlogViewModel.new(@blog.reload)
140
- newly_published = view_model.entries.select { |entry| entry.name == 'Unpublished' }
141
-
142
- assert_equal(4, view_model.entries.count)
143
- refute newly_published.empty?
139
+ view_model = Workarea::Storefront::BlogViewModel.new(@blog.reload)
140
+ newly_published = view_model.entries.select do |entry|
141
+ entry.name == 'Unpublished'
144
142
  end
143
+
144
+ assert_equal(4, view_model.entries.count)
145
+ refute(newly_published.empty?)
145
146
  end
146
147
 
147
148
  def test_total
@@ -8,12 +8,12 @@ Gem::Specification.new do |s|
8
8
  s.authors = ['bcrouse']
9
9
  s.email = ['bcrouse@workarea.com']
10
10
  s.homepage = 'https://github.com/workarea-commerce/workarea-blog'
11
- s.summary = 'Blog plugin for Workarea.'
12
- s.description = 'This plugin adds blogs capability to Workarea.'
11
+ s.summary = 'Blog plugin for the Workarea Commerce Platform'
12
+ s.description = 'This plugin adds blogs functionality to the Workarea Commerce Platform.'
13
13
 
14
14
  s.files = `git ls-files`.split("\n")
15
15
 
16
16
  s.license = 'Business Software License'
17
17
 
18
- s.add_dependency 'workarea', '~> 3.x', '>= 3.3.x'
18
+ s.add_dependency 'workarea', '~> 3.x', '>= 3.5.x'
19
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workarea-blog
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.9
4
+ version: 3.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - bcrouse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-16 00:00:00.000000000 Z
11
+ date: 2019-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: workarea
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: 3.x
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 3.3.x
22
+ version: 3.5.x
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,8 +29,8 @@ dependencies:
29
29
  version: 3.x
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 3.3.x
33
- description: This plugin adds blogs capability to Workarea.
32
+ version: 3.5.x
33
+ description: This plugin adds blogs functionality to the Workarea Commerce Platform.
34
34
  email:
35
35
  - bcrouse@workarea.com
36
36
  executables: []
@@ -39,7 +39,7 @@ extra_rdoc_files: []
39
39
  files:
40
40
  - ".editorconfig"
41
41
  - ".eslintignore"
42
- - ".eslintrc"
42
+ - ".eslintrc.json"
43
43
  - ".github/ISSUE_TEMPLATE/bug_report.md"
44
44
  - ".github/ISSUE_TEMPLATE/documentation-request.md"
45
45
  - ".github/ISSUE_TEMPLATE/feature_request.md"
@@ -47,9 +47,7 @@ files:
47
47
  - ".gitignore"
48
48
  - ".rspec"
49
49
  - ".rubocop.yml"
50
- - ".scss-lint.yml"
51
50
  - ".stylelintrc.json"
52
- - ".tailor"
53
51
  - ".yardopts"
54
52
  - CHANGELOG.md
55
53
  - CODE_OF_CONDUCT.md
@@ -72,10 +70,12 @@ files:
72
70
  - app/controllers/workarea/admin/content_blog_entries_controller.rb
73
71
  - app/controllers/workarea/admin/content_blogs_controller.rb
74
72
  - app/controllers/workarea/admin/create_content_blog_entries_controller.rb
73
+ - app/controllers/workarea/storefront/application_controller.decorator
75
74
  - app/controllers/workarea/storefront/blog_comments_controller.rb
76
75
  - app/controllers/workarea/storefront/blog_entries_controller.rb
77
76
  - app/controllers/workarea/storefront/blogs_controller.rb
78
77
  - app/helpers/workarea/admin/blogs_helper.rb
78
+ - app/helpers/workarea/storefront/blogs_helper.rb
79
79
  - app/models/workarea/content/blog.rb
80
80
  - app/models/workarea/content/blog_comment.rb
81
81
  - app/models/workarea/content/blog_entry.rb
@@ -153,7 +153,9 @@ files:
153
153
  - bin/rails
154
154
  - config/initializers/appends.rb
155
155
  - config/initializers/content_block_types.rb
156
+ - config/initializers/fields.rb
156
157
  - config/initializers/jump_to_navigation.rb
158
+ - config/initializers/rack_attack.rb
157
159
  - config/initializers/seeds.rb
158
160
  - config/initializers/workarea.rb
159
161
  - config/locales/en.yml
@@ -174,6 +176,7 @@ files:
174
176
  - lib/workarea/blog/import/wordpress/page.rb
175
177
  - lib/workarea/blog/import/wordpress/page_parser.rb
176
178
  - lib/workarea/blog/version.rb
179
+ - package.json
177
180
  - test/dummy/Rakefile
178
181
  - test/dummy/app/assets/config/manifest.js
179
182
  - test/dummy/app/assets/images/.keep
@@ -225,6 +228,7 @@ files:
225
228
  - test/fixtures/test_wordpress.xml
226
229
  - test/integration/workarea/blog/admin_integration_test.rb
227
230
  - test/integration/workarea/blog/create_blog_entries_integration_test.rb
231
+ - test/integration/workarea/blog/rack_attack_integration_test.rb
228
232
  - test/integration/workarea/blog/storefront_integration_test.rb
229
233
  - test/integration/workarea/blog/wordpress_import_integration_test.rb
230
234
  - test/lib/workarea/blog/import/wordpress/attachment_test.rb
@@ -253,6 +257,7 @@ files:
253
257
  - test/view_models/workarea/storefront/blog_view_model_test.rb
254
258
  - test/workers/workarea/generate_content_blog_metadata_test.rb
255
259
  - workarea-blog.gemspec
260
+ - yarn.lock
256
261
  homepage: https://github.com/workarea-commerce/workarea-blog
257
262
  licenses:
258
263
  - Business Software License
@@ -275,5 +280,5 @@ requirements: []
275
280
  rubygems_version: 3.0.6
276
281
  signing_key:
277
282
  specification_version: 4
278
- summary: Blog plugin for Workarea.
283
+ summary: Blog plugin for the Workarea Commerce Platform
279
284
  test_files: []
data/.scss-lint.yml DELETED
@@ -1,188 +0,0 @@
1
- # Extension of the default configuration:
2
- # https://github.com/causes/scss-lint/blob/master/config/default.yml
3
-
4
- linters:
5
- Comment:
6
- enabled: false
7
-
8
- DeclarationOrder:
9
- enabled: true
10
-
11
- ElsePlacement:
12
- enabled: true
13
- style: new_line
14
-
15
- EmptyRule:
16
- enabled: false
17
-
18
- HexLength:
19
- enabled: true
20
- style: long
21
-
22
- Indentation:
23
- enabled: true
24
- allow_non_nested_indentation: true
25
- character: space
26
- width: 4
27
-
28
- LeadingZero:
29
- enabled: true
30
- style: include_zero
31
-
32
- MergeableSelector:
33
- enabled: true
34
- force_nesting: false
35
-
36
- PropertySortOrder:
37
- enabled: true
38
- ignore_unspecified: false
39
- separate_groups: false
40
- order:
41
- - display
42
- -
43
- - position
44
- - top
45
- - right
46
- - bottom
47
- - left
48
- - z-index
49
- -
50
- - margin
51
- - margin-top
52
- - margin-right
53
- - margin-bottom
54
- - margin-left
55
- -
56
- - margin-collapse
57
- - margin-top-collapse
58
- - margin-right-collapse
59
- - margin-bottom-collapse
60
- - margin-left-collapse
61
- -
62
- - padding
63
- - padding-top
64
- - padding-right
65
- - padding-bottom
66
- - padding-left
67
- -
68
- - width
69
- - height
70
- - max-width
71
- - max-height
72
- - min-width
73
- - min-height
74
- -
75
- - float
76
- - clear
77
- -
78
- - color
79
- -
80
- - font
81
- - font-size
82
- - font-style
83
- - font-family
84
- - font-weight
85
- - font-variant
86
- - font-smoothing
87
- -
88
- - line-height
89
- - letter-spacing
90
- - word-spacing
91
- -
92
- - text-align
93
- - text-indent
94
- - text-shadow
95
- - text-overflow
96
- - text-rendering
97
- - text-transform
98
- - text-decoration
99
- - text-size-adjust
100
- -
101
- - word-break
102
- - word-wrap
103
- -
104
- - white-space
105
- -
106
- - background
107
- - background-size
108
- - background-color
109
- - background-image
110
- - background-repeat
111
- - background-position
112
- - background-attachment
113
- -
114
- - border
115
- - border-top
116
- - border-right
117
- - border-bottom
118
- - border-left
119
- -
120
- - border-image
121
- - border-spacing
122
- - border-collapse
123
- -
124
- - border-color
125
- - border-top-color
126
- - border-right-color
127
- - border-bottom-color
128
- - border-left-color
129
- -
130
- - border-style
131
- - border-top-style
132
- - border-right-style
133
- - border-bottom-style
134
- - border-left-style
135
- -
136
- - border-width
137
- - border-top-width
138
- - border-right-width
139
- - border-bottom-width
140
- - border-left-width
141
- -
142
- - border-radius
143
- - border-top-right-radius
144
- - border-bottom-right-radius
145
- - border-bottom-left-radius
146
- - border-top-left-radius
147
- - border-radius-topright
148
- - border-radius-bottomright
149
- - border-radius-bottomleft
150
- - border-radius-topleft
151
- -
152
- - box-shadow
153
-
154
- SelectorFormat:
155
- enabled: true
156
- convention: hyphenated_BEM
157
-
158
- SingleLinePerSelector:
159
- enabled: false
160
-
161
- SpaceAfterPropertyColon:
162
- enabled: true
163
- style: at_least_one_space
164
-
165
- SpaceBeforeBrace:
166
- enabled: true
167
- style: space
168
- allow_single_line_padding: true
169
-
170
- VariableForProperty:
171
- enabled: true
172
- properties:
173
- - color
174
- - font-family
175
- - background-color
176
-
177
- # These default settings may be problematic to implementors. They are not
178
- # ommitted so that they may be adjusted as needed during an implementation.
179
- #
180
- # For documentation:
181
- # https://github.com/causes/scss-lint/blob/master/lib/scss_lint/linter/README.md
182
-
183
- DuplicateProperty:
184
- enabled: true
185
-
186
- PropertySpelling:
187
- enabled: true
188
- extra_properties: [] # Add experimental CSS to this array, if needed