cmor_cms 0.0.57.pre → 0.0.58.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bd2a6435a8cebd9eaf5548875ec3e29bbde6c239ce83647a22f4a1e625e85153
4
- data.tar.gz: e3467e2bbe73b40325e8368278c5884d03544aef4eebbcfea9cb9015bdae6f9b
3
+ metadata.gz: 7e62b58cc0f32abc8a8e6cac3b17b5350a7ba6350033c2cb56daee44999c18d7
4
+ data.tar.gz: 868f1976844967465b2d1927eb3663451a2765d1f4af6dad2b46a5aeb023fe48
5
5
  SHA512:
6
- metadata.gz: b83c50abc359f7160212c82e46f594a81d48a5b444d08a5fe5f599e4ef74f5151466cdba4e7d372ebe156ae78ecaec6e3a9ce7ff2f378a3c6464d6fd7a42705e
7
- data.tar.gz: 16f4a3f52d5d9ac2c9e4f4b36109da04b83cdaf84e00fd72a65bf32ff6ec57028efdc6391fbb112c7f968fed5a76a56cd0bfaa8302fafc5a3c7835933b8604cf
6
+ metadata.gz: e5d90528cdf4eca40def1bed25061495afecd6c4e262f422745e299d8d93bfd6f326283d4bb66f525255e508d62031301127318b20cb759cb275845bb2720f9c
7
+ data.tar.gz: 6aa4f799ca502629eec72427a7463cc62ee57b0ae0a3718478f7d73d1234e14c66b8257afdd3f474fecd7aaf19930c6f58ed66b8b12166d98264cd5c03f43a91
@@ -0,0 +1,63 @@
1
+ module Cmor
2
+ module Cms
3
+ module Models
4
+ module DatabaseTemplateConcern
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ # callbacks
9
+ after_initialize :set_defaults
10
+ before_validation :assert_trailing_slash_on_pathname
11
+ after_save :clear_resolver_cache
12
+
13
+ # validations
14
+ validates :basename, presence: true,
15
+ uniqueness: { scope: [:pathname, :locale, :format, :handler] }
16
+ validates :handler, inclusion: { in: ActionView::Template::Handlers.extensions.map(&:to_s) }
17
+ validates :locale, inclusion: { in: I18n.available_locales.map(&:to_s) },
18
+ allow_nil: true,
19
+ allow_blank: true
20
+ validates :format, inclusion: { in: Mime::SET.symbols.map(&:to_s) },
21
+ allow_nil: true,
22
+ allow_blank: true
23
+ validates :pathname, presence: true
24
+ end
25
+
26
+ def human
27
+ "#{self.class.name}: #{path_and_filename}"
28
+ end
29
+
30
+ def filename
31
+ filename = basename.nil? ? '' : basename.dup
32
+ filename << ".#{locale}" if locale.present?
33
+ filename << ".#{format}" if format.present?
34
+ filename << ".#{handler}" if handler.present?
35
+ filename
36
+ end
37
+
38
+ def path_and_filename
39
+ "#{pathname}#{filename}"
40
+ end
41
+
42
+ private
43
+
44
+ def assert_trailing_slash_on_pathname
45
+ self.pathname = '/' and return if pathname.blank?
46
+ pathname << '/' unless pathname.end_with?('/')
47
+ end
48
+
49
+ def clear_resolver_cache
50
+ klass = "#{self.class.name}Resolver"
51
+ klass.constantize.instance.clear_cache
52
+ end
53
+
54
+ def set_defaults
55
+ if new_record?
56
+ self.locale ||= I18n.default_locale.to_s
57
+ self.handler ||= Cmor::Cms::Configuration.default_handlers[self.class.name.demodulize.underscore.to_sym].to_s
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -1,7 +1,7 @@
1
1
  module Cmor::Cms
2
2
  class Layout < ApplicationRecord
3
3
  # add shared behaviour for database backed templates
4
- include Cmor::Cms::DatabaseTemplate
4
+ include Cmor::Cms::Models::DatabaseTemplateConcern
5
5
 
6
6
  # publishing
7
7
  include ActsAsPublished::ActiveRecord
@@ -1,7 +1,7 @@
1
1
  module Cmor::Cms
2
2
  class Page < ActiveRecord::Base
3
3
  # add shared behaviour for database backed templates
4
- include Cmor::Cms::DatabaseTemplate
4
+ include Cmor::Cms::Models::DatabaseTemplateConcern
5
5
 
6
6
  # associations
7
7
  has_many :navigation_items,
@@ -1,7 +1,7 @@
1
1
  module Cmor::Cms
2
2
  class Partial < ActiveRecord::Base
3
3
  # add shared behaviour for database backed templates
4
- include Cmor::Cms::DatabaseTemplate
4
+ include Cmor::Cms::Models::DatabaseTemplateConcern
5
5
 
6
6
  # publishing
7
7
  include ActsAsPublished::ActiveRecord
@@ -1,7 +1,7 @@
1
1
  module Cmor::Cms
2
2
  class Template < ActiveRecord::Base
3
3
  # add shared behaviour for database backed templates
4
- include Cmor::Cms::DatabaseTemplate
4
+ include Cmor::Cms::Models::DatabaseTemplateConcern
5
5
 
