occams 1.0.1 → 1.0.2

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/.rubocop.yml +23 -40
  3. data/CHANGELOG.md +8 -0
  4. data/Gemfile +17 -17
  5. data/LICENSE +1 -1
  6. data/README.md +15 -18
  7. data/Rakefile +1 -1
  8. data/TODOS.md +6 -0
  9. data/app/controllers/occams/admin/base_controller.rb +1 -1
  10. data/app/controllers/occams/admin/cms/base_controller.rb +7 -7
  11. data/app/controllers/occams/admin/cms/files_controller.rb +17 -17
  12. data/app/controllers/occams/admin/cms/layouts_controller.rb +7 -7
  13. data/app/controllers/occams/admin/cms/pages_controller.rb +25 -25
  14. data/app/controllers/occams/admin/cms/revisions/base_controller.rb +5 -5
  15. data/app/controllers/occams/admin/cms/revisions/layout_controller.rb +1 -1
  16. data/app/controllers/occams/admin/cms/revisions/page_controller.rb +3 -3
  17. data/app/controllers/occams/admin/cms/revisions/snippet_controller.rb +1 -1
  18. data/app/controllers/occams/admin/cms/revisions/translation_controller.rb +3 -3
  19. data/app/controllers/occams/admin/cms/sites_controller.rb +6 -6
  20. data/app/controllers/occams/admin/cms/snippets_controller.rb +6 -6
  21. data/app/controllers/occams/admin/cms/translations_controller.rb +24 -24
  22. data/app/controllers/occams/cms/assets_controller.rb +5 -5
  23. data/app/controllers/occams/cms/base_controller.rb +7 -12
  24. data/app/controllers/occams/cms/content_controller.rb +14 -10
  25. data/app/helpers/occams/admin/cms_helper.rb +3 -3
  26. data/app/helpers/occams/cms_helper.rb +8 -8
  27. data/app/models/concerns/occams/cms/with_categories.rb +3 -3
  28. data/app/models/concerns/occams/cms/with_fragments.rb +3 -3
  29. data/app/models/occams/cms/categorization.rb +1 -1
  30. data/app/models/occams/cms/category.rb +1 -1
  31. data/app/models/occams/cms/file.rb +4 -4
  32. data/app/models/occams/cms/fragment.rb +2 -2
  33. data/app/models/occams/cms/layout.rb +5 -5
  34. data/app/models/occams/cms/page.rb +6 -6
  35. data/app/models/occams/cms/revision.rb +1 -1
  36. data/app/models/occams/cms/site.rb +8 -8
  37. data/app/models/occams/cms/snippet.rb +1 -1
  38. data/app/models/occams/cms/translation.rb +1 -1
  39. data/app/views/layouts/occams/admin/cms/_left.html.haml +1 -0
  40. data/config/application.rb +4 -4
  41. data/config/boot.rb +4 -3
  42. data/config/environment.rb +1 -1
  43. data/config/environments/development.rb +2 -2
  44. data/config/environments/test.rb +1 -1
  45. data/config/initializers/occams.rb +2 -2
  46. data/config.ru +1 -1
  47. data/lib/generators/occams/cms/assets_generator.rb +3 -3
  48. data/lib/generators/occams/cms/cms_generator.rb +13 -13
  49. data/lib/generators/occams/cms/controllers_generator.rb +2 -2
  50. data/lib/generators/occams/cms/models_generator.rb +2 -2
  51. data/lib/generators/occams/cms/views_generator.rb +2 -2
  52. data/lib/generators/occams/scaffold/scaffold_generator.rb +18 -18
  53. data/lib/occams/configuration.rb +33 -33
  54. data/lib/occams/content/params_parser.rb +3 -3
  55. data/lib/occams/content/renderer.rb +8 -8
  56. data/lib/occams/content/tag.rb +1 -1
  57. data/lib/occams/content/tags/asset.rb +13 -13
  58. data/lib/occams/content/tags/checkbox.rb +4 -4
  59. data/lib/occams/content/tags/date.rb +2 -2
  60. data/lib/occams/content/tags/datetime.rb +4 -4
  61. data/lib/occams/content/tags/file.rb +8 -8
  62. data/lib/occams/content/tags/file_link.rb +8 -8
  63. data/lib/occams/content/tags/files.rb +5 -5
  64. data/lib/occams/content/tags/fragment.rb +4 -4
  65. data/lib/occams/content/tags/helper.rb +6 -6
  66. data/lib/occams/content/tags/markdown.rb +2 -2
  67. data/lib/occams/content/tags/mixins/file_content.rb +3 -3
  68. data/lib/occams/content/tags/number.rb +1 -1
  69. data/lib/occams/content/tags/page_file_link.rb +8 -8
  70. data/lib/occams/content/tags/partial.rb +5 -5
  71. data/lib/occams/content/tags/snippet.rb +3 -3
  72. data/lib/occams/content/tags/template.rb +5 -5
  73. data/lib/occams/content/tags/text.rb +1 -1
  74. data/lib/occams/content/tags/textarea.rb +1 -1
  75. data/lib/occams/content/tags/wysiwyg.rb +1 -1
  76. data/lib/occams/content.rb +22 -22
  77. data/lib/occams/engine.rb +10 -10
  78. data/lib/occams/extensions/acts_as_tree.rb +1 -1
  79. data/lib/occams/extensions/has_revisions.rb +3 -3
  80. data/lib/occams/form_builder.rb +4 -4
  81. data/lib/occams/render_methods.rb +2 -2
  82. data/lib/occams/routes/cms.rb +3 -3
  83. data/lib/occams/routes/cms_admin.rb +6 -6
  84. data/lib/occams/routing.rb +2 -2
  85. data/lib/occams/seeds/file/exporter.rb +7 -11
  86. data/lib/occams/seeds/file/importer.rb +5 -5
  87. data/lib/occams/seeds/layout/exporter.rb +9 -9
  88. data/lib/occams/seeds/layout/importer.rb +9 -9
  89. data/lib/occams/seeds/page/exporter.rb +19 -21
  90. data/lib/occams/seeds/page/importer.rb +14 -14
  91. data/lib/occams/seeds/snippet/exporter.rb +6 -6
  92. data/lib/occams/seeds/snippet/importer.rb +6 -6
  93. data/lib/occams/seeds.rb +5 -5
  94. data/lib/occams/version.rb +1 -1
  95. data/lib/occams/view_hooks.rb +1 -1
  96. data/lib/occams.rb +24 -24
  97. data/lib/tasks/cms_seeds.rake +2 -2
  98. data/occams.gemspec +22 -21
  99. metadata +5 -4
  100. data/LICENSE.comfy +0 -20
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "boot"
3
+ require_relative 'boot'
4
4
 
