panda-cms 0.7.3 → 0.7.5

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.
Files changed (182) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +40 -5
  3. data/Rakefile +2 -0
  4. data/app/assets/builds/panda.cms.css +2 -6
  5. data/app/assets/tailwind/application.css +178 -0
  6. data/app/assets/tailwind/tailwind.config.js +15 -0
  7. data/app/builders/panda/cms/form_builder.rb +27 -36
  8. data/app/components/panda/cms/admin/flash_message_component.html.erb +2 -2
  9. data/app/components/panda/cms/admin/heading_component.rb +5 -4
  10. data/app/components/panda/cms/admin/panel_component.rb +2 -2
  11. data/app/components/panda/cms/admin/statistics_component.rb +1 -2
  12. data/app/components/panda/cms/admin/user_activity_component.html.erb +3 -1
  13. data/app/components/panda/cms/admin/user_activity_component.rb +8 -21
  14. data/app/components/panda/cms/code_component.rb +8 -4
  15. data/app/components/panda/cms/menu_component.rb +7 -6
  16. data/app/components/panda/cms/page_menu_component.rb +15 -17
  17. data/app/components/panda/cms/rich_text_component.rb +5 -6
  18. data/app/components/panda/cms/text_component.rb +6 -7
  19. data/app/constraints/panda/cms/admin_constraint.rb +4 -1
  20. data/app/controllers/panda/cms/admin/block_contents_controller.rb +0 -1
  21. data/app/controllers/panda/cms/admin/dashboard_controller.rb +13 -9
  22. data/app/controllers/panda/cms/admin/forms_controller.rb +0 -3
  23. data/app/controllers/panda/cms/admin/my_profile_controller.rb +44 -0
  24. data/app/controllers/panda/cms/admin/pages_controller.rb +15 -4
  25. data/app/controllers/panda/cms/admin/posts_controller.rb +6 -22
  26. data/app/controllers/panda/cms/admin/sessions_controller.rb +3 -5
  27. data/app/controllers/panda/cms/admin/settings/bulk_editor_controller.rb +32 -25
  28. data/app/controllers/panda/cms/admin/settings_controller.rb +14 -10
  29. data/app/controllers/panda/cms/application_controller.rb +7 -2
  30. data/app/controllers/panda/cms/errors_controller.rb +5 -2
  31. data/app/controllers/panda/cms/form_submissions_controller.rb +4 -0
  32. data/app/controllers/panda/cms/pages_controller.rb +40 -35
  33. data/app/controllers/panda/cms/posts_controller.rb +2 -0
  34. data/app/helpers/panda/cms/admin/files_helper.rb +5 -1
  35. data/app/helpers/panda/cms/admin/pages_helper.rb +5 -1
  36. data/app/helpers/panda/cms/asset_helper.rb +182 -0
  37. data/app/helpers/panda/cms/pages_helper.rb +2 -0
  38. data/app/helpers/panda/cms/posts_helper.rb +2 -0
  39. data/app/helpers/panda/cms/theme_helper.rb +2 -0
  40. data/app/javascript/panda/cms/controllers/editor_form_controller.js +59 -6
  41. data/app/javascript/panda/cms/controllers/index.js +5 -9
  42. data/app/javascript/panda/cms/controllers/slug_controller.js +64 -31
  43. data/app/javascript/panda/cms/controllers/theme_form_controller.js +25 -0
  44. data/app/javascript/panda/cms/stimulus-loading.js +39 -0
  45. data/app/javascript/panda_cms/stimulus-loading.js +39 -0
  46. data/app/jobs/panda/cms/application_job.rb +2 -0
  47. data/app/jobs/panda/cms/record_visit_job.rb +14 -14
  48. data/app/mailers/panda/cms/application_mailer.rb +2 -0
  49. data/app/mailers/panda/cms/form_mailer.rb +3 -1
  50. data/app/models/panda/cms/application_record.rb +3 -0
  51. data/app/models/panda/cms/block.rb +12 -17
  52. data/app/models/panda/cms/block_content.rb +7 -6
  53. data/app/models/panda/cms/breadcrumb.rb +2 -0
  54. data/app/models/panda/cms/current.rb +2 -0
  55. data/app/models/panda/cms/form.rb +2 -0
  56. data/app/models/panda/cms/form_submission.rb +2 -0
  57. data/app/models/panda/cms/menu.rb +12 -9
  58. data/app/models/panda/cms/menu_item.rb +10 -6
  59. data/app/models/panda/cms/page.rb +31 -16
  60. data/app/models/panda/cms/post.rb +12 -10
  61. data/app/models/panda/cms/redirect.rb +9 -1
  62. data/app/models/panda/cms/template.rb +17 -13
  63. data/app/models/panda/cms/user.rb +2 -0
  64. data/app/models/panda/cms/visit.rb +3 -1
  65. data/app/models/panda/social/instagram_post.rb +17 -0
  66. data/app/services/panda/cms/html_to_editor_js_converter.rb +10 -15
  67. data/app/services/panda/social/instagram_feed_service.rb +63 -0
  68. data/app/views/layouts/different_page.html.erb +6 -0
  69. data/app/views/layouts/homepage.html.erb +37 -0
  70. data/app/views/layouts/page.html.erb +18 -0
  71. data/app/views/layouts/panda/cms/application.html.erb +1 -0
  72. data/app/views/panda/cms/admin/my_profile/edit.html.erb +35 -0
  73. data/app/views/panda/cms/admin/pages/index.html.erb +1 -1
  74. data/app/views/panda/cms/admin/pages/new.html.erb +14 -8
  75. data/app/views/panda/cms/admin/posts/_form.html.erb +10 -0
  76. data/app/views/panda/cms/admin/posts/edit.html.erb +3 -2
  77. data/app/views/panda/cms/admin/posts/index.html.erb +1 -1
  78. data/app/views/panda/cms/admin/settings/index.html.erb +3 -1
  79. data/app/views/panda/cms/admin/shared/_sidebar.html.erb +1 -1
  80. data/app/views/panda/cms/shared/_header.html.erb +14 -4
  81. data/app/views/panda/cms/shared/_importmap.html.erb +2 -1
  82. data/app/views/shared/_footer.html.erb +3 -0
  83. data/app/views/shared/_header.html.erb +11 -0
  84. data/config/importmap.rb +2 -0
  85. data/config/initializers/inflections.rb +2 -0
  86. data/config/initializers/panda/cms/form_errors.rb +20 -21
  87. data/config/initializers/panda/cms/healthcheck_log_silencer.rb +2 -0
  88. data/config/initializers/panda/cms.rb +2 -0
  89. data/config/initializers/zeitwork.rb +2 -0
  90. data/config/locales/en.yml +5 -0
  91. data/config/puma/test.rb +3 -1
  92. data/config/routes.rb +11 -8
  93. data/db/migrate/20240205223709_create_panda_cms_pages.rb +2 -0
  94. data/db/migrate/20240219213327_create_panda_cms_page_versions.rb +2 -0
  95. data/db/migrate/20240303002805_create_panda_cms_templates.rb +4 -1
  96. data/db/migrate/20240303003434_create_panda_cms_template_versions.rb +2 -0
  97. data/db/migrate/20240303022441_create_panda_cms_blocks.rb +4 -1
  98. data/db/migrate/20240303024256_create_panda_cms_block_contents.rb +2 -0
  99. data/db/migrate/20240303024746_create_panda_cms_block_content_versions.rb +2 -0
  100. data/db/migrate/20240303233238_add_panda_cms_menu_table.rb +2 -0
  101. data/db/migrate/20240303234724_add_panda_cms_menu_item_table.rb +2 -0
  102. data/db/migrate/20240304134343_add_parent_id_to_panda_cms_pages.rb +2 -0
  103. data/db/migrate/20240315125411_add_status_to_panda_cms_pages.rb +7 -5
  104. data/db/migrate/20240315125421_add_nested_sets_to_panda_cms_pages.rb +2 -0
  105. data/db/migrate/20240316212822_add_kind_to_panda_cms_menus.rb +3 -1
  106. data/db/migrate/20240316221425_add_start_page_to_panda_cms_menus.rb +2 -0
  107. data/db/migrate/20240316230706_add_nested_to_panda_cms_menu_items.rb +2 -0
  108. data/db/migrate/20240317010532_create_panda_cms_users.rb +2 -0
  109. data/db/migrate/20240317161534_add_max_uses_to_panda_cms_template.rb +2 -0
  110. data/db/migrate/20240317163053_reset_counter_cache_on_panda_cms_template.rb +2 -0
  111. data/db/migrate/20240317214827_create_panda_cms_redirects.rb +2 -0
  112. data/db/migrate/20240317230622_create_panda_cms_visits.rb +2 -0
  113. data/db/migrate/20240324205703_create_active_storage_tables.active_storage.rb +5 -2
  114. data/db/migrate/20240408084718_default_panda_cms_users_admin_to_false.rb +2 -0
  115. data/db/migrate/20240701225422_add_service_name_to_active_storage_blobs.active_storage.rb +8 -6
  116. data/db/migrate/20240701225423_create_active_storage_variant_records.active_storage.rb +2 -0
  117. data/db/migrate/20240701225424_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb +2 -0
  118. data/db/migrate/20240804235210_create_panda_cms_forms.rb +2 -0
  119. data/db/migrate/20240805013612_create_panda_cms_form_submissions.rb +2 -0
  120. data/db/migrate/20240805121123_create_panda_cms_posts.rb +3 -1
  121. data/db/migrate/20240805123104_create_panda_cms_post_versions.rb +2 -0
  122. data/db/migrate/20240806112735_fix_panda_cms_visits_column_names.rb +2 -0
  123. data/db/migrate/20240806204412_add_completion_path_to_panda_cms_forms.rb +2 -0
  124. data/db/migrate/20240820081917_change_form_submissions_to_submission_count.rb +2 -0
  125. data/db/migrate/20240923234535_add_depth_to_panda_cms_menus.rb +6 -4
  126. data/db/migrate/20241031205109_add_cached_content_to_panda_cms_block_contents.rb +2 -0
  127. data/db/migrate/20241119214548_convert_post_content_to_editor_js.rb +2 -0
  128. data/db/migrate/20241120000419_remove_post_tag_references.rb +2 -0
  129. data/db/migrate/20241120110943_add_editor_js_to_posts.rb +2 -0
  130. data/db/migrate/20241120113859_add_cached_content_to_panda_cms_posts.rb +2 -0
  131. data/db/migrate/20241123234140_remove_post_tag_id_from_posts.rb +2 -0
  132. data/db/migrate/20250106223303_add_author_id_to_panda_cms_posts.rb +2 -0
  133. data/db/migrate/20250120235542_remove_paper_trail.rb +56 -0
  134. data/db/migrate/20250126234001_create_panda_social_instagram_posts.rb +16 -0
  135. data/db/migrate/20250504221812_add_current_theme_to_panda_cms_users.rb +7 -0
  136. data/db/seeds.rb +2 -0
  137. data/lib/generators/panda/cms/install_generator.rb +2 -0
  138. data/lib/panda/cms/asset_loader.rb +390 -0
  139. data/lib/panda/cms/bulk_editor.rb +7 -3
  140. data/lib/panda/cms/demo_site_generator.rb +27 -4
  141. data/lib/panda/cms/editor_js/blocks/alert.rb +2 -0
  142. data/lib/panda/cms/editor_js/blocks/base.rb +2 -0
  143. data/lib/panda/cms/editor_js/blocks/header.rb +2 -0
  144. data/lib/panda/cms/editor_js/blocks/image.rb +3 -0
  145. data/lib/panda/cms/editor_js/blocks/list.rb +2 -0
  146. data/lib/panda/cms/editor_js/blocks/paragraph.rb +3 -0
  147. data/lib/panda/cms/editor_js/blocks/quote.rb +3 -0
  148. data/lib/panda/cms/editor_js/blocks/table.rb +3 -1
  149. data/lib/panda/cms/editor_js/renderer.rb +3 -0
  150. data/lib/panda/cms/editor_js.rb +2 -0
  151. data/lib/panda/cms/editor_js_content.rb +50 -23
  152. data/lib/panda/cms/engine.rb +36 -37
  153. data/lib/panda/cms/exceptions_app.rb +2 -0
  154. data/lib/panda/cms/railtie.rb +2 -0
  155. data/lib/panda/cms/slug.rb +3 -1
  156. data/lib/panda-cms/version.rb +3 -1
  157. data/lib/panda-cms.rb +17 -2
  158. data/lib/tasks/assets.rake +547 -0
  159. data/lib/tasks/panda/cms/install.rake +25 -0
  160. data/lib/tasks/panda/social/instagram.rake +20 -0
  161. data/lib/tasks/panda_cms.rake +3 -30
  162. data/public/panda-cms-assets/editor-js/core/editorjs.min.js +83 -0
  163. data/public/panda-cms-assets/editor-js/plugins/embed.min.js +2 -0
  164. data/public/panda-cms-assets/editor-js/plugins/header.min.js +9 -0
  165. data/public/panda-cms-assets/editor-js/plugins/nested-list.min.js +2 -0
  166. data/public/panda-cms-assets/editor-js/plugins/paragraph.min.js +9 -0
  167. data/public/panda-cms-assets/editor-js/plugins/quote.min.js +2 -0
  168. data/public/panda-cms-assets/editor-js/plugins/simple-image.min.js +2 -0
  169. data/public/panda-cms-assets/editor-js/plugins/table.min.js +2 -0
  170. data/public/panda-cms-assets/manifest.json +20 -0
  171. data/public/panda-cms-assets/panda-cms-0.7.4.css +26 -0
  172. data/public/panda-cms-assets/panda-cms-0.7.4.js +150 -0
  173. metadata +71 -438
  174. data/app/models/action_text/rich_text_version.rb +0 -6
  175. data/app/models/panda/cms/block_content_version.rb +0 -8
  176. data/app/models/panda/cms/page_version.rb +0 -8
  177. data/app/models/panda/cms/post_version.rb +0 -8
  178. data/app/models/panda/cms/template_version.rb +0 -8
  179. data/app/models/panda/cms/version.rb +0 -8
  180. data/config/initializers/panda/cms/paper_trail.rb +0 -7
  181. data/db/migrate/20240904200605_create_action_text_tables.action_text.rb +0 -24
  182. data/db/migrate/20241119214549_remove_action_text_from_posts.rb +0 -9
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Panda
2
4
  module CMS
