activeadmin_mitosis_editor 0.1.0

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 (165) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +17 -0
  3. data/CLAUDE.md +118 -0
  4. data/Gemfile +3 -0
  5. data/LICENSE +21 -0
  6. data/README.md +126 -0
  7. data/RELEASE.md +80 -0
  8. data/Rakefile +2 -0
  9. data/activeadmin_mitosis_editor.gemspec +17 -0
  10. data/app/views/inputs/mitosis_editor_input/_dependencies.html.erb +9 -0
  11. data/app/views/inputs/mitosis_editor_input/_form.html.erb +52 -0
  12. data/bin/console +5 -0
  13. data/bin/setup +14 -0
  14. data/demo/.dockerignore +51 -0
  15. data/demo/.gitattributes +9 -0
  16. data/demo/.gitignore +37 -0
  17. data/demo/.kamal/hooks/docker-setup.sample +3 -0
  18. data/demo/.kamal/hooks/post-app-boot.sample +3 -0
  19. data/demo/.kamal/hooks/post-deploy.sample +14 -0
  20. data/demo/.kamal/hooks/post-proxy-reboot.sample +3 -0
  21. data/demo/.kamal/hooks/pre-app-boot.sample +3 -0
  22. data/demo/.kamal/hooks/pre-build.sample +51 -0
  23. data/demo/.kamal/hooks/pre-connect.sample +47 -0
  24. data/demo/.kamal/hooks/pre-deploy.sample +122 -0
  25. data/demo/.kamal/hooks/pre-proxy-reboot.sample +3 -0
  26. data/demo/.kamal/secrets +20 -0
  27. data/demo/.rubocop.yml +8 -0
  28. data/demo/.ruby-version +1 -0
  29. data/demo/Dockerfile +76 -0
  30. data/demo/Gemfile +78 -0
  31. data/demo/Procfile.dev +2 -0
  32. data/demo/README.md +24 -0
  33. data/demo/Rakefile +6 -0
  34. data/demo/app/admin/articles.rb +12 -0
  35. data/demo/app/admin/dashboard.rb +17 -0
  36. data/demo/app/admin/pages.rb +12 -0
  37. data/demo/app/admin/posts.rb +12 -0
  38. data/demo/app/assets/builds/.keep +0 -0
  39. data/demo/app/assets/builds/active_admin.css +3852 -0
  40. data/demo/app/assets/images/.keep +0 -0
  41. data/demo/app/assets/stylesheets/active_admin.css +3 -0
  42. data/demo/app/assets/stylesheets/application.css +1 -0
  43. data/demo/app/assets/stylesheets/mitosis-editor.css +1 -0
  44. data/demo/app/assets/stylesheets/theme-dark.css +1 -0
  45. data/demo/app/assets/stylesheets/theme-light.css +1 -0
  46. data/demo/app/controllers/application_controller.rb +7 -0
  47. data/demo/app/controllers/articles_controller.rb +7 -0
  48. data/demo/app/controllers/concerns/.keep +0 -0
  49. data/demo/app/helpers/application_helper.rb +2 -0
  50. data/demo/app/helpers/articles_helper.rb +2 -0
  51. data/demo/app/javascript/application.js +3 -0
  52. data/demo/app/javascript/controllers/application.js +9 -0
  53. data/demo/app/javascript/controllers/hello_controller.js +7 -0
  54. data/demo/app/javascript/controllers/index.js +4 -0
  55. data/demo/app/jobs/application_job.rb +7 -0
  56. data/demo/app/mailers/application_mailer.rb +4 -0
  57. data/demo/app/models/application_record.rb +3 -0
  58. data/demo/app/models/article.rb +5 -0
  59. data/demo/app/models/concerns/.keep +0 -0
  60. data/demo/app/models/page.rb +5 -0
  61. data/demo/app/models/post.rb +5 -0
  62. data/demo/app/views/articles/_article.html.erb +12 -0
  63. data/demo/app/views/articles/_article.json.jbuilder +2 -0
  64. data/demo/app/views/articles/_form.html.erb +27 -0
  65. data/demo/app/views/articles/edit.html.erb +12 -0
  66. data/demo/app/views/articles/index.html.erb +16 -0
  67. data/demo/app/views/articles/index.json.jbuilder +1 -0
  68. data/demo/app/views/articles/new.html.erb +11 -0
  69. data/demo/app/views/articles/show.html.erb +10 -0
  70. data/demo/app/views/articles/show.json.jbuilder +1 -0
  71. data/demo/app/views/inputs/mitosis_editor_input/_dependencies.html.erb +17 -0
  72. data/demo/app/views/layouts/application.html.erb +29 -0
  73. data/demo/app/views/layouts/mailer.html.erb +13 -0
  74. data/demo/app/views/layouts/mailer.text.erb +1 -0
  75. data/demo/app/views/pwa/manifest.json.erb +22 -0
  76. data/demo/app/views/pwa/service-worker.js +26 -0
  77. data/demo/bin/brakeman +7 -0
  78. data/demo/bin/bundler-audit +6 -0
  79. data/demo/bin/ci +6 -0
  80. data/demo/bin/dev +8 -0
  81. data/demo/bin/docker-entrypoint +8 -0
  82. data/demo/bin/importmap +4 -0
  83. data/demo/bin/jobs +6 -0
  84. data/demo/bin/kamal +27 -0
  85. data/demo/bin/rails +4 -0
  86. data/demo/bin/rake +4 -0
  87. data/demo/bin/rubocop +8 -0
  88. data/demo/bin/setup +35 -0
  89. data/demo/bin/thrust +5 -0
  90. data/demo/config/application.rb +27 -0
  91. data/demo/config/boot.rb +4 -0
  92. data/demo/config/bundler-audit.yml +5 -0
  93. data/demo/config/cable.yml +17 -0
  94. data/demo/config/cache.yml +16 -0
  95. data/demo/config/ci.rb +23 -0
  96. data/demo/config/credentials.yml.enc +1 -0
  97. data/demo/config/database.yml +41 -0
  98. data/demo/config/deploy.yml +120 -0
  99. data/demo/config/environment.rb +21 -0
  100. data/demo/config/environments/development.rb +78 -0
  101. data/demo/config/environments/production.rb +90 -0
  102. data/demo/config/environments/test.rb +53 -0
  103. data/demo/config/importmap.rb +7 -0
  104. data/demo/config/initializers/active_admin.rb +275 -0
  105. data/demo/config/initializers/activeadmin_mitosis_editor.rb +19 -0
  106. data/demo/config/initializers/assets.rb +7 -0
  107. data/demo/config/initializers/content_security_policy.rb +29 -0
  108. data/demo/config/initializers/filter_parameter_logging.rb +8 -0
  109. data/demo/config/initializers/inflections.rb +16 -0
  110. data/demo/config/locales/en.yml +31 -0
  111. data/demo/config/puma.rb +42 -0
  112. data/demo/config/queue.yml +18 -0
  113. data/demo/config/recurring.yml +15 -0
  114. data/demo/config/routes.rb +16 -0
  115. data/demo/config/storage.yml +27 -0
  116. data/demo/config.ru +6 -0
  117. data/demo/db/cable_schema.rb +11 -0
  118. data/demo/db/cache_schema.rb +12 -0
  119. data/demo/db/migrate/20260215110410_create_active_admin_comments.rb +16 -0
  120. data/demo/db/migrate/20260215110416_create_articles.rb +10 -0
  121. data/demo/db/migrate/20260216124916_create_posts.rb +10 -0
  122. data/demo/db/migrate/20260216124919_create_pages.rb +10 -0
  123. data/demo/db/queue_schema.rb +129 -0
  124. data/demo/db/schema.rb +48 -0
  125. data/demo/db/seeds.rb +9 -0
  126. data/demo/lib/tasks/.keep +0 -0
  127. data/demo/log/.keep +0 -0
  128. data/demo/package-lock.json +1260 -0
  129. data/demo/package.json +13 -0
  130. data/demo/public/400.html +135 -0
  131. data/demo/public/404.html +135 -0
  132. data/demo/public/406-unsupported-browser.html +135 -0
  133. data/demo/public/422.html +135 -0
  134. data/demo/public/500.html +135 -0
  135. data/demo/public/icon.png +0 -0
  136. data/demo/public/icon.svg +3 -0
  137. data/demo/public/robots.txt +1 -0
  138. data/demo/script/.keep +0 -0
  139. data/demo/spec/rails_helper.rb +72 -0
  140. data/demo/spec/spec_helper.rb +94 -0
  141. data/demo/spec/system/admin_articles_spec.rb +22 -0
  142. data/demo/spec/system/mitosis_editor_prism_spec.rb +34 -0
  143. data/demo/spec/system/mitosis_editor_theme_spec.rb +63 -0
  144. data/demo/storage/.keep +0 -0
  145. data/demo/tailwind-active_admin.config.js +17 -0
  146. data/demo/tmp/.keep +0 -0
  147. data/demo/tmp/storage/.keep +0 -0
  148. data/demo/vendor/.keep +0 -0
  149. data/demo/vendor/javascript/.keep +0 -0
  150. data/docs/plans/2026-02-15-mitosis-editor-gem-design.md +70 -0
  151. data/docs/plans/2026-02-15-mitosis-editor-gem-implementation.md +407 -0
  152. data/lib/activeadmin_mitosis_editor/inputs/mitosis_editor_input.rb +29 -0
  153. data/lib/activeadmin_mitosis_editor/railtie.rb +7 -0
  154. data/lib/activeadmin_mitosis_editor/version.rb +3 -0
  155. data/lib/activeadmin_mitosis_editor.rb +13 -0
  156. data/lib/generators/mitosis_editor/styles_generator.rb +23 -0
  157. data/lib/generators/mitosis_editor/templates/_dependencies.html.erb +17 -0
  158. data/lib/generators/mitosis_editor/views_generator.rb +14 -0
  159. data/preview.png +0 -0
  160. data/script/bump-version +78 -0
  161. data/vendor/assets/javascripts/mitosis-editor.js +61 -0
  162. data/vendor/assets/stylesheets/mitosis-editor.css +1 -0
  163. data/vendor/assets/stylesheets/theme-dark.min.css +1 -0
  164. data/vendor/assets/stylesheets/theme-light.min.css +1 -0
  165. metadata +248 -0
