panda-cms 0.8.2 → 0.10.2

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 (123) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +75 -5
  3. data/app/components/panda/cms/code_component.rb +154 -39
  4. data/app/components/panda/cms/grid_component.rb +26 -6
  5. data/app/components/panda/cms/menu_component.rb +72 -34
  6. data/app/components/panda/cms/page_menu_component.rb +102 -13
  7. data/app/components/panda/cms/rich_text_component.rb +229 -139
  8. data/app/components/panda/cms/text_component.rb +107 -42
  9. data/app/controllers/panda/cms/admin/base_controller.rb +19 -3
  10. data/app/controllers/panda/cms/admin/dashboard_controller.rb +3 -3
  11. data/app/controllers/panda/cms/admin/files_controller.rb +7 -0
  12. data/app/controllers/panda/cms/admin/menus_controller.rb +47 -3
  13. data/app/controllers/panda/cms/admin/pages_controller.rb +11 -2
  14. data/app/controllers/panda/cms/admin/posts_controller.rb +3 -1
  15. data/app/controllers/panda/cms/form_submissions_controller.rb +134 -11
  16. data/app/controllers/panda/cms/pages_controller.rb +7 -2
  17. data/app/controllers/panda/cms/posts_controller.rb +16 -0
  18. data/app/helpers/panda/cms/application_helper.rb +17 -4
  19. data/app/helpers/panda/cms/asset_helper.rb +14 -61
  20. data/app/helpers/panda/cms/forms_helper.rb +60 -0
  21. data/app/helpers/panda/cms/seo_helper.rb +85 -0
  22. data/app/javascript/panda/cms/{application_panda_cms.js → application.js} +5 -1
  23. data/app/javascript/panda/cms/controllers/code_editor_controller.js +95 -0
  24. data/app/javascript/panda/cms/controllers/editor_iframe_controller.js +31 -4
  25. data/app/javascript/panda/cms/controllers/file_gallery_controller.js +128 -0
  26. data/app/javascript/panda/cms/controllers/file_upload_controller.js +165 -0
  27. data/app/javascript/panda/cms/controllers/index.js +54 -13
  28. data/app/javascript/panda/cms/controllers/inline_code_editor_controller.js +96 -0
  29. data/app/javascript/panda/cms/controllers/menu_form_controller.js +53 -0
  30. data/app/javascript/panda/cms/controllers/nested_form_controller.js +35 -0
  31. data/app/javascript/panda/cms/controllers/page_form_controller.js +454 -0
  32. data/app/javascript/panda/cms/controllers/tree_controller.js +214 -0
  33. data/app/javascript/panda/cms/stimulus-loading.js +6 -7
  34. data/app/models/panda/cms/block_content.rb +9 -0
  35. data/app/models/panda/cms/menu.rb +12 -0
  36. data/app/models/panda/cms/page.rb +147 -0
  37. data/app/models/panda/cms/post.rb +98 -0
  38. data/app/views/layouts/homepage.html.erb +1 -4
  39. data/app/views/layouts/page.html.erb +1 -4
  40. data/app/views/panda/cms/admin/dashboard/show.html.erb +5 -5
  41. data/app/views/panda/cms/admin/files/_file_details.html.erb +45 -0
  42. data/app/views/panda/cms/admin/files/index.html.erb +11 -118
  43. data/app/views/panda/cms/admin/forms/index.html.erb +2 -2
  44. data/app/views/panda/cms/admin/forms/new.html.erb +1 -2
  45. data/app/views/panda/cms/admin/forms/show.html.erb +15 -30
  46. data/app/views/panda/cms/admin/menus/_menu_item_fields.html.erb +11 -0
  47. data/app/views/panda/cms/admin/menus/edit.html.erb +62 -0
  48. data/app/views/panda/cms/admin/menus/index.html.erb +3 -2
  49. data/app/views/panda/cms/admin/menus/new.html.erb +38 -0
  50. data/app/views/panda/cms/admin/pages/edit.html.erb +147 -22
  51. data/app/views/panda/cms/admin/pages/index.html.erb +49 -11
  52. data/app/views/panda/cms/admin/pages/new.html.erb +3 -11
  53. data/app/views/panda/cms/admin/posts/_form.html.erb +44 -15
  54. data/app/views/panda/cms/admin/posts/edit.html.erb +2 -2
  55. data/app/views/panda/cms/admin/posts/index.html.erb +6 -6
  56. data/app/views/panda/cms/admin/posts/new.html.erb +1 -1
  57. data/app/views/panda/cms/admin/settings/bulk_editor/new.html.erb +1 -1
  58. data/app/views/panda/cms/admin/settings/index.html.erb +3 -3
  59. data/app/views/shared/_header.html.erb +1 -4
  60. data/config/brakeman.ignore +38 -0
  61. data/config/importmap.rb +10 -10
  62. data/config/initializers/panda/cms/healthcheck_log_silencer.rb.disabled +31 -0
  63. data/config/initializers/panda/cms.rb +52 -10
  64. data/config/locales/en.yml +41 -0
  65. data/config/routes.rb +5 -3
  66. data/db/migrate/20240305000000_convert_html_content_to_editor_js.rb +2 -2
  67. data/db/migrate/20240315125421_add_nested_sets_to_panda_cms_pages.rb +6 -1
  68. data/db/migrate/20250809231125_migrate_users_to_panda_core.rb +23 -21
  69. data/db/migrate/20251104150640_add_cached_last_updated_at_to_panda_cms_pages.rb +22 -0
  70. data/db/migrate/20251104172242_add_page_type_to_panda_cms_pages.rb +6 -0
  71. data/db/migrate/20251104172638_set_page_types_for_existing_pages.rb +27 -0
  72. data/db/migrate/20251105000001_add_pending_review_status_to_pages_and_posts.panda_cms.rb +21 -0
  73. data/db/migrate/20251109131150_add_seo_fields_to_pages.rb +32 -0
  74. data/db/migrate/20251109131205_add_seo_fields_to_posts.rb +27 -0
  75. data/db/migrate/20251110114258_add_spam_tracking_to_form_submissions.rb +7 -0
  76. data/db/migrate/20251110122812_add_performance_indexes_to_pages_and_redirects.rb +13 -0
  77. data/lib/generators/panda/cms/install_generator.rb +2 -5
  78. data/lib/panda/cms/asset_loader.rb +46 -76
  79. data/lib/panda/cms/bulk_editor.rb +288 -12
  80. data/lib/panda/cms/debug.rb +29 -0
  81. data/lib/panda/cms/engine/asset_config.rb +49 -0
  82. data/lib/panda/cms/engine/autoload_config.rb +19 -0
  83. data/lib/panda/cms/engine/backtrace_config.rb +42 -0
  84. data/lib/panda/cms/engine/core_config.rb +106 -0
  85. data/lib/panda/cms/engine/helper_config.rb +20 -0
  86. data/lib/panda/cms/engine/route_config.rb +34 -0
  87. data/lib/panda/cms/engine/view_component_config.rb +31 -0
  88. data/lib/panda/cms/engine.rb +44 -162
  89. data/lib/panda/cms/features.rb +52 -0
  90. data/lib/panda/cms.rb +10 -0
  91. data/lib/panda-cms/version.rb +1 -1
  92. data/lib/panda-cms.rb +20 -7
  93. data/lib/tasks/panda_cms_tasks.rake +16 -0
  94. metadata +41 -50
  95. data/app/components/panda/cms/admin/container_component.html.erb +0 -13
  96. data/app/components/panda/cms/admin/flash_message_component.html.erb +0 -31
  97. data/app/components/panda/cms/admin/panel_component.html.erb +0 -7
  98. data/app/components/panda/cms/admin/slideover_component.html.erb +0 -9
  99. data/app/components/panda/cms/admin/slideover_component.rb +0 -15
  100. data/app/components/panda/cms/admin/statistics_component.html.erb +0 -4
  101. data/app/components/panda/cms/admin/statistics_component.rb +0 -16
  102. data/app/components/panda/cms/admin/tab_bar_component.html.erb +0 -35
  103. data/app/components/panda/cms/admin/tab_bar_component.rb +0 -15
  104. data/app/components/panda/cms/admin/table_component.html.erb +0 -29
  105. data/app/components/panda/cms/admin/user_activity_component.html.erb +0 -7
  106. data/app/components/panda/cms/admin/user_activity_component.rb +0 -20
  107. data/app/components/panda/cms/admin/user_display_component.html.erb +0 -17
  108. data/app/components/panda/cms/admin/user_display_component.rb +0 -21
  109. data/app/components/panda/cms/grid_component.html.erb +0 -6
  110. data/app/components/panda/cms/menu_component.html.erb +0 -6
  111. data/app/components/panda/cms/page_menu_component.html.erb +0 -21
  112. data/app/components/panda/cms/rich_text_component.html.erb +0 -90
  113. data/app/javascript/panda_cms/stimulus-loading.js +0 -39
  114. data/app/views/layouts/panda/cms/application.html.erb +0 -42
  115. data/app/views/panda/cms/admin/shared/_breadcrumbs.html.erb +0 -28
  116. data/app/views/panda/cms/admin/shared/_flash.html.erb +0 -5
  117. data/app/views/panda/cms/admin/shared/_sidebar.html.erb +0 -41
  118. data/app/views/panda/cms/shared/_footer.html.erb +0 -2
  119. data/app/views/panda/cms/shared/_header.html.erb +0 -25
  120. data/app/views/panda/cms/shared/_importmap.html.erb +0 -34
  121. data/config/initializers/inflections.rb +0 -5
  122. data/config/initializers/panda/cms/healthcheck_log_silencer.rb +0 -13
  123. data/lib/tasks/assets.rake +0 -587