3
5
  module EditorJs
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Panda
2
4
  module CMS
3
5
  module EditorJs
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Panda
2
4
  module CMS
3
5
  module EditorJs
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Panda
2
4
  module CMS
3
5
  module EditorJs
@@ -27,6 +29,7 @@ module Panda
27
29
 
28
30
  def caption_element(caption)
29
31
  return "" if caption.blank?
32
+
30
33
  "<figcaption>#{caption}</figcaption>"
31
34
  end
32
35
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Panda
2
4
  module CMS
3
5
  module EditorJs
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Panda
2
4
  module CMS
3
5
  module EditorJs
@@ -6,6 +8,7 @@ module Panda
6
8
  def render
7
9
  content = sanitize(data["text"])
8
10
  return "" if content.blank?
11
+
9
12
  html_safe("<p>#{content}</p>")
10
13
  end
11
14
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Panda
2
4
  module CMS
3
5
  module EditorJs
@@ -32,6 +34,7 @@ module Panda
32
34
 
33
35
  def caption_element(caption)
34
36
  return "" if caption.blank?
37
+
35
38
  "<figcaption>#{sanitize(caption)}</figcaption>"
36
39
  end
37
40
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Panda
2
4
  module CMS
3
5
  module EditorJs
@@ -23,7 +25,7 @@ module Panda
23
25
  index = 0
