occams 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/.github/issue_template.md +2 -4
  3. data/CHANGELOG.md +10 -3
  4. data/README.md +0 -1
  5. data/app/controllers/application_controller.rb +0 -2
  6. data/app/controllers/concerns/occams/paginate.rb +0 -2
  7. data/app/controllers/concerns/occams/reorder_action.rb +0 -2
  8. data/app/controllers/occams/admin/base_controller.rb +0 -2
  9. data/app/controllers/occams/admin/cms/base_controller.rb +3 -4
  10. data/app/controllers/occams/admin/cms/categories_controller.rb +0 -2
  11. data/app/controllers/occams/admin/cms/files_controller.rb +4 -7
  12. data/app/controllers/occams/admin/cms/layouts_controller.rb +1 -2
  13. data/app/controllers/occams/admin/cms/pages_controller.rb +4 -5
  14. data/app/controllers/occams/admin/cms/revisions/base_controller.rb +0 -2
  15. data/app/controllers/occams/admin/cms/revisions/layout_controller.rb +0 -2
  16. data/app/controllers/occams/admin/cms/revisions/page_controller.rb +0 -2
  17. data/app/controllers/occams/admin/cms/revisions/snippet_controller.rb +0 -2
  18. data/app/controllers/occams/admin/cms/revisions/translation_controller.rb +0 -2
  19. data/app/controllers/occams/admin/cms/sites_controller.rb +1 -2
  20. data/app/controllers/occams/admin/cms/snippets_controller.rb +1 -2
  21. data/app/controllers/occams/admin/cms/translations_controller.rb +3 -5
  22. data/app/controllers/occams/cms/assets_controller.rb +0 -2
  23. data/app/controllers/occams/cms/base_controller.rb +0 -2
  24. data/app/controllers/occams/cms/content_controller.rb +5 -6
  25. data/app/helpers/occams/admin/cms_helper.rb +0 -2
  26. data/app/helpers/occams/cms_helper.rb +5 -2
  27. data/app/models/concerns/occams/cms/with_categories.rb +5 -7
  28. data/app/models/concerns/occams/cms/with_fragments.rb +7 -9
  29. data/app/models/occams/cms/categorization.rb +2 -4
  30. data/app/models/occams/cms/category.rb +4 -6
  31. data/app/models/occams/cms/file.rb +9 -9
  32. data/app/models/occams/cms/fragment.rb +3 -4
  33. data/app/models/occams/cms/layout.rb +6 -7
  34. data/app/models/occams/cms/page.rb +16 -13
  35. data/app/models/occams/cms/revision.rb +0 -2
  36. data/app/models/occams/cms/site.rb +8 -9
  37. data/app/models/occams/cms/snippet.rb +4 -6
  38. data/app/models/occams/cms/translation.rb +4 -5
  39. data/app/views/layouts/occams/admin/cms/_left.html.haml +4 -0
  40. data/app/views/occams/admin/cms/files/_file.html.haml +1 -1
  41. data/config/application.rb +0 -2
  42. data/config.ru +1 -1
  43. data/lib/generators/occams/cms/assets_generator.rb +0 -2
  44. data/lib/generators/occams/cms/cms_generator.rb +3 -5
  45. data/lib/generators/occams/cms/controllers_generator.rb +0 -2
  46. data/lib/generators/occams/cms/models_generator.rb +0 -2
  47. data/lib/generators/occams/cms/views_generator.rb +0 -2
  48. data/lib/generators/occams/scaffold/scaffold_generator.rb +1 -2
  49. data/lib/occams/access_control/admin_authentication.rb +0 -2
  50. data/lib/occams/access_control/admin_authorization.rb +0 -2
  51. data/lib/occams/access_control/public_authentication.rb +0 -2
  52. data/lib/occams/access_control/public_authorization.rb +0 -2
  53. data/lib/occams/configuration.rb +21 -23
  54. data/lib/occams/content/block.rb +0 -2
  55. data/lib/occams/content/params_parser.rb +9 -11
  56. data/lib/occams/content/renderer.rb +7 -10
  57. data/lib/occams/content/tag.rb +0 -2
  58. data/lib/occams/content/tags/asset.rb +0 -2
  59. data/lib/occams/content/tags/checkbox.rb +0 -2
  60. data/lib/occams/content/tags/date.rb +0 -2
  61. data/lib/occams/content/tags/datetime.rb +0 -2
  62. data/lib/occams/content/tags/file.rb +5 -7
  63. data/lib/occams/content/tags/file_link.rb +1 -2
  64. data/lib/occams/content/tags/files.rb +5 -7
  65. data/lib/occams/content/tags/fragment.rb +0 -2
  66. data/lib/occams/content/tags/helper.rb +0 -2
  67. data/lib/occams/content/tags/markdown.rb +0 -2
  68. data/lib/occams/content/tags/mixins/file_content.rb +1 -2
  69. data/lib/occams/content/tags/number.rb +0 -2
  70. data/lib/occams/content/tags/page_file_link.rb +1 -2
  71. data/lib/occams/content/tags/partial.rb +0 -2
  72. data/lib/occams/content/tags/snippet.rb +0 -2
  73. data/lib/occams/content/tags/template.rb +0 -2
  74. data/lib/occams/content/tags/text.rb +0 -2
  75. data/lib/occams/content/tags/textarea.rb +0 -2
  76. data/lib/occams/content/tags/wysiwyg.rb +0 -2
  77. data/lib/occams/engine.rb +1 -3
  78. data/lib/occams/error.rb +0 -8
  79. data/lib/occams/extensions/acts_as_tree.rb +14 -20
  80. data/lib/occams/extensions/has_revisions.rb +5 -9
  81. data/lib/occams/form_builder.rb +2 -6
  82. data/lib/occams/render_methods.rb +9 -15
  83. data/lib/occams/routes/cms.rb +0 -2
  84. data/lib/occams/routes/cms_admin.rb +1 -3
  85. data/lib/occams/routing.rb +0 -2
  86. data/lib/occams/seeds/file/exporter.rb +2 -4
  87. data/lib/occams/seeds/file/importer.rb +9 -13
  88. data/lib/occams/seeds/layout/exporter.rb +2 -4
  89. data/lib/occams/seeds/layout/importer.rb +3 -5
  90. data/lib/occams/seeds/page/exporter.rb +7 -9
  91. data/lib/occams/seeds/page/importer.rb +3 -5
  92. data/lib/occams/seeds/snippet/exporter.rb +3 -5
  93. data/lib/occams/seeds/snippet/importer.rb +1 -3
  94. data/lib/occams/seeds.rb +1 -7
  95. data/lib/occams/version.rb +1 -3
  96. data/lib/occams/view_hooks.rb +0 -2
  97. data/lib/occams.rb +0 -4
  98. data/lib/tasks/cms_seeds.rake +2 -2
  99. data/occams.gemspec +13 -13
  100. 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^", gravity: "center", crop: "100x75+0+0" },