@@ -0,0 +1,11 @@
1
+ <div class="mb-6 pb-6 border-b border-gray-200 dark:border-gray-700 nested-form-wrapper" data-new-record="<%= form.object.new_record? %>">
2
+ <%= form.text_field :text, label: "Menu Item Text" %>
3
+ <%= form.collection_select :panda_cms_page_id, Panda::CMS::Page.order(:title), :id, :title, { include_blank: "Select a page (optional)", label: "Page" }, { class: "mt-1" } %>
4
+ <%= form.text_field :external_url, label: "External URL (optional)" %>
5
+
6
+ <div class="mt-3">
7
+ <%= render Panda::Core::Admin::ButtonComponent.new(text: "Remove", action: :delete, link: "#", size: :small, data: { action: "click->nested-form#remove" }) %>
8
+ </div>
9
+
10
+ <%= form.hidden_field :_destroy %>
11
+ </div>
@@ -0,0 +1,62 @@
1
+ <%= render Panda::Core::Admin::ContainerComponent.new do |component| %>
2
+ <% component.heading(text: "Edit Menu: #{@menu.name}", level: 1) %>
3
+
4
+ <%= panda_cms_form_with model: @menu, url: admin_cms_menu_path(@menu), method: :put, data: { controller: "menu-form" } do |f| %>
5
+ <%= render Panda::Core::Admin::FormErrorComponent.new(model: @menu) %>
6
+
7
+ <%= f.text_field :name %>
8
+ <%= f.select :kind, options_for_select([["Static", "static"], ["Auto", "auto"]], selected: @menu.kind), {}, { data: { action: "change->menu-form#kindChanged" } } %>
9
+
10
+ <div data-menu-form-target="startPageField" class="<%= 'hidden' unless @menu.kind == 'auto' %>">
11
+ <%= f.collection_select :start_page_id, Panda::CMS::Page.order(:title), :id, :title, { include_blank: "Select a page...", label: "Start Page" }, { class: "mt-1" } %>
12
+ </div>
13
+
14
+ <% if @menu.kind == "static" %>
15
+ <%= render Panda::Core::Admin::PanelComponent.new do |panel| %>
16
+ <% panel.heading(text: "Menu Items") %>
17
+
18
+ <div data-controller="nested-form" data-nested-form-wrapper-selector-value=".nested-form-wrapper">
19
+ <template data-nested-form-target="template">
20
+ <%= f.fields_for :menu_items, Panda::CMS::MenuItem.new, child_index: "NEW_RECORD" do |item_form| %>
21
+ <%= render "menu_item_fields", form: item_form %>
22
+ <% end %>
23
+ </template>
24
+
25
+ <div class="space-y-4">
26
+ <% if @menu.menu_items.any? %>
27
+ <%= f.fields_for :menu_items, @menu.menu_items.sort_by(&:lft) do |item_form| %>
28
+ <%= render "menu_item_fields", form: item_form %>
29
+ <% end %>
30
+ <% end %>
31
+ </div>
32
+
33
+ <div data-nested-form-target="target"></div>
34
+
35
+ <div class="mt-4">
36
+ <%= render Panda::Core::Admin::ButtonComponent.new(text: "Add Menu Item", action: :add, link: "#", size: :small, data: { action: "click->nested-form#add" }) %>
37
+ </div>
38
+ </div>
39
+ <% end %>
40
+ <% else %>
41
+ <%= render Panda::Core::Admin::PanelComponent.new do |panel| %>
42
+ <% panel.heading(text: "Auto-Generated Menu Items") %>
43
+
44
+ <% if @menu.menu_items.any? %>
45
+ <%= render Panda::Core::Admin::TableComponent.new(term: "menu item", rows: @menu.menu_items.root.self_and_descendants) do |table| %>
46
+ <% table.column("Text") do |menu_item| %>
47
+ <div class="<%= "ml-#{menu_item.depth * 6}" %>">
48
+ <%= menu_item.text %>
49
+ </div>
50
+ <% end %>
51
+ <% table.column("Page") { |menu_item| menu_item.page&.title } %>
52
+ <% table.column("Path") { |menu_item| menu_item.page&.path } %>
53
+ <% end %>
54
+ <% else %>
55
+ <p class="text-sm text-gray-500 dark:text-gray-400">No menu items generated yet. Select a start page and save to generate menu items.</p>
56
+ <% end %>
57
+ <% end %>
58
+ <% end %>
59
+
60
+ <%= f.button "Save Menu" %>
61
+ <% end %>
62
+ <% end %>
@@ -1,8 +1,9 @@
1
1
  <%= render Panda::Core::Admin::ContainerComponent.new do |component| %>