24
26
 
25
27
  while index < content.length
26
- rows << if index == 0 && with_headings
28
+ rows << if index.zero? && with_headings
27
29
  render_header_row(content[index])
28
30
  else
29
31
  render_data_row(content[index])
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "sanitize"
2
4
 
3
5
  module Panda
@@ -60,6 +62,7 @@ module Panda
60
62
  # Only allow the exact valid content we expect
61
63
  valid_content = '<figure class="text-left"><blockquote><p>Valid HTML</p></blockquote><figcaption>Valid caption</figcaption></figure>'
62
64
  return html if html.strip == valid_content.strip
65
+
63
66
  return ""
64
67
  end
65
68
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative "editor_js/blocks/base"
2
4
  require_relative "editor_js/blocks/alert"
3
5
  require_relative "editor_js/blocks/header"
@@ -1,34 +1,61 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "json"
2
4
 
3
- module Panda::CMS::EditorJsContent
4
- extend ActiveSupport::Concern
5
+ module Panda
6
+ module CMS
7
+ module EditorJsContent
8
+ extend ActiveSupport::Concern
5
9
 
6
- included do
7
- include ActiveModel::Validations
8
- include ActiveModel::Callbacks
10
+ included do
11
+ include ActiveModel::Validations
12
+ include ActiveModel::Callbacks
9
13
 