5
- require "rails/all"
5
+ require 'rails/all'
6
6
 
7
7
  # Require the gems listed in Gemfile, including any gems
8
8
  # you've limited to :test, :development, or :production.
@@ -10,7 +10,7 @@ Bundler.require(*Rails.groups)
10
10
 
11
11
  module Occams
12
12
  class Application < Rails::Application
13
- require_relative "../lib/occams"
13
+ require_relative '../lib/occams'
14
14
 
15
15
  config.load_defaults 5.2
16
16
 
@@ -30,7 +30,7 @@ module Occams
30
30
  config.railties_order = [ActiveStorage::Engine, :main_app, :all]
31
31
 
32
32
  # Making sure we don't load our dev routes as part of the engine
33
- config.paths["config/routes.rb"] << "config/cms_routes.rb"
33
+ config.paths['config/routes.rb'] << 'config/cms_routes.rb'
34
34
 
35
35
  config.i18n.enforce_available_locales = true
36
36
  end
data/config/boot.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Set up gems listed in the Gemfile.
4
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
4
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
5
5
 
6
- require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
7
- File.exist?(ENV["BUNDLE_GEMFILE"])
6
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
7
+
8
+ File.exist? ENV.fetch('BUNDLE_GEMFILE')
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Load the rails application
4
- require File.expand_path("application", __dir__)
4
+ require File.expand_path('application', __dir__)
5
5
 
6
6
  # Initialize the rails application
7
7
  Occams::Application.initialize!
