occams 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/issue_template.md +2 -4
- data/CHANGELOG.md +10 -3
- data/README.md +0 -1
- data/app/controllers/application_controller.rb +0 -2
- data/app/controllers/concerns/occams/paginate.rb +0 -2
- data/app/controllers/concerns/occams/reorder_action.rb +0 -2
- data/app/controllers/occams/admin/base_controller.rb +0 -2
- data/app/controllers/occams/admin/cms/base_controller.rb +3 -4
- data/app/controllers/occams/admin/cms/categories_controller.rb +0 -2
- data/app/controllers/occams/admin/cms/files_controller.rb +4 -7
- data/app/controllers/occams/admin/cms/layouts_controller.rb +1 -2
- data/app/controllers/occams/admin/cms/pages_controller.rb +4 -5
- data/app/controllers/occams/admin/cms/revisions/base_controller.rb +0 -2
- data/app/controllers/occams/admin/cms/revisions/layout_controller.rb +0 -2
- data/app/controllers/occams/admin/cms/revisions/page_controller.rb +0 -2
- data/app/controllers/occams/admin/cms/revisions/snippet_controller.rb +0 -2
- data/app/controllers/occams/admin/cms/revisions/translation_controller.rb +0 -2
- data/app/controllers/occams/admin/cms/sites_controller.rb +1 -2
- data/app/controllers/occams/admin/cms/snippets_controller.rb +1 -2
- data/app/controllers/occams/admin/cms/translations_controller.rb +3 -5
- data/app/controllers/occams/cms/assets_controller.rb +0 -2
- data/app/controllers/occams/cms/base_controller.rb +0 -2
- data/app/controllers/occams/cms/content_controller.rb +5 -6
- data/app/helpers/occams/admin/cms_helper.rb +0 -2
- data/app/helpers/occams/cms_helper.rb +5 -2
- data/app/models/concerns/occams/cms/with_categories.rb +5 -7
- data/app/models/concerns/occams/cms/with_fragments.rb +7 -9
- data/app/models/occams/cms/categorization.rb +2 -4
- data/app/models/occams/cms/category.rb +4 -6
- data/app/models/occams/cms/file.rb +9 -9
- data/app/models/occams/cms/fragment.rb +3 -4
- data/app/models/occams/cms/layout.rb +6 -7
- data/app/models/occams/cms/page.rb +16 -13
- data/app/models/occams/cms/revision.rb +0 -2
- data/app/models/occams/cms/site.rb +8 -9
- data/app/models/occams/cms/snippet.rb +4 -6
- data/app/models/occams/cms/translation.rb +4 -5
- data/app/views/layouts/occams/admin/cms/_left.html.haml +4 -0
- data/app/views/occams/admin/cms/files/_file.html.haml +1 -1
- data/config/application.rb +0 -2
- data/config.ru +1 -1
- data/lib/generators/occams/cms/assets_generator.rb +0 -2
- data/lib/generators/occams/cms/cms_generator.rb +3 -5
- data/lib/generators/occams/cms/controllers_generator.rb +0 -2
- data/lib/generators/occams/cms/models_generator.rb +0 -2
- data/lib/generators/occams/cms/views_generator.rb +0 -2
- data/lib/generators/occams/scaffold/scaffold_generator.rb +1 -2
- data/lib/occams/access_control/admin_authentication.rb +0 -2
- data/lib/occams/access_control/admin_authorization.rb +0 -2
- data/lib/occams/access_control/public_authentication.rb +0 -2
- data/lib/occams/access_control/public_authorization.rb +0 -2
- data/lib/occams/configuration.rb +21 -23
- data/lib/occams/content/block.rb +0 -2
- data/lib/occams/content/params_parser.rb +9 -11
- data/lib/occams/content/renderer.rb +7 -10
- data/lib/occams/content/tag.rb +0 -2
- data/lib/occams/content/tags/asset.rb +0 -2
- data/lib/occams/content/tags/checkbox.rb +0 -2
- data/lib/occams/content/tags/date.rb +0 -2
- data/lib/occams/content/tags/datetime.rb +0 -2
- data/lib/occams/content/tags/file.rb +5 -7
- data/lib/occams/content/tags/file_link.rb +1 -2
- data/lib/occams/content/tags/files.rb +5 -7
- data/lib/occams/content/tags/fragment.rb +0 -2
- data/lib/occams/content/tags/helper.rb +0 -2
- data/lib/occams/content/tags/markdown.rb +0 -2
- data/lib/occams/content/tags/mixins/file_content.rb +1 -2
- data/lib/occams/content/tags/number.rb +0 -2
- data/lib/occams/content/tags/page_file_link.rb +1 -2
- data/lib/occams/content/tags/partial.rb +0 -2
- data/lib/occams/content/tags/snippet.rb +0 -2
- data/lib/occams/content/tags/template.rb +0 -2
- data/lib/occams/content/tags/text.rb +0 -2
- data/lib/occams/content/tags/textarea.rb +0 -2
- data/lib/occams/content/tags/wysiwyg.rb +0 -2
- data/lib/occams/engine.rb +1 -3
- data/lib/occams/error.rb +0 -8
- data/lib/occams/extensions/acts_as_tree.rb +14 -20
- data/lib/occams/extensions/has_revisions.rb +5 -9
- data/lib/occams/form_builder.rb +2 -6
- data/lib/occams/render_methods.rb +9 -15
- data/lib/occams/routes/cms.rb +0 -2
- data/lib/occams/routes/cms_admin.rb +1 -3
- data/lib/occams/routing.rb +0 -2
- data/lib/occams/seeds/file/exporter.rb +2 -4
- data/lib/occams/seeds/file/importer.rb +9 -13
- data/lib/occams/seeds/layout/exporter.rb +2 -4
- data/lib/occams/seeds/layout/importer.rb +3 -5
- data/lib/occams/seeds/page/exporter.rb +7 -9
- data/lib/occams/seeds/page/importer.rb +3 -5
- data/lib/occams/seeds/snippet/exporter.rb +3 -5
- data/lib/occams/seeds/snippet/importer.rb +1 -3
- data/lib/occams/seeds.rb +1 -7
- data/lib/occams/version.rb +1 -3
- data/lib/occams/view_hooks.rb +0 -2
- data/lib/occams.rb +0 -4
- data/lib/tasks/cms_seeds.rake +2 -2
- data/occams.gemspec +13 -13
- metadata +62 -8
@@ -1,15 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Occams::Cms::File < ActiveRecord::Base
|
4
|
-
|
5
4
|
self.table_name = "occams_cms_files"
|
6
5
|
|
7
6
|
include Occams::Cms::WithCategories
|
8
7
|
|
9
8
|
VARIANT_SIZE = {
|
10
|
-
redactor: { resize: "100x75^",
|
11
|
-
thumb:
|
12
|
-
icon:
|
9
|
+
redactor: { resize: "100x75^", gravity: "center", crop: "100x75+0+0" },
|
10
|
+
thumb: { resize: "200x150^", gravity: "center", crop: "200x150+0+0" },
|
11
|
+
icon: { resize: "28x28^", gravity: "center", crop: "28x28+0+0" }
|
13
12
|
}.freeze
|
14
13
|
|
15
14
|
# temporary place to store attachment
|
@@ -30,7 +29,7 @@ class Occams::Cms::File < ActiveRecord::Base
|
|
30
29
|
after_save :process_attachment
|
31
30
|
end
|
32
31
|
|
33
|
-
after_save
|
32
|
+
after_save :clear_page_content_cache
|
34
33
|
|
35
34
|
# -- Validations -------------------------------------------------------------
|
36
35
|
validates :label, presence: true
|
@@ -45,9 +44,9 @@ class Occams::Cms::File < ActiveRecord::Base
|
|
45
44
|
|
46
45
|
private
|
47
46
|
|
48
|
-
def clear_page_content_cache
|
49
|
-
|
50
|
-
end
|
47
|
+
def clear_page_content_cache
|
48
|
+
Occams::Cms::Page.where(id: site.pages.pluck(:id)).update_all(content_cache: nil)
|
49
|
+
end
|
51
50
|
|
52
51
|
protected
|
53
52
|
|
@@ -59,12 +58,13 @@ protected
|
|
59
58
|
# TODO: Change db schema not to set blank string
|
60
59
|
def assign_label
|
61
60
|
return if label.present?
|
61
|
+
|
62
62
|
self.label = file&.original_filename
|
63
63
|
end
|
64
64
|
|
65
65
|
def process_attachment
|
66
66
|
return if @file.blank?
|
67
|
+
|
67
68
|
self.attachment = @file
|
68
69
|
end
|
69
|
-
|
70
70
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Occams::Cms::Fragment < ActiveRecord::Base
|
4
|
-
|
5
4
|
self.table_name = "occams_cms_fragments"
|
6
5
|
|
7
6
|
has_many_attached :attachments
|
@@ -23,8 +22,8 @@ class Occams::Cms::Fragment < ActiveRecord::Base
|
|
23
22
|
|
24
23
|
# -- Validations -------------------------------------------------------------
|
25
24
|
validates :identifier,
|
26
|
-
|
27
|
-
|
25
|
+
presence: true,
|
26
|
+
uniqueness: { scope: :record }
|
28
27
|
|
29
28
|
# -- Instance Methods --------------------------------------------------------
|
30
29
|
|
@@ -45,6 +44,7 @@ protected
|
|
45
44
|
|
46
45
|
def remove_attachments
|
47
46
|
return unless @file_ids_destroy.present?
|
47
|
+
|
48
48
|
attachments.where(id: @file_ids_destroy).destroy_all
|
49
49
|
end
|
50
50
|
|
@@ -59,5 +59,4 @@ protected
|
|
59
59
|
|
60
60
|
attachments.attach(@files)
|
61
61
|
end
|
62
|
-
|
63
62
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Occams::Cms::Layout < ActiveRecord::Base
|
4
|
-
|
5
4
|
self.table_name = "occams_cms_layouts"
|
6
5
|
|
7
6
|
cms_acts_as_tree
|
@@ -19,13 +18,13 @@ class Occams::Cms::Layout < ActiveRecord::Base
|
|
19
18
|
|
20
19
|
# -- Validations -------------------------------------------------------------
|
21
20
|
validates :site_id,
|
22
|
-
|
21
|
+
presence: true
|
23
22
|
validates :label,
|
24
|
-
|
23
|
+
presence: true
|
25
24
|
validates :identifier,
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
presence: true,
|
26
|
+
uniqueness: { scope: :site_id },
|
27
|
+
format: { with: %r{\A\w[a-z0-9_-]*\z}i }
|
29
28
|
|
30
29
|
# -- Class Methods -----------------------------------------------------------
|
31
30
|
# Tree-like structure for layouts
|
@@ -106,8 +105,8 @@ protected
|
|
106
105
|
|
107
106
|
def assign_position
|
108
107
|
return if position.to_i.positive?
|
108
|
+
|
109
109
|
max = site.layouts.where(parent_id: parent_id).maximum(:position)
|
110
110
|
self.position = max ? max + 1 : 0
|
111
111
|
end
|
112
|
-
|
113
112
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Occams::Cms::Page < ActiveRecord::Base
|
4
|
-
|
5
4
|
self.table_name = "occams_cms_pages"
|
6
5
|
|
7
6
|
include Occams::Cms::WithFragments
|
@@ -15,11 +14,11 @@ class Occams::Cms::Page < ActiveRecord::Base
|
|
15
14
|
# -- Relationships -----------------------------------------------------------
|
16
15
|
belongs_to :site
|
17
16
|
belongs_to :target_page,
|
18
|
-
|
19
|
-
|
17
|
+
class_name: "Occams::Cms::Page",
|
18
|
+
optional: true
|
20
19
|
|
21
20
|
has_many :translations,
|
22
|
-
|
21
|
+
dependent: :destroy
|
23
22
|
|
24
23
|
# -- Callbacks ---------------------------------------------------------------
|
25
24
|
before_validation :assigns_label,
|
@@ -32,13 +31,13 @@ class Occams::Cms::Page < ActiveRecord::Base
|
|
32
31
|
|
33
32
|
# -- Validations -------------------------------------------------------------
|
34
33
|
validates :label,
|
35
|
-
|
34
|
+
presence: true
|
36
35
|
validates :slug,
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
36
|
+
presence: true,
|
37
|
+
uniqueness: { scope: :parent_id },
|
38
|
+
unless: ->(p) {
|
39
|
+
p.site && (p.site.pages.count.zero? || p.site.pages.root == self)
|
40
|
+
}
|
42
41
|
validate :validate_target_page
|
43
42
|
validate :validate_format_of_unescaped_slug
|
44
43
|
|
@@ -75,7 +74,7 @@ class Occams::Cms::Page < ActiveRecord::Base
|
|
75
74
|
|
76
75
|
# Somewhat unique method of identifying a page that is not a full_path
|
77
76
|
def identifier
|
78
|
-
parent_id.blank? ? "index" : full_path[1
|
77
|
+
parent_id.blank? ? "index" : full_path[1..].parameterize
|
79
78
|
end
|
80
79
|
|
81
80
|
# Full url for a page
|
@@ -113,6 +112,7 @@ protected
|
|
113
112
|
|
114
113
|
def assign_parent
|
115
114
|
return unless site
|
115
|
+
|
116
116
|
self.parent ||= site.pages.root unless self == site.pages.root || site.pages.count.zero?
|
117
117
|
end
|
118
118
|
|
@@ -128,12 +128,14 @@ protected
|
|
128
128
|
def assign_position
|
129
129
|
return unless self.parent
|
130
130
|
return if position.to_i.positive?
|
131
|
+
|
131
132
|
max = self.parent.children.maximum(:position)
|
132
133
|
self.position = max ? max + 1 : 0
|
133
134
|
end
|
134
135
|
|
135
136
|
def validate_target_page
|
136
137
|
return unless target_page
|
138
|
+
|
137
139
|
p = self
|
138
140
|
while p.target_page
|
139
141
|
if (p = p.target_page) == self
|
@@ -144,13 +146,15 @@ protected
|
|
144
146
|
|
145
147
|
def validate_format_of_unescaped_slug
|
146
148
|
return unless slug.present?
|
149
|
+
|
147
150
|
unescaped_slug = CGI.unescape(slug)
|
148
|
-
errors.add(:slug, :invalid) unless unescaped_slug =~ %r{^\p{Alnum}[
|
151
|
+
errors.add(:slug, :invalid) unless unescaped_slug =~ %r{^\p{Alnum}[.\p{Alnum}\p{Mark}_-]*$}i
|
149
152
|
end
|
150
153
|
|
151
154
|
# Forcing re-saves for child pages so they can update full_paths
|
152
155
|
def sync_child_full_paths!
|
153
156
|
return unless full_path_previously_changed?
|
157
|
+
|
154
158
|
children.each do |p|
|
155
159
|
p.update_attribute(:full_path, p.send(:assign_full_path))
|
156
160
|
end
|
@@ -166,5 +170,4 @@ protected
|
|
166
170
|
self.slug = CGI.unescape(slug) unless slug.nil?
|
167
171
|
self.full_path = CGI.unescape(full_path) unless full_path.nil?
|
168
172
|
end
|
169
|
-
|
170
173
|
end
|
@@ -1,12 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Occams::Cms::Revision < ActiveRecord::Base
|
4
|
-
|
5
4
|
self.table_name = "occams_cms_revisions"
|
6
5
|
|
7
6
|
serialize :data
|
8
7
|
|
9
8
|
# -- Relationships --------------------------------------------------------
|
10
9
|
belongs_to :record, polymorphic: true
|
11
|
-
|
12
10
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Occams::Cms::Site < ActiveRecord::Base
|
4
|
-
|
5
4
|
self.table_name = "occams_cms_sites"
|
6
5
|
|
7
6
|
# -- Relationships -----------------------------------------------------------
|
@@ -21,20 +20,21 @@ class Occams::Cms::Site < ActiveRecord::Base
|
|
21
20
|
|
22
21
|
# -- Validations -------------------------------------------------------------
|
23
22
|
validates :identifier,
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
presence: true,
|
24
|
+
uniqueness: true,
|
25
|
+
format: { with: %r{\A\w[a-z0-9_-]*\z}i }
|
27
26
|
validates :label,
|
28
|
-
|
27
|
+
presence: true
|
29
28
|
validates :hostname,
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
presence: true,
|
30
|
+
uniqueness: { scope: :path },
|
31
|
+
format: { with: %r{\A[\w.-]+(?::\d+)?\z} }
|
33
32
|
|
34
33
|
# -- Class Methods -----------------------------------------------------------
|
35
34
|
# returning the Occams::Cms::Site instance based on host and path
|
36
35
|
def self.find_site(host, path = nil)
|
37
36
|
return Occams::Cms::Site.first if Occams::Cms::Site.count == 1
|
37
|
+
|
38
38
|
cms_site = nil
|
39
39
|
|
40
40
|
public_cms_path = Occams.configuration.public_cms_path
|
@@ -90,5 +90,4 @@ protected
|
|
90
90
|
self.path.gsub!(%r{/$}, "")
|
91
91
|
self.path = nil if self.path.blank?
|
92
92
|
end
|
93
|
-
|
94
93
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Occams::Cms::Snippet < ActiveRecord::Base
|
4
|
-
|
5
4
|
self.table_name = "occams_cms_snippets"
|
6
5
|
|
7
6
|
include Occams::Cms::WithCategories
|
@@ -19,11 +18,11 @@ class Occams::Cms::Snippet < ActiveRecord::Base
|
|
19
18
|
|
20
19
|
# -- Validations -------------------------------------------------------------
|
21
20
|
validates :label,
|
22
|
-
|
21
|
+
presence: true
|
23
22
|
validates :identifier,
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
presence: true,
|
24
|
+
uniqueness: { scope: :site_id },
|
25
|
+
format: { with: %r{\A\w[a-z0-9_-]*\z}i }
|
27
26
|
|
28
27
|
protected
|
29
28
|
|
@@ -41,5 +40,4 @@ protected
|
|
41
40
|
max = site.snippets.maximum(:position)
|
42
41
|
self.position = max ? max + 1 : 0
|
43
42
|
end
|
44
|
-
|
45
43
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Occams::Cms::Translation < ActiveRecord::Base
|
4
|
-
|
5
4
|
self.table_name = "occams_cms_translations"
|
6
5
|
|
7
6
|
include Occams::Cms::WithFragments
|
@@ -21,11 +20,11 @@ class Occams::Cms::Translation < ActiveRecord::Base
|
|
21
20
|
|
22
21
|
# -- Validations -------------------------------------------------------------
|
23
22
|
validates :label,
|
24
|
-
|
23
|
+
presence: true
|
25
24
|
|
26
25
|
validates :locale,
|
27
|
-
|
28
|
-
|
26
|
+
presence: true,
|
27
|
+
uniqueness: { scope: :page_id }
|
29
28
|
|
30
29
|
validate :validate_locale
|
31
30
|
|
@@ -33,11 +32,11 @@ private
|
|
33
32
|
|
34
33
|
def validate_locale
|
35
34
|
return unless page
|
35
|
+
|
36
36
|
errors.add(:locale) if locale == page.site.locale
|
37
37
|
end
|
38
38
|
|
39
39
|
def assign_layout
|
40
40
|
self.layout ||= page.layout if page.present?
|
41
41
|
end
|
42
|
-
|
43
42
|
end
|
@@ -37,3 +37,7 @@
|
|
37
37
|
.left-footer
|
38
38
|
= link_to 'Occams', 'https://github.com/avonderluft/occams', target: '_blank'
|
39
39
|
%span.version= Occams::VERSION
|
40
|
+
= link_to 'Rails', 'https://rubyonrails.org', target: '_blank'
|
41
|
+
%span.version= Rails::version
|
42
|
+
= link_to 'Ruby', 'https://www.ruby-lang.org', target: '_blank'
|
43
|
+
%span.version= RUBY_VERSION
|
@@ -1,7 +1,7 @@
|
|
1
1
|
%li{data: {id: file.id}}
|
2
2
|
:ruby
|
3
3
|
file_tag = cms_file_link_tag(file)
|
4
|
-
thumb_url = url_for(file.attachment.
|
4
|
+
thumb_url = url_for(file.attachment.representation(resize_to_limit: [200, nil])) if file.attachment.variable?
|
5
5
|
.row
|
6
6
|
.col-md-5.item
|
7
7
|
.item-controls.d-none.d-lg-block
|
data/config/application.rb
CHANGED
@@ -10,7 +10,6 @@ Bundler.require(*Rails.groups)
|
|
10
10
|
|
11
11
|
module Occams
|
12
12
|
class Application < Rails::Application
|
13
|
-
|
14
13
|
require_relative "../lib/occams"
|
15
14
|
|
16
15
|
config.load_defaults 5.2
|
@@ -34,6 +33,5 @@ module Occams
|
|
34
33
|
config.paths["config/routes.rb"] << "config/cms_routes.rb"
|
35
34
|
|
36
35
|
config.i18n.enforce_available_locales = true
|
37
|
-
|
38
36
|
end
|
39
37
|
end
|
data/config.ru
CHANGED
@@ -4,14 +4,12 @@ module Occams
|
|
4
4
|
module Generators
|
5
5
|
module Cms
|
6
6
|
class AssetsGenerator < Rails::Generators::Base
|
7
|
-
|
8
7
|
source_root File.expand_path(File.join(File.dirname(__FILE__), "../../../../app/assets"))
|
9
8
|
|
10
9
|
def generate_assets
|
11
10
|
directory "javascripts/occams/admin/cms", "app/assets/javascripts/occams/admin/cms"
|
12
11
|
directory "stylesheets/occams/admin/cms", "app/assets/stylesheets/occams/admin/cms"
|
13
12
|
end
|
14
|
-
|
15
13
|
end
|
16
14
|
end
|
17
15
|
end
|
@@ -5,7 +5,6 @@ require "rails/generators/active_record"
|
|
5
5
|
module Occams
|
6
6
|
module Generators
|
7
7
|
class CmsGenerator < Rails::Generators::Base
|
8
|
-
|
9
8
|
include Rails::Generators::Migration
|
10
9
|
include Thor::Actions
|
11
10
|
|
@@ -25,7 +24,7 @@ module Occams
|
|
25
24
|
|
26
25
|
def generate_initializer
|
27
26
|
copy_file "config/initializers/occams.rb",
|
28
|
-
|
27
|
+
"config/initializers/occams.rb"
|
29
28
|
end
|
30
29
|
|
31
30
|
def generate_railties_order
|
@@ -51,9 +50,9 @@ module Occams
|
|
51
50
|
|
52
51
|
def generate_assets
|
53
52
|
copy_file "app/assets/javascripts/occams/admin/cms/custom.js",
|
54
|
-
|
53
|
+
"app/assets/javascripts/occams/admin/cms/custom.js"
|
55
54
|
copy_file "app/assets/stylesheets/occams/admin/cms/custom.sass",
|
56
|
-
|
55
|
+
"app/assets/stylesheets/occams/admin/cms/custom.sass"
|
57
56
|
end
|
58
57
|
|
59
58
|
def show_readme
|
@@ -63,7 +62,6 @@ module Occams
|
|
63
62
|
def self.next_migration_number(dirname)
|
64
63
|
ActiveRecord::Generators::Base.next_migration_number(dirname)
|
65
64
|
end
|
66
|
-
|
67
65
|
end
|
68
66
|
end
|
69
67
|
end
|
@@ -4,13 +4,11 @@ module Occams
|
|
4
4
|
module Generators
|
5
5
|
module Cms
|
6
6
|
class ControllersGenerator < Rails::Generators::Base
|
7
|
-
|
8
7
|
source_root File.expand_path(File.join(File.dirname(__FILE__), "../../../../app/controllers"))
|
9
8
|
|
10
9
|
def generate_controllers
|
11
10
|
directory "occams", "app/controllers/occams"
|
12
11
|
end
|
13
|
-
|
14
12
|
end
|
15
13
|
end
|
16
14
|
end
|
@@ -4,13 +4,11 @@ module Occams
|
|
4
4
|
module Generators
|
5
5
|
module Cms
|
6
6
|
class ModelsGenerator < Rails::Generators::Base
|
7
|
-
|
8
7
|
source_root File.expand_path(File.join(File.dirname(__FILE__), "../../../../app/models"))
|
9
8
|
|
10
9
|
def generate_models
|
11
10
|
directory "occams", "app/models/occams"
|
12
11
|
end
|
13
|
-
|
14
12
|
end
|
15
13
|
end
|
16
14
|
end
|
@@ -4,13 +4,11 @@ module Occams
|
|
4
4
|
module Generators
|
5
5
|
module Cms
|
6
6
|
class ViewsGenerator < Rails::Generators::Base
|
7
|
-
|
8
7
|
source_root File.expand_path(File.join(File.dirname(__FILE__), "../../../../app/views"))
|
9
8
|
|
10
9
|
def generate_views
|
11
10
|
directory "occams", "app/views/occams"
|
12
11
|
end
|
13
|
-
|
14
12
|
end
|
15
13
|
end
|
16
14
|
end
|
@@ -6,7 +6,6 @@ require "rails/generators/active_record"
|
|
6
6
|
module Occams
|
7
7
|
module Generators
|
8
8
|
class ScaffoldGenerator < Rails::Generators::NamedBase
|
9
|
-
|
10
9
|
include Rails::Generators::Migration
|
11
10
|
|
12
11
|
no_tasks do
|
@@ -22,6 +21,7 @@ module Occams
|
|
22
21
|
@model_attrs = []
|
23
22
|
model_args.each do |arg|
|
24
23
|
next unless arg.include?(":")
|
24
|
+
|
25
25
|
@model_attrs << Rails::Generators::GeneratedAttribute.new(*arg.split(":"))
|
26
26
|
end
|
27
27
|
end
|
@@ -74,7 +74,6 @@ module Occams
|
|
74
74
|
HAML
|
75
75
|
end
|
76
76
|
end
|
77
|
-
|
78
77
|
end
|
79
78
|
end
|
80
79
|
end
|
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
module Occams::AccessControl
|
4
4
|
module AdminAuthentication
|
5
|
-
|
6
5
|
# Set username and password in config/initializers/occams.rb
|
7
6
|
# Like this:
|
8
7
|
# Occams::AccessControl::AdminAuthentication.username = 'myname'
|
@@ -19,6 +18,5 @@ module Occams::AccessControl
|
|
19
18
|
self.username == username && self.password == password
|
20
19
|
end
|
21
20
|
end
|
22
|
-
|
23
21
|
end
|
24
22
|
end
|
data/lib/occams/configuration.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Occams::Configuration
|
4
|
-
|
5
4
|
# Don't like Occams? Set it to whatever you like. :(
|
6
5
|
attr_accessor :cms_title
|
7
6
|
|
@@ -101,28 +100,28 @@ class Occams::Configuration
|
|
101
100
|
@seeds_path = File.expand_path("db/cms_seeds", Rails.root)
|
102
101
|
@revisions_limit = 25
|
103
102
|
@locales = {
|
104
|
-
"ar"
|
105
|
-
"ca"
|
106
|
-
"cs"
|
107
|
-
"da"
|
108
|
-
"de"
|
109
|
-
"en"
|
110
|
-
"es"
|
111
|
-
"fi"
|
112
|
-
"fr"
|
113
|
-
"gr"
|
114
|
-
"hr"
|
115
|
-
"it"
|
116
|
-
"ja"
|
117
|
-
"nb"
|
118
|
-
"nl"
|
119
|
-
"pl"
|
103
|
+
"ar" => "عربي",
|
104
|
+
"ca" => "Català",
|
105
|
+
"cs" => "Česky",
|
106
|
+
"da" => "Dansk",
|
107
|
+
"de" => "Deutsch",
|
108
|
+
"en" => "English",
|
109
|
+
"es" => "Español",
|
110
|
+
"fi" => "Suomi",
|
111
|
+
"fr" => "Français",
|
112
|
+
"gr" => "Ελληνικά",
|
113
|
+
"hr" => "Hrvatski",
|
114
|
+
"it" => "Italiano",
|
115
|
+
"ja" => "日本語",
|
116
|
+
"nb" => "Norsk",
|
117
|
+
"nl" => "Nederlands",
|
118
|
+
"pl" => "Polski",
|
120
119
|
"pt-BR" => "Português Brasileiro",
|
121
|
-
"ru"
|
122
|
-
"sk"
|
123
|
-
"sv"
|
124
|
-
"tr"
|
125
|
-
"uk"
|
120
|
+
"ru" => "Русский",
|
121
|
+
"sk" => "Slovensky",
|
122
|
+
"sv" => "Svenska",
|
123
|
+
"tr" => "Türkçe",
|
124
|
+
"uk" => "Українська",
|
126
125
|
"zh-CN" => "简体中文",
|
127
126
|
"zh-TW" => "正體中文"
|
128
127
|
}
|
@@ -136,5 +135,4 @@ class Occams::Configuration
|
|
136
135
|
@public_cms_path = nil
|
137
136
|
@page_to_json_options = { methods: [:content], except: [:content_cache] }
|
138
137
|
end
|
139
|
-
|
140
138
|
end
|
data/lib/occams/content/block.rb
CHANGED
@@ -3,18 +3,17 @@
|
|
3
3
|
require "strscan"
|
4
4
|
|
5
5
|
class Occams::Content::ParamsParser
|
6
|
-
|
7
6
|
class Error < StandardError; end
|
8
7
|
|
9
|
-
STRING_LITERAL = %r{'[^']*'|"[^"]*"}
|
10
|
-
IDENTIFIER = %r{[a-z0-9][\w\-/.]*}i
|
11
|
-
HASH_KEY = %r{#{IDENTIFIER}:}
|
12
|
-
COMMA = %r{,}
|
13
|
-
HASH_OPEN = %r{\{}
|
14
|
-
HASH_CLOSE = %r{\}}
|
15
|
-
ARRAY_OPEN = %r{\[}
|
16
|
-
ARRAY_CLOSE = %r{\]}
|
17
|
-
INTEGER = %r{\b[0-9]+\b}i
|
8
|
+
STRING_LITERAL = %r{'[^']*'|"[^"]*"}.freeze
|
9
|
+
IDENTIFIER = %r{[a-z0-9][\w\-/.]*}i.freeze
|
10
|
+
HASH_KEY = %r{#{IDENTIFIER}:}.freeze
|
11
|
+
COMMA = %r{,}.freeze
|
12
|
+
HASH_OPEN = %r{\{}.freeze
|
13
|
+
HASH_CLOSE = %r{\}}.freeze
|
14
|
+
ARRAY_OPEN = %r{\[}.freeze
|
15
|
+
ARRAY_CLOSE = %r{\]}.freeze
|
16
|
+
INTEGER = %r{\b[0-9]+\b}i.freeze
|
18
17
|
|
19
18
|
# @param <String> string
|
20
19
|
def initialize(string = "")
|
@@ -147,5 +146,4 @@ private
|
|
147
146
|
|
148
147
|
tokens
|
149
148
|
end
|
150
|
-
|
151
149
|
end
|