10
- before_save :generate_cached_content
11
- end
14
+ before_save :generate_cached_content
15
+ end
16
+
17
+ def content=(value)
18
+ if value.is_a?(Hash)
19
+ super(value.to_json)
20
+ else
21
+ super
22
+ end
23
+ end
24
+
25
+ def content
26
+ value = super
27
+ if value.is_a?(String)
28
+ begin
29
+ JSON.parse(value)
30
+ rescue JSON::ParserError
31
+ value
32
+ end
33
+ else
34
+ value
35
+ end
36
+ end
12
37
 
13
- def generate_cached_content
14
- if content.is_a?(String)
15
- begin
16
- parsed_content = JSON.parse(content)
17
- self.cached_content = if parsed_content.is_a?(Hash) && parsed_content["blocks"].present?
18
- Panda::CMS::EditorJs::Renderer.new(parsed_content).render
38
+ def generate_cached_content
39
+ if content.is_a?(String)
40
+ begin
41
+ parsed_content = JSON.parse(content)
42
+ self.cached_content = if parsed_content.is_a?(Hash) && parsed_content["blocks"].present?
43
+ Panda::CMS::EditorJs::Renderer.new(parsed_content).render
44
+ else
45
+ content
46
+ end
47
+ rescue JSON::ParserError
48
+ # If it's not JSON, treat it as plain text
49
+ self.cached_content = content
50
+ end
51
+ elsif content.is_a?(Hash) && content["blocks"].present?
52
+ # Process EditorJS content
53
+ self.cached_content = Panda::CMS::EditorJs::Renderer.new(content).render
19
54
  else