2
- <% component.with_heading(text: "Menus", level: 1) do |heading| %>
2
+ <% component.heading(text: "Menus", level: 1) do |heading| %>
3
+ <% heading.button(action: :add, text: "New Menu", href: new_admin_cms_menu_path) %>
3
4
  <% end %>
4
5
  <%= render Panda::Core::Admin::TableComponent.new(term: "menu", rows: menus) do |table| %>
5
6
  <% table.column("Name") { |menu| link_to menu.name, edit_admin_cms_menu_path(menu) } %>
6
- <% table.column("Kind") { |menu| render Panda::Core::Admin::TagComponent.new(status: :active, text: menu.kind.titleize) } %>
7
+ <% table.column("Kind") { |menu| render Panda::Core::Admin::TagComponent.new(status: menu.kind.to_sym) } %>
7
8
  <% end %>
8
9
  <% end %>
@@ -0,0 +1,38 @@
1
+ <%= render Panda::Core::Admin::ContainerComponent.new do |component| %>
2
+ <% component.heading(text: "New Menu", level: 1) %>
3
+
4
+ <%= panda_cms_form_with model: menu, url: admin_cms_menus_path, method: :post, data: { controller: "menu-form" } do |f| %>
5
+ <%= render Panda::Core::Admin::FormErrorComponent.new(model: menu) %>
6
+
7
+ <%= f.text_field :name %>
8
+ <%= f.select :kind, options_for_select([["Static", "static"], ["Auto", "auto"]], selected: menu.kind || "static"), {}, { data: { action: "change->menu-form#kindChanged" } } %>
9
+
10
+ <div data-menu-form-target="startPageField" class="hidden">
11
+ <%= f.collection_select :start_page_id, Panda::CMS::Page.order(:title), :id, :title, { include_blank: "Select a page...", label: "Start Page" }, { class: "mt-1" } %>
12
+ </div>
13
+
14
+ <div data-menu-form-target="menuItemsSection">
15
+ <%= render Panda::Core::Admin::PanelComponent.new do |panel| %>
16
+ <% panel.heading(text: "Menu Items") %>
17
+
18
+ <div data-controller="nested-form" data-nested-form-wrapper-selector-value=".nested-form-wrapper">
19
+ <template data-nested-form-target="template">
20
+ <%= f.fields_for :menu_items, Panda::CMS::MenuItem.new, child_index: "NEW_RECORD" do |item_form| %>
21
+ <%= render "menu_item_fields", form: item_form %>
22
+ <% end %>
23
+ </template>
24
+
25
+ <div class="space-y-4"></div>
26
+
27
+ <div data-nested-form-target="target"></div>
28
+
29
+ <div class="mt-4">
30
+ <%= render Panda::Core::Admin::ButtonComponent.new(text: "Add Menu Item", action: :add, link: "#", size: :small, data: { action: "click->nested-form#add" }) %>
31
+ </div>
32
+ </div>
33
+ <% end %>
34
+ </div>
35
+
36
+ <%= f.button "Create Menu" %>
37
+ <% end %>
38
+ <% end %>
@@ -1,27 +1,151 @@
1
- <%= render Panda::Core::Admin::ContainerComponent.new do |component| %>
2
- <% component.with_heading(text: "#{page.title}", level: 1) %>
1
+ <%= render Panda::Core::Admin::ContainerComponent.new(full_height: true) do |component| %>
2
+ <% component.heading(text: "#{page.title}", level: 1, meta: (link_to page.path, target: "_blank", class: "text-black/60 hover:text-black/80 inline-flex items-center gap-x-1" do
3
+ raw("#{page.path}<i class='fa-solid fa-arrow-up-right-from-square text-xs ml-1'></i>")
4
+ end)) do |h| %>
5
+ <% h.button(text: "Page Details", action: :secondary, as_button: true, size: :regular, id: "open-page-details", icon: "gear", data: { action: "click->toggle#toggle touch->toggle#toggle" }) %>
6
+ <% h.button(text: "Save Changes", action: :save, href: "#", size: :regular, id: "saveEditableButton", icon: "check") %>
7
+ <% end %>
3
8
  <% component.with_slideover(title: "Page Details") do %>