File without changes
@@ -0,0 +1,3 @@
1
+ @import "tailwindcss";
2
+ @plugin "@activeadmin/activeadmin/plugin";
3
+ @config "../../../tailwind-active_admin.config.js";
@@ -0,0 +1 @@
1
+ /* empty — gem CSS is loaded via the editor form partial */
@@ -0,0 +1 @@
1
+ .mitosis-editor-wrapper{--editor-width:100%;--editor-height:600px;--editor-padding:16px;--editor-border-radius:4px;--divider-width:2px;--editor-font-family:ui-monospace,monospace;--editor-font-size:14px;--editor-line-height:1.6;--editor-bg:#ffffff;--editor-text:#282a36;--editor-border:#e0e0e0;--editor-caret:#000000;--editor-placeholder:#999999;--editor-selection:#b3d9ff;--preview-bg:#ffffff;--preview-text:#282a36;--preview-border:#e0e0e0;--preview-code-bg:#f6f8fa;--preview-link:#0366d6;--divider-bg:#e0e0e0;--divider-hover:#bdbdbd;--scrollbar-width:6px;--scrollbar-track:transparent;--scrollbar-thumb:#c1c1c1;--scrollbar-thumb-hover:#a8a8a8;width:var(--editor-width);height:var(--editor-height);position:relative;font-family:system-ui,-apple-system,sans-serif;box-sizing:border-box}.mitosis-editor-wrapper *,.mitosis-editor-wrapper ::after,.mitosis-editor-wrapper ::before{box-sizing:inherit}.mitosis-editor-container{position:relative;height:100%;overflow:hidden}.mitosis-textarea{position:absolute;top:0;left:0;width:100%;height:100%;padding:var(--editor-padding);outline:0;resize:none;font-family:var(--editor-font-family);font-size:var(--editor-font-size);line-height:var(--editor-line-height);caret-color:var(--editor-caret);z-index:2;color:var(--editor-text);border:1px solid var(--editor-border);border-radius:var(--editor-border-radius);background:var(--editor-bg);border-top-right-radius:0;border-bottom-right-radius:0;border-right:0}.mitosis-textarea::placeholder{color:var(--editor-placeholder)}.mitosis-textarea::selection{background:var(--editor-selection)}.mitosis-highlight{position:absolute;top:0;left:0;width:100%;height:100%;padding:var(--editor-padding);pointer-events:none;font-family:var(--editor-font-family);font-size:var(--editor-font-size);line-height:var(--editor-line-height);white-space:pre-wrap;word-wrap:break-word;overflow:auto;z-index:1;color:var(--editor-text)}.mitosis-preview{height:100%;overflow:hidden;display:flex;flex-direction:column;border:1px solid var(--preview-border);border-radius:var(--editor-border-radius);background:var(--preview-bg);border-top-left-radius:0;border-bottom-left-radius:0;border-left:0}.mitosis-preview-content{padding:var(--editor-padding);overflow:auto;flex:1;background:var(--preview-bg);color:var(--preview-text)}.mitosis-preview-content h1,.mitosis-preview-content h2,.mitosis-preview-content h3,.mitosis-preview-content h4,.mitosis-preview-content h5,.mitosis-preview-content h6{margin-top:1.5em;margin-bottom:.5em;font-weight:600;line-height:1.25}.mitosis-preview-content h1{font-size:2em;border-bottom:1px solid var(--preview-border);padding-bottom:.3em}.mitosis-preview-content h2{font-size:1.5em;border-bottom:1px solid var(--preview-border);padding-bottom:.3em}.mitosis-preview-content h3{font-size:1.25em}.mitosis-preview-content h4{font-size:1em}.mitosis-preview-content h5{font-size:.875em}.mitosis-preview-content h6{font-size:.85em;color:var(--preview-text);opacity:.7}.mitosis-preview-content p{margin:1em 0}.mitosis-preview-content ol,.mitosis-preview-content ul{padding-left:2em;margin:1em 0}.mitosis-preview-content li{margin:.25em 0}.mitosis-preview-content code{background:var(--preview-code-bg);padding:.2em .4em;border-radius:3px;font-family:ui-monospace,monospace;font-size:.9em}.mitosis-preview-content pre{background:var(--preview-code-bg);padding:16px;border-radius:6px;overflow:auto;margin:1em 0}.mitosis-preview-content pre code{background:0 0;padding:0}.mitosis-preview-content blockquote{border-left:4px solid var(--preview-border);padding-left:1em;color:var(--preview-text);opacity:.7;margin:1em 0}.mitosis-preview-content img{max-width:100%;height:auto}.mitosis-preview-content a{color:var(--preview-link);text-decoration:none}.mitosis-preview-content a:hover{text-decoration:underline}.mitosis-preview-content hr{border:none;border-top:1px solid var(--preview-border);margin:2em 0}.mitosis-layout{display:flex;height:100%;gap:0;border:1px solid var(--editor-border);border-radius:var(--editor-border-radius);overflow:hidden}.mitosis-layout .mitosis-panel{flex:1;min-height:0;display:flex;flex-direction:column;background:var(--editor-bg)}.mitosis-divider{width:var(--divider-width);cursor:col-resize;border-left:3px solid var(--divider-bg);position:relative;flex-shrink:0;transition:border-color .15s ease}.mitosis-divider:hover{border-color:var(--divider-hover)}.mitosis-editor-wrapper ::-webkit-scrollbar{width:var(--scrollbar-width);height:var(--scrollbar-width)}.mitosis-editor-wrapper ::-webkit-scrollbar-track{background:var(--scrollbar-track)}.mitosis-editor-wrapper ::-webkit-scrollbar-thumb{background:var(--scrollbar-thumb);border-radius:3px}.mitosis-editor-wrapper ::-webkit-scrollbar-thumb:hover{background:var(--scrollbar-thumb-hover)}
@@ -0,0 +1 @@
1
+ .mitosis-editor-wrapper[data-theme=dark]{--editor-bg:#282a36;--editor-text:#f8f8f2;--editor-border:#44475a;--editor-caret:#f8f8f2;--editor-placeholder:#6272a4;--editor-selection:#44475a;--preview-bg:#282a36;--preview-text:#f8f8f2;--preview-border:#44475a;--preview-code-bg:#44475a;--preview-link:#8be9fd;--divider-bg:#21222c;--divider-hover:#44475a}
@@ -0,0 +1 @@
1
+ .mitosis-editor-wrapper[data-theme=light]{--editor-bg:#ffffff;--editor-text:#282a36;--editor-border:#e0e0e0;--editor-caret:#000000;--editor-placeholder:#999999;--editor-selection:#b3d9ff;--preview-bg:#ffffff;--preview-text:#282a36;--preview-border:#e0e0e0;--preview-code-bg:#f6f8fa;--preview-link:#0366d6;--divider-bg:#e0e0e0;--divider-hover:#bdbdbd}
@@ -0,0 +1,7 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has.
3
+ allow_browser versions: :modern
4
+
5
+ # Changes to the importmap will invalidate the etag for HTML responses
6
+ stale_when_importmap_changes
7
+ end
@@ -0,0 +1,7 @@
1
+ class ArticlesController < InheritedResources::Base
2
+ private
3
+
4
+ def article_params
5
+ params.require(:article).permit(:title, :body)
6
+ end
7
+ end
File without changes
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module ArticlesHelper
2
+ end
@@ -0,0 +1,3 @@
1
+ // Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
2
+ import "@hotwired/turbo-rails"
3
+ import "controllers"
@@ -0,0 +1,9 @@
1
+ import { Application } from "@hotwired/stimulus"
2
+
3
+ const application = Application.start()
4
+
5
+ // Configure Stimulus development experience
6
+ application.debug = false
7
+ window.Stimulus = application
8
+
9
+ export { application }
@@ -0,0 +1,7 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ export default class extends Controller {
4
+ connect() {
5
+ this.element.textContent = "Hello World!"
6
+ }
7
+ }
@@ -0,0 +1,4 @@
1
+ // Import and register all your controllers from the importmap via controllers/**/*_controller
2
+ import { application } from "controllers/application"
3
+ import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading"
4
+ eagerLoadControllersFrom("controllers", application)
@@ -0,0 +1,7 @@
1
+ class ApplicationJob < ActiveJob::Base
2
+ # Automatically retry jobs that encountered a deadlock
3
+ # retry_on ActiveRecord::Deadlocked
4
+
5
+ # Most jobs are safe to ignore if the underlying records are no longer available
6
+ # discard_on ActiveJob::DeserializationError
7
+ end
@@ -0,0 +1,4 @@
1
+ class ApplicationMailer < ActionMailer::Base
2
+ default from: "from@example.com"
3
+ layout "mailer"
4
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ primary_abstract_class
3
+ end
@@ -0,0 +1,5 @@
1
+ class Article < ApplicationRecord
2
+ def self.ransackable_attributes(auth_object = nil)
3
+ [ "body", "created_at", "id", "title", "updated_at" ]
4
+ end
5
+ end
File without changes
@@ -0,0 +1,5 @@
1
+ class Page < ApplicationRecord
2
+ def self.ransackable_attributes(auth_object = nil)
3
+ [ "body", "created_at", "id", "title", "updated_at" ]
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class Post < ApplicationRecord
2
+ def self.ransackable_attributes(auth_object = nil)
3
+ [ "body", "created_at", "id", "title", "updated_at" ]
4
+ end
5
+ end
@@ -0,0 +1,12 @@
1
+ <div id="<%= dom_id article %>">
2
+ <div>
3
+ <strong>Title:</strong>
4
+ <%= article.title %>
5
+ </div>
6
+
7
+ <div>
8
+ <strong>Body:</strong>
9
+ <%= article.body %>
10
+ </div>
11
+
12
+ </div>
@@ -0,0 +1,2 @@
1
+ json.extract! article, :id, :title, :body, :created_at, :updated_at
2
+ json.url article_url(article, format: :json)
@@ -0,0 +1,27 @@
1
+ <%= form_with(model: article) do |form| %>
2
+ <% if article.errors.any? %>
3
+ <div style="color: red">
4
+ <h2><%= pluralize(article.errors.count, "error") %> prohibited this article from being saved:</h2>
5
+
6
+ <ul>
7
+ <% article.errors.each do |error| %>
8
+ <li><%= error.full_message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div>
15
+ <%= form.label :title, style: "display: block" %>
16
+ <%= form.text_field :title %>
17
+ </div>
18
+
19
+ <div>
20
+ <%= form.label :body, style: "display: block" %>
21
+ <%= form.textarea :body %>
22
+ </div>
23
+
24
+ <div>
25
+ <%= form.submit %>
26
+ </div>
27
+ <% end %>
@@ -0,0 +1,12 @@
1
+ <% content_for :title, "Editing article" %>
2
+
3
+ <h1>Editing article</h1>
4
+
5
+ <%= render "form", article: @article %>
6
+
7
+ <br>
8
+
9
+ <div>
10
+ <%= link_to "Show this article", @article %> |
11
+ <%= link_to "Back to articles", articles_path %>
12
+ </div>
@@ -0,0 +1,16 @@
1
+ <p style="color: green"><%= notice %></p>
2
+
3
+ <% content_for :title, "Articles" %>
4
+
5
+ <h1>Articles</h1>
6
+
7
+ <div id="articles">
8
+ <% @articles.each do |article| %>
9
+ <%= render article %>
10
+ <p>
11
+ <%= link_to "Show this article", article %>
12
+ </p>
13
+ <% end %>
14
+ </div>
15
+
16
+ <%= link_to "New article", new_article_path %>
@@ -0,0 +1 @@
1
+ json.array! @articles, partial: "articles/article", as: :article
@@ -0,0 +1,11 @@
1
+ <% content_for :title, "New article" %>
2
+
3
+ <h1>New article</h1>
4
+
5
+ <%= render "form", article: @article %>
6
+
7
+ <br>
8
+
9
+ <div>
10
+ <%= link_to "Back to articles", articles_path %>
11
+ </div>
@@ -0,0 +1,10 @@
1
+ <p style="color: green"><%= notice %></p>
2
+
3
+ <%= render @article %>
4
+
5
+ <div>
6
+ <%= link_to "Edit this article", edit_article_path(@article) %> |
7
+ <%= link_to "Back to articles", articles_path %>
8
+
9
+ <%= button_to "Destroy this article", @article, method: :delete %>
10
+ </div>
@@ -0,0 +1 @@
1
+ json.partial! "articles/article", article: @article
@@ -0,0 +1,17 @@
1
+ <%# Parameters:
2
+ # theme - 'light', 'dark', or 'auto' (default: 'light') %>
3
+ <% theme = local_assigns[:theme] || "auto"
4
+ theme_light = %w[light auto].include?(theme)
5
+ theme_dark = %w[dark auto].include?(theme) %>
6
+ <%= stylesheet_link_tag "mitosis-editor" %>
7
+ <%= stylesheet_link_tag "theme-light" if theme_light %>
8
+ <%= stylesheet_link_tag "theme-dark" if theme_dark %>
9
+ <%= javascript_include_tag "mitosis-editor" %>
10
+
11
+ <%# Uncomment the lines below to enable syntax highlighting with Prism %>
12
+ <%= stylesheet_link_tag "https://cdn.jsdelivr.net/npm/prismjs@1.29.0/themes/prism-tomorrow.min.css" %>
13
+ <%= javascript_include_tag "https://cdn.jsdelivr.net/npm/prismjs@1.29.0/prism.min.js" %>
14
+ <%= javascript_include_tag "https://cdn.jsdelivr.net/npm/prismjs@1.29.0/components/prism-javascript.min.js" %>
15
+ <%= javascript_include_tag "https://cdn.jsdelivr.net/npm/prismjs@1.29.0/components/prism-typescript.min.js" %>
16
+ <%= javascript_include_tag "https://cdn.jsdelivr.net/npm/prismjs@1.29.0/components/prism-python.min.js" %>
17
+ <%= javascript_include_tag "https://cdn.jsdelivr.net/npm/prismjs@1.29.0/components/prism-css.min.js" %>
@@ -0,0 +1,29 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title><%= content_for(:title) || "Demo" %></title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <meta name="apple-mobile-web-app-capable" content="yes">
7
+ <meta name="application-name" content="Demo">
8
+ <meta name="mobile-web-app-capable" content="yes">
9
+ <%= csrf_meta_tags %>
10
+ <%= csp_meta_tag %>
11
+
12
+ <%= yield :head %>
13
+
14
+ <%# Enable PWA manifest for installable apps (make sure to enable in config/routes.rb too!) %>
15
+ <%#= tag.link rel: "manifest", href: pwa_manifest_path(format: :json) %>
16
+
17
+ <link rel="icon" href="/icon.png" type="image/png">
18
+ <link rel="icon" href="/icon.svg" type="image/svg+xml">
19
+ <link rel="apple-touch-icon" href="/icon.png">
20
+
21
+ <%# Includes all stylesheet files in app/assets/stylesheets %>
22
+ <%= stylesheet_link_tag :app, "data-turbo-track": "reload" %>
23
+ <%= javascript_importmap_tags %>
24
+ </head>
25
+
26
+ <body>
27
+ <%= yield %>
28
+ </body>
29
+ </html>
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
+ <style>
6
+ /* Email styles need to be inline */
7
+ </style>
8
+ </head>
9
+
10
+ <body>
11
+ <%= yield %>
12
+ </body>
13
+ </html>
@@ -0,0 +1 @@
1
+ <%= yield %>
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "Demo",
3
+ "icons": [
4
+ {
5
+ "src": "/icon.png",
6
+ "type": "image/png",
7
+ "sizes": "512x512"
8
+ },
9
+ {
10
+ "src": "/icon.png",
11
+ "type": "image/png",
12
+ "sizes": "512x512",
13
+ "purpose": "maskable"
14
+ }
15
+ ],
16
+ "start_url": "/",
17
+ "display": "standalone",
18
+ "scope": "/",
19
+ "description": "Demo.",
20
+ "theme_color": "red",
21
+ "background_color": "red"
22
+ }
@@ -0,0 +1,26 @@
1
+ // Add a service worker for processing Web Push notifications:
2
+ //
3
+ // self.addEventListener("push", async (event) => {
4
+ // const { title, options } = await event.data.json()
5
+ // event.waitUntil(self.registration.showNotification(title, options))
6
+ // })
7
+ //
8
+ // self.addEventListener("notificationclick", function(event) {
9
+ // event.notification.close()
10
+ // event.waitUntil(
11
+ // clients.matchAll({ type: "window" }).then((clientList) => {
12
+ // for (let i = 0; i < clientList.length; i++) {
13
+ // let client = clientList[i]
14
+ // let clientPath = (new URL(client.url)).pathname
15
+ //
16
+ // if (clientPath == event.notification.data.path && "focus" in client) {
17
+ // return client.focus()
18
+ // }
19
+ // }
20
+ //
21
+ // if (clients.openWindow) {
22
+ // return clients.openWindow(event.notification.data.path)
23
+ // }
24
+ // })
25
+ // )
26
+ // })
data/demo/bin/brakeman ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ require "rubygems"
3
+ require "bundler/setup"
4
+
5
+ ARGV.unshift("--ensure-latest")
6
+
7
+ load Gem.bin_path("brakeman", "brakeman")
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative "../config/boot"
3
+ require "bundler/audit/cli"
4
+
5
+ ARGV.concat %w[ --config config/bundler-audit.yml ] if ARGV.empty? || ARGV.include?("check")
6
+ Bundler::Audit::CLI.start
data/demo/bin/ci ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative "../config/boot"
3
+ require "active_support/continuous_integration"
4
+
5
+ CI = ActiveSupport::ContinuousIntegration
6
+ require_relative "../config/ci.rb"
data/demo/bin/dev ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env sh
2
+
3
+ if gem list foreman -i --silent; then
4
+ exec foreman start -f Procfile.dev "$@"
5
+ else
6
+ echo "Installing foreman..."
7
+ gem install foreman && exec foreman start -f Procfile.dev "$@"
8
+ fi
@@ -0,0 +1,8 @@
1
+ #!/bin/bash -e
2
+
3
+ # If running the rails server then create or migrate existing database
4
+ if [ "${@: -2:1}" == "./bin/rails" ] && [ "${@: -1:1}" == "server" ]; then
5
+ ./bin/rails db:prepare
6
+ fi
7
+
8
+ exec "${@}"
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative "../config/application"
4
+ require "importmap/commands"
data/demo/bin/jobs ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative "../config/environment"
4
+ require "solid_queue/cli"
5
+
6
+ SolidQueue::Cli.start(ARGV)
data/demo/bin/kamal ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'kamal' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
12
+
13
+ bundle_binstub = File.expand_path("bundle", __dir__)
14
+
15
+ if File.file?(bundle_binstub)
16
+ if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
17
+ load(bundle_binstub)
18
+ else
19
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
20
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
21
+ end
22
+ end
23
+
24
+ require "rubygems"
25
+ require "bundler/setup"
26
+
27
+ load Gem.bin_path("kamal", "kamal")
data/demo/bin/rails ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path("../config/application", __dir__)
3
+ require_relative "../config/boot"
4
+ require "rails/commands"
data/demo/bin/rake ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative "../config/boot"
3
+ require "rake"
4
+ Rake.application.run
data/demo/bin/rubocop ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ require "rubygems"
3
+ require "bundler/setup"
4
+
5
+ # Explicit RuboCop config increases performance slightly while avoiding config confusion.
6
+ ARGV.unshift("--config", File.expand_path("../.rubocop.yml", __dir__))
7
+
8
+ load Gem.bin_path("rubocop", "rubocop")
data/demo/bin/setup ADDED
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env ruby
2
+ require "fileutils"
3
+
4
+ APP_ROOT = File.expand_path("..", __dir__)
5
+
6
+ def system!(*args)
7
+ system(*args, exception: true)
8
+ end
9
+
10
+ FileUtils.chdir APP_ROOT do
11
+ # This script is a way to set up or update your development environment automatically.
12
+ # This script is idempotent, so that you can run it at any time and get an expectable outcome.
13
+ # Add necessary setup steps to this file.
14
+
15
+ puts "== Installing dependencies =="
16
+ system("bundle check") || system!("bundle install")
17
+
18
+ # puts "\n== Copying sample files =="
19
+ # unless File.exist?("config/database.yml")
20
+ # FileUtils.cp "config/database.yml.sample", "config/database.yml"
21
+ # end
22
+
23
+ puts "\n== Preparing database =="
24
+ system! "bin/rails db:prepare"
25
+ system! "bin/rails db:reset" if ARGV.include?("--reset")
26
+
27
+ puts "\n== Removing old logs and tempfiles =="
28
+ system! "bin/rails log:clear tmp:clear"
29
+
30
+ unless ARGV.include?("--skip-server")
31
+ puts "\n== Starting development server =="
32
+ STDOUT.flush # flush the output before exec(2) so that it displays
33
+ exec "bin/dev"
34
+ end
35
+ end
data/demo/bin/thrust ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ require "rubygems"
3
+ require "bundler/setup"
4
+
5
+ load Gem.bin_path("thruster", "thrust")
@@ -0,0 +1,27 @@
1
+ require_relative "boot"
2
+
3
+ require "rails/all"
4
+
5
+ # Require the gems listed in Gemfile, including any gems
6
+ # you've limited to :test, :development, or :production.
7
+ Bundler.require(*Rails.groups)
8
+
9
+ module Demo
10
+ class Application < Rails::Application
11
+ # Initialize configuration defaults for originally generated Rails version.
12
+ config.load_defaults 8.1
13
+
14
+ # Please, add to the `ignore` list any other `lib` subdirectories that do
15
+ # not contain `.rb` files, or that should not be reloaded or eager loaded.
16
+ # Common ones are `templates`, `generators`, or `middleware`, for example.
17
+ config.autoload_lib(ignore: %w[assets tasks])
18
+
19
+ # Configuration for the application, engines, and railties goes here.
20
+ #
21
+ # These settings can be overridden in specific environments using the files
22
+ # in config/environments, which are processed later.
23
+ #
24
+ # config.time_zone = "Central Time (US & Canada)"
25
+ # config.eager_load_paths << Rails.root.join("extras")
26
+ end
27
+ end
@@ -0,0 +1,4 @@
1
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
2
+
3
+ require "bundler/setup" # Set up gems listed in the Gemfile.
4
+ require "bootsnap/setup" # Speed up boot time by caching expensive operations.
@@ -0,0 +1,5 @@
1
+ # Audit all gems listed in the Gemfile for known security problems by running bin/bundler-audit.
2
+ # CVEs that are not relevant to the application can be enumerated on the ignore list below.
3
+
4
+ ignore:
5
+ - CVE-THAT-DOES-NOT-APPLY
@@ -0,0 +1,17 @@
1
+ # Async adapter only works within the same process, so for manually triggering cable updates from a console,
2
+ # and seeing results in the browser, you must do so from the web console (running inside the dev process),
3
+ # not a terminal started via bin/rails console! Add "console" to any action or any ERB template view
4
+ # to make the web console appear.
5
+ development:
6
+ adapter: async
7
+
8
+ test:
9
+ adapter: test
10
+
11
+ production:
12
+ adapter: solid_cable
13
+ connects_to:
14
+ database:
15
+ writing: cable
16
+ polling_interval: 0.1.seconds
17
+ message_retention: 1.day
@@ -0,0 +1,16 @@
1
+ default: &default
2
+ store_options:
3
+ # Cap age of oldest cache entry to fulfill retention policies
4
+ # max_age: <%= 60.days.to_i %>
5
+ max_size: <%= 256.megabytes %>
6
+ namespace: <%= Rails.env %>
7
+
8
+ development:
9
+ <<: *default
10
+
11
+ test:
12
+ <<: *default
13
+
14
+ production:
15
+ database: cache
16
+ <<: *default
data/demo/config/ci.rb ADDED
@@ -0,0 +1,23 @@
1
+ # Run using bin/ci
2
+
3
+ CI.run do
4
+ step "Setup", "bin/setup --skip-server"
5
+
6
+ step "Style: Ruby", "bin/rubocop"
7
+
8
+ step "Security: Gem audit", "bin/bundler-audit"
9
+ step "Security: Importmap vulnerability audit", "bin/importmap audit"
10
+ step "Security: Brakeman code analysis", "bin/brakeman --quiet --no-pager --exit-on-warn --exit-on-error"
11
+
12
+ step "Tests: Rails", "bin/rails test"
13
+ step "Tests: System", "bin/rails test:system"
14
+ step "Tests: Seeds", "env RAILS_ENV=test bin/rails db:seed:replant"
15
+
16
+ # Optional: set a green GitHub commit status to unblock PR merge.
17
+ # Requires the `gh` CLI and `gh extension install basecamp/gh-signoff`.
18
+ # if success?
19
+ # step "Signoff: All systems go. Ready for merge and deploy.", "gh signoff"
20
+ # else
21
+ # failure "Signoff: CI failed. Do not merge or deploy.", "Fix the issues and try again."
22
+ # end
23
+ end
@@ -0,0 +1 @@
1
+ BRZdlkP7vbeixVpUxnCXAg4VKQZoaA0qbWn0eT1vAd8JHKi+Izw27r2srk7kPh5MyYuYy+llxDorXompbgUeDdlyh3YeEEG9rJ0SJ5GajaMcFrRXxZVWrWo2cjPeNFqvq7MqVBhHA3S4ZIGs9U/xSJ9kGF9AA3duQi0SqLRJ/JLGkBEOtigpqm/KJEFZHAYuRig3iNJ0bydlMR9YNMurI+ZbuUglxKrD+n31e0zYEq+RX8T8APnhAALFxox18eBG096E5pR+/D3QDYtOlr1dXEK4g/YNd/j3PZ4ujLcHBS3qnPyL4RPSkffNJspuqsG+oRVE5l8ZgTuVlQrdRVd2galXLO7qMjilaOZBvyLIXM4VCdxnFcn4PmyXKaqqfFRGulgrYzEC5215s2xVWa3lHyETxtRexVJqgicg1cNIubBkVQdf9zVpScDhXSTSot6kQRsO0v/0d3E6O1zqtJXMIMrKejue50GaDOhmOwt5AQLkp88gyCU5btvK--Z0p8OkBZkr7bowbE--urDDJ6pryS54t1L6AgjM0Q==