20
- content
55
+ # For any other case, store as is
56
+ self.cached_content = content.to_s
21
57
  end
22
- rescue JSON::ParserError
23
- # If it's not JSON, treat it as plain text
24
- self.cached_content = content
25
58
  end
26
- elsif content.is_a?(Hash) && content["blocks"].present?
27
- # Process EditorJS content
28
- self.cached_content = Panda::CMS::EditorJs::Renderer.new(content).render
29
- else
30
- # For any other case, store as is
31
- self.cached_content = content.to_s
32
59
  end
33
60
  end
34
61
  end
@@ -1,12 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "rubygems"
2
4
  require "panda/core"
5
+ require "panda/core/engine"
3
6
  require "panda/cms/railtie"
4
7
 
8
+ require "invisible_captcha"
9
+
5
10
  module Panda
6
11
  module CMS
7
12
  class Engine < ::Rails::Engine
8
13
  isolate_namespace Panda::CMS
9
- engine_name "panda-cms"
10
14
 
11
15
  # Add services directory to autoload paths
12
16
  config.autoload_paths += %W[
@@ -14,10 +18,8 @@ module Panda
14
18
  ]
15
19
 
16
20
  # Basic session setup only
17
- initializer "panda.cms.session", before: :load_config_initializers do |app|
18
- if app.config.middleware.frozen?
19
- app.config.middleware = app.config.middleware.dup
20
- end
21
+ initializer "panda_cms.session", before: :load_config_initializers do |app|
22
+ app.config.middleware = app.config.middleware.dup if app.config.middleware.frozen?
21
23
 
22
24
  app.config.session_store :cookie_store, key: "_panda_cms_session"
23
25
  app.config.middleware.use ActionDispatch::Cookies
@@ -26,18 +28,19 @@ module Panda
26
28
 
27
29
  config.to_prepare do
28
30
  ApplicationController.helper(::ApplicationHelper)
31
+ ApplicationController.helper(Panda::CMS::AssetHelper)
29
32
  end
30
33
 
31
34
  # Set our generators
32
35
  config.generators do |g|