@@ -16,12 +16,12 @@ defined?(Occams::Application) && Occams::Application.configure do
16
16
 
17
17
  # Enable/disable caching. By default caching is disabled.
18
18
  # Run rails dev:cache to toggle caching.
19
- if Rails.root.join("tmp/caching-dev.txt").exist?
19
+ if Rails.root.join('tmp/caching-dev.txt').exist?
20
20
  config.action_controller.perform_caching = true
21
21
 
22
22
  config.cache_store = :memory_store
23
23
  config.public_file_server.headers = {
24
- "Cache-Control" => "public, max-age=#{2.days.to_i}"
24
+ 'Cache-Control' => "public, max-age=#{2.days.to_i}"
25
25
  }
26
26
  else
27
27
  config.action_controller.perform_caching = false
@@ -17,7 +17,7 @@ defined?(Occams::Application) && Occams::Application.configure do
17
17
  # Configure public file server for tests with Cache-Control for performance.
18
18
  config.public_file_server.enabled = true
19
19
  config.public_file_server.headers = {
20
- "Cache-Control" => "public, max-age=#{1.hour.to_i}"
20
+ 'Cache-Control' => "public, max-age=#{1.hour.to_i}"
21
21
  }
22
22
 
23
23
  # Show full error reports and disable caching.
@@ -90,8 +90,8 @@ end
90
90
 
91
91
  # Default credentials for Occams::AccessControl::AdminAuthentication
92
92
  # YOU REALLY WANT TO CHANGE THIS BEFORE PUTTING YOUR SITE LIVE
93
- Occams::AccessControl::AdminAuthentication.username = "user"
94
- Occams::AccessControl::AdminAuthentication.password = "pass"
93
+ Occams::AccessControl::AdminAuthentication.username = 'user'
94
+ Occams::AccessControl::AdminAuthentication.password = 'pass'
95
95
 
96
96
  # Uncomment this module and `config.admin_auth` above to use custom admin authentication
97
97
  # module OccamsAdminAuthentication
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", __dir__)
5
+ require File.expand_path('config/environment', __dir__)
6
6
  run Occams::Application
@@ -4,11 +4,11 @@ module Occams
4
4
  module Generators
5
5
  module Cms
6
6
  class AssetsGenerator < Rails::Generators::Base
7
- source_root File.expand_path(File.join(File.dirname(__FILE__), "../../../../app/assets"))
7
+ source_root File.expand_path(File.join(File.dirname(__FILE__), '../../../../app/assets'))
8
8
 
9
9
  def generate_assets
10
- directory "javascripts/occams/admin/cms", "app/assets/javascripts/occams/admin/cms"
11
- directory "stylesheets/occams/admin/cms", "app/assets/stylesheets/occams/admin/cms"
10
+ directory 'javascripts/occams/admin/cms', 'app/assets/javascripts/occams/admin/cms'
11
+ directory 'stylesheets/occams/admin/cms', 'app/assets/stylesheets/occams/admin/cms'
12
12
  end
13
13
  end
14
14
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "rails/generators/active_record"
3
+ require 'rails/generators/active_record'
4
4
 
5
5
  module Occams
6
6
  module Generators
@@ -8,23 +8,23 @@ module Occams
8
8
  include Rails::Generators::Migration
9
9
  include Thor::Actions
10
10
 
11
- source_root File.expand_path("../../../..", __dir__)
11
+ source_root File.expand_path('../../../..', __dir__)
12
12
 
13
13
  def generate_migration
14
- destination = File.expand_path("db/migrate/01_create_cms.rb", destination_root)
14
+ destination = File.expand_path('db/migrate/01_create_cms.rb', destination_root)
15
15
  migration_dir = File.dirname(destination)
16
- destination = self.class.migration_exists?(migration_dir, "create_cms")
16
+ destination = self.class.migration_exists?(migration_dir, 'create_cms')
17
17
 
18
18
  if destination
19
19
  puts "\e[0m\e[31mFound existing cms_create.rb migration. Remove it if you want to regenerate.\e[0m"
20
20
  else