4
- <%= panda_cms_form_with model: page, url: admin_cms_page_path, method: :put do |f| %>
5
- <%= f.text_field :title, class: "block w-full rounded-md border-0 p-2 text-gray-900 ring-1 ring-inset ring-mid placeholder:text-gray-300 focus:ring-1 focus:ring-inset focus:ring-dark sm:leading-6 hover:pointer" %>
6
- <%= f.text_field :template, value: template.name, readonly: true, class: "read-only:bg-gray-100 block w-full rounded-md border-0 p-2 text-gray-900 ring-1 ring-inset ring-mid placeholder:text-gray-300 focus:ring-1 focus:ring-inset focus:ring-dark sm:leading-6 hover:pointer" %>
7
- <%= f.select :status, options_for_select([["Active", "active"], ["Draft", "draft"], ["Hidden", "hidden"], ["Archived", "archived"]], selected: page.status), {}, class: "block w-full rounded-md border-0 py-1.5 pl-3 pr-10 text-gray-900 ring-1 ring-inset ring-mid focus:ring-1 focus:ring-inset focus:ring-dark sm:leading-6 hover:pointer" %>
8
- <%= f.submit "Save" %>
9
+ <% parent_seo_data = page.parent ? {
10
+ seoTitle: page.parent.seo_title,
11
+ seoDescription: page.parent.seo_description,
12
+ seoKeywords: page.parent.seo_keywords,
13
+ canonicalUrl: page.parent.canonical_url,
14
+ ogTitle: page.parent.og_title,
15
+ ogDescription: page.parent.og_description,
16
+ ogType: page.parent.og_type
17
+ }.to_json : '{}' %>
18
+ <% ai_generation_url = begin
19
+ admin_cms_pro_ai_generate_seo_path(page.id)
20
+ rescue NoMethodError
21
+ nil
22
+ end %>
23
+ <%= panda_cms_form_with model: page, url: admin_cms_page_path, method: :put, id: "page-form", data: {
24
+ controller: "page-form",
25
+ page_form_parent_seo_data_value: parent_seo_data,
26
+ page_form_page_id_value: page.id,
27
+ page_form_ai_generation_url_value: ai_generation_url
28
+ } do |f| %>
29
+ <%= f.text_field :title, { data: { page_form_target: "pageTitle" } } %>
30
+ <%= f.text_field :template, value: template.name, readonly: true %>
31
+ <%= f.select :status, options_for_select([["Active", "active"], ["Draft", "draft"], ["Hidden", "hidden"], ["Archived", "archived"]], selected: page.status) %>
32
+ <% if page.page_type.in?(["system", "posts"]) %>
33
+ <%= f.text_field :page_type, value: page.page_type.humanize, readonly: true %>
34
+ <% else %>
35
+ <%= f.select :page_type, options_for_select([["Standard", "standard"], ["Hidden", "hidden"], ["Code", "code"]], selected: page.page_type) %>
36
+ <% end %>
37
+
38
+ <%= f.section_heading "SEO Settings" %>
39
+
40
+ <% if defined?(Panda::CMS::Pro) && ai_generation_url.present? %>
41
+ <div class="mb-4">
42
+ <%= render Panda::Core::Admin::ButtonComponent.new(
43
+ text: "Generate With AI",
44
+ action: :save,
45
+ icon: "wand-magic-sparkles",
46
+ size: :regular,
47
+ as_button: true,
48
+ data: {
49
+ action: "click->page-form#generateSeoWithAI",
50
+ page_form_target: "generateButton"
51
+ }
52
+ ) %>
53
+ <p class="mt-1 text-xs text-gray-500 dark:text-gray-400">Uses AI to analyze page content and generate optimized SEO fields.</p>
54
+ </div>
55
+ <% end %>
56
+
57
+ <% unless page.parent_id.nil? %>
58
+ <%= f.check_box :inherit_seo, {
59
+ label: "Inherit SEO from parent page",
60
+ data: {
61
+ page_form_target: "inheritCheckbox",
62
+ action: "change->page-form#toggleInherit"
63
+ }
64
+ } %>
65
+ <% end %>
66
+
67
+ <div class="space-y-4">
68
+ <%= f.text_field :seo_title, {
69
+ meta: "Max 70 characters. Leave blank to use page title.",
70
+ max_length: 70,
71
+ data: { page_form_target: "seoTitle" }
72
+ } %>
73
+ <%= f.text_area :seo_description, {
74
+ rows: 3,
75
+ meta: "Max 160 characters. Shown in search results.",
76
+ max_length: 160,
77
+ data: { page_form_target: "seoDescription" }
78
+ } %>
79
+ <%= f.text_field :seo_keywords, {
80
+ meta: "Comma-separated keywords for search engines.",
81
+ data: { page_form_target: "seoKeywords" }
82
+ } %>
83
+ <%= f.radio_button_group :seo_index_mode,
84
+ [["Visible to search engines", "visible"], ["Hidden from search engines", "invisible"]],
85
+ { meta: "Control how search engines index this page." } %>
86
+ <%= f.text_field :canonical_url, {
87
+ meta: "Optional. Full URL to the canonical version of this page.",
88
+ data: { page_form_target: "canonicalUrl" }
89
+ } %>
90
+ </div>
91
+
92
+ <%= f.section_heading "Social Sharing" %>
93
+
94
+ <div class="space-y-4">
95
+ <%= f.text_field :og_title, {
96
+ label: "Social Media Title",
97
+ meta: "Max 60 characters. Leave blank to use SEO title.",
98
+ max_length: 60,
99
+ data: { page_form_target: "ogTitle" }
100
+ } %>
101
+ <%= f.text_area :og_description, {
102
+ label: "Social Media Description",
103
+ rows: 2,
104
+ meta: "Max 200 characters. Used on Facebook, LinkedIn, Twitter.",
105
+ max_length: 200,
106
+ data: { page_form_target: "ogDescription" }
107
+ } %>
108
+ <%= f.select :og_type,
109
+ options_for_select(
110
+ [["Website", "website"], ["Article", "article"], ["Profile", "profile"], ["Video", "video"], ["Book", "book"]],
111
+ selected: page.og_type
112
+ ),
113
+ { label: "Content Type" },
114
+ { data: { page_form_target: "ogType" } } %>
115
+ <%= f.file_field :og_image, {
116
+ label: "Social Media Image",
117
+ meta: "Recommended: 1200×630px (1.91:1 ratio). Used on Facebook, LinkedIn, Twitter.",
118
+ accept: "image/png,image/jpeg,image/jpg,image/webp",
119
+ with_cropper: true,
120
+ aspect_ratio: 1.91,
121
+ min_width: 1200,
122
+ min_height: 630
123
+ } %>
124
+ <% if page.og_image.attached? %>
125
+ <div class="mt-2">
126
+ <%= image_tag page.og_image.variant(:og_share), class: "max-w-xs rounded border border-gray-300" %>
127
+ </div>
128
+ <% end %>
129
+ </div>
9
130
  <% end %>