6
6
  # publishing
7
7
  include ActsAsPublished::ActiveRecord
@@ -4,8 +4,6 @@ require 'cmor/cms/action_view/template_renderer_patch'
4
4
  require 'cmor/cms/engine'
5
5
  require 'cmor/cms/configuration'
6
6
 
7
- require 'cmor/cms/database_template'
8
-
9
7
  require 'cmor/cms/controller_extensions/layout_resolver'
10
8
  require 'cmor/cms/controller_extensions/page_resolver'
11
9
  require 'cmor/cms/controller_extensions/partial_resolver'
@@ -11,6 +11,10 @@ module Cmor
11
11
  c.performance_tool :rspec
12
12
 
13
13
  end
14
+
15
+ initializer "cmor_cms_engine.register_template_handlers" do |app|
16
+ ::ActionView::Template.register_template_handler :textile, ::ActionView::Template::Handlers::Textile.new
17
+ end
14
18
  end
15
19
  end
16
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cmor_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.57.pre
4
+ version: 0.0.58.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-07-15 00:00:00.000000000 Z
11
+ date: 2020-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -30,28 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 0.0.57.pre
33
+ version: 0.0.58.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.57.pre
40
+ version: 0.0.58.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.57.pre
47
+ version: 0.0.58.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.57.pre
54
+ version: 0.0.58.pre
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: sqlite3
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -418,6 +418,7 @@ files:
418
418
  - app/assets/stylesheets/cmor/cms/application.css
419
419
  - app/assets/stylesheets/cmor/cms/application/keep.css
420
420
  - app/assets/stylesheets/cmor_cms.css
421
+ - app/concerns/cmor/cms/models/database_template_concern.rb
421
422
  - app/concerns/cmor/cms/navigation_item/properties_concern.rb~
422
423
  - app/controllers/cmor/cms/page_controller.rb
423
424
  - app/importers/cmor/cms/importers/navigation.rb
@@ -449,7 +450,6 @@ files:
449
450
  - config/initializers/assets.rb
450
451
  - config/initializers/mime_types.rb
451
452
  - config/initializers/simple_navigation.rb
452
- - config/initializers/textile_support.rb
453
453
  - config/locales/de.yml
454
454
  - config/locales/en.yml
455
455
  - config/navigation.rb
@@ -476,7 +476,6 @@ files:
476
476
  - lib/cmor/cms/controller_extensions/partial_resolver.rb
477
477
  - lib/cmor/cms/controller_extensions/template_resolver.rb
478
478
  - lib/cmor/cms/database_resolver.rb~
479
- - lib/cmor/cms/database_template.rb
480
479
  - lib/cmor/cms/engine.rb
481
480
  - lib/cmor/cms/version.rb
482
481
  - lib/cmor_cms.rb
@@ -1,3 +0,0 @@
1
- Rails.application.config.to_prepare do
2
- ::ActionView::Template.register_template_handler :textile, ::ActionView::Template::Handlers::Textile.new
3
- end
@@ -1,64 +0,0 @@
1
- module Cmor
2
- module Cms
3
- module DatabaseTemplate
4
- def self.included(base)
5
- base.extend(ClassMethods)
6
-
7
- # callbacks
8
- base.after_initialize :set_defaults
9
- base.before_validation :assert_trailing_slash_on_pathname
10
- base.after_save :clear_resolver_cache
11
-
12
- # validations
13
- base.validates :basename, presence: true,
14
- uniqueness: { scope: [:pathname, :locale, :format, :handler] }
15
- base.validates :handler, inclusion: ActionView::Template::Handlers.extensions.map(&:to_s)
16
- base.validates :locale, inclusion: I18n.available_locales.map(&:to_s),
17
- allow_nil: true,
18
- allow_blank: true
19
- base.validates :format, inclusion: Mime::SET.symbols.map(&:to_s),
20
- allow_nil: true,
21
- allow_blank: true
22
- base.validates :pathname, presence: true
23
- end
24
-
25
- module ClassMethods
26
- end
27
-
28
- def human
29
- "#{self.class.name}: #{path_and_filename}"
30
- end
31
-
32
- def filename
33
- filename = basename.nil? ? '' : basename.dup
34
- filename << ".#{locale}" if locale.present?
35
- filename << ".#{format}" if format.present?
36
- filename << ".#{handler}" if handler.present?
37
- filename
38
- end
39
-
40
- def path_and_filename
41
- "#{pathname}#{filename}"
42
- end
43
-
44
- private
45
-
46
- def assert_trailing_slash_on_pathname
47
- self.pathname = '/' and return if pathname.blank?
48
- pathname << '/' unless pathname.end_with?('/')
49
- end
50
-
51
- def clear_resolver_cache
52
- klass = "#{self.class.name}Resolver"
53
- klass.constantize.instance.clear_cache
54
- end
55
-
56
- def set_defaults
57
- if new_record?
58
- self.locale ||= I18n.default_locale.to_s
59
- self.handler ||= Cmor::Cms::Configuration.default_handlers[self.class.name.demodulize.underscore.to_sym].to_s
60
- end
61
- end
62
- end
63
- end
64
- end