21
- migration_template "db/migrate/01_create_cms.rb", "db/migrate/create_cms.rb"
21
+ migration_template 'db/migrate/01_create_cms.rb', 'db/migrate/create_cms.rb'
22
22
  end
23
23
  end
24
24
 
25
25
  def generate_initializer
26
- copy_file "config/initializers/occams.rb",
27
- "config/initializers/occams.rb"
26
+ copy_file 'config/initializers/occams.rb',
27
+ 'config/initializers/occams.rb'
28
28
  end
29
29
 
30
30
  def generate_railties_order
@@ -45,18 +45,18 @@ module Occams
45
45
  end
46
46
 
47
47
  def generate_cms_seeds
48
- directory "db/cms_seeds", "db/cms_seeds"
48
+ directory 'db/cms_seeds', 'db/cms_seeds'
49
49
  end
50
50
 
51
51
  def generate_assets
52
- copy_file "app/assets/javascripts/occams/admin/cms/custom.js",
53
- "app/assets/javascripts/occams/admin/cms/custom.js"
54
- copy_file "app/assets/stylesheets/occams/admin/cms/custom.sass",
55
- "app/assets/stylesheets/occams/admin/cms/custom.sass"
52
+ copy_file 'app/assets/javascripts/occams/admin/cms/custom.js',
53
+ 'app/assets/javascripts/occams/admin/cms/custom.js'
54
+ copy_file 'app/assets/stylesheets/occams/admin/cms/custom.sass',
55
+ 'app/assets/stylesheets/occams/admin/cms/custom.sass'
56
56
  end
57
57
 
58
58
  def show_readme
59
- readme "lib/generators/occams/cms/README"
59
+ readme 'lib/generators/occams/cms/README'
60
60
  end
61
61
 
62
62
  def self.next_migration_number(dirname)
@@ -4,10 +4,10 @@ module Occams
4
4
  module Generators
5
5
  module Cms
6
6
  class ControllersGenerator < Rails::Generators::Base
7
- source_root File.expand_path(File.join(File.dirname(__FILE__), "../../../../app/controllers"))
7
+ source_root File.expand_path(File.join(File.dirname(__FILE__), '../../../../app/controllers'))
8
8
 
9
9
  def generate_controllers
10
- directory "occams", "app/controllers/occams"
10
+ directory 'occams', 'app/controllers/occams'
11
11
  end
12
12
  end
13
13
  end
@@ -4,10 +4,10 @@ module Occams
4
4
  module Generators
5
5
  module Cms
6
6
  class ModelsGenerator < Rails::Generators::Base
7
- source_root File.expand_path(File.join(File.dirname(__FILE__), "../../../../app/models"))
7
+ source_root File.expand_path(File.join(File.dirname(__FILE__), '../../../../app/models'))
8
8
 
9
9
  def generate_models
10
- directory "occams", "app/models/occams"
10
+ directory 'occams', 'app/models/occams'
11
11
  end
12
12
  end
13
13
  end
@@ -4,10 +4,10 @@ module Occams
4
4
  module Generators
5
5
  module Cms
6
6
  class ViewsGenerator < Rails::Generators::Base
7
- source_root File.expand_path(File.join(File.dirname(__FILE__), "../../../../app/views"))
7
+ source_root File.expand_path(File.join(File.dirname(__FILE__), '../../../../app/views'))
8
8
 
9
9
  def generate_views
10
- directory "occams", "app/views/occams"
10
+ directory 'occams', 'app/views/occams'
11
11
  end
12
12
  end
13
13
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "rails/generators/generated_attribute"
4
- require "rails/generators/active_record"
3
+ require 'rails/generators/generated_attribute'
4
+ require 'rails/generators/active_record'
5
5
 
6
6
  module Occams
7
7
  module Generators
@@ -12,17 +12,17 @@ module Occams
12
12
  attr_accessor :model_attrs
13
13
  end
14
14
 
15
- source_root File.expand_path(File.join(File.dirname(__FILE__), "templates"))
15
+ source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
16
16
 
17
- argument :model_args, type: :array, default: [], banner: "attribute:type"
17
+ argument :model_args, type: :array, default: [], banner: 'attribute:type'
18
18
 
