cmor_blog 0.0.44.pre → 0.0.45.pre
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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/cmor/blog/application.js +1 -1
- data/app/assets/javascripts/cmor/blog/application/keep.js +0 -0
- data/app/assets/javascripts/cmor_blog.js +1 -0
- data/app/controllers/cmor/blog/posts_controller.rb +3 -3
- data/app/helpers/cmor/blog/application_helper.rb +1 -1
- data/app/models/cmor/blog/post.rb +5 -1
- data/app/view_helpers/cmor/blog/application_view_helper.rb +14 -2
- data/app/views/cmor/blog/application_view_helper/_render_post.html.haml +1 -1
- data/app/views/cmor/blog/posts/_post.html.haml +1 -1
- data/app/views/cmor/blog/posts/_post_in_index.html.haml +1 -1
- data/app/views/cmor/blog/posts/_post_in_index_with_preview_picture.haml +1 -1
- data/config/locales/de.yml +6 -5
- data/config/locales/en.yml +6 -5
- data/db/migrate/20200217105600_add_locale_to_cmor_blog_posts.rb +5 -0
- data/lib/cmor/blog/configuration.rb +2 -2
- data/lib/cmor_blog.rb +2 -1
- data/lib/generators/cmor/blog/install/templates/initializer.rb +11 -3
- data/spec/models/cmor/blog/post_spec.rb +42 -36
- data/spec/support/shoulda_matchers.rb +8 -0
- metadata +12 -9
- data/app/views/layouts/cmor/blog/application.html.erb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97a7d0f0313e974c46029c6a8007a232efe65b7ccb0e7887db726f7a06f8ad0d
|
4
|
+
data.tar.gz: 21da5ddbe8126eb3ca1001dc0facce11c34fac5571031db3e86fa3d13bef0313
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bffa2904af71c91cd81e4454b677a805f0c44286ef1f28aaca6427c226d5d71027ad9cd3d009dbab8a801c4d762af7b4eba7b8e97832603888533a51411a19e7
|
7
|
+
data.tar.gz: 494486d7f401a088a73aa5ecb88fa01a6ca9135aefd672d222e6a9553afcc2db91b8b3d69f3977b0c760aeef7d4c0e2efcdb476450be36c811c525ccd7573195
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require cmor/blog/application
|
@@ -18,14 +18,14 @@ module Cmor
|
|
18
18
|
|
19
19
|
def load_collection_scope
|
20
20
|
if params.has_key?(:year)
|
21
|
-
super.published.for_date(params[:year], params[:month], params[:day])
|
21
|
+
super.published.for_locale.for_date(params[:year], params[:month], params[:day])
|
22
22
|
else
|
23
|
-
super.published
|
23
|
+
super.published.for_locale
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
def load_resource_scope
|
28
|
-
super.published.friendly
|
28
|
+
super.published.for_locale.friendly
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -19,7 +19,7 @@ module Cmor
|
|
19
19
|
# = blog_render_monthly_navigation if controller.class.name.deconstantize == 'Cmor::Blog'
|
20
20
|
#
|
21
21
|
def blog_render_monthly_navigation
|
22
|
-
posts = Cmor::Blog::Post.published.all.pluck(:created_at)
|
22
|
+
posts = Cmor::Blog::Post.published.for_locale.all.pluck(:created_at)
|
23
23
|
posts_by_month = posts.group_by {|t| t.beginning_of_month }
|
24
24
|
render partial: 'cmor/blog/posts/monthly_navigation', locals: { posts_by_month: posts_by_month}
|
25
25
|
end
|
@@ -19,11 +19,13 @@ module Cmor
|
|
19
19
|
extend FriendlyId
|
20
20
|
friendly_id :title, use: :slugged
|
21
21
|
|
22
|
-
belongs_to :creator, class_name: Cmor::Blog.creator_class_name, foreign_key: 'created_by_id'
|
22
|
+
belongs_to :creator, class_name: Cmor::Blog.creator_class_name, foreign_key: 'created_by_id', optional: true
|
23
23
|
belongs_to :updater, class_name: Cmor::Blog.creator_class_name, foreign_key: 'updated_by_id', optional: true
|
24
24
|
|
25
25
|
scope :for_date, ->(year, month, day) { where(created_at: "#{year}-#{month || 1}-#{day || 1}".to_date.beginning_of_month.."#{year}-#{month || 1}-#{day || 1}".to_date.end_of_month) }
|
26
26
|
|
27
|
+
validates :title, :body, presence: true
|
28
|
+
|
27
29
|
def human
|
28
30
|
title
|
29
31
|
end
|
@@ -112,6 +114,8 @@ module Cmor
|
|
112
114
|
end
|
113
115
|
|
114
116
|
include PreviewPictureConcern
|
117
|
+
|
118
|
+
include Cmor::Core::Model::LocalizationConcern
|
115
119
|
end
|
116
120
|
end
|
117
121
|
end
|
@@ -1,13 +1,25 @@
|
|
1
1
|
module Cmor
|
2
2
|
module Blog
|
3
|
+
# Example:
|
4
|
+
#
|
5
|
+
# # app/controllers/application_controller.rb
|
6
|
+
# class ApplicationController < ActionController::Base
|
7
|
+
# view_helper Cmor::Blog::ApplicationViewHelper, as: :blog_helper
|
8
|
+
# end
|
9
|
+
#
|
3
10
|
class ApplicationViewHelper < Rao::ViewHelper::Base
|
11
|
+
# Example:
|
12
|
+
#
|
13
|
+
# # app/views/layouts/application.html.haml
|
14
|
+
# = blog_helper(self).render_recent_posts(3)
|
15
|
+
#
|
4
16
|
def render_recent_posts(count)
|
5
|
-
posts = Cmor::Blog::Post.limit(count).all
|
17
|
+
posts = Cmor::Blog::Post.published.for_locale.limit(count).all
|
6
18
|
c.render html: posts.collect { |p| render_post(p.id) }.join("<hr />").html_safe
|
7
19
|
end
|
8
20
|
|
9
21
|
def render_post(id)
|
10
|
-
post = Cmor::Blog::Post.where(id: id).first
|
22
|
+
post = Cmor::Blog::Post.published.for_locale.where(id: id).first
|
11
23
|
render(post: post) if post.present?
|
12
24
|
end
|
13
25
|
end
|
@@ -4,7 +4,7 @@
|
|
4
4
|
= link_to(post.title, cmor_blog.url_for(post))
|
5
5
|
%small
|
6
6
|
%span.post-creation-information.text-muted
|
7
|
-
= "#{l(post.created_at)} | #{
|
7
|
+
= "#{l(post.created_at)} | #{Cmor::Blog::Configuration.creator_label_for_post_proc.call(post)}"
|
8
8
|
- if Cmor::Core.features?(:cmor_comments)
|
9
9
|
|
|
10
10
|
%span.comments-information
|
@@ -3,7 +3,7 @@
|
|
3
3
|
= link_to(post.title, cmor_blog.url_for(post))
|
4
4
|
%small
|
5
5
|
%span.post-creation-information.text-muted
|
6
|
-
= "#{l(post.created_at)} | #{
|
6
|
+
= "#{l(post.created_at)} | #{Cmor::Blog::Configuration.creator_label_for_post_proc.call(post)}"
|
7
7
|
- if Cmor::Core.features?(:cmor_comments)
|
8
8
|
|
|
9
9
|
%span.comments-information
|
@@ -4,7 +4,7 @@
|
|
4
4
|
= link_to(post.title, cmor_blog.url_for(post))
|
5
5
|
%small
|
6
6
|
%span.post-creation-information.text-muted
|
7
|
-
= "#{l(post.created_at)} | #{
|
7
|
+
= "#{l(post.created_at)} | #{Cmor::Blog::Configuration.creator_label_for_post_proc.call(post)}"
|
8
8
|
- if Cmor::Core.features?(:cmor_comments)
|
9
9
|
|
|
10
10
|
%span.comments-information
|
@@ -7,7 +7,7 @@
|
|
7
7
|
= link_to(post.title, cmor_blog.url_for(post))
|
8
8
|
%small
|
9
9
|
%span.post-creation-information.text-muted
|
10
|
-
= "#{l(post.created_at)} | #{
|
10
|
+
= "#{l(post.created_at)} | #{Cmor::Blog::Configuration.creator_label_for_post_proc.call(post)}"
|
11
11
|
- if Cmor::Core.features?(:cmor_comments)
|
12
12
|
|
|
13
13
|
%span.comments-information
|
data/config/locales/de.yml
CHANGED
@@ -12,17 +12,18 @@ de:
|
|
12
12
|
attributes:
|
13
13
|
cmor/blog/post:
|
14
14
|
id: ID
|
15
|
-
assets: Anhänge
|
16
15
|
asset_details_count: Anhänge
|
17
|
-
|
18
|
-
tags: Tags
|
16
|
+
assets: Anhänge
|
19
17
|
body: Inhalt
|
18
|
+
created_by_id: Erstellt von
|
19
|
+
creator: Erstellt von
|
20
|
+
locale: Sprache
|
20
21
|
position: Position
|
21
22
|
published: Veröffentlicht
|
22
23
|
published_at: Veröffentlicht am
|
23
|
-
created_by_id: Erstellt von
|
24
|
-
creator: Erstellt von
|
25
24
|
slug: Freundliche ID
|
25
|
+
tags: Tags
|
26
|
+
title: Titel
|
26
27
|
updated_by_id: Aktualisiert von
|
27
28
|
updater: Aktualisiert von
|
28
29
|
created_at: Erstellt am
|
data/config/locales/en.yml
CHANGED
@@ -12,17 +12,18 @@ en:
|
|
12
12
|
attributes:
|
13
13
|
cmor/blog/post:
|
14
14
|
id: ID
|
15
|
-
assets: Asset
|
16
15
|
asset_details_count: Assets
|
17
|
-
|
18
|
-
tags: Tags
|
16
|
+
assets: Asset
|
19
17
|
body: Body
|
18
|
+
created_by_id: Created by
|
19
|
+
creator: Created by
|
20
|
+
locale: Locale
|
20
21
|
position: Position
|
21
22
|
published: Published
|
22
23
|
published_at: Published at
|
23
|
-
created_by_id: Created by
|
24
|
-
creator: Created by
|
25
24
|
slug: Slug
|
25
|
+
tags: Tags
|
26
|
+
title: Title
|
26
27
|
updated_by_id: Updated by
|
27
28
|
updater: Updated by
|
28
29
|
created_at: Created at
|
@@ -32,8 +32,8 @@ module Cmor
|
|
32
32
|
{ combine_options: { resize: "320x240^", extent: "384x216", gravity: "center" } }
|
33
33
|
end
|
34
34
|
|
35
|
-
mattr_accessor(:
|
36
|
-
|
35
|
+
mattr_accessor(:creator_label_for_post_proc) do
|
36
|
+
-> (post) { post.creator&.to_s }
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
data/lib/cmor_blog.rb
CHANGED
@@ -46,9 +46,17 @@ Cmor::Blog.configure do |config|
|
|
46
46
|
#
|
47
47
|
config.preview_picture_asset_variant_options = { combine_options: { resize: "320x240^", extent: "384x216", gravity: "center" } }
|
48
48
|
|
49
|
-
#
|
49
|
+
# Define how the author will be shown on posts.
|
50
50
|
#
|
51
|
-
#
|
51
|
+
# You can generalize the label by not taking the creator into account at all:
|
52
52
|
#
|
53
|
-
config.
|
53
|
+
# config.creator_label_for_post_proc = -> (post) { "Site Owner" }
|
54
|
+
#
|
55
|
+
# You can show a default when the creator is not set:
|
56
|
+
#
|
57
|
+
# config.creator_label_for_post_proc = -> (post) { post.creator&.to_s || "Site owner" }
|
58
|
+
#
|
59
|
+
# default: config.creator_label_for_post_proc = -> (post) { post.creator&.to_s }
|
60
|
+
#
|
61
|
+
config.creator_label_for_post_proc = -> (post) { post.creator&.to_s }
|
54
62
|
end
|
@@ -1,55 +1,61 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
3
|
RSpec.describe Cmor::Blog::Post, type: :model do
|
4
|
-
|
4
|
+
it { expect(described_class).to respond_to(:for_locale) }
|
5
|
+
it { expect(subject).to respond_to(:locale) }
|
6
|
+
it { expect(subject).to validate_inclusion_of(:locale).in_array(I18n.available_locales.map(&:to_s)) }
|
5
7
|
|
6
8
|
describe 'assets' do
|
7
|
-
|
8
|
-
{ io: File.open(Cmor::Blog::Engine.root.join(*%w(spec files cmor blog asset example.jpg))), filename: 'example.jpg'},
|
9
|
-
{ io: File.open(Cmor::Blog::Engine.root.join(*%w(spec files cmor blog asset example.jpg))), filename: 'example.jpg'}
|
10
|
-
]}
|
9
|
+
before(:each) { ActiveStorage::Attachment.destroy_all; ActiveStorage::Blob.destroy_all; }
|
11
10
|
|
12
|
-
|
11
|
+
describe '#assets' do
|
12
|
+
let(:assets) {[
|
13
|
+
{ io: File.open(Cmor::Blog::Engine.root.join(*%w(spec files cmor blog asset example.jpg))), filename: 'example.jpg'},
|
14
|
+
{ io: File.open(Cmor::Blog::Engine.root.join(*%w(spec files cmor blog asset example.jpg))), filename: 'example.jpg'}
|
15
|
+
]}
|
13
16
|
|
14
|
-
|
17
|
+
subject { build(:cmor_blog_post) }
|
15
18
|
|
16
|
-
|
17
|
-
it { expect{ subject.append_assets = assets; subject.save }.to change { ActiveStorage::Attachment.count }.from(0).to(2) }
|
18
|
-
end
|
19
|
+
before(:each) { subject.save }
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
{ io: File.open(Cmor::Blog::Engine.root.join(*%w(spec files cmor blog asset example.jpg))), filename: 'example.jpg'}
|
24
|
-
]}
|
21
|
+
it { expect{ subject.append_assets = assets; subject.save }.to change { Cmor::Blog::AssetDetail.count }.from(0).to(2) }
|
22
|
+
it { expect{ subject.append_assets = assets; subject.save }.to change { ActiveStorage::Attachment.count }.from(0).to(2) }
|
23
|
+
end
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
describe '#appending assets' do
|
26
|
+
let(:original_assets) {[
|
27
|
+
{ io: File.open(Cmor::Blog::Engine.root.join(*%w(spec files cmor blog asset example.jpg))), filename: 'example.jpg'},
|
28
|
+
{ io: File.open(Cmor::Blog::Engine.root.join(*%w(spec files cmor blog asset example.jpg))), filename: 'example.jpg'}
|
29
|
+
]}
|
29
30
|
|
30
|
-
|
31
|
+
let(:new_assets) {[
|
32
|
+
{ io: File.open(Cmor::Blog::Engine.root.join(*%w(spec files cmor blog asset example.jpg))), filename: 'example.jpg'}
|
33
|
+
]}
|
31
34
|
|
32
|
-
|
35
|
+
subject { build(:cmor_blog_post, assets: original_assets) }
|
33
36
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
+
before(:each) { subject.save }
|
38
|
+
|
39
|
+
it { expect{ subject.append_assets = new_assets; subject.save }.to change { Cmor::Blog::AssetDetail.count }.from(2).to(3) }
|
40
|
+
it { expect{ subject.append_assets = new_assets; subject.save }.to change { ActiveStorage::Attachment.count }.from(2).to(3) }
|
41
|
+
end
|
37
42
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
+
describe '#overwriting assets' do
|
44
|
+
let(:original_assets) {[
|
45
|
+
{ io: File.open(Cmor::Blog::Engine.root.join(*%w(spec files cmor blog asset example.jpg))), filename: 'example.jpg'},
|
46
|
+
{ io: File.open(Cmor::Blog::Engine.root.join(*%w(spec files cmor blog asset example.jpg))), filename: 'example.jpg'}
|
47
|
+
]}
|
43
48
|
|
44
|
-
|
45
|
-
|
46
|
-
|
49
|
+
let(:new_assets) {[
|
50
|
+
{ io: File.open(Cmor::Blog::Engine.root.join(*%w(spec files cmor blog asset example.jpg))), filename: 'example.jpg'}
|
51
|
+
]}
|
47
52
|
|
48
|
-
|
53
|
+
subject { build(:cmor_blog_post, assets: original_assets) }
|
49
54
|
|
50
|
-
|
55
|
+
before(:each) { subject.save }
|
51
56
|
|
52
|
-
|
53
|
-
|
57
|
+
it { expect{ subject.overwrite_assets = new_assets; subject.save }.to change { Cmor::Blog::AssetDetail.count }.from(2).to(1) }
|
58
|
+
it { expect{ subject.overwrite_assets = new_assets; subject.save }.to change { ActiveStorage::Attachment.count }.from(2).to(1) }
|
59
|
+
end
|
54
60
|
end
|
55
|
-
end
|
61
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cmor_blog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.45.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roberto Vasquez Angel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01
|
11
|
+
date: 2020-03-01 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: 5.2.
|
19
|
+
version: 5.2.3
|
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: 5.2.
|
26
|
+
version: 5.2.3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: cmor_core
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.0.
|
33
|
+
version: 0.0.45.pre
|
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: 0.0.
|
40
|
+
version: 0.0.45.pre
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: cmor_core_frontend
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - '='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.0.
|
47
|
+
version: 0.0.45.pre
|
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: 0.0.
|
54
|
+
version: 0.0.45.pre
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: sqlite3
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -440,6 +440,8 @@ files:
|
|
440
440
|
- MIT-LICENSE
|
441
441
|
- Rakefile
|
442
442
|
- app/assets/javascripts/cmor/blog/application.js
|
443
|
+
- app/assets/javascripts/cmor/blog/application/keep.js
|
444
|
+
- app/assets/javascripts/cmor_blog.js
|
443
445
|
- app/assets/stylesheets/cmor/blog/application.css
|
444
446
|
- app/assets/stylesheets/cmor/blog/application/truncate.css
|
445
447
|
- app/assets/stylesheets/cmor_blog.css
|
@@ -458,13 +460,13 @@ files:
|
|
458
460
|
- app/views/cmor/blog/posts/_post_in_index_with_preview_picture.haml
|
459
461
|
- app/views/cmor/blog/posts/index.html.haml
|
460
462
|
- app/views/cmor/blog/posts/show.html.haml
|
461
|
-
- app/views/layouts/cmor/blog/application.html.erb
|
462
463
|
- config/initializers/assets.rb
|
463
464
|
- config/locales/de.yml
|
464
465
|
- config/locales/en.yml
|
465
466
|
- config/routes.rb
|
466
467
|
- db/migrate/20160214133500_create_cmor_blog_posts.rb
|
467
468
|
- db/migrate/20180429134813_create_cmor_blog_asset_details.rb
|
469
|
+
- db/migrate/20200217105600_add_locale_to_cmor_blog_posts.rb
|
468
470
|
- lib/cmor/blog.rb
|
469
471
|
- lib/cmor/blog/configuration.rb
|
470
472
|
- lib/cmor/blog/engine.rb
|
@@ -742,6 +744,7 @@ files:
|
|
742
744
|
- spec/support/capybara.rb
|
743
745
|
- spec/support/factory_bot.rb
|
744
746
|
- spec/support/rao-shoulda_matchers.rb
|
747
|
+
- spec/support/shoulda_matchers.rb
|
745
748
|
homepage: https://github.com/content-management-on-rails
|
746
749
|
licenses:
|
747
750
|
- MIT
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>Blog</title>
|
5
|
-
<%= stylesheet_link_tag "cmor/blog/application", media: "all" %>
|
6
|
-
<%= javascript_include_tag "cmor/blog/application" %>
|
7
|
-
<%= csrf_meta_tags %>
|
8
|
-
</head>
|
9
|
-
<body>
|
10
|
-
|
11
|
-
<%= yield %>
|
12
|
-
|
13
|
-
</body>
|
14
|
-
</html>
|