33
36
  g.orm :active_record, primary_key_type: :uuid
34
37
  g.test_framework :rspec, fixture: true
35
- g.fixture_replacement :factory_bot, dir: "spec/factories"
38
+ g.fixture_replacement nil
36
39
  g.view_specs false
37
- g.templates.unshift File.expand_path("../../templates", __FILE__)
40
+ g.templates.unshift File.expand_path("../templates", __dir__)
38
41
  end
39
42
 
40
- # Make files in public available to the main app (e.g. /panda-cms-assets/favicon.ico)
43
+ # Make files in public available to the main app (e.g. /panda_cms-assets/favicon.ico)
41
44
  config.app_middleware.use(
42
45
  Rack::Static,
43
46
  urls: ["/panda-cms-assets"],
@@ -47,7 +50,7 @@ module Panda
47
50
  # Custom error handling
48
51
  # config.exceptions_app = Panda::CMS::ExceptionsApp.new(exceptions_app: routes)
49
52
 
50
- initializer "panda.cms.assets" do |app|
53
+ initializer "panda_cms.assets" do |app|
51
54
  if Rails.configuration.respond_to?(:assets)
52
55
  # Add JavaScript paths
53
56
  app.config.assets.paths << root.join("app/javascript")
@@ -65,12 +68,10 @@ module Panda
65
68
  end
66
69
 
67
70
  # Add importmap paths from the engine
68
- initializer "panda.cms.importmap", before: "importmap" do |app|
71
+ initializer "panda_cms.importmap", before: "importmap" do |app|
69
72
  if app.config.respond_to?(:importmap)
70
73
  # Create a new array if frozen
71
- if app.config.importmap.paths.frozen?
72
- app.config.importmap.paths = app.config.importmap.paths.dup
73
- end
74
+ app.config.importmap.paths = app.config.importmap.paths.dup if app.config.importmap.paths.frozen?
74
75
 
75
76
  # Add our paths
76
77
  app.config.importmap.paths << root.join("config/importmap.rb")
@@ -94,13 +95,13 @@ module Panda
94
95
  end
95
96
  end
96
97
 
97
- initializer "#{engine_name}.backtrace_cleaner" do |app|
98
+ initializer "#{engine_name}.backtrace_cleaner" do |_app|
98
99
  engine_root_regex = Regexp.escape(root.to_s + File::SEPARATOR)
99
100
 
100
101
  # Clean those ERB lines, we don't need the internal autogenerated
101
102
  # ERB method, what we do need (line number in ERB file) is already there
102
103
  Rails.backtrace_cleaner.add_filter do |line|
103
- line.sub(/(\.erb:\d+):in `__.*$/, "\\1")
104
+ line.sub(/(\.erb:\d+):in `__.*$/, '\\1')
104
105
  end
105
106
 
106
107
  # Remove our own engine's path prefix, even if it's
@@ -122,15 +123,13 @@ module Panda
122
123
  end
123
124
  end
124
125
 
125
- # Set up ViewComponent and Lookbook
126
- # config.view_component.component_parent_class = "Panda::CMS::BaseComponent"
127
- # config.view_component.view_component_path = Panda::CMS::Engine.root.join("lib/components").to_s
128
- # config.eager_load_paths << Panda::CMS::Engine.root.join("lib/components").to_s
129
- # config.view_component.generate.sidecar = true
130
- # config.view_component.generate.preview = truexw
131
- # config.view_component.preview_paths ||= []
132
- # config.view_component.preview_paths << Panda::CMS::Engine.root.join("lib/component_previews").to_s
133
- # config.view_component.generate.preview_path = "lib/component_previews"
126
+ # Set up ViewComponent
127
+ initializer "panda_cms.view_component" do |app|
128
+ app.config.view_component.preview_paths ||= []
129
+ app.config.view_component.preview_paths << root.join("spec/components/previews")
130
+ app.config.view_component.generate.sidecar = true
131
+ app.config.view_component.generate.preview = true
132
+ end
134
133
 
135
134
  # Set up authentication
136
135
  initializer "panda_cms.omniauth", before: "omniauth" do |app|
@@ -214,26 +213,26 @@ module Panda
214
213
  }
215
214
 
216
215
  available_providers.each do |provider, options|