11
- thumb: { resize: "200x150^", gravity: "center", crop: "200x150+0+0" },
12
- icon: { resize: "28x28^", gravity: "center", crop: "28x28+0+0" }
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 :clear_page_content_cache
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
- Occams::Cms::Page.where(id: site.pages.pluck(:id)).update_all(content_cache: nil)
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
- presence: true,
27
- uniqueness: { scope: :record }
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
- presence: true
21
+ presence: true
23
22
  validates :label,
24
- presence: true
23
+ presence: true
25
24
  validates :identifier,
26
- presence: true,
27
- uniqueness: { scope: :site_id },
28
- format: { with: %r{\A\w[a-z0-9_-]*\z}i }
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
- class_name: "Occams::Cms::Page",
19
- optional: true
17
+ class_name: "Occams::Cms::Page",
18
+ optional: true
20
19
 
21
20
  has_many :translations,
22
- dependent: :destroy
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
- presence: true
34
+ presence: true
36
35
  validates :slug,
37
- presence: true,
38
- uniqueness: { scope: :parent_id },
39
- unless: ->(p) {
40
- p.site && (p.site.pages.count.zero? || p.site.pages.root == self)
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..-1].parameterize
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}[\.\p{Alnum}\p{Mark}_-]*$}i
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
- presence: true,
25
- uniqueness: true,
26
- format: { with: %r{\A\w[a-z0-9_-]*\z}i }
23
+ presence: true,
24
+ uniqueness: true,
25
+ format: { with: %r{\A\w[a-z0-9_-]*\z}i }
27
26
  validates :label,