10
131
  <% end %>
11
- <div id="successMessage" class="hidden">
12
- <%= render Panda::Core::Admin::FlashMessageComponent.new(kind: "success", message: "This page was successfully updated!", temporary: false) %>
13
- </div>
14
- <div id="errorMessage" class="hidden">
15
- <%= render Panda::Core::Admin::FlashMessageComponent.new(kind: "error", message: "There was an error updating this page.", temporary: false) %>
16
- </div>
17
- <div class="grid grid-cols-2 mb-4 -mt-5">
18
- <div>
19
- <a class="inline-block mb-2 text-sm text-black/60" target="_blank" href="<%= @page.path %>"><%= @page.path %> <i class="ml-2 fa-solid fa-arrow-up-right-from-square"></i></a>
20
- </div>
21
- <div class="relative -mt-5">
22
- <span class="absolute right-0"><%= render Panda::Core::Admin::ButtonComponent.new(text: "Save Changes", action: :save_inactive, icon: "check", link: "#", size: :regular, id: "saveEditableButton") %></span>
23
- </div>
24
- </div>
132
+ <% component.with_footer do %>
133
+ <button type="button" data-action="click->toggle#toggle touch->toggle#toggle" class="inline-flex items-center gap-x-1.5 rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-xs inset-ring inset-ring-gray-300 hover:bg-gray-50 cursor-pointer dark:bg-white/10 dark:text-gray-100 dark:shadow-none dark:inset-ring-white/5 dark:hover:bg-white/20">
134
+ <i class="fa-solid fa-xmark"></i> Cancel
135
+ </button>
136
+ <button type="submit" form="page-form" class="inline-flex items-center gap-x-1.5 justify-center rounded-md bg-mid px-3 py-2 text-sm font-semibold text-white shadow-xs hover:bg-mid/80 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-mid cursor-pointer dark:shadow-none">
137
+ <i class="fa-solid fa-check"></i> Save
138
+ </button>
139
+ <% end %>
140
+
141
+ <%= content_tag :div, id: "successMessage", class: "hidden fixed top-4 right-4 z-50" do %>
142
+ <%= render Panda::Core::Admin::FlashMessageComponent.new(kind: :success, message: "This page was successfully updated!", temporary: false) %>
143
+ <% end %>
144
+
145
+ <%= content_tag :div, id: "errorMessage", class: "hidden fixed top-4 right-4 z-50" do %>
146
+ <%= render Panda::Core::Admin::FlashMessageComponent.new(kind: :error, message: "There was an error updating this page.", temporary: false) %>
147
+ <% end %>
148
+
25
149
  <%= content_tag :iframe, nil,
26
150
  src: "#{page.path}?embed_id=#{page.id}",
27
151
  class: "p-0 m-0 w-full h-full border border-slate-200",
@@ -31,6 +155,7 @@
31
155
  controller: "editor-iframe",
32
156
  editor_iframe_page_id_value: @page.id,
33
157
  editor_iframe_admin_path_value: "#{admin_cms_dashboard_url}",
34
- editor_iframe_autosave_value: false
158
+ editor_iframe_autosave_value: false,
159
+ editor_iframe_assets_value: panda_cms_injectable_assets
35
160
  } %>
36
161
  <% end %>
@@ -1,19 +1,57 @@
1
1
  <%= render Panda::Core::Admin::ContainerComponent.new do |component| %>
2
- <% component.with_heading(text: "Pages", level: 1) do |heading| %>
3
- <% heading.with_button(action: :add, text: "Add Page", link: new_admin_cms_page_path) %>
2
+ <% component.heading(text: "Pages", level: 1) do |heading| %>
3
+ <% heading.button(action: :add, text: "Add Page", href: new_admin_cms_page_path) %>
4
4
  <% end %>
5
5
 
6
6
  <% if root_page %>