19
19
  def initialize(*args, &block)
20
20
  super
21
21
  @model_attrs = []
22
22
  model_args.each do |arg|
23
- next unless arg.include?(":")
23
+ next unless arg.include?(':')
24
24
 
25
- @model_attrs << Rails::Generators::GeneratedAttribute.new(*arg.split(":"))
25
+ @model_attrs << Rails::Generators::GeneratedAttribute.new(*arg.split(':'))
26
26
  end
27
27
  end
28
28
 
@@ -31,23 +31,23 @@ module Occams
31
31
  end
32
32
 
33
33
  def generate_model
34
- migration_template "migration.rb", "db/migrate/create_#{file_name.pluralize}.rb"
35
- template "model.rb", "app/models/#{file_name}.rb"
36
- template "tests/model.rb", "test/models/#{file_name}_test.rb"
37
- template "tests/fixture.yml", "test/fixtures/#{file_name.pluralize}.yml"
34
+ migration_template 'migration.rb', "db/migrate/create_#{file_name.pluralize}.rb"
35
+ template 'model.rb', "app/models/#{file_name}.rb"
36
+ template 'tests/model.rb', "test/models/#{file_name}_test.rb"
37
+ template 'tests/fixture.yml', "test/fixtures/#{file_name.pluralize}.yml"
38
38
  end
39
39
 
40
40
  def generate_controller
41
- template "controller.rb", "app/controllers/admin/#{file_name.pluralize}_controller.rb"
42
- template "tests/controller.rb", "test/controllers/admin/#{file_name.pluralize}_controller_test.rb"
41
+ template 'controller.rb', "app/controllers/admin/#{file_name.pluralize}_controller.rb"
42
+ template 'tests/controller.rb', "test/controllers/admin/#{file_name.pluralize}_controller_test.rb"
43
43
  end
44
44
 
45
45
  def generate_views
46
- template "views/index.haml", "app/views/admin/#{file_name.pluralize}/index.html.haml"
47
- template "views/show.haml", "app/views/admin/#{file_name.pluralize}/show.html.haml"
48
- template "views/new.haml", "app/views/admin/#{file_name.pluralize}/new.html.haml"
49
- template "views/edit.haml", "app/views/admin/#{file_name.pluralize}/edit.html.haml"
50
- template "views/_form.haml", "app/views/admin/#{file_name.pluralize}/_form.html.haml"
46
+ template 'views/index.haml', "app/views/admin/#{file_name.pluralize}/index.html.haml"
47
+ template 'views/show.haml', "app/views/admin/#{file_name.pluralize}/show.html.haml"
48
+ template 'views/new.haml', "app/views/admin/#{file_name.pluralize}/new.html.haml"
49
+ template 'views/edit.haml', "app/views/admin/#{file_name.pluralize}/edit.html.haml"
50
+ template 'views/_form.haml', "app/views/admin/#{file_name.pluralize}/_form.html.haml"
51
51
  end
52
52
 
53
53
  def generate_route
@@ -61,7 +61,7 @@ module Occams
61
61
  end
62
62
 
63
63
  def generate_navigation_link
64
- partial_path = "app/views/occams/admin/cms/partials/_navigation_inner.html.haml"
64
+ partial_path = 'app/views/occams/admin/cms/partials/_navigation_inner.html.haml'
65
65
 
66
66
  unless File.exist?(File.join(destination_root, partial_path))
67
67
  create_file partial_path
@@ -86,44 +86,44 @@ class Occams::Configuration
86
86
 
87
87
  # Configuration defaults
88
88
  def initialize
89
- @cms_title = "Occams CMS Engine"
90
- @admin_base_controller = "ApplicationController"
91
- @public_base_controller = "ApplicationController"
92
- @admin_auth = "Occams::AccessControl::AdminAuthentication"
93
- @admin_authorization = "Occams::AccessControl::AdminAuthorization"
94
- @public_auth = "Occams::AccessControl::PublicAuthentication"
95
- @public_authorization = "Occams::AccessControl::PublicAuthorization"
89
+ @cms_title = 'Occams CMS Engine'
90
+ @admin_base_controller = 'ApplicationController'
91
+ @public_base_controller = 'ApplicationController'
92
+ @admin_auth = 'Occams::AccessControl::AdminAuthentication'
93
+ @admin_authorization = 'Occams::AccessControl::AdminAuthorization'
94
+ @public_auth = 'Occams::AccessControl::PublicAuthentication'
95
+ @public_authorization = 'Occams::AccessControl::PublicAuthorization'
96
96
  @seed_data_path = nil