28
- presence: true
27
+ presence: true
29
28
  validates :hostname,
30
- presence: true,
31
- uniqueness: { scope: :path },
32
- format: { with: %r{\A[\w.-]+(?:\:\d+)?\z} }
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
- presence: true
21
+ presence: true
23
22
  validates :identifier,
24
- presence: true,
25
- uniqueness: { scope: :site_id },
26
- format: { with: %r{\A\w[a-z0-9_-]*\z}i }
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
- presence: true
23
+ presence: true
25
24
 
26
25
  validates :locale,
27
- presence: true,
28
- uniqueness: { scope: :page_id }
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.variant(Occams::Cms::File::VARIANT_SIZE[:thumb])) if file.attachment.variable?
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
@@ -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
@@ -2,5 +2,5 @@
2
2
 
3
3
  # This file is used by Rack-based servers to start the application.
4
4
 
5
- require ::File.expand_path("../config/environment", __FILE__)
5
+ require ::File.expand_path("config/environment", __dir__)
6
6
  run Occams::Application
@@ -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
- "config/initializers/occams.rb"
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
- "app/assets/javascripts/occams/admin/cms/custom.js"
53
+ "app/assets/javascripts/occams/admin/cms/custom.js"
55
54
  copy_file "app/assets/stylesheets/occams/admin/cms/custom.sass",
56
- "app/assets/stylesheets/occams/admin/cms/custom.sass"
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
@@ -2,11 +2,9 @@
2
2
 
3
3
  module Occams::AccessControl
4
4
  module AdminAuthorization
5
-
6
5
  # By default there's no authorization of any kind
7
6
  def authorize
8
7
  true
9
8
  end
10
-
11
9
  end
12
10
  end
@@ -2,11 +2,9 @@
2
2
 
3
3
  module Occams::AccessControl
4
4
  module PublicAuthentication
5
-
6
5
  # By defaut all published pages are accessible
7
6
  def authenticate
8
7
  true
9
8
  end
10
-
11
9
  end
12
10
  end
@@ -2,11 +2,9 @@
2
2
 
3
3
  module Occams::AccessControl
4
4
  module PublicAuthorization
5
-
6
5
  # By default there's no authorization of any kind
7
6
  def authorize
8
7
  true
9
8
  end
10
-
11
9
  end
12
10
  end
@@ -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" => "Català",
106
- "cs" => "Česky",
107
- "da" => "Dansk",
108
- "de" => "Deutsch",
109
- "en" => "English",
110
- "es" => "Español",
111
- "fi" => "Suomi",
112
- "fr" => "Français",
113
- "gr" => "Ελληνικά",
114
- "hr" => "Hrvatski",
115
- "it" => "Italiano",
116
- "ja" => "日本語",
117
- "nb" => "Norsk",
118
- "nl" => "Nederlands",
119
- "pl" => "Polski",
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" => "Slovensky",
123
- "sv" => "Svenska",
124
- "tr" => "Türkçe",
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
@@ -4,11 +4,9 @@
4
4
  # it means that all nodes between this must be moved into here
5
5
  # {{cms:block}} some content {{cms:end_block}}
6
6
  class Occams::Content::Block < Occams::Content::Tag
7
-
8
7
  attr_writer :nodes
9
8
 
10
9
  def nodes
11
10
  @nodes ||= []
12
11
  end
13
-
14
12
  end
@@ -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