7
- <%= render Panda::Core::Admin::TableComponent.new(term: "page", rows: root_page.self_and_descendants) do |table| %>
8
- <% table.column("Name") do |page| %>
9
- <div class="<%= table_indent(page) %>">
10
- <%= link_to page.title, edit_admin_cms_page_path(page), class: "block h-full w-full" %>
11
- <span class="block text-xs text-black/60"><%= page.path %></span>
12
- </div>
7
+ <div data-controller="tree" data-tree-target="container" style="opacity: 0; transition: opacity 0.2s;">
8
+ <%= render Panda::Core::Admin::TableComponent.new(term: "page", rows: root_page.self_and_descendants) do |table| %>
9
+ <% table.column("Name") do |page| %>
10
+ <div class="flex items-start" data-tree-target="row" data-page-id="<%= page.id %>" data-level="<%= page.level %>" data-parent-id="<%= page.parent_id %>">
11
+ <div class="flex-1 min-w-0">
12
+ <%# Add indentation for nested levels %>
13
+ <% indent_class = case page.level
14
+ when 0 then ""
15
+ when 1 then "ml-4"
16
+ when 2 then "ml-8"
17
+ else "ml-12"
18
+ end %>
19
+ <div class="flex items-start <%= indent_class %>">
20
+ <div class="flex-1 min-w-0">
21
+ <div class="flex items-center gap-2">
22
+ <%# Chevron/icon section %>
23
+ <% if page.children_count > 0 %>
24
+ <% if page.level > 0 %>
25
+ <%# Non-root pages with children: show chevron button only %>
26
+ <button type="button"
27
+ class="text-xs text-gray-500 hover:text-gray-700 focus:outline-none focus:ring-2 focus:ring-primary rounded px-1 w-4 flex items-center justify-center"
28
+ data-tree-target="toggle"
29
+ data-action="click->tree#toggle"
30
+ data-page-id="<%= page.id %>">
31
+ <i class="fa-solid fa-chevron-right"></i>
32
+ </button>
33
+ <% else %>
34
+ <%# Root page (Home): show folder icon %>
35
+ <i class="fa-solid fa-folder text-gray-500 mr-2"></i>
36
+ <% end %>
37
+ <% else %>
38
+ <%# Leaf pages: show file icon %>
39
+ <i class="fa-solid fa-file text-gray-400 mr-2"></i>
40
+ <% end %>
41
+ <%= link_to page.title, edit_admin_cms_page_path(page), class: "font-medium hover:text-primary #{page.children_count > 0 && page.level > 0 ? 'ml-2' : ''}" %>
42
+ </div>
43
+ <div class="text-xs text-black/60 mt-1 ml-6">
44
+ <%= page.path %>
45
+ </div>
46
+ </div>
47
+ </div>
48
+ </div>
49
+ </div>
50
+ <% end %>
51
+ <% table.column("Type", width: "12%") { |page| render Panda::Core::Admin::TagComponent.new(page_type: page.page_type.to_sym) } %>
52
+ <% table.column("Last Updated", width: "18%") { |page| render Panda::Core::Admin::UserActivityComponent.new(at: page.last_updated_at) } %>
13
53
  <% end %>
14
- <% table.column("Status") { |page| render Panda::Core::Admin::TagComponent.new(status: page.status) } %>
15
- <% table.column("Last Updated") { |page| render Panda::CMS::Admin::UserActivityComponent.new(model: page) } %>
16
- <% end %>
54
+ </div>
17
55
  <% else %>
18
56
  <div class="p-6 bg-error/10 text-error rounded-lg">
19
57
  <p class="text-base">No homepage (at <code>/</code>) found. Please create a homepage to start building your site.</p>
@@ -1,21 +1,13 @@
1
1
  <%= render Panda::Core::Admin::ContainerComponent.new do |component| %>
2
- <% component.with_heading(text: "Add Page", level: 1) do |heading| %>
3
- <% end %>
2
+ <% component.heading(text: "Add Page", level: 1) %>
4
3
  <%= panda_cms_form_with model: page, url: admin_cms_pages_path, method: :post do |f| %>
5
- <% if page.errors.any? %>
6
- <div class="mb-4 p-4 bg-red-50 border border-red-200 rounded-md">
7
- <div class="text-sm text-red-600">
8
- <% page.errors.full_messages.each do |message| %>
9
- <p><%= message %></p>
10
- <% end %>
11
- </div>
12
- </div>
13
- <% end %>
4
+ <%= render Panda::Core::Admin::FormErrorComponent.new(model: page) %>
14
5
  <% options = nested_set_options(Panda::CMS::Page, page) { |i| "#{"-" * i.level} #{i.title} (#{i.path})" } %>
15
6
  <%= f.select :parent_id, options %>
16
7
  <%= f.text_field :title %>
17
8
  <%= f.text_field :path, { meta: t(".path.meta") } %>
18
9
  <%= f.collection_select :panda_cms_template_id, available_templates, :id, :name %>
10
+ <%= f.select :page_type, options_for_select([["Active", "standard"], ["Hidden", "hidden"], ["Code", "code"]], selected: "standard") %>
19
11
  <%= f.button "Create Page" %>
20
12
  <% end %>
21
13
  <% end %>
@@ -1,30 +1,20 @@
1
1
  <%= panda_cms_form_with model: post, url: url, method: post.persisted? ? :put : :post do |f| %>
2
- <% if post.errors.any? %>
3
- <div class="mb-4 p-4 bg-red-50 border border-red-200 rounded-md">
4
- <div class="text-sm text-red-600">
5
- <% post.errors.full_messages.each do |message| %>
6
- <p><%= message %></p>
7
- <% end %>
8
- </div>
9
- </div>
10
- <% end %>
2
+ <%= render Panda::Core::Admin::FormErrorComponent.new(model: post) %>
11
3
 
12
4
  <div data-controller="slug" data-slug-add-date-prefix-value="true">
13
5
  <%= f.text_field :title,
14
- class: "block w-full rounded-md border-0 p-2 text-gray-900 ring-1 ring-inset ring-mid placeholder:text-gray-300 focus:ring-1 focus:ring-inset focus:ring-dark sm:leading-6 hover:pointer",
15
6
  data: {
16
7
  "slug-target": "input_text",
17
8
  action: "focusout->slug#generatePath"
18
9
  } %>
19
10
  <%= f.text_field :slug,
20
- class: "block w-full rounded-md border-0 p-2 text-gray-900 ring-1 ring-inset ring-mid placeholder:text-gray-300 focus:ring-1 focus:ring-inset focus:ring-dark sm:leading-6 hover:pointer",
21
11
  data: {
22
12
  "slug-target": "output_text"
23
13
  } %>