97
- @admin_route_redirect = ""
97
+ @admin_route_redirect = ''
98
98
  @enable_sitemap = true
99
99
  @enable_seeds = false
100
- @seeds_path = File.expand_path("db/cms_seeds", Rails.root)
100
+ @seeds_path = File.expand_path('db/cms_seeds', Rails.root)
101
101
  @revisions_limit = 25
102
102
  @locales = {
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",
119
- "pt-BR" => "Português Brasileiro",
120
- "ru" => "Русский",
121
- "sk" => "Slovensky",
122
- "sv" => "Svenska",
123
- "tr" => "Türkçe",
124
- "uk" => "Українська",
125
- "zh-CN" => "简体中文",
126
- "zh-TW" => "正體中文"
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',
119
+ 'pt-BR' => 'Português Brasileiro',
120
+ 'ru' => 'Русский',
121
+ 'sk' => 'Slovensky',
122
+ 'sv' => 'Svenska',
123
+ 'tr' => 'Türkçe',
124
+ 'uk' => 'Українська',
125
+ 'zh-CN' => '简体中文',
126
+ 'zh-TW' => '正體中文'
127
127
  }
128
128
  @admin_locale = nil
129
129
  @admin_cache_sweeper = nil
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "strscan"
3
+ require 'strscan'
4
4
 
5
5
  class Occams::Content::ParamsParser
6
6
  class Error < StandardError; end
@@ -16,7 +16,7 @@ class Occams::Content::ParamsParser
16
16
  INTEGER = %r{\b[0-9]+\b}i.freeze
17
17
 
18
18
  # @param <String> string
19
- def initialize(string = "")
19
+ def initialize(string = '')
20
20
  @string = string
21
21
  end
22
22
 
@@ -120,7 +120,7 @@ private
120
120
  # @param [String] args_string
121
121
  # @return [Array<String>] tokens
122
122
  def tokenize(args_string)
123
- args_string = args_string.tr("“”‘’", %q(""''))
123
+ args_string = args_string.tr('“”‘’', %q(""''))
124
124
  ss = StringScanner.new(args_string)
125
125
  tokens = []
126
126
  loop do
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "strscan"
3
+ require 'strscan'
4
4
 
5
5
  # Processing content follows these stages:
6
6
  #
@@ -48,7 +48,7 @@ class Occams::Content::Renderer
48
48
  # @param [Boolean] allow_erb
49
49
  def render(nodes, allow_erb = Occams.config.allow_erb)
50
50
  if (@depth += 1) > MAX_DEPTH
51
- raise Error, "Deep tag nesting or recursive nesting detected"
51
+ raise Error, 'Deep tag nesting or recursive nesting detected'
52
52
  end
53
53
 
54
54
  nodes.map do |node|
@@ -67,7 +67,7 @@ class Occams::Content::Renderer
67
67
  if allow_erb
68
68
  string.to_s
69
69
  else
70
- string.to_s.gsub("<%", "&lt;%").gsub("%>", "%&gt;")
70
+ string.to_s.gsub('<%', '&lt;%').gsub('%>', '%&gt;')
71
71
  end
72
72
  end
73
73
 
@@ -77,7 +77,7 @@ class Occams::Content::Renderer
77
77
  tokens = []
78
78
  ss = StringScanner.new(string.to_s)
79
79
  while (string = ss.scan_until(TAG_REGEX))
80
- text = string.sub(ss[0], "")
80
+ text = string.sub(ss[0], '')
81
81
  tokens << text unless text.empty?