217
- if Panda::CMS.config.authentication.dig(provider, :enabled)
218
- auth_path = auth_path.starts_with?("/") ? auth_path : "/#{auth_path}"
219
- options[:defaults][:path_prefix] = auth_path
216
+ next unless Panda::CMS.config.authentication.dig(provider, :enabled)
217
+
218
+ auth_path = auth_path.starts_with?("/") ? auth_path : "/#{auth_path}"
219
+ options[:defaults][:path_prefix] = auth_path
220
220
 
221
- options[:defaults][:redirect_uri] = if Rails.env.test?
222
- "#{Capybara.app_host}#{auth_path}/#{provider}#{callback_path}"
223
- else
224
- "#{Panda::CMS.config.url}#{auth_path}/#{provider}#{callback_path}"
225
- end
221
+ options[:defaults][:redirect_uri] = if Rails.env.test?
222
+ "#{Capybara.app_host}#{auth_path}/#{provider}#{callback_path}"
223
+ else
224
+ "#{Panda::CMS.config.url}#{auth_path}/#{provider}#{callback_path}"
225
+ end
226
226
 
227
- provider_config = options[:defaults].merge(Panda::CMS.config.authentication[provider])
227
+ provider_config = options[:defaults].merge(Panda::CMS.config.authentication[provider])
228
228
 
229
- app.config.middleware.use OmniAuth::Builder do
230
- provider options[:strategy], provider_config
231
- end
229
+ app.config.middleware.use OmniAuth::Builder do
230
+ provider options[:strategy], provider_config
232
231
  end
233
232
  end
234
233
  end
235
234
 
236
- config.before_initialize do |app|
235
+ config.before_initialize do |_app|
237
236
  # Default configuration
238
237
  Panda::CMS.configure do |config|
239
238
  # Array of additional EditorJS tools to load
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # https://guides.rubyonrails.org/configuring.html#config-exceptions-app
2
4
  module Panda
3
5
  module CMS
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Panda
2
4
  module CMS
3
5
  class Railtie < Rails::Railtie
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Panda
2
4
  module CMS
3
5
  class Slug
@@ -13,7 +15,7 @@ module Panda
13
15
  # Replace & with "and"
14
16
  string = string.gsub("&", "and")
15
17
  # Remove special characters
16
- string = string.gsub(/[\!\@\£\$\%\^\&\*\(\)\+\=\{\}\[\]\:\;\"\'\|\\\`\<\>\?\,\.\/]+/, "")
18
+ string = string.gsub(%r{[!@£\\\^\[\]/]+}, "")
17
19
  # Replace any whitespace character with -
18
20
  string = string.gsub(/[^\w\s-]/, "-")
19
21
  # Replace multiple occurences of _ and - with -
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Panda
2
4
  module CMS
3
- VERSION = "0.7.3"
5
+ VERSION = "0.7.5"
4
6
  end
5
7
  end
data/lib/panda-cms.rb CHANGED
@@ -1,8 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "rubygems"
2
4
  require "panda/core"
3
5
  require "panda/cms/railtie"
4
-
5
- require "capybara/rspec"
6
+ require "view_component"
6
7
 
7
8
  module Panda
8
9
  module CMS
@@ -18,6 +19,19 @@ module Panda
18
19
  setting :editor_js_tools, default: []
19
20
  setting :editor_js_tool_config, default: {}
20
21
 
22
+ setting :instagram, default: {
23
+ enabled: false,
24
+ username: nil,
25
+ access_token: nil
26
+ }
27
+
28
+ setting :analytics, default: {
29
+ google_analytics: {
30
+ enabled: false,
31
+ tracking_id: nil
32
+ }
33
+ }
34
+
21
35
  def self.root_path
22
36
  config.admin_path
23
37
  end
@@ -60,6 +74,7 @@ require_relative "panda-cms/version"
60
74
  require_relative "panda/cms/exceptions_app"
61
75
  require_relative "panda/cms/engine"
62
76
  require_relative "panda/cms/demo_site_generator"
77
+ require_relative "panda/cms/asset_loader"
63
78
  require_relative "panda/cms/editor_js"
64
79
  require_relative "panda/cms/editor_js_content"
65
80
  require_relative "panda/cms/editor_js/renderer"