24
14
  </div>
25
- <%= f.select :author_id, Panda::Core::User.admin.map { |u| [u.name, u.id] }, {}, class: "block w-full rounded-md border-0 py-1.5 pl-3 pr-10 text-gray-900 ring-1 ring-inset ring-mid focus:ring-1 focus:ring-inset focus:ring-dark sm:leading-6 hover:pointer" %>
26
- <%= f.datetime_field :published_at, class: "block w-full rounded-md border-0 p-2 text-gray-900 ring-1 ring-inset ring-mid placeholder:text-gray-300 focus:ring-1 focus:ring-inset focus:ring-dark sm:leading-6 hover:pointer" %>
27
- <%= f.select :status, options_for_select([["Active", "active"], ["Draft", "draft"], ["Hidden", "hidden"], ["Archived", "archived"]], selected: post.status), {}, class: "block w-full rounded-md border-0 py-1.5 pl-3 pr-10 text-gray-900 ring-1 ring-inset ring-mid focus:ring-1 focus:ring-inset focus:ring-dark sm:leading-6 hover:pointer" %>
15
+ <%= f.select :author_id, Panda::Core::User.admins.map { |u| [u.name, u.id] } %>
16
+ <%= f.datetime_field :published_at %>
17
+ <%= f.select :status, options_for_select([["Active", "active"], ["Draft", "draft"], ["Hidden", "hidden"], ["Archived", "archived"]], selected: post.status) %>
28
18
 
29
19
  <% editor_id = "editor_#{dom_id(post, :content)}" %>
30
20
  <div data-controller="editor-form"
@@ -41,7 +31,46 @@
41
31
  </div>
42
32
  </div>
43
33
 
44
- <%= f.submit post.persisted? ? "Update Post" : "Create Post",
34
+ <%= f.section_heading "SEO Settings" %>
35
+
36
+ <div class="space-y-4">
37
+ <%= f.text_field :seo_title, { meta: "Max 70 characters. Leave blank to use post title." } %>
38
+ <%= f.text_area :seo_description, { rows: 3, meta: "Max 160 characters. Leave blank to use post excerpt." } %>
39
+ <%= f.text_field :seo_keywords, { meta: "Comma-separated keywords for search engines." } %>
40
+ <%= f.radio_button_group :seo_index_mode,
41
+ [["Visible to search engines", "visible"], ["Hidden from search engines", "invisible"]],
42
+ { meta: "Control how search engines index this post." } %>
43
+ <%= f.text_field :canonical_url, { meta: "Optional. Full URL to the canonical version of this post." } %>
44
+ </div>
45
+
46
+ <%= f.section_heading "Social Sharing" %>
47
+
48
+ <div class="space-y-4">
49
+ <%= f.text_field :og_title, { label: "Social Media Title", meta: "Max 60 characters. Leave blank to use SEO title." } %>
50
+ <%= f.text_area :og_description, { label: "Social Media Description", rows: 2, meta: "Max 200 characters. Used on Facebook, LinkedIn, Twitter." } %>
51
+ <%= f.select :og_type,
52
+ options_for_select(
53
+ [["Website", "website"], ["Article", "article"], ["Profile", "profile"], ["Video", "video"], ["Book", "book"]],
54
+ selected: post.og_type
55
+ ),
56
+ { label: "Content Type" } %>
57
+ <%= f.file_field :og_image, {
58
+ label: "Social Media Image",
59
+ meta: "Recommended: 1200×630px (1.91:1 ratio). Used on Facebook, LinkedIn, Twitter.",
60
+ accept: "image/png,image/jpeg,image/jpg,image/webp",
61
+ with_cropper: true,
62
+ aspect_ratio: 1.91,
63
+ min_width: 1200,
64
+ min_height: 630
65
+ } %>
66
+ <% if f.object.present? && f.object.persisted? && f.object.og_image.attached? %>
67
+ <div class="mt-2">
68
+ <%= image_tag f.object.og_image.variant(:og_share), class: "max-w-xs rounded border border-gray-300" %>
69
+ </div>
70
+ <% end %>
71
+ </div>
72
+
73
+ <%= f.submit f.object.persisted? ? "Update Post" : "Create Post",
45
74
  class: "btn btn-primary",