82
82
  tokens << {
83
83
  tag_class: ss[:class],
@@ -105,9 +105,9 @@ class Occams::Content::Renderer
105
105
  case tag_class = token[:tag_class]
106
106
 
107
107
  # This handles {{cms:end}} tag. Stopping collecting block nodes.
108
- when "end"
108
+ when 'end'
109
109
  if nodes.count == 1
110
- raise SyntaxError, "closing unopened block"
110
+ raise SyntaxError, 'closing unopened block'
111
111
  end
112
112
 
113
113
  nodes.pop
@@ -115,7 +115,7 @@ class Occams::Content::Renderer
115
115
  else
116
116
  # @type [Class<Occams::Content::Tag>]
117
117
  klass = self.class.tags[tag_class] ||
118
- raise(SyntaxError, "Unrecognized tag: #{token[:source]}")
118
+ raise(SyntaxError, "Unrecognized tag: #{token[:source]}")
119
119
 
120
120
  # @type [Occams::Content::Tag]
121
121
  tag = klass.new(
@@ -138,7 +138,7 @@ class Occams::Content::Renderer
138
138
  end
139
139
 
140
140
  if nodes.count > 1
141
- raise SyntaxError, "unclosed block detected"
141
+ raise SyntaxError, 'unclosed block detected'
142
142
  end
143
143
 
144
144
  nodes.flatten
@@ -38,7 +38,7 @@ class Occams::Content::Tag
38
38
 
39
39
  # @return [String]
40
40
  def content
41
- raise Error, "This is a base class. It holds no content"
41
+ raise Error, 'This is a base class. It holds no content'
42
42
  end
43
43
 
44
44
  # @return [String]
@@ -15,12 +15,12 @@ class Occams::Content::Tag::Asset < Occams::Content::Tag
15
15
 
16
16
  options = params.extract_options!
17
17
  @identifier = params[0]
18
- @type = options["type"]
19
- @as = options["as"] || "url"
18
+ @type = options['type']
19
+ @as = options['as'] || 'url'
20
20
 
21
- unless @identifier.present?
22
- raise Error, "Missing layout identifier for asset tag"
23
- end
21
+ return if @identifier.present?
22
+
23
+ raise Error, 'Missing layout identifier for asset tag'
24
24
  end
25
25
 
26
26
  def layout
@@ -28,23 +28,23 @@ class Occams::Content::Tag::Asset < Occams::Content::Tag
28
28
  end
29
29
 
30
30
  def content
31
- return "" unless layout
31
+ return '' unless layout
32
32
 
33
- base = Occams.config.public_cms_path || ""
34
- unless base.ends_with?("/")
35
- base += "/"
33
+ base = Occams.config.public_cms_path || ''
34
+ unless base.ends_with?('/')
35
+ base += '/'
36
36
  end
37
37
 
38
38
  case @type
39
- when "css"
39
+ when 'css'
40
40
  out = "#{base}cms-css/#{context.site.id}/#{@identifier}/#{layout.cache_buster}.css"
41
- if @as == "tag"
41
+ if @as == 'tag'
42
42
  out = "<link href='#{out}' media='screen' rel='stylesheet' type='text/css' />"
43
43
  end
44
44
  out
45
- when "js"
45
+ when 'js'
46
46
  out = "#{base}cms-js/#{context.site.id}/#{@identifier}/#{layout.cache_buster}.js"
47
- if @as == "tag"
47
+ if @as == 'tag'
48
48
  out = "<script src='#{out}' type='text/javascript'></script>"
49
49
  end
50
50
  out
@@ -11,11 +11,11 @@ class Occams::Content::Tag::Checkbox < Occams::Content::Tag::Fragment
11
11
  def form_field(object_name, view, index)
12
12
  name = "#{object_name}[fragments_attributes][#{index}][boolean]"
13
13
 
14
- input = view.content_tag(:div, class: "form-check mt-2") do
15
- view.concat view.hidden_field_tag(name, "0", id: nil)
14
+ input = view.content_tag(:div, class: 'form-check mt-2') do
15
+ view.concat view.hidden_field_tag(name, '0', id: nil)
16
16
 
17
- options = { id: form_field_id, class: "form-check-input position-static" }
18
- view.concat view.check_box_tag(name, "1", content.present?, options)
17
+ options = { id: form_field_id, class: 'form-check-input position-static' }
18
+ view.concat view.check_box_tag(name, '1', content.present?, options)
19
19
  end
20
20
 
21
21
  yield input
@@ -6,8 +6,8 @@
6
6
  class Occams::Content::Tag::Date < Occams::Content::Tag::Datetime
7
7
  def form_field(object_name, view, index)
8
8
  name = "#{object_name}[fragments_attributes][#{index}][datetime]"
9
- options = { id: form_field_id, class: "form-control", data: { "cms-date" => true } }
10
- value = content.present? ? content.to_s(:db) : ""
9
+ options = { id: form_field_id, class: 'form-control', data: { 'cms-date' => true } }
10
+ value = content.present? ? content.to_s(:db) : ''
11
11
  input = view.send(:text_field_tag, name, value, options)
12
12
 
13
13
  yield input
@@ -10,7 +10,7 @@ class Occams::Content::Tag::Datetime < Occams::Content::Tag::Fragment
10
10
 
11
11
  def initialize(context:, params: [], source: nil)
12
12
  super
13
- @strftime = options["strftime"]
13
+ @strftime = options['strftime']
14
14
  end
15
15
 
16
16
  def content
@@ -18,7 +18,7 @@ class Occams::Content::Tag::Datetime < Occams::Content::Tag::Fragment
18
18
  end
19
19
 
20
20
  def render
21
- return "" unless renderable
21
+ return '' unless renderable
22
22
 
23
23
  if strftime.present?
24
24
  content.strftime(strftime)
@@ -29,8 +29,8 @@ class Occams::Content::Tag::Datetime < Occams::Content::Tag::Fragment
29
29
 
30
30
  def form_field(object_name, view, index)
31
31
  name = "#{object_name}[fragments_attributes][#{index}][datetime]"
32
- options = { id: form_field_id, class: "form-control", data: { "cms-datetime" => true } }
33
- value = content.present? ? content.to_s(:db) : ""
32
+ options = { id: form_field_id, class: 'form-control', data: { 'cms-datetime' => true } }
33
+ value = content.present? ? content.to_s(:db) : ''
34
34
  input = view.send(:text_field_tag, name, value, options)
35
35
 
36
36
  yield input
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "./mixins/file_content"
3
+ require_relative 'mixins/file_content'
4
4
 
5
5
  # File tag allows attaching of file to the page. This controls how files are
6
6
  # uploaded and then displayed on the page. Example tag:
@@ -25,20 +25,20 @@ class Occams::Content::Tag::File < Occams::Content::Tag::Fragment
25
25
  # @param (see Occams::Content::Tag#initialize)
26
26
  def initialize(context:, params: [], source: nil)
27
27
  super
28
- @as = options["as"] || "url"
29
- @label = options["label"]
30
- @class = options["class"]
31
- @variant_attrs = options.slice("resize", "gravity", "crop")
28
+ @as = options['as'] || 'url'
29
+ @label = options['label']
30
+ @class = options['class']
31
+ @variant_attrs = options.slice('resize', 'gravity', 'crop')
32
32
  end
33
33
 
34
34
  def form_field(object_name, view, index)
35
35
  name = "#{object_name}[fragments_attributes][#{index}][files]"
36
- input = view.send(:file_field_tag, name, id: form_field_id, class: "form-control")
36
+ input = view.send(:file_field_tag, name, id: form_field_id, class: 'form-control')
37
37
 
38
38
  attachments_partial =
39
39
  if fragment.attachments
40
40
  view.render(
41
- partial: "occams/admin/cms/fragments/form_fragment_attachments",
41
+ partial: 'occams/admin/cms/fragments/form_fragment_attachments',
42
42
  locals: {
43
43
  object_name: object_name,
44
44
  index: index,
@@ -49,7 +49,7 @@ class Occams::Content::Tag::File < Occams::Content::Tag::Fragment
49
49
  )
50
50
  end
51
51
 
52
- yield view.safe_join([input, attachments_partial], "")
52
+ yield view.safe_join([input, attachments_partial], '')
53
53
  end
54
54
 
55
55
  protected