admin_suite 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 (128) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/Gemfile +13 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +7 -0
  6. data/Rakefile +11 -0
  7. data/app/assets/admin_suite.css +444 -0
  8. data/app/assets/admin_suite_tailwind.css +8 -0
  9. data/app/assets/builds/admin_suite_tailwind.css +8 -0
  10. data/app/assets/rouge.css +218 -0
  11. data/app/assets/tailwind/admin_suite.css +22 -0
  12. data/app/controllers/admin_suite/application_controller.rb +118 -0
  13. data/app/controllers/admin_suite/dashboard_controller.rb +258 -0
  14. data/app/controllers/admin_suite/docs_controller.rb +155 -0
  15. data/app/controllers/admin_suite/portals_controller.rb +22 -0
  16. data/app/controllers/admin_suite/resources_controller.rb +238 -0
  17. data/app/helpers/admin_suite/base_helper.rb +1199 -0
  18. data/app/helpers/admin_suite/icon_helper.rb +61 -0
  19. data/app/helpers/admin_suite/panels_helper.rb +52 -0
  20. data/app/helpers/admin_suite/resources_helper.rb +15 -0
  21. data/app/helpers/admin_suite/theme_helper.rb +99 -0
  22. data/app/javascript/controllers/admin_suite/click_actions_controller.js +73 -0
  23. data/app/javascript/controllers/admin_suite/clipboard_controller.js +57 -0
  24. data/app/javascript/controllers/admin_suite/code_editor_controller.js +45 -0
  25. data/app/javascript/controllers/admin_suite/file_upload_controller.js +238 -0
  26. data/app/javascript/controllers/admin_suite/json_editor_controller.js +62 -0
  27. data/app/javascript/controllers/admin_suite/live_filter_controller.js +71 -0
  28. data/app/javascript/controllers/admin_suite/markdown_editor_controller.js +67 -0
  29. data/app/javascript/controllers/admin_suite/searchable_select_controller.js +171 -0
  30. data/app/javascript/controllers/admin_suite/sidebar_controller.js +33 -0
  31. data/app/javascript/controllers/admin_suite/tag_select_controller.js +193 -0
  32. data/app/javascript/controllers/admin_suite/toggle_switch_controller.js +66 -0
  33. data/app/views/admin_suite/dashboard/index.html.erb +21 -0
  34. data/app/views/admin_suite/docs/index.html.erb +86 -0
  35. data/app/views/admin_suite/panels/_cards.html.erb +107 -0
  36. data/app/views/admin_suite/panels/_chart.html.erb +47 -0
  37. data/app/views/admin_suite/panels/_health.html.erb +44 -0
  38. data/app/views/admin_suite/panels/_recent.html.erb +56 -0
  39. data/app/views/admin_suite/panels/_stat.html.erb +64 -0
  40. data/app/views/admin_suite/panels/_table.html.erb +36 -0
  41. data/app/views/admin_suite/portals/show.html.erb +75 -0
  42. data/app/views/admin_suite/resources/_form.html.erb +32 -0
  43. data/app/views/admin_suite/resources/edit.html.erb +24 -0
  44. data/app/views/admin_suite/resources/index.html.erb +315 -0
  45. data/app/views/admin_suite/resources/new.html.erb +22 -0
  46. data/app/views/admin_suite/resources/show.html.erb +184 -0
  47. data/app/views/admin_suite/shared/_flash.html.erb +30 -0
  48. data/app/views/admin_suite/shared/_form.html.erb +60 -0
  49. data/app/views/admin_suite/shared/_json_editor_field.html.erb +52 -0
  50. data/app/views/admin_suite/shared/_sidebar.html.erb +94 -0
  51. data/app/views/admin_suite/shared/_toggle_cell.html.erb +34 -0
  52. data/app/views/admin_suite/shared/_topbar.html.erb +47 -0
  53. data/app/views/layouts/admin_suite/application.html.erb +79 -0
  54. data/lib/admin/base/action_executor.rb +155 -0
  55. data/lib/admin/base/action_handler.rb +31 -0
  56. data/lib/admin/base/filter_builder.rb +121 -0
  57. data/lib/admin/base/resource.rb +541 -0
  58. data/lib/admin_suite/configuration.rb +42 -0
  59. data/lib/admin_suite/engine.rb +101 -0
  60. data/lib/admin_suite/markdown_renderer.rb +115 -0
  61. data/lib/admin_suite/portal_definition.rb +64 -0
  62. data/lib/admin_suite/portal_registry.rb +32 -0
  63. data/lib/admin_suite/theme_palette.rb +36 -0
  64. data/lib/admin_suite/ui/dashboard_definition.rb +69 -0
  65. data/lib/admin_suite/ui/field_renderer_registry.rb +119 -0
  66. data/lib/admin_suite/ui/form_field_renderer.rb +48 -0
  67. data/lib/admin_suite/ui/show_formatter_registry.rb +120 -0
  68. data/lib/admin_suite/ui/show_value_formatter.rb +70 -0
  69. data/lib/admin_suite/version.rb +10 -0
  70. data/lib/admin_suite.rb +54 -0
  71. data/lib/generators/admin_suite/install/install_generator.rb +23 -0
  72. data/lib/generators/admin_suite/install/templates/admin_suite.rb +60 -0
  73. data/lib/generators/admin_suite/resource/resource_generator.rb +83 -0
  74. data/lib/generators/admin_suite/resource/templates/resource.rb.tt +47 -0
  75. data/lib/generators/admin_suite/scaffold/scaffold_generator.rb +28 -0
  76. data/lib/tasks/admin_suite_tailwind.rake +28 -0
  77. data/lib/tasks/admin_suite_test.rake +11 -0
  78. data/test/dummy/Gemfile +21 -0
  79. data/test/dummy/README.md +24 -0
  80. data/test/dummy/Rakefile +6 -0
  81. data/test/dummy/app/assets/stylesheets/application.css +10 -0
  82. data/test/dummy/app/controllers/application_controller.rb +4 -0
  83. data/test/dummy/app/helpers/application_helper.rb +2 -0
  84. data/test/dummy/app/models/application_record.rb +2 -0
  85. data/test/dummy/app/views/layouts/application.html.erb +28 -0
  86. data/test/dummy/app/views/pwa/manifest.json.erb +22 -0
  87. data/test/dummy/app/views/pwa/service-worker.js +26 -0
  88. data/test/dummy/bin/ci +6 -0
  89. data/test/dummy/bin/dev +2 -0
  90. data/test/dummy/bin/rails +4 -0
  91. data/test/dummy/bin/rake +4 -0
  92. data/test/dummy/bin/setup +35 -0
  93. data/test/dummy/config/application.rb +43 -0
  94. data/test/dummy/config/boot.rb +3 -0
  95. data/test/dummy/config/ci.rb +19 -0
  96. data/test/dummy/config/database.yml +31 -0
  97. data/test/dummy/config/environment.rb +5 -0
  98. data/test/dummy/config/environments/development.rb +57 -0
  99. data/test/dummy/config/environments/production.rb +67 -0
  100. data/test/dummy/config/environments/test.rb +42 -0
  101. data/test/dummy/config/initializers/assets.rb +7 -0
  102. data/test/dummy/config/initializers/content_security_policy.rb +29 -0
  103. data/test/dummy/config/initializers/filter_parameter_logging.rb +8 -0
  104. data/test/dummy/config/initializers/inflections.rb +16 -0
  105. data/test/dummy/config/locales/en.yml +31 -0
  106. data/test/dummy/config/puma.rb +39 -0
  107. data/test/dummy/config/routes.rb +16 -0
  108. data/test/dummy/config.ru +6 -0
  109. data/test/dummy/db/seeds.rb +9 -0
  110. data/test/dummy/log/test.log +441 -0
  111. data/test/dummy/public/400.html +135 -0
  112. data/test/dummy/public/404.html +135 -0
  113. data/test/dummy/public/406-unsupported-browser.html +135 -0
  114. data/test/dummy/public/422.html +135 -0
  115. data/test/dummy/public/500.html +135 -0
  116. data/test/dummy/public/icon.png +0 -0
  117. data/test/dummy/public/icon.svg +3 -0
  118. data/test/dummy/public/robots.txt +1 -0
  119. data/test/dummy/test/test_helper.rb +15 -0
  120. data/test/dummy/tmp/local_secret.txt +1 -0
  121. data/test/fixtures/docs/progress/PROGRESS_REPORT.md +6 -0
  122. data/test/integration/dashboard_test.rb +13 -0
  123. data/test/integration/docs_test.rb +46 -0
  124. data/test/integration/theme_test.rb +27 -0
  125. data/test/lib/markdown_renderer_test.rb +20 -0
  126. data/test/lib/theme_palette_test.rb +24 -0
  127. data/test/test_helper.rb +11 -0
  128. metadata +264 -0
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ require "lucide-rails"
5
+ rescue LoadError
6
+ # Host app may choose a different icon provider via `AdminSuite.config.icon_renderer`.
7
+ end
8
+
9
+ require "pagy"
10
+
11
+ require "admin_suite/version"
12
+ require "admin_suite/configuration"
13
+ require "admin_suite/markdown_renderer"
14
+ require "admin_suite/theme_palette"
15
+ require "admin_suite/portal_registry"
16
+ require "admin_suite/portal_definition"
17
+ require "admin_suite/ui/form_field_renderer"
18
+ require "admin_suite/ui/show_value_formatter"
19
+ require "admin_suite/engine"
20
+
21
+ module AdminSuite
22
+ class << self
23
+ # @return [AdminSuite::Configuration]
24
+ def config
25
+ @config ||= Configuration.new
26
+ end
27
+
28
+ # @yieldparam config [AdminSuite::Configuration]
29
+ # @return [AdminSuite::Configuration]
30
+ def configure
31
+ yield(config)
32
+ config
33
+ end
34
+
35
+ # Defines (or updates) a portal using a Ruby DSL.
36
+ #
37
+ # Host apps typically place these in `app/admin/portals/*.rb`.
38
+ #
39
+ # @param key [Symbol, String]
40
+ # @yield Portal definition DSL
41
+ # @return [AdminSuite::PortalDefinition]
42
+ def portal(key, &block)
43
+ definition = PortalDefinition.new(key)
44
+ definition.instance_eval(&block) if block_given?
45
+ PortalRegistry.register(definition)
46
+ definition
47
+ end
48
+
49
+ # @return [Hash{Symbol=>AdminSuite::PortalDefinition}]
50
+ def portal_definitions
51
+ PortalRegistry.all
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/generators"
4
+
5
+ module AdminSuite
6
+ module Generators
7
+ class InstallGenerator < Rails::Generators::Base
8
+ source_root File.expand_path("templates", __dir__)
9
+
10
+ desc "Installs AdminSuite initializer and mounts the engine."
11
+
12
+ class_option :mount_path, type: :string, default: "/internal/admin", desc: "Path to mount AdminSuite::Engine"
13
+
14
+ def create_initializer
15
+ template "admin_suite.rb", "config/initializers/admin_suite.rb"
16
+ end
17
+
18
+ def mount_engine
19
+ route %(mount AdminSuite::Engine => "#{options[:mount_path]}")
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ # AdminSuite configuration (host app adapter layer).
4
+ AdminSuite.configure do |config|
5
+ # Hook called as a before_action inside the engine.
6
+ # config.authenticate = ->(controller) { ... }
7
+ config.authenticate = nil
8
+
9
+ # Actor used for actions/auditing/authorization.
10
+ # config.current_actor = ->(controller) { ... }
11
+ config.current_actor = ->(controller) { controller.respond_to?(:current_user) ? controller.current_user : nil }
12
+
13
+ # Optional authorization hook (Pundit/CanCan/ActionPolicy/custom).
14
+ # config.authorize = ->(actor, action:, subject:, resource:, controller:) { true }
15
+ config.authorize = nil
16
+
17
+ # Resource definition file globs (host app can override).
18
+ config.resource_globs = [
19
+ Rails.root.join("config/admin_suite/resources/*.rb").to_s,
20
+ Rails.root.join("app/admin/resources/*.rb").to_s
21
+ ]
22
+
23
+ # Portal dashboard DSL globs (host app can override).
24
+ # Files typically call `AdminSuite.portal :ops do ... end`
25
+ config.portal_globs = [
26
+ Rails.root.join("config/admin_suite/portals/*.rb").to_s,
27
+ Rails.root.join("app/admin/portals/*.rb").to_s
28
+ ]
29
+
30
+ # Portal metadata (host app can override).
31
+ config.portals = {
32
+ ops: { label: "Ops Portal", icon: "settings", color: :amber, order: 10 }
33
+ }
34
+
35
+ # Theme (Tailwind color names).
36
+ config.theme = { primary: :indigo, secondary: :purple }
37
+
38
+ # Optional host stylesheet to include after AdminSuite's baseline CSS.
39
+ # In apps that use Tailwind, this is typically `:app`.
40
+ config.host_stylesheet = :app
41
+
42
+ # Tailwind CDN fallback (helps when host doesn't compile Tailwind).
43
+ # Disable if you provide your own Tailwind build.
44
+ config.tailwind_cdn = true
45
+
46
+ # Optional docs link shown in the sidebar.
47
+ # config.docs_url = "https://..."
48
+ config.docs_url = nil
49
+
50
+ # Docs viewer source folder (host app filesystem).
51
+ # Defaults to Rails.root/docs.
52
+ config.docs_path = Rails.root.join("docs")
53
+
54
+ # Partial overrides.
55
+ # config.partials[:flash] = "my/shared/flash"
56
+ # config.partials[:panel_stat] = "my/admin/panels/stat"
57
+
58
+ # Custom renderers:
59
+ # config.custom_renderers[:my_renderer] = ->(record, view_context) { ... }
60
+ end
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/generators"
4
+
5
+ module AdminSuite
6
+ module Generators
7
+ class ResourceGenerator < Rails::Generators::Base
8
+ source_root File.expand_path("templates", __dir__)
9
+
10
+ argument :model_name, type: :string, required: true, desc: "ActiveRecord model name (e.g. User)"
11
+
12
+ class_option :portal, type: :string, default: "ops", desc: "Portal key (e.g. ops, ai, assistant)"
13
+ class_option :section, type: :string, default: "general", desc: "Sidebar section key"
14
+ class_option :output_dir, type: :string, default: "app/admin/resources", desc: "Where to write the resource file"
15
+
16
+ def create_resource_definition
17
+ @model_class_name = model_name.camelize
18
+ @resource_class_name = "#{@model_class_name}Resource"
19
+ @portal = options[:portal].to_s
20
+ @section = options[:section].to_s
21
+
22
+ klass = safe_constantize(@model_class_name)
23
+ @columns = build_columns(klass)
24
+ @searchable = build_searchable(klass)
25
+ @form_fields = build_form_fields(klass)
26
+
27
+ template "resource.rb.tt", File.join(options[:output_dir], "#{@model_class_name.underscore}_resource.rb")
28
+ end
29
+
30
+ private
31
+
32
+ def safe_constantize(name)
33
+ name.constantize
34
+ rescue NameError
35
+ nil
36
+ end
37
+
38
+ def build_columns(klass)
39
+ return [] unless klass&.respond_to?(:columns_hash)
40
+
41
+ keys = klass.columns_hash.keys
42
+ preferred = %w[id name title email email_address status active created_at updated_at]
43
+ chosen = (preferred & keys)
44
+ chosen = (chosen + (keys - chosen)).uniq
45
+ chosen.take(6).map(&:to_sym)
46
+ end
47
+
48
+ def build_searchable(klass)
49
+ return [] unless klass&.respond_to?(:columns_hash)
50
+
51
+ stringish = klass.columns.select { |c| %i[string text].include?(c.type) }.map(&:name)
52
+ preferred = %w[name title email email_address]
53
+ (preferred & stringish).presence || stringish.take(3)
54
+ end
55
+
56
+ def build_form_fields(klass)
57
+ return [] unless klass&.respond_to?(:columns)
58
+
59
+ enums = klass.respond_to?(:defined_enums) ? klass.defined_enums : {}
60
+
61
+ klass.columns.reject { |c| %w[id created_at updated_at].include?(c.name) }.map do |c|
62
+ name = c.name
63
+ if enums.key?(name)
64
+ { name: name, type: :select, enum: enums[name].keys }
65
+ else
66
+ type =
67
+ case c.type
68
+ when :boolean then :toggle
69
+ when :text then :textarea
70
+ when :json, :jsonb then :json
71
+ when :datetime, :timestamp then :datetime
72
+ when :date then :date
73
+ when :integer, :bigint, :float, :decimal then :number
74
+ else
75
+ :text
76
+ end
77
+ { name: name, type: type }
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,47 @@
1
+ <%# frozen_string_literal: true %>
2
+
3
+ module Admin
4
+ module Resources
5
+ class <%= @resource_class_name %> < Admin::Base::Resource
6
+ model ::<%= @model_class_name %>
7
+ portal :<%= @portal %>
8
+ section :<%= @section %>
9
+
10
+ index do
11
+ <% if @searchable.present? %>
12
+ searchable <%= @searchable.map { |f| ":#{f}" }.join(", ") %>
13
+ <% end %>
14
+ sortable :created_at, default: :created_at, direction: :desc
15
+
16
+ columns do
17
+ <% @columns.each do |col| %>
18
+ column :<%= col %>
19
+ <% end %>
20
+ end
21
+ end
22
+
23
+ form do
24
+ <% @form_fields.each do |f| %>
25
+ <% if f[:type] == :select %>
26
+ field :<%= f[:name] %>, type: :select, collection: <%= f[:enum].map { |v| [v.humanize, v] }.inspect %>
27
+ <% elsif f[:type] == :textarea %>
28
+ field :<%= f[:name] %>, type: :textarea
29
+ <% elsif f[:type] == :toggle %>
30
+ field :<%= f[:name] %>, type: :toggle
31
+ <% elsif f[:type] == :json %>
32
+ field :<%= f[:name] %>, type: :json
33
+ <% elsif f[:type] == :datetime %>
34
+ field :<%= f[:name] %>, type: :datetime
35
+ <% elsif f[:type] == :date %>
36
+ field :<%= f[:name] %>, type: :date
37
+ <% elsif f[:type] == :number %>
38
+ field :<%= f[:name] %>, type: :number
39
+ <% else %>
40
+ field :<%= f[:name] %>
41
+ <% end %>
42
+ <% end %>
43
+ end
44
+ end
45
+ end
46
+ end
47
+
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/generators"
4
+
5
+ module AdminSuite
6
+ module Generators
7
+ class ScaffoldGenerator < Rails::Generators::Base
8
+ argument :model_name, type: :string, required: true
9
+ argument :attributes, type: :array, default: [], banner: "field:type field:type"
10
+
11
+ class_option :portal, type: :string, default: "ops"
12
+ class_option :section, type: :string, default: "general"
13
+
14
+ def run_rails_scaffold
15
+ Rails::Generators.invoke("scaffold", [ model_name, *attributes ], behavior: behavior)
16
+ end
17
+
18
+ def run_admin_suite_resource
19
+ Rails::Generators.invoke(
20
+ "admin_suite:resource",
21
+ [ model_name ],
22
+ portal: options[:portal],
23
+ section: options[:section]
24
+ )
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :admin_suite do
4
+ namespace :tailwind do
5
+ desc "Build AdminSuite Tailwind CSS into host app builds"
6
+ task build: :environment do
7
+ engine_root = AdminSuite::Engine.root
8
+ input = engine_root.join("app/assets/tailwind/admin_suite.css")
9
+ output = Rails.root.join("app/assets/builds/admin_suite_tailwind.css")
10
+
11
+ FileUtils.mkdir_p(output.dirname)
12
+
13
+ cmd = [
14
+ "tailwindcss",
15
+ "-i", input.to_s,
16
+ "-o", output.to_s,
17
+ "--minify"
18
+ ]
19
+
20
+ puts("[admin_suite] building Tailwind CSS -> #{output}")
21
+ success = system(*cmd)
22
+ raise("AdminSuite Tailwind build failed (#{cmd.join(' ')})") unless success
23
+ end
24
+ end
25
+ end
26
+
27
+ # Ensure the engine stylesheet is present for production builds.
28
+ Rake::Task["assets:precompile"].enhance([ "admin_suite:tailwind:build" ]) if Rake::Task.task_defined?("assets:precompile")
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rake/testtask"
4
+
5
+ namespace :admin_suite do
6
+ desc "Run AdminSuite gem tests (Minitest)"
7
+ Rake::TestTask.new(:test) do |t|
8
+ t.libs << "test"
9
+ t.pattern = "test/**/*_test.rb"
10
+ end
11
+ end
@@ -0,0 +1,21 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
4
+ gem "rails", "~> 8.1.2"
5
+ # The modern asset pipeline for Rails [https://github.com/rails/propshaft]
6
+ gem "propshaft"
7
+ # Use sqlite3 as the database for Active Record
8
+ gem "sqlite3", ">= 2.1"
9
+ # Use the Puma web server [https://github.com/puma/puma]
10
+ gem "puma", ">= 5.0"
11
+
12
+ # Use the engine under test.
13
+ gem "admin_suite", path: "../.."
14
+
15
+ # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
16
+ gem "tzinfo-data", platforms: %i[ windows jruby ]
17
+
18
+ group :development, :test do
19
+ # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
20
+ gem "debug", platforms: %i[ mri windows ], require: "debug/prelude"
21
+ end
@@ -0,0 +1,24 @@
1
+ # README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require_relative "config/application"
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,10 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css.
3
+ *
4
+ * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
5
+ * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
6
+ * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
7
+ * depending on specificity.
8
+ *
9
+ * Consider organizing styles into separate files for maintainability.
10
+ */
@@ -0,0 +1,4 @@
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
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ class ApplicationRecord
2
+ end
@@ -0,0 +1,28 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title><%= content_for(:title) || "Dummy" %></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="Dummy">
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 %>
23
+ </head>
24
+
25
+ <body>
26
+ <%= yield %>
27
+ </body>
28
+ </html>
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "Dummy",
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": "Dummy.",
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/test/dummy/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"
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ exec "./bin/rails", "server", *ARGV
@@ -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"
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative "../config/boot"
3
+ require "rake"
4
+ Rake.application.run
@@ -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
@@ -0,0 +1,43 @@
1
+ require_relative "boot"
2
+
3
+ require "rails"
4
+ # Pick the frameworks you want:
5
+ require "active_model/railtie"
6
+ require "active_job/railtie"
7
+ # AdminSuite does not require a database; keep the dummy app DB-free.
8
+ # require "active_record/railtie"
9
+ # require "active_storage/engine"
10
+ require "action_controller/railtie"
11
+ # require "action_mailer/railtie"
12
+ # require "action_mailbox/engine"
13
+ # require "action_text/engine"
14
+ require "action_view/railtie"
15
+ # require "action_cable/engine"
16
+ require "rails/test_unit/railtie"
17
+
18
+ # Require the gems listed in Gemfile, including any gems
19
+ # you've limited to :test, :development, or :production.
20
+ Bundler.require(*Rails.groups)
21
+
22
+ module Dummy
23
+ class Application < Rails::Application
24
+ # Initialize configuration defaults for originally generated Rails version.
25
+ config.load_defaults 8.1
26
+
27
+ # Please, add to the `ignore` list any other `lib` subdirectories that do
28
+ # not contain `.rb` files, or that should not be reloaded or eager loaded.
29
+ # Common ones are `templates`, `generators`, or `middleware`, for example.
30
+ config.autoload_lib(ignore: %w[assets tasks])
31
+
32
+ # Configuration for the application, engines, and railties goes here.
33
+ #
34
+ # These settings can be overridden in specific environments using the files
35
+ # in config/environments, which are processed later.
36
+ #
37
+ # config.time_zone = "Central Time (US & Canada)"
38
+ # config.eager_load_paths << Rails.root.join("extras")
39
+
40
+ # Don't generate system test files.
41
+ config.generators.system_tests = nil
42
+ end
43
+ end
@@ -0,0 +1,3 @@
1
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
2
+
3
+ require "bundler/setup" # Set up gems listed in the Gemfile.
@@ -0,0 +1,19 @@
1
+ # Run using bin/ci
2
+
3
+ CI.run do
4
+ step "Setup", "bin/setup --skip-server"
5
+
6
+ step "Tests: Rails", "bin/rails test"
7
+ step "Tests: Seeds", "env RAILS_ENV=test bin/rails db:seed:replant"
8
+
9
+ # Optional: Run system tests
10
+ # step "Tests: System", "bin/rails test:system"
11
+
12
+ # Optional: set a green GitHub commit status to unblock PR merge.
13
+ # Requires the `gh` CLI and `gh extension install basecamp/gh-signoff`.
14
+ # if success?
15
+ # step "Signoff: All systems go. Ready for merge and deploy.", "gh signoff"
16
+ # else
17
+ # failure "Signoff: CI failed. Do not merge or deploy.", "Fix the issues and try again."
18
+ # end
19
+ end
@@ -0,0 +1,31 @@
1
+ # SQLite. Versions 3.8.0 and up are supported.
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem "sqlite3"
6
+ #
7
+ default: &default
8
+ adapter: sqlite3
9
+ max_connections: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
10
+ timeout: 5000
11
+
12
+ development:
13
+ <<: *default
14
+ database: storage/development.sqlite3
15
+
16
+ # Warning: The database defined as "test" will be erased and
17
+ # re-generated from your development database when you run "rake".
18
+ # Do not set this db to the same as development or production.
19
+ test:
20
+ <<: *default
21
+ database: storage/test.sqlite3
22
+
23
+ # SQLite3 write its data on the local filesystem, as such it requires
24
+ # persistent disks. If you are deploying to a managed service, you should
25
+ # make sure it provides disk persistence, as many don't.
26
+ #
27
+ # Similarly, if you deploy your application as a Docker container, you must
28
+ # ensure the database is located in a persisted volume.
29
+ production:
30
+ <<: *default
31
+ # database: path/to/persistent/storage/production.sqlite3
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require_relative "application"
3
+
4
+ # Initialize the Rails application.
5
+ Rails.application.initialize!