46
75
  data: {
47
76
  disable_with: "Saving...",
@@ -1,6 +1,6 @@
1
1
  <%= render Panda::Core::Admin::ContainerComponent.new do |component| %>
2
- <% component.with_heading(text: post.title, level: 1) do |heading| %>
3
- <% heading.with_button(action: :view, text: "View Post", link: post_path(post.admin_param)) %>
2
+ <% component.heading(text: post.title, level: 1) do |heading| %>
3
+ <% heading.button(action: :view, text: "View Post", href: post_path(post.admin_param)) %>
4
4
  <% end %>
5
5
 
6
6
  <%= render "form", post: post, url: admin_cms_post_path(post.admin_param), method: :patch %>
@@ -1,9 +1,9 @@
1
1
  <%= render Panda::Core::Admin::ContainerComponent.new do |component| %>
2
- <% component.with_heading(text: "Posts", level: 1) do |heading| %>
3
- <% heading.with_button(action: :add, text: "Add Post", link: new_admin_cms_post_path) %>
2
+ <% component.heading(text: "Posts", level: 1, icon: "fa-solid fa-newspaper") do |heading| %>
3
+ <% heading.button(action: :add, text: "Add Post", href: new_admin_cms_post_path) %>
4
4
  <% end %>
5
5
 
6
- <%= render Panda::Core::Admin::TableComponent.new(term: "post", rows: posts) do |table| %>
6
+ <%= render Panda::Core::Admin::TableComponent.new(term: "post", rows: posts, icon: "fa-solid fa-newspaper") do |table| %>
7
7
  <% table.column("Title") do |post| %>
8
8
  <div>
9
9
  <%= link_to post.title, edit_admin_cms_post_path(post.admin_param), class: "block h-full w-full" %>
@@ -12,9 +12,9 @@
12
12
  </span>
13
13
  </div>
14
14
  <% end %>
15
- <% table.column("Status") { |post| render Panda::Core::Admin::TagComponent.new(status: post.status) } %>
16
- <% table.column("Published") { |post| render Panda::CMS::Admin::UserActivityComponent.new(at: post.published_at, user: post.author)} %>
17
- <% table.column("Last Updated") { |post| render Panda::CMS::Admin::UserActivityComponent.new(at: post.updated_at)} %>
15
+ <% table.column("Status") { |post| render Panda::Core::Admin::TagComponent.new(status: post.status.to_sym) } %>
16
+ <% table.column("Published") { |post| render Panda::Core::Admin::UserActivityComponent.new(at: post.published_at, user: post.author)} %>
17
+ <% table.column("Last Updated") { |post| render Panda::Core::Admin::UserActivityComponent.new(at: post.updated_at)} %>
18
18
  <% end %>
19
19
 
20
20
  <% end %>
@@ -1,5 +1,5 @@
1
1
  <%= render Panda::Core::Admin::ContainerComponent.new do |component| %>
2
- <% component.with_heading(text: "Add Post", level: 1) do |heading| %>
2
+ <% component.heading(text: "Add Post", level: 1) do |heading| %>
3
3
  <% end %>
4
4
 
5
5
  <%= render "form", post: post, url: url, method: :post %>
@@ -1,5 +1,5 @@
1
1
  <%= render Panda::Core::Admin::ContainerComponent.new do |component| %>
2
- <% component.with_heading(text: "Bulk Editor", level: 1) %>
2
+ <% component.heading(text: "Bulk Editor", level: 1) %>
3
3
 
4
4
  <% if @debug && @debug[:error].any? %>
5
5
  <div class="p-4 mb-4 bg-red-50 rounded-md">
@@ -1,8 +1,8 @@
1
1
  <%= render Panda::Core::Admin::ContainerComponent.new do |component| %>
2
- <% component.with_heading(text: "Settings", level: 1) %>
2
+ <% component.heading(text: "Settings", level: 1) %>
3
3
 
4
4
  <%= render Panda::Core::Admin::PanelComponent.new do |panel| %>
5
- <% panel.with_heading(text: "System Status") %>
5
+ <% panel.heading(text: "System Status") %>
6
6
 
7
7
  <p class="text-base leading-loose"><i class="mr-2 text-active fa fa-check-circle"></i> <span class="font-medium">Panda CMS:</span> v<%= Panda::CMS::VERSION %></p>
8
8
  <p class="text-base leading-loose"><i class="mr-2 text-active fa fa-check-circle"></i> <span class="font-medium">Rails:</span> v<%= Rails.version %></p>
@@ -11,7 +11,7 @@
11
11
  <% end %>
12
12
 
13
13
  <%= render Panda::Core::Admin::PanelComponent.new do |panel| %>
14
- <% panel.with_heading(text: "Integrations") %>
14
+ <% panel.heading(text: "Integrations") %>
15
15
 
16
16
  <p class="text-base leading-loose"><i class="mr-2 text-active fa-brands fa-instagram"></i> <span class="font-medium">Instagram:</span> <%= Panda::CMS.config.instagram[:enabled] ? "Connected (@#{Panda::CMS.config.instagram[:username]})" : "Not Connected" %></p>
17
17
  <% end %>
@@ -2,10 +2,7 @@
2
2
  <html>
3
3
  <head>
4
4
  <title>Panda CMS Page</title>
5
- <% if params[:embed_id].present? %>
6
- <!-- Include Panda CMS assets for editor functionality when in edit mode -->
7
- <%= panda_cms_complete_assets %>
8
- <% end %>
5
+ <!-- CMS assets are automatically injected by editor_iframe_controller when in edit mode -->
9
6
  </head>
10
7
  <body>
11
8
  <h1>Test Header</h1>
@@ -0,0 +1,38 @@
1
+ {
2
+ "ignored_warnings": [
3
+ {
4
+ "warning_type": "Dynamic Render Path",
5
+ "warning_code": 15,
6
+ "fingerprint": "cbd974174800cbaa06ad90971544cdfb087e88c17ca6ca42d5e9b7e2f62f544f",
7
+ "check_name": "Render",
8
+ "message": "Render path contains parameter value",
9
+ "file": "app/views/panda/cms/admin/menus/edit.html.erb",
10
+ "line": 5,
11
+ "link": "https://brakemanscanner.org/docs/warning_types/dynamic_render_path/",
12
+ "code": "render(action => Panda::Core::Admin::FormErrorComponent.new(:model => Panda::CMS::Menu.find(params[:id])), { :locals => ({ :\"panda::core::admin::formerrorcomponent\" => Panda::Core::Admin::FormErrorComponent.new(:model => Panda::CMS::Menu.find(params[:id])) }) })",
13
+ "render_path": [
14
+ {
15
+ "type": "controller",
16
+ "class": "Panda::CMS::Admin::MenusController",
17
+ "method": "edit",
18
+ "line": 39,
19
+ "file": "app/controllers/panda/cms/admin/menus_controller.rb",
20
+ "rendered": {
21
+ "name": "panda/cms/admin/menus/edit",
22
+ "file": "app/views/panda/cms/admin/menus/edit.html.erb"
23
+ }
24
+ }
25
+ ],
26
+ "location": {
27
+ "type": "template",
28
+ "template": "panda/cms/admin/menus/edit"
29
+ },
30
+ "user_input": "params[:id]",
31
+ "confidence": "Weak",
32
+ "cwe_id": [22],
33
+ "note": "False positive: The component class is hardcoded (Panda::Core::Admin::FormErrorComponent), not dynamically determined. The model parameter is validated through Rails' find method and only used as data to pass to the component, not to determine the rendering path."
34
+ }
35
+ ],
36
+ "updated": "2025-11-09 00:00:00 +0000",
37
+ "brakeman_version": "7.1.1"
38
+ }