<% if !@user.label? && @user.is_child_of?(current_user) %>
diff --git a/backstage-rails/.gitignore b/backstage-rails/.gitignore
new file mode 100644
index 0000000..a3ee5aa
--- /dev/null
+++ b/backstage-rails/.gitignore
@@ -0,0 +1,10 @@
+/.bundle/
+/doc/
+/log/*.log
+/pkg/
+/tmp/
+/test/dummy/db/*.sqlite3
+/test/dummy/db/*.sqlite3-*
+/test/dummy/log/*.log
+/test/dummy/storage/
+/test/dummy/tmp/
diff --git a/backstage-rails/Gemfile b/backstage-rails/Gemfile
new file mode 100644
index 0000000..b2cf356
--- /dev/null
+++ b/backstage-rails/Gemfile
@@ -0,0 +1,14 @@
+source "https://rubygems.org"
+git_source(:github) { |repo| "https://github.com/#{repo}.git" }
+
+# Specify your gem's dependencies in backstage-rails.gemspec.
+gemspec
+
+gem "puma"
+
+gem "sqlite3"
+
+gem "sprockets-rails"
+
+# Start debugger with binding.b [https://github.com/ruby/debug]
+# gem "debug", ">= 1.0.0"
diff --git a/backstage-rails/README.md b/backstage-rails/README.md
new file mode 100644
index 0000000..b45cf25
--- /dev/null
+++ b/backstage-rails/README.md
@@ -0,0 +1,28 @@
+# Backstage::Rails
+Short description and motivation.
+
+## Usage
+How to use my plugin.
+
+## Installation
+Add this line to your application's Gemfile:
+
+```ruby
+gem "backstage-rails"
+```
+
+And then execute:
+```bash
+$ bundle
+```
+
+Or install it yourself as:
+```bash
+$ gem install backstage-rails
+```
+
+## Contributing
+Contribution directions go here.
+
+## License
+The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
diff --git a/backstage-rails/Rakefile b/backstage-rails/Rakefile
new file mode 100644
index 0000000..e7793b5
--- /dev/null
+++ b/backstage-rails/Rakefile
@@ -0,0 +1,8 @@
+require "bundler/setup"
+
+APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
+load "rails/tasks/engine.rake"
+
+load "rails/tasks/statistics.rake"
+
+require "bundler/gem_tasks"
diff --git a/backstage-rails/app/assets/config/backstage_rails_manifest.js b/backstage-rails/app/assets/config/backstage_rails_manifest.js
new file mode 100644
index 0000000..485db61
--- /dev/null
+++ b/backstage-rails/app/assets/config/backstage_rails_manifest.js
@@ -0,0 +1 @@
+//= link_directory ../stylesheets/backstage/rails .css
diff --git a/backstage-rails/app/assets/images/backstage/rails/.keep b/backstage-rails/app/assets/images/backstage/rails/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/backstage-rails/app/assets/stylesheets/backstage/rails/application.css b/backstage-rails/app/assets/stylesheets/backstage/rails/application.css
new file mode 100644
index 0000000..0ebd7fe
--- /dev/null
+++ b/backstage-rails/app/assets/stylesheets/backstage/rails/application.css
@@ -0,0 +1,15 @@
+/*
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
+ * listed below.
+ *
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
+ *
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
+ * files in this directory. Styles in this file should be added after the last require_* statement.
+ * It is generally better to create a new file per style scope.
+ *
+ *= require_tree .
+ *= require_self
+ */
diff --git a/backstage-rails/app/controllers/backstage/rails/application_controller.rb b/backstage-rails/app/controllers/backstage/rails/application_controller.rb
new file mode 100644
index 0000000..4735b42
--- /dev/null
+++ b/backstage-rails/app/controllers/backstage/rails/application_controller.rb
@@ -0,0 +1,6 @@
+module Backstage
+ module Rails
+ class ApplicationController < ActionController::Base
+ end
+ end
+end
diff --git a/backstage-rails/app/controllers/backstage/rails/base_controller.rb b/backstage-rails/app/controllers/backstage/rails/base_controller.rb
new file mode 100644
index 0000000..b141f36
--- /dev/null
+++ b/backstage-rails/app/controllers/backstage/rails/base_controller.rb
@@ -0,0 +1,204 @@
+class Backstage::Rails::BaseController < ApplicationController
+ layout 'admin'
+ before_action :authenticate_admin!
+ before_action :set_resource_config
+ helper_method :resource_class
+ before_action :set_resource_scope
+ before_action :set_filter_form
+ helper_method :resource_class
+ before_action :set_resource, only: [:show, :edit, :update, :destroy]
+
+
+ def indexxx
+ @q = @resources.ransack(params[:q])
+ @resources = @q.result.page(params[:page])
+ end
+
+ def index
+ @filter_form = Backstage::Rails::FilterForm.new(filter_params)
+
+ #ransack_params = build_ransack_params(@filter_form)
+
+ # @q = resource_class.ransack(ransack_params)
+ # @q = resource_class.ransack(ransack_params[:conditions], combinator: ransack_params[:combinator])
+ # @resources = @q.result
+
+ @resources = apply_filters(resource_class, @filter_form.filter_items)
+
+ @resources = resource_class if @resources.blank?
+
+ # @resources = @filter_form.apply_scope(@resources) if @filter_form.scope.present?
+ @resources = @resources.page(params[:page]).per(10) # Adjust per-page as needed
+ end
+
+ def show
+ end
+
+ def new
+ @resource = model_class.new
+ end
+
+ def edit
+ end
+
+ def create
+ @resource = model_class.new(permitted_params)
+
+ if @resource.save
+ redirect_to [:admin, @resource], notice: "#{model_class.name} was successfully created."
+ else
+ render :new
+ end
+ end
+
+ def update
+ if @resource.update(permitted_params)
+ redirect_to [:admin, @resource], notice: "#{model_class.name} was successfully updated."
+ else
+ Rails.logger.error(@resource.errors.full_messages)
+ render :edit
+ end
+ end
+
+ def destroy
+ @resource.destroy
+ redirect_to [:admin, model_class], notice: "#{model_class.name} was successfully destroyed."
+ end
+
+ def add_filter
+ @resource = Backstage::Rails::Config.resources[controller_name.to_sym]
+ @index = @filter_form.filter_items.size + 1
+ end
+
+ private
+
+ def build_ransack_params(filter_form)
+ return {} if filter_form.filter_items.blank?
+
+ groupings = filter_form.filter_items.map.with_index do |item, index|
+ next if item.field.blank? || item.operator.blank?
+
+ condition = { "#{item.field}_#{item.operator}" => item.value }
+
+ if index == 0
+ { m: 'or', condition => condition }
+ else
+ { m: item.condition.downcase, condition => condition }
+ end
+ end.compact
+
+ { g: groupings }
+ end
+
+ def set_filter_form
+ @filter_form = Backstage::Rails::FilterForm.new(filter_params)
+ end
+
+ def filter_params
+ params.fetch(:filter_form, {}).permit(
+ :scope,
+ :filter_combine,
+ filter_items_attributes: [:field, :operator, :value, :condition]
+ )
+ end
+
+ def default_render
+ if lookup_context.template_exists?(action_name, "admin/#{controller_name}", true)
+ super
+ else
+ render template: "backstage/rails/default/#{action_name}"
+ end
+ end
+
+ def authenticate_admin!
+ redirect_to root_path, alert: 'Access denied.' unless current_user&.is_admin?
+ end
+
+ def set_resource_config
+ @resource_config = Backstage::Rails::Config.resources[controller_name.to_sym]
+ end
+
+ def set_resource_scope
+ return unless @resource_config
+
+ scope = params[:scope]&.to_sym
+ @resources = resource_class.all
+
+ if scope
+ scope_config = @resource_config.scopes.find { |s| s[:name] == scope }
+ if scope_config
+ @resources = if scope_config[:lambda]
+ resource_class.instance_exec(&scope_config[:lambda])
+ elsif scope == :all
+ resource_class.all
+ else
+ resource_class.send(scope)
+ end
+ end
+ end
+
+ @resources = @resources.page(params[:page]).per(10) # Adjust per-page as needed
+ end
+
+ def resource_class
+ @resource_class ||= controller_name.classify.constantize
+ end
+
+ def set_resource
+ if model_class.respond_to?(:friendly)
+ @resource = model_class.friendly.find(params[:id])
+ else
+ @resource = model_class.find(params[:id])
+ end
+ end
+
+ def model_class
+ raise NotImplementedError, "Subclasses must define model_class"
+ end
+
+ def permitted_params
+ raise NotImplementedError, "Subclasses must define permitted_params"
+ end
+
+
+ def apply_filters(relation, filter_items)
+ return relation if filter_items.blank?
+
+ table = relation.arel_table
+ conditions = filter_items.inject(nil) do |cond, item|
+ next cond if item.field.blank? || item.operator.blank? #|| item.value.blank?
+
+ new_condition = build_arel_condition(table, item)
+ if cond.nil?
+ new_condition
+ else
+ item.condition&.downcase == 'or' ? cond.or(new_condition) : cond.and(new_condition)
+ end
+ end
+
+ relation.where(conditions) if conditions
+ end
+
+ def build_arel_condition(table, item)
+ column = table[item.field]
+ case item.operator
+ when 'eq'
+ column.eq(item.value)
+ when 'not_eq'
+ column.not_eq(item.value)
+ when 'matches'
+ column.matches("%#{item.value}%")
+ when 'gt'
+ column.gt(item.value)
+ when 'lt'
+ column.lt(item.value)
+ when 'gteq'
+ column.gteq(item.value)
+ when 'lteq'
+ column.lteq(item.value)
+ else
+ raise "Unsupported operator: #{item.operator}"
+ end
+ end
+
+end
\ No newline at end of file
diff --git a/backstage-rails/app/controllers/backstage/rails/dashboard/index.html.erb b/backstage-rails/app/controllers/backstage/rails/dashboard/index.html.erb
new file mode 100644
index 0000000..6a12ebd
--- /dev/null
+++ b/backstage-rails/app/controllers/backstage/rails/dashboard/index.html.erb
@@ -0,0 +1,7 @@
+
+
Admin Dashboard
+
+
+ <%= markdown(@readme_content) %>
+
+
\ No newline at end of file
diff --git a/backstage-rails/app/controllers/backstage/rails/default/add_filter.turbo_stream.erb b/backstage-rails/app/controllers/backstage/rails/default/add_filter.turbo_stream.erb
new file mode 100644
index 0000000..711a9e0
--- /dev/null
+++ b/backstage-rails/app/controllers/backstage/rails/default/add_filter.turbo_stream.erb
@@ -0,0 +1,8 @@
+
+<%= form_with(model: @filter_form, url: "") do |f| %>
+ <%= f.fields_for :filter_items, Backstage::Rails::FilterFormItem.new, :child_index => @index do |ff| %>
+ <%= turbo_stream.append 'filterList' do %>
+ <%= render 'admin/shared/filter_item', f: ff, resource: @resource, index: ff.index %>
+ <% end %>
+ <% end %>
+<% end %>
\ No newline at end of file
diff --git a/backstage-rails/app/controllers/backstage/rails/default/edit.html.erb b/backstage-rails/app/controllers/backstage/rails/default/edit.html.erb
new file mode 100644
index 0000000..918d97c
--- /dev/null
+++ b/backstage-rails/app/controllers/backstage/rails/default/edit.html.erb
@@ -0,0 +1,10 @@
+
+
Edit <%= controller_name.singularize.titleize %>
+
+ <%= render 'admin/shared/form', resource: @resource %>
+
+
+ <%= link_to 'Show', [:admin, @resource], class: "text-indigo-600 hover:text-indigo-900 mr-2" %>
+ <%= link_to "Back to #{controller_name.titleize}", polymorphic_path([:admin, controller_name.classify.constantize]), class: "text-gray-600 hover:text-gray-900" %>
+
+
\ No newline at end of file
diff --git a/backstage-rails/app/controllers/backstage/rails/default/index.html.erb b/backstage-rails/app/controllers/backstage/rails/default/index.html.erb
new file mode 100644
index 0000000..a67602b
--- /dev/null
+++ b/backstage-rails/app/controllers/backstage/rails/default/index.html.erb
@@ -0,0 +1,26 @@
+<% resource = Backstage::Rails::Config.resources[controller_name.to_sym] %>
+
+
+
+
<%= resource.name.to_s.titleize %>
+
+ <%= render 'backstage/rails/shared/filter_form', resource: resource %>
+ <%= render 'backstage/rails/shared/scopes_menu', resource: resource %>
+
+
+
+
+
+ <%= render 'backstage/rails/shared/table', resource: resource, resources: @resources %>
+
+
+ <%= paginate @resources %>
+
+
+
+ <% #= render 'backstage/rails/shared/filters', resource: resource %>
+
+
+
+ <%= link_to "New #{resource.name.to_s.singularize.titleize}", new_polymorphic_path([:admin, resource.name.to_s.singularize.classify.constantize]), class: "mt-4 inline-block bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline" %>
+
\ No newline at end of file
diff --git a/backstage-rails/app/controllers/backstage/rails/default/new.html.erb b/backstage-rails/app/controllers/backstage/rails/default/new.html.erb
new file mode 100644
index 0000000..6ac9d4d
--- /dev/null
+++ b/backstage-rails/app/controllers/backstage/rails/default/new.html.erb
@@ -0,0 +1,9 @@
+
+
New <%= controller_name.singularize.titleize %>
+
+ <%= render 'admin/shared/form', resource: @resource %>
+
+
+ <%= link_to "Back to #{controller_name.titleize}", polymorphic_path([:admin, controller_name.classify.constantize]), class: "text-gray-600 hover:text-gray-900" %>
+
+
\ No newline at end of file
diff --git a/backstage-rails/app/controllers/backstage/rails/default/show.html.erb b/backstage-rails/app/controllers/backstage/rails/default/show.html.erb
new file mode 100644
index 0000000..786f7be
--- /dev/null
+++ b/backstage-rails/app/controllers/backstage/rails/default/show.html.erb
@@ -0,0 +1,27 @@
+<% resource = Backstage::Rails::Config.resources[controller_name.to_sym] %>
+
+
+
<%= controller_name.singularize.titleize %> Details
+
+
+ <% resource.columns.each do |column| %>
+
+
+ <%= column[:name].to_s.titleize %>
+
+
+ <% if column[:block] %>
+ <%= column[:block].call(@resource, self) %>
+ <% else %>
+ <%= @resource.send(column[:name]) %>
+ <% end %>
+
+
+ <% end %>
+
+
+
+ <%= link_to 'Edit', edit_polymorphic_path([:admin, @resource]), class: "text-indigo-600 hover:text-indigo-900 mr-2" %>
+ <%= link_to "Back to #{controller_name.titleize}", polymorphic_path([:admin, controller_name.classify.constantize]), class: "text-gray-600 hover:text-gray-900" %>
+
+
\ No newline at end of file
diff --git a/backstage-rails/app/controllers/backstage/rails/shared/_actions.erb b/backstage-rails/app/controllers/backstage/rails/shared/_actions.erb
new file mode 100644
index 0000000..65308e3
--- /dev/null
+++ b/backstage-rails/app/controllers/backstage/rails/shared/_actions.erb
@@ -0,0 +1,10 @@
+<% resource.actions.each do |action| %>
+ <% case action[:name] %>
+ <% when :view %>
+ <%= link_to 'View', polymorphic_path([:admin, item]), class: "text-blue-600 hover:text-blue-900 mr-2" %>
+ <% when :edit %>
+ <%= link_to 'Edit', edit_polymorphic_path([:admin, item]), class: "text-green-600 hover:text-green-900 mr-2" %>
+ <% when :delete %>
+ <%= link_to 'Delete', polymorphic_path([:admin, item]), data: {turbo_method: :delete, turbo_confirm: 'Are you sure?' }, class: "text-red-600 hover:text-red-900" %>
+ <% end %>
+<% end %>
\ No newline at end of file
diff --git a/backstage-rails/app/controllers/backstage/rails/shared/_filter_form.html.erb b/backstage-rails/app/controllers/backstage/rails/shared/_filter_form.html.erb
new file mode 100644
index 0000000..cfd585a
--- /dev/null
+++ b/backstage-rails/app/controllers/backstage/rails/shared/_filter_form.html.erb
@@ -0,0 +1,27 @@
+<%= @filter_form.as_json %>
+
+
+ <%= form_with(model: @filter_form, url: url_for(action: 'index'), method: :get, data: { filter_manager_target: 'filterForm', turbo_frame: 'results' }) do |f| %>
+
+
+ <%= f.fields_for :filter_items do |filter_form| %>
+ <%= render 'backstage/rails/shared/filter_item', f: filter_form, resource: resource, index: filter_form.index %>
+ <% end %>
+
+
+
+
+ + Add Filter
+
+
+ <% # f.select :filter_combine, [['AND', 'AND'], ['OR', 'OR']], {}, class: "mr-2" %>
+ <% # f.select :scope, options_for_select(resource.scopes.map { |s| [s[:name].to_s.titleize, s[:name]] }, @filter_form.scope), { include_blank: 'All' }, class: "mr-2" %>
+
+
+ <%= f.submit 'Apply', class: 'bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded' %>
+ Clear All
+
+ <% end %>
+
\ No newline at end of file
diff --git a/backstage-rails/app/controllers/backstage/rails/shared/_filter_item.html.erb b/backstage-rails/app/controllers/backstage/rails/shared/_filter_item.html.erb
new file mode 100644
index 0000000..7e4fdf1
--- /dev/null
+++ b/backstage-rails/app/controllers/backstage/rails/shared/_filter_item.html.erb
@@ -0,0 +1,27 @@
+
+ <% if index != 0 %>
+
+ <%= f.select :condition, [['AND', 'AND'], ['OR', 'OR']], {}, class: "mr-2" %>
+
+ <% end %>
+
+
+ <%= f.select :field, resource.filterable_fields.map { |field|
+ [field[:options][:label] || field[:name].to_s.titleize, field[:name].to_s ] },
+ {}, class: "mr-2"
+ %>
+
+ <%= f.select :operator, [
+ ['Is', 'eq'],
+ ['Is not', 'not_eq'],
+ ['Greater than', 'gt'],
+ ['Less than', 'lt'],
+ ['Greater than or equal to', 'gteq'],
+ ['Less than or equal to', 'lteq'],
+ ['Contains', 'matches']
+ ], {}, class: "mr-2" %>
+
+ <%= f.text_field :value, class: "mr-2", label: false %>
+ ×
+
+
\ No newline at end of file
diff --git a/backstage-rails/app/controllers/backstage/rails/shared/_filters.erb b/backstage-rails/app/controllers/backstage/rails/shared/_filters.erb
new file mode 100644
index 0000000..b520111
--- /dev/null
+++ b/backstage-rails/app/controllers/backstage/rails/shared/_filters.erb
@@ -0,0 +1,19 @@
+<%= search_form_for @q, url: url_for(action: 'index'), class: "mb-6" do |f| %>
+
+ <% resource.filters.each do |filter| %>
+
+ <%= f.label filter[:name], filter[:options][:label], class: "block text-gray-700 text-sm font-bold mb-2" %>
+ <% case filter[:type] %>
+ <% when :string %>
+ <%= f.search_field filter[:name], class: "shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" %>
+ <% when :select %>
+ <% collection = filter[:options][:collection].is_a?(Proc) ? filter[:options][:collection].call : filter[:options][:collection] %>
+ <%= f.select filter[:name], collection, { include_blank: 'All' }, class: "shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" %>
+ <% end %>
+
+ <% end %>
+
+ <%= f.submit "Search", class: "bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline" %>
+
+
+<% end %>
\ No newline at end of file
diff --git a/backstage-rails/app/controllers/backstage/rails/shared/_form.erb b/backstage-rails/app/controllers/backstage/rails/shared/_form.erb
new file mode 100644
index 0000000..c0d712a
--- /dev/null
+++ b/backstage-rails/app/controllers/backstage/rails/shared/_form.erb
@@ -0,0 +1,19 @@
+<%= form_with(model: [:admin, resource], builder: Admin::FormBuilder, local: true, class: "space-y-6") do |form| %>
+ <% if resource.errors.any? %>
+
+
Error!
+
<%= pluralize(resource.errors.count, "error") %> prohibited this <%= resource.class.name.downcase %> from being saved:
+
+ <% resource.errors.full_messages.each do |message| %>
+ <%= message %>
+ <% end %>
+
+
+ <% end %>
+
+ <%= form.generate_fields(@resource_config) %>
+
+
+ <%= form.submit class: "inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500" %>
+
+<% end %>
\ No newline at end of file
diff --git a/backstage-rails/app/controllers/backstage/rails/shared/_scopes_menu.html.erb b/backstage-rails/app/controllers/backstage/rails/shared/_scopes_menu.html.erb
new file mode 100644
index 0000000..f07e881
--- /dev/null
+++ b/backstage-rails/app/controllers/backstage/rails/shared/_scopes_menu.html.erb
@@ -0,0 +1,11 @@
+<% if resource.scopes.any? %>
+
+
+ <% resource.scopes.each do |scope| %>
+ <%= link_to scope[:options][:label] || scope[:name].to_s.titleize,
+ url_for(scope: scope[:name]),
+ class: "px-3 py-2 rounded-md text-sm font-medium #{params[:scope] == scope[:name].to_s ? 'bg-gray-900 text-white' : 'text-gray-300 hover:bg-gray-700 hover:text-white'}" %>
+ <% end %>
+
+
+<% end %>
\ No newline at end of file
diff --git a/backstage-rails/app/controllers/backstage/rails/shared/_table.erb b/backstage-rails/app/controllers/backstage/rails/shared/_table.erb
new file mode 100644
index 0000000..a8c92f3
--- /dev/null
+++ b/backstage-rails/app/controllers/backstage/rails/shared/_table.erb
@@ -0,0 +1,32 @@
+
+
+
+ <% resource.columns.each do |column| %>
+
+ <% # sort_link(@q, column[:name], column[:options][:label] || column[:name].to_s.titleize, { class: "text-gray-600 hover:text-gray-900" }) %>
+
+ <% end %>
+
+ Actions
+
+
+
+
+ <% resources.each do |item| %>
+
+ <% resource.columns.each do |column| %>
+
+ <% if column[:block] %>
+ <%= column[:block].call(item, self) %>
+ <% else %>
+ <%= item.send(column[:name]) %>
+ <% end %>
+
+ <% end %>
+
+ <%= render 'admin/shared/actions', resource: resource, item: item %>
+
+
+ <% end %>
+
+
\ No newline at end of file
diff --git a/backstage-rails/app/controllers/concerns/.keep b/backstage-rails/app/controllers/concerns/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/backstage-rails/app/forms/backstage/rails/filter_form.rb b/backstage-rails/app/forms/backstage/rails/filter_form.rb
new file mode 100644
index 0000000..66bca61
--- /dev/null
+++ b/backstage-rails/app/forms/backstage/rails/filter_form.rb
@@ -0,0 +1,82 @@
+# app/forms/admin_filter_form.rb
+class Backstage::Rails::FilterForm
+ include ActiveModel::Model
+ include ActiveModel::Attributes
+ # include ActiveModel::NestedAttributes
+
+ #attribute :scope, :string
+ #attribute :filter_combine, :string, default: 'AND'
+
+ #validates :scope, presence: true
+ #validates :filter_combine, inclusion: { in: %w[AND OR] }
+
+ attr_accessor :filter_items
+
+ def initialize(attributes = {})
+ super
+ self.filter_items = [] if filter_items.nil?
+ self.filter_items << Backstage::Rails::FilterFormItem.new if filter_items.empty?
+ end
+
+ def filter_items_attributes=(attributes)
+ self.filter_items = attributes.values.map { |attrs| Backstage::Rails::FilterFormItem.new(attrs) }
+ end
+
+ def add_filter_item
+ filter_items << Backstage::Rails::FilterFormItem.new
+ end
+
+ def apply(relation)
+ scope_relation = apply_scope(relation)
+ apply_filters(scope_relation)
+ end
+
+ def apply_scope(relation)
+ return relation if scope.blank?
+
+ if relation.respond_to?(scope)
+ relation.public_send(scope)
+ else
+ relation
+ end
+ end
+
+ private
+
+ def apply_scope(relation)
+ return relation if scope.blank?
+
+ if relation.respond_to?(scope)
+ relation.public_send(scope)
+ else
+ relation
+ end
+ end
+
+ def apply_filters(relation)
+ return relation if filter_items.empty?
+
+ filter_items.inject(relation) do |result, filter|
+ next result if filter.field.blank? || filter.operator.blank? || filter.value.blank?
+
+ condition = filter.condition&.downcase&.to_sym || :and
+ query = { filter.field => { filter.operator => filter.value } }
+
+ result.ransack({ condition => query }).result
+ end
+ end
+end
+
+
+# app/models/admin_filter_form_item.rb
+class Backstage::Rails::FilterFormItem
+ include ActiveModel::Model
+ include ActiveModel::Attributes
+
+ attribute :field, :string
+ attribute :operator, :string
+ attribute :value, :string
+ attribute :condition, :string, default: 'AND'
+
+ validates :field, :operator, presence: true
+end
\ No newline at end of file
diff --git a/backstage-rails/app/helpers/backstage/rails/application_helper.rb b/backstage-rails/app/helpers/backstage/rails/application_helper.rb
new file mode 100644
index 0000000..7837025
--- /dev/null
+++ b/backstage-rails/app/helpers/backstage/rails/application_helper.rb
@@ -0,0 +1,6 @@
+module Backstage
+ module Rails
+ module ApplicationHelper
+ end
+ end
+end
diff --git a/backstage-rails/app/jobs/backstage/rails/application_job.rb b/backstage-rails/app/jobs/backstage/rails/application_job.rb
new file mode 100644
index 0000000..554dedf
--- /dev/null
+++ b/backstage-rails/app/jobs/backstage/rails/application_job.rb
@@ -0,0 +1,6 @@
+module Backstage
+ module Rails
+ class ApplicationJob < ActiveJob::Base
+ end
+ end
+end
diff --git a/backstage-rails/app/mailers/backstage/rails/application_mailer.rb b/backstage-rails/app/mailers/backstage/rails/application_mailer.rb
new file mode 100644
index 0000000..0aafcbf
--- /dev/null
+++ b/backstage-rails/app/mailers/backstage/rails/application_mailer.rb
@@ -0,0 +1,8 @@
+module Backstage
+ module Rails
+ class ApplicationMailer < ActionMailer::Base
+ default from: "from@example.com"
+ layout "mailer"
+ end
+ end
+end
diff --git a/backstage-rails/app/models/backstage/rails/application_record.rb b/backstage-rails/app/models/backstage/rails/application_record.rb
new file mode 100644
index 0000000..fdb3117
--- /dev/null
+++ b/backstage-rails/app/models/backstage/rails/application_record.rb
@@ -0,0 +1,7 @@
+module Backstage
+ module Rails
+ class ApplicationRecord < ActiveRecord::Base
+ self.abstract_class = true
+ end
+ end
+end
diff --git a/backstage-rails/app/models/concerns/.keep b/backstage-rails/app/models/concerns/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/backstage-rails/app/views/backstage/rails/dashboard/index.html.erb b/backstage-rails/app/views/backstage/rails/dashboard/index.html.erb
new file mode 100644
index 0000000..6a12ebd
--- /dev/null
+++ b/backstage-rails/app/views/backstage/rails/dashboard/index.html.erb
@@ -0,0 +1,7 @@
+
+
Admin Dashboard
+
+
+ <%= markdown(@readme_content) %>
+
+
\ No newline at end of file
diff --git a/backstage-rails/app/views/backstage/rails/default/add_filter.turbo_stream.erb b/backstage-rails/app/views/backstage/rails/default/add_filter.turbo_stream.erb
new file mode 100644
index 0000000..f003733
--- /dev/null
+++ b/backstage-rails/app/views/backstage/rails/default/add_filter.turbo_stream.erb
@@ -0,0 +1,8 @@
+
+<%= form_with(model: @filter_form, url: "") do |f| %>
+ <%= f.fields_for :filter_items, Backstage::Rails::FilterFormItem.new, :child_index => @index do |ff| %>
+ <%= turbo_stream.append 'filterList' do %>
+ <%= render 'backstage/rails/shared/filter_item', f: ff, resource: @resource, index: ff.index %>
+ <% end %>
+ <% end %>
+<% end %>
\ No newline at end of file
diff --git a/backstage-rails/app/views/backstage/rails/default/edit.html.erb b/backstage-rails/app/views/backstage/rails/default/edit.html.erb
new file mode 100644
index 0000000..918d97c
--- /dev/null
+++ b/backstage-rails/app/views/backstage/rails/default/edit.html.erb
@@ -0,0 +1,10 @@
+
+
Edit <%= controller_name.singularize.titleize %>
+
+ <%= render 'admin/shared/form', resource: @resource %>
+
+
+ <%= link_to 'Show', [:admin, @resource], class: "text-indigo-600 hover:text-indigo-900 mr-2" %>
+ <%= link_to "Back to #{controller_name.titleize}", polymorphic_path([:admin, controller_name.classify.constantize]), class: "text-gray-600 hover:text-gray-900" %>
+
+
\ No newline at end of file
diff --git a/backstage-rails/app/views/backstage/rails/default/index.html.erb b/backstage-rails/app/views/backstage/rails/default/index.html.erb
new file mode 100644
index 0000000..a67602b
--- /dev/null
+++ b/backstage-rails/app/views/backstage/rails/default/index.html.erb
@@ -0,0 +1,26 @@
+<% resource = Backstage::Rails::Config.resources[controller_name.to_sym] %>
+
+
+
+
<%= resource.name.to_s.titleize %>
+
+ <%= render 'backstage/rails/shared/filter_form', resource: resource %>
+ <%= render 'backstage/rails/shared/scopes_menu', resource: resource %>
+
+
+
+
+
+ <%= render 'backstage/rails/shared/table', resource: resource, resources: @resources %>
+
+
+ <%= paginate @resources %>
+
+
+
+ <% #= render 'backstage/rails/shared/filters', resource: resource %>
+
+
+
+ <%= link_to "New #{resource.name.to_s.singularize.titleize}", new_polymorphic_path([:admin, resource.name.to_s.singularize.classify.constantize]), class: "mt-4 inline-block bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline" %>
+
\ No newline at end of file
diff --git a/backstage-rails/app/views/backstage/rails/default/new.html.erb b/backstage-rails/app/views/backstage/rails/default/new.html.erb
new file mode 100644
index 0000000..6ac9d4d
--- /dev/null
+++ b/backstage-rails/app/views/backstage/rails/default/new.html.erb
@@ -0,0 +1,9 @@
+
+
New <%= controller_name.singularize.titleize %>
+
+ <%= render 'admin/shared/form', resource: @resource %>
+
+
+ <%= link_to "Back to #{controller_name.titleize}", polymorphic_path([:admin, controller_name.classify.constantize]), class: "text-gray-600 hover:text-gray-900" %>
+
+
\ No newline at end of file
diff --git a/backstage-rails/app/views/backstage/rails/default/show.html.erb b/backstage-rails/app/views/backstage/rails/default/show.html.erb
new file mode 100644
index 0000000..786f7be
--- /dev/null
+++ b/backstage-rails/app/views/backstage/rails/default/show.html.erb
@@ -0,0 +1,27 @@
+<% resource = Backstage::Rails::Config.resources[controller_name.to_sym] %>
+
+
+
<%= controller_name.singularize.titleize %> Details
+
+
+ <% resource.columns.each do |column| %>
+
+
+ <%= column[:name].to_s.titleize %>
+
+
+ <% if column[:block] %>
+ <%= column[:block].call(@resource, self) %>
+ <% else %>
+ <%= @resource.send(column[:name]) %>
+ <% end %>
+
+
+ <% end %>
+
+
+
+ <%= link_to 'Edit', edit_polymorphic_path([:admin, @resource]), class: "text-indigo-600 hover:text-indigo-900 mr-2" %>
+ <%= link_to "Back to #{controller_name.titleize}", polymorphic_path([:admin, controller_name.classify.constantize]), class: "text-gray-600 hover:text-gray-900" %>
+
+
\ No newline at end of file
diff --git a/backstage-rails/app/views/backstage/rails/shared/_actions.erb b/backstage-rails/app/views/backstage/rails/shared/_actions.erb
new file mode 100644
index 0000000..65308e3
--- /dev/null
+++ b/backstage-rails/app/views/backstage/rails/shared/_actions.erb
@@ -0,0 +1,10 @@
+<% resource.actions.each do |action| %>
+ <% case action[:name] %>
+ <% when :view %>
+ <%= link_to 'View', polymorphic_path([:admin, item]), class: "text-blue-600 hover:text-blue-900 mr-2" %>
+ <% when :edit %>
+ <%= link_to 'Edit', edit_polymorphic_path([:admin, item]), class: "text-green-600 hover:text-green-900 mr-2" %>
+ <% when :delete %>
+ <%= link_to 'Delete', polymorphic_path([:admin, item]), data: {turbo_method: :delete, turbo_confirm: 'Are you sure?' }, class: "text-red-600 hover:text-red-900" %>
+ <% end %>
+<% end %>
\ No newline at end of file
diff --git a/backstage-rails/app/views/backstage/rails/shared/_filter_form.html.erb b/backstage-rails/app/views/backstage/rails/shared/_filter_form.html.erb
new file mode 100644
index 0000000..cfd585a
--- /dev/null
+++ b/backstage-rails/app/views/backstage/rails/shared/_filter_form.html.erb
@@ -0,0 +1,27 @@
+<%= @filter_form.as_json %>
+
+
+ <%= form_with(model: @filter_form, url: url_for(action: 'index'), method: :get, data: { filter_manager_target: 'filterForm', turbo_frame: 'results' }) do |f| %>
+
+
+ <%= f.fields_for :filter_items do |filter_form| %>
+ <%= render 'backstage/rails/shared/filter_item', f: filter_form, resource: resource, index: filter_form.index %>
+ <% end %>
+
+
+
+
+ + Add Filter
+
+
+ <% # f.select :filter_combine, [['AND', 'AND'], ['OR', 'OR']], {}, class: "mr-2" %>
+ <% # f.select :scope, options_for_select(resource.scopes.map { |s| [s[:name].to_s.titleize, s[:name]] }, @filter_form.scope), { include_blank: 'All' }, class: "mr-2" %>
+
+
+ <%= f.submit 'Apply', class: 'bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded' %>
+ Clear All
+
+ <% end %>
+
\ No newline at end of file
diff --git a/backstage-rails/app/views/backstage/rails/shared/_filter_item.html.erb b/backstage-rails/app/views/backstage/rails/shared/_filter_item.html.erb
new file mode 100644
index 0000000..7e4fdf1
--- /dev/null
+++ b/backstage-rails/app/views/backstage/rails/shared/_filter_item.html.erb
@@ -0,0 +1,27 @@
+
+ <% if index != 0 %>
+
+ <%= f.select :condition, [['AND', 'AND'], ['OR', 'OR']], {}, class: "mr-2" %>
+
+ <% end %>
+
+
+ <%= f.select :field, resource.filterable_fields.map { |field|
+ [field[:options][:label] || field[:name].to_s.titleize, field[:name].to_s ] },
+ {}, class: "mr-2"
+ %>
+
+ <%= f.select :operator, [
+ ['Is', 'eq'],
+ ['Is not', 'not_eq'],
+ ['Greater than', 'gt'],
+ ['Less than', 'lt'],
+ ['Greater than or equal to', 'gteq'],
+ ['Less than or equal to', 'lteq'],
+ ['Contains', 'matches']
+ ], {}, class: "mr-2" %>
+
+ <%= f.text_field :value, class: "mr-2", label: false %>
+ ×
+
+
\ No newline at end of file
diff --git a/backstage-rails/app/views/backstage/rails/shared/_filters.erb b/backstage-rails/app/views/backstage/rails/shared/_filters.erb
new file mode 100644
index 0000000..b520111
--- /dev/null
+++ b/backstage-rails/app/views/backstage/rails/shared/_filters.erb
@@ -0,0 +1,19 @@
+<%= search_form_for @q, url: url_for(action: 'index'), class: "mb-6" do |f| %>
+
+ <% resource.filters.each do |filter| %>
+
+ <%= f.label filter[:name], filter[:options][:label], class: "block text-gray-700 text-sm font-bold mb-2" %>
+ <% case filter[:type] %>
+ <% when :string %>
+ <%= f.search_field filter[:name], class: "shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" %>
+ <% when :select %>
+ <% collection = filter[:options][:collection].is_a?(Proc) ? filter[:options][:collection].call : filter[:options][:collection] %>
+ <%= f.select filter[:name], collection, { include_blank: 'All' }, class: "shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" %>
+ <% end %>
+
+ <% end %>
+
+ <%= f.submit "Search", class: "bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline" %>
+
+
+<% end %>
\ No newline at end of file
diff --git a/backstage-rails/app/views/backstage/rails/shared/_form.erb b/backstage-rails/app/views/backstage/rails/shared/_form.erb
new file mode 100644
index 0000000..c0d712a
--- /dev/null
+++ b/backstage-rails/app/views/backstage/rails/shared/_form.erb
@@ -0,0 +1,19 @@
+<%= form_with(model: [:admin, resource], builder: Admin::FormBuilder, local: true, class: "space-y-6") do |form| %>
+ <% if resource.errors.any? %>
+
+
Error!
+
<%= pluralize(resource.errors.count, "error") %> prohibited this <%= resource.class.name.downcase %> from being saved:
+
+ <% resource.errors.full_messages.each do |message| %>
+ <%= message %>
+ <% end %>
+
+
+ <% end %>
+
+ <%= form.generate_fields(@resource_config) %>
+
+
+ <%= form.submit class: "inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500" %>
+
+<% end %>
\ No newline at end of file
diff --git a/backstage-rails/app/views/backstage/rails/shared/_scopes_menu.html.erb b/backstage-rails/app/views/backstage/rails/shared/_scopes_menu.html.erb
new file mode 100644
index 0000000..f07e881
--- /dev/null
+++ b/backstage-rails/app/views/backstage/rails/shared/_scopes_menu.html.erb
@@ -0,0 +1,11 @@
+<% if resource.scopes.any? %>
+
+
+ <% resource.scopes.each do |scope| %>
+ <%= link_to scope[:options][:label] || scope[:name].to_s.titleize,
+ url_for(scope: scope[:name]),
+ class: "px-3 py-2 rounded-md text-sm font-medium #{params[:scope] == scope[:name].to_s ? 'bg-gray-900 text-white' : 'text-gray-300 hover:bg-gray-700 hover:text-white'}" %>
+ <% end %>
+
+
+<% end %>
\ No newline at end of file
diff --git a/backstage-rails/app/views/backstage/rails/shared/_table.erb b/backstage-rails/app/views/backstage/rails/shared/_table.erb
new file mode 100644
index 0000000..66e755d
--- /dev/null
+++ b/backstage-rails/app/views/backstage/rails/shared/_table.erb
@@ -0,0 +1,32 @@
+
+
+
+ <% resource.columns.each do |column| %>
+
+ <% # sort_link(@q, column[:name], column[:options][:label] || column[:name].to_s.titleize, { class: "text-gray-600 hover:text-gray-900" }) %>
+
+ <% end %>
+
+ Actions
+
+
+
+
+ <% resources.each do |item| %>
+
+ <% resource.columns.each do |column| %>
+
+ <% if column[:block] %>
+ <%= column[:block].call(item, self) %>
+ <% else %>
+ <%= item.send(column[:name]) %>
+ <% end %>
+
+ <% end %>
+
+ <%= render 'backstage/rails/shared/actions', resource: resource, item: item %>
+
+
+ <% end %>
+
+
\ No newline at end of file
diff --git a/backstage-rails/app/views/layouts/backstage/rails/application.html.erb b/backstage-rails/app/views/layouts/backstage/rails/application.html.erb
new file mode 100644
index 0000000..75b8c25
--- /dev/null
+++ b/backstage-rails/app/views/layouts/backstage/rails/application.html.erb
@@ -0,0 +1,15 @@
+
+
+
+
Backstage rails
+ <%= csrf_meta_tags %>
+ <%= csp_meta_tag %>
+
+ <%= stylesheet_link_tag "backstage/rails/application", media: "all" %>
+
+
+
+<%= yield %>
+
+
+
diff --git a/backstage-rails/backstage-rails.gemspec b/backstage-rails/backstage-rails.gemspec
new file mode 100644
index 0000000..ce55ab5
--- /dev/null
+++ b/backstage-rails/backstage-rails.gemspec
@@ -0,0 +1,19 @@
+require_relative "lib/backstage/rails/version"
+
+
+Gem::Specification.new do |spec|
+ spec.name = "backstage-rails"
+ spec.version = Backstage::Rails::VERSION
+ spec.authors = ["Miguel Michelson Martinez"]
+ spec.email = ["miguelmichelson@gmail.com"]
+ spec.homepage = "https://github.com/yourusername/backstage-rails"
+ spec.summary = "A flexible and powerful admin panel for Rails applications"
+ spec.description = "Backstage Rails provides a customizable admin interface for Rails applications, with advanced filtering and management capabilities."
+ spec.license = "MIT"
+
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
+ Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]
+ end
+
+ spec.add_dependency "rails", ">= 7.1.3.2"
+end
diff --git a/backstage-rails/bin/rails b/backstage-rails/bin/rails
new file mode 100755
index 0000000..01ce760
--- /dev/null
+++ b/backstage-rails/bin/rails
@@ -0,0 +1,14 @@
+#!/usr/bin/env ruby
+# This command will automatically be run when you run "rails" with Rails gems
+# installed from the root of your application.
+
+ENGINE_ROOT = File.expand_path("..", __dir__)
+ENGINE_PATH = File.expand_path("../lib/backstage/rails/engine", __dir__)
+APP_PATH = File.expand_path("../test/dummy/config/application", __dir__)
+
+# Set up gems listed in the Gemfile.
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
+require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
+
+require "rails/all"
+require "rails/engine/commands"
diff --git a/backstage-rails/config/routes.rb b/backstage-rails/config/routes.rb
new file mode 100644
index 0000000..0360f13
--- /dev/null
+++ b/backstage-rails/config/routes.rb
@@ -0,0 +1,2 @@
+Backstage::Rails::Engine.routes.draw do
+end
diff --git a/backstage-rails/lib/backstage/rails.rb b/backstage-rails/lib/backstage/rails.rb
new file mode 100644
index 0000000..7975312
--- /dev/null
+++ b/backstage-rails/lib/backstage/rails.rb
@@ -0,0 +1,8 @@
+require "backstage/rails/version"
+require "backstage/rails/engine"
+
+module Backstage
+ module Rails
+ # Your code goes here...
+ end
+end
diff --git a/lib/admin/config.rb b/backstage-rails/lib/backstage/rails/config.rb
similarity index 65%
rename from lib/admin/config.rb
rename to backstage-rails/lib/backstage/rails/config.rb
index e29b693..c076b30 100644
--- a/lib/admin/config.rb
+++ b/backstage-rails/lib/backstage/rails/config.rb
@@ -1,4 +1,4 @@
-module Admin
+module Backstage::Rails
class Config
class << self
def configure(&block)
@@ -17,7 +17,8 @@ def resources
end
class Resource
- attr_reader :name, :options, :columns, :filters, :actions, :form_fields
+ attr_reader :name, :options, :columns, :filters,
+ :actions, :form_fields, :scopes, :filterable_fields
def initialize(name, options = {})
@name = name
@@ -26,6 +27,20 @@ def initialize(name, options = {})
@filters = []
@actions = []
@form_fields = []
+ @scopes = []
+ @filterable_fields = []
+ end
+
+ def filterable_field(name, type, options = {})
+ @filterable_fields << { name: name, type: type, options: options }
+ end
+
+ def scope(name, lambda = nil, options = {})
+ if lambda.is_a?(Hash)
+ options = lambda
+ lambda = nil
+ end
+ @scopes << { name: name, lambda: lambda, options: options }
end
def form_field(name, type, options = {})
diff --git a/backstage-rails/lib/backstage/rails/engine.rb b/backstage-rails/lib/backstage/rails/engine.rb
new file mode 100644
index 0000000..0824af7
--- /dev/null
+++ b/backstage-rails/lib/backstage/rails/engine.rb
@@ -0,0 +1,12 @@
+module Backstage
+ module Rails
+ class Engine < ::Rails::Engine
+ isolate_namespace Backstage::Rails
+
+ initializer "backstage.assets.precompile" do |app|
+ app.config.assets.precompile += %w( backstage/application.css backstage/application.js )
+ end
+
+ end
+ end
+end
diff --git a/lib/admin/form_builder.rb b/backstage-rails/lib/backstage/rails/form_builder.rb
similarity index 85%
rename from lib/admin/form_builder.rb
rename to backstage-rails/lib/backstage/rails/form_builder.rb
index f95aea0..b8c614b 100644
--- a/lib/admin/form_builder.rb
+++ b/backstage-rails/lib/backstage/rails/form_builder.rb
@@ -1,8 +1,12 @@
-module Admin
+module Backstage::Rails
class FormBuilder < ActionView::Helpers::FormBuilder
def generate_fields(resource)
fields = resource.form_fields.map do |field|
- send("#{field[:type]}_field", field[:name], field[:options])
+ if field[:type] == :custom
+ field[:options].call(@template, self)
+ else
+ send("#{field[:type]}_field", field[:name], field[:options])
+ end
end
fields.join.html_safe
end
diff --git a/backstage-rails/lib/backstage/rails/version.rb b/backstage-rails/lib/backstage/rails/version.rb
new file mode 100644
index 0000000..4dae9d7
--- /dev/null
+++ b/backstage-rails/lib/backstage/rails/version.rb
@@ -0,0 +1,5 @@
+module Backstage
+ module Rails
+ VERSION = "0.1.0"
+ end
+end
diff --git a/backstage-rails/lib/tasks/backstage/rails_tasks.rake b/backstage-rails/lib/tasks/backstage/rails_tasks.rake
new file mode 100644
index 0000000..cc7ec87
--- /dev/null
+++ b/backstage-rails/lib/tasks/backstage/rails_tasks.rake
@@ -0,0 +1,4 @@
+# desc "Explaining what the task does"
+# task :backstage_rails do
+# # Task goes here
+# end
diff --git a/backstage-rails/test/backstage/rails_test.rb b/backstage-rails/test/backstage/rails_test.rb
new file mode 100644
index 0000000..c6c3e7a
--- /dev/null
+++ b/backstage-rails/test/backstage/rails_test.rb
@@ -0,0 +1,7 @@
+require "test_helper"
+
+class Backstage::RailsTest < ActiveSupport::TestCase
+ test "it has a version number" do
+ assert Backstage::Rails::VERSION
+ end
+end
diff --git a/backstage-rails/test/controllers/.keep b/backstage-rails/test/controllers/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/backstage-rails/test/dummy/Rakefile b/backstage-rails/test/dummy/Rakefile
new file mode 100644
index 0000000..9a5ea73
--- /dev/null
+++ b/backstage-rails/test/dummy/Rakefile
@@ -0,0 +1,6 @@
+# Add your own tasks in files placed in lib/tasks ending in .rake,
+# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
+
+require_relative "config/application"
+
+Rails.application.load_tasks
diff --git a/backstage-rails/test/dummy/app/assets/config/manifest.js b/backstage-rails/test/dummy/app/assets/config/manifest.js
new file mode 100644
index 0000000..be2ad6f
--- /dev/null
+++ b/backstage-rails/test/dummy/app/assets/config/manifest.js
@@ -0,0 +1,3 @@
+//= link_tree ../images
+//= link_directory ../stylesheets .css
+//= link backstage_rails_manifest.js
diff --git a/backstage-rails/test/dummy/app/assets/images/.keep b/backstage-rails/test/dummy/app/assets/images/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/backstage-rails/test/dummy/app/assets/stylesheets/application.css b/backstage-rails/test/dummy/app/assets/stylesheets/application.css
new file mode 100644
index 0000000..0ebd7fe
--- /dev/null
+++ b/backstage-rails/test/dummy/app/assets/stylesheets/application.css
@@ -0,0 +1,15 @@
+/*
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
+ * listed below.
+ *
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
+ *
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
+ * files in this directory. Styles in this file should be added after the last require_* statement.
+ * It is generally better to create a new file per style scope.
+ *
+ *= require_tree .
+ *= require_self
+ */
diff --git a/backstage-rails/test/dummy/app/channels/application_cable/channel.rb b/backstage-rails/test/dummy/app/channels/application_cable/channel.rb
new file mode 100644
index 0000000..d672697
--- /dev/null
+++ b/backstage-rails/test/dummy/app/channels/application_cable/channel.rb
@@ -0,0 +1,4 @@
+module ApplicationCable
+ class Channel < ActionCable::Channel::Base
+ end
+end
diff --git a/backstage-rails/test/dummy/app/channels/application_cable/connection.rb b/backstage-rails/test/dummy/app/channels/application_cable/connection.rb
new file mode 100644
index 0000000..0ff5442
--- /dev/null
+++ b/backstage-rails/test/dummy/app/channels/application_cable/connection.rb
@@ -0,0 +1,4 @@
+module ApplicationCable
+ class Connection < ActionCable::Connection::Base
+ end
+end
diff --git a/backstage-rails/test/dummy/app/controllers/application_controller.rb b/backstage-rails/test/dummy/app/controllers/application_controller.rb
new file mode 100644
index 0000000..09705d1
--- /dev/null
+++ b/backstage-rails/test/dummy/app/controllers/application_controller.rb
@@ -0,0 +1,2 @@
+class ApplicationController < ActionController::Base
+end
diff --git a/backstage-rails/test/dummy/app/controllers/concerns/.keep b/backstage-rails/test/dummy/app/controllers/concerns/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/backstage-rails/test/dummy/app/helpers/application_helper.rb b/backstage-rails/test/dummy/app/helpers/application_helper.rb
new file mode 100644
index 0000000..de6be79
--- /dev/null
+++ b/backstage-rails/test/dummy/app/helpers/application_helper.rb
@@ -0,0 +1,2 @@
+module ApplicationHelper
+end
diff --git a/backstage-rails/test/dummy/app/jobs/application_job.rb b/backstage-rails/test/dummy/app/jobs/application_job.rb
new file mode 100644
index 0000000..d394c3d
--- /dev/null
+++ b/backstage-rails/test/dummy/app/jobs/application_job.rb
@@ -0,0 +1,7 @@
+class ApplicationJob < ActiveJob::Base
+ # Automatically retry jobs that encountered a deadlock
+ # retry_on ActiveRecord::Deadlocked
+
+ # Most jobs are safe to ignore if the underlying records are no longer available
+ # discard_on ActiveJob::DeserializationError
+end
diff --git a/backstage-rails/test/dummy/app/mailers/application_mailer.rb b/backstage-rails/test/dummy/app/mailers/application_mailer.rb
new file mode 100644
index 0000000..3c34c81
--- /dev/null
+++ b/backstage-rails/test/dummy/app/mailers/application_mailer.rb
@@ -0,0 +1,4 @@
+class ApplicationMailer < ActionMailer::Base
+ default from: "from@example.com"
+ layout "mailer"
+end
diff --git a/backstage-rails/test/dummy/app/models/application_record.rb b/backstage-rails/test/dummy/app/models/application_record.rb
new file mode 100644
index 0000000..b63caeb
--- /dev/null
+++ b/backstage-rails/test/dummy/app/models/application_record.rb
@@ -0,0 +1,3 @@
+class ApplicationRecord < ActiveRecord::Base
+ primary_abstract_class
+end
diff --git a/backstage-rails/test/dummy/app/models/concerns/.keep b/backstage-rails/test/dummy/app/models/concerns/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/backstage-rails/test/dummy/app/views/layouts/application.html.erb b/backstage-rails/test/dummy/app/views/layouts/application.html.erb
new file mode 100644
index 0000000..f72b4ef
--- /dev/null
+++ b/backstage-rails/test/dummy/app/views/layouts/application.html.erb
@@ -0,0 +1,15 @@
+
+
+
+
Dummy
+
+ <%= csrf_meta_tags %>
+ <%= csp_meta_tag %>
+
+ <%= stylesheet_link_tag "application" %>
+
+
+
+ <%= yield %>
+
+
diff --git a/backstage-rails/test/dummy/app/views/layouts/mailer.html.erb b/backstage-rails/test/dummy/app/views/layouts/mailer.html.erb
new file mode 100644
index 0000000..3aac900
--- /dev/null
+++ b/backstage-rails/test/dummy/app/views/layouts/mailer.html.erb
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+ <%= yield %>
+
+
diff --git a/backstage-rails/test/dummy/app/views/layouts/mailer.text.erb b/backstage-rails/test/dummy/app/views/layouts/mailer.text.erb
new file mode 100644
index 0000000..37f0bdd
--- /dev/null
+++ b/backstage-rails/test/dummy/app/views/layouts/mailer.text.erb
@@ -0,0 +1 @@
+<%= yield %>
diff --git a/backstage-rails/test/dummy/bin/rails b/backstage-rails/test/dummy/bin/rails
new file mode 100755
index 0000000..efc0377
--- /dev/null
+++ b/backstage-rails/test/dummy/bin/rails
@@ -0,0 +1,4 @@
+#!/usr/bin/env ruby
+APP_PATH = File.expand_path("../config/application", __dir__)
+require_relative "../config/boot"
+require "rails/commands"
diff --git a/backstage-rails/test/dummy/bin/rake b/backstage-rails/test/dummy/bin/rake
new file mode 100755
index 0000000..4fbf10b
--- /dev/null
+++ b/backstage-rails/test/dummy/bin/rake
@@ -0,0 +1,4 @@
+#!/usr/bin/env ruby
+require_relative "../config/boot"
+require "rake"
+Rake.application.run
diff --git a/backstage-rails/test/dummy/bin/setup b/backstage-rails/test/dummy/bin/setup
new file mode 100755
index 0000000..3cd5a9d
--- /dev/null
+++ b/backstage-rails/test/dummy/bin/setup
@@ -0,0 +1,33 @@
+#!/usr/bin/env ruby
+require "fileutils"
+
+# path to your application root.
+APP_ROOT = File.expand_path("..", __dir__)
+
+def system!(*args)
+ system(*args, exception: true)
+end
+
+FileUtils.chdir APP_ROOT do
+ # This script is a way to set up or update your development environment automatically.
+ # This script is idempotent, so that you can run it at any time and get an expectable outcome.
+ # Add necessary setup steps to this file.
+
+ puts "== Installing dependencies =="
+ system! "gem install bundler --conservative"
+ system("bundle check") || system!("bundle install")
+
+ # puts "\n== Copying sample files =="
+ # unless File.exist?("config/database.yml")
+ # FileUtils.cp "config/database.yml.sample", "config/database.yml"
+ # end
+
+ puts "\n== Preparing database =="
+ system! "bin/rails db:prepare"
+
+ puts "\n== Removing old logs and tempfiles =="
+ system! "bin/rails log:clear tmp:clear"
+
+ puts "\n== Restarting application server =="
+ system! "bin/rails restart"
+end
diff --git a/backstage-rails/test/dummy/config.ru b/backstage-rails/test/dummy/config.ru
new file mode 100644
index 0000000..4a3c09a
--- /dev/null
+++ b/backstage-rails/test/dummy/config.ru
@@ -0,0 +1,6 @@
+# This file is used by Rack-based servers to start the application.
+
+require_relative "config/environment"
+
+run Rails.application
+Rails.application.load_server
diff --git a/backstage-rails/test/dummy/config/application.rb b/backstage-rails/test/dummy/config/application.rb
new file mode 100644
index 0000000..67cc140
--- /dev/null
+++ b/backstage-rails/test/dummy/config/application.rb
@@ -0,0 +1,29 @@
+require_relative "boot"
+
+require "rails/all"
+
+# Require the gems listed in Gemfile, including any gems
+# you've limited to :test, :development, or :production.
+Bundler.require(*Rails.groups)
+
+module Dummy
+ class Application < Rails::Application
+ config.load_defaults Rails::VERSION::STRING.to_f
+
+ # For compatibility with applications that use this config
+ config.action_controller.include_all_helpers = false
+
+ # Please, add to the `ignore` list any other `lib` subdirectories that do
+ # not contain `.rb` files, or that should not be reloaded or eager loaded.
+ # Common ones are `templates`, `generators`, or `middleware`, for example.
+ config.autoload_lib(ignore: %w(assets tasks))
+
+ # Configuration for the application, engines, and railties goes here.
+ #
+ # These settings can be overridden in specific environments using the files
+ # in config/environments, which are processed later.
+ #
+ # config.time_zone = "Central Time (US & Canada)"
+ # config.eager_load_paths << Rails.root.join("extras")
+ end
+end
diff --git a/backstage-rails/test/dummy/config/boot.rb b/backstage-rails/test/dummy/config/boot.rb
new file mode 100644
index 0000000..116591a
--- /dev/null
+++ b/backstage-rails/test/dummy/config/boot.rb
@@ -0,0 +1,5 @@
+# Set up gems listed in the Gemfile.
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__)
+
+require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
+$LOAD_PATH.unshift File.expand_path("../../../lib", __dir__)
diff --git a/backstage-rails/test/dummy/config/cable.yml b/backstage-rails/test/dummy/config/cable.yml
new file mode 100644
index 0000000..98367f8
--- /dev/null
+++ b/backstage-rails/test/dummy/config/cable.yml
@@ -0,0 +1,10 @@
+development:
+ adapter: async
+
+test:
+ adapter: test
+
+production:
+ adapter: redis
+ url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
+ channel_prefix: dummy_production
diff --git a/backstage-rails/test/dummy/config/database.yml b/backstage-rails/test/dummy/config/database.yml
new file mode 100644
index 0000000..796466b
--- /dev/null
+++ b/backstage-rails/test/dummy/config/database.yml
@@ -0,0 +1,25 @@
+# SQLite. Versions 3.8.0 and up are supported.
+# gem install sqlite3
+#
+# Ensure the SQLite 3 gem is defined in your Gemfile
+# gem "sqlite3"
+#
+default: &default
+ adapter: sqlite3
+ pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
+ timeout: 5000
+
+development:
+ <<: *default
+ database: storage/development.sqlite3
+
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
+# Do not set this db to the same as development or production.
+test:
+ <<: *default
+ database: storage/test.sqlite3
+
+production:
+ <<: *default
+ database: storage/production.sqlite3
diff --git a/backstage-rails/test/dummy/config/environment.rb b/backstage-rails/test/dummy/config/environment.rb
new file mode 100644
index 0000000..cac5315
--- /dev/null
+++ b/backstage-rails/test/dummy/config/environment.rb
@@ -0,0 +1,5 @@
+# Load the Rails application.
+require_relative "application"
+
+# Initialize the Rails application.
+Rails.application.initialize!
diff --git a/backstage-rails/test/dummy/config/environments/development.rb b/backstage-rails/test/dummy/config/environments/development.rb
new file mode 100644
index 0000000..2e7fb48
--- /dev/null
+++ b/backstage-rails/test/dummy/config/environments/development.rb
@@ -0,0 +1,76 @@
+require "active_support/core_ext/integer/time"
+
+Rails.application.configure do
+ # Settings specified here will take precedence over those in config/application.rb.
+
+ # In the development environment your application's code is reloaded any time
+ # it changes. This slows down response time but is perfect for development
+ # since you don't have to restart the web server when you make code changes.
+ config.enable_reloading = true
+
+ # Do not eager load code on boot.
+ config.eager_load = false
+
+ # Show full error reports.
+ config.consider_all_requests_local = true
+
+ # Enable server timing
+ config.server_timing = true
+
+ # Enable/disable caching. By default caching is disabled.
+ # Run rails dev:cache to toggle caching.
+ if Rails.root.join("tmp/caching-dev.txt").exist?
+ config.action_controller.perform_caching = true
+ config.action_controller.enable_fragment_cache_logging = true
+
+ config.cache_store = :memory_store
+ config.public_file_server.headers = {
+ "Cache-Control" => "public, max-age=#{2.days.to_i}"
+ }
+ else
+ config.action_controller.perform_caching = false
+
+ config.cache_store = :null_store
+ end
+
+ # Store uploaded files on the local file system (see config/storage.yml for options).
+ config.active_storage.service = :local
+
+ # Don't care if the mailer can't send.
+ config.action_mailer.raise_delivery_errors = false
+
+ config.action_mailer.perform_caching = false
+
+ # Print deprecation notices to the Rails logger.
+ config.active_support.deprecation = :log
+
+ # Raise exceptions for disallowed deprecations.
+ config.active_support.disallowed_deprecation = :raise
+
+ # Tell Active Support which deprecation messages to disallow.
+ config.active_support.disallowed_deprecation_warnings = []
+
+ # Raise an error on page load if there are pending migrations.
+ config.active_record.migration_error = :page_load
+
+ # Highlight code that triggered database queries in logs.
+ config.active_record.verbose_query_logs = true
+
+ # Highlight code that enqueued background job in logs.
+ config.active_job.verbose_enqueue_logs = true
+
+ # Suppress logger output for asset requests.
+ config.assets.quiet = true
+
+ # Raises error for missing translations.
+ # config.i18n.raise_on_missing_translations = true
+
+ # Annotate rendered view with file names.
+ # config.action_view.annotate_rendered_view_with_filenames = true
+
+ # Uncomment if you wish to allow Action Cable access from any origin.
+ # config.action_cable.disable_request_forgery_protection = true
+
+ # Raise error when a before_action's only/except options reference missing actions
+ config.action_controller.raise_on_missing_callback_actions = true
+end
diff --git a/backstage-rails/test/dummy/config/environments/production.rb b/backstage-rails/test/dummy/config/environments/production.rb
new file mode 100644
index 0000000..f25aaaf
--- /dev/null
+++ b/backstage-rails/test/dummy/config/environments/production.rb
@@ -0,0 +1,97 @@
+require "active_support/core_ext/integer/time"
+
+Rails.application.configure do
+ # Settings specified here will take precedence over those in config/application.rb.
+
+ # Code is not reloaded between requests.
+ config.enable_reloading = false
+
+ # Eager load code on boot. This eager loads most of Rails and
+ # your application in memory, allowing both threaded web servers
+ # and those relying on copy on write to perform better.
+ # Rake tasks automatically ignore this option for performance.
+ config.eager_load = true
+
+ # Full error reports are disabled and caching is turned on.
+ config.consider_all_requests_local = false
+ config.action_controller.perform_caching = true
+
+ # Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment
+ # key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files).
+ # config.require_master_key = true
+
+ # Disable serving static files from `public/`, relying on NGINX/Apache to do so instead.
+ # config.public_file_server.enabled = false
+
+ # Compress CSS using a preprocessor.
+ # config.assets.css_compressor = :sass
+
+ # Do not fall back to assets pipeline if a precompiled asset is missed.
+ config.assets.compile = false
+
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
+ # config.asset_host = "http://assets.example.com"
+
+ # Specifies the header that your server uses for sending files.
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
+ # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
+
+ # Store uploaded files on the local file system (see config/storage.yml for options).
+ config.active_storage.service = :local
+
+ # Mount Action Cable outside main process or domain.
+ # config.action_cable.mount_path = nil
+ # config.action_cable.url = "wss://example.com/cable"
+ # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ]
+
+ # Assume all access to the app is happening through a SSL-terminating reverse proxy.
+ # Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies.
+ # config.assume_ssl = true
+
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
+ config.force_ssl = true
+
+ # Log to STDOUT by default
+ config.logger = ActiveSupport::Logger.new(STDOUT)
+ .tap { |logger| logger.formatter = ::Logger::Formatter.new }
+ .then { |logger| ActiveSupport::TaggedLogging.new(logger) }
+
+ # Prepend all log lines with the following tags.
+ config.log_tags = [ :request_id ]
+
+ # "info" includes generic and useful information about system operation, but avoids logging too much
+ # information to avoid inadvertent exposure of personally identifiable information (PII). If you
+ # want to log everything, set the level to "debug".
+ config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
+
+ # Use a different cache store in production.
+ # config.cache_store = :mem_cache_store
+
+ # Use a real queuing backend for Active Job (and separate queues per environment).
+ # config.active_job.queue_adapter = :resque
+ # config.active_job.queue_name_prefix = "dummy_production"
+
+ config.action_mailer.perform_caching = false
+
+ # Ignore bad email addresses and do not raise email delivery errors.
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
+ # config.action_mailer.raise_delivery_errors = false
+
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
+ # the I18n.default_locale when a translation cannot be found).
+ config.i18n.fallbacks = true
+
+ # Don't log any deprecations.
+ config.active_support.report_deprecations = false
+
+ # Do not dump schema after migrations.
+ config.active_record.dump_schema_after_migration = false
+
+ # Enable DNS rebinding protection and other `Host` header attacks.
+ # config.hosts = [
+ # "example.com", # Allow requests from example.com
+ # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
+ # ]
+ # Skip DNS rebinding protection for the default health check endpoint.
+ # config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
+end
diff --git a/backstage-rails/test/dummy/config/environments/test.rb b/backstage-rails/test/dummy/config/environments/test.rb
new file mode 100644
index 0000000..adbb4a6
--- /dev/null
+++ b/backstage-rails/test/dummy/config/environments/test.rb
@@ -0,0 +1,64 @@
+require "active_support/core_ext/integer/time"
+
+# The test environment is used exclusively to run your application's
+# test suite. You never need to work with it otherwise. Remember that
+# your test database is "scratch space" for the test suite and is wiped
+# and recreated between test runs. Don't rely on the data there!
+
+Rails.application.configure do
+ # Settings specified here will take precedence over those in config/application.rb.
+
+ # While tests run files are not watched, reloading is not necessary.
+ config.enable_reloading = false
+
+ # Eager loading loads your entire application. When running a single test locally,
+ # this is usually not necessary, and can slow down your test suite. However, it's
+ # recommended that you enable it in continuous integration systems to ensure eager
+ # loading is working properly before deploying your code.
+ config.eager_load = ENV["CI"].present?
+
+ # Configure public file server for tests with Cache-Control for performance.
+ config.public_file_server.enabled = true
+ config.public_file_server.headers = {
+ "Cache-Control" => "public, max-age=#{1.hour.to_i}"
+ }
+
+ # Show full error reports and disable caching.
+ config.consider_all_requests_local = true
+ config.action_controller.perform_caching = false
+ config.cache_store = :null_store
+
+ # Render exception templates for rescuable exceptions and raise for other exceptions.
+ config.action_dispatch.show_exceptions = :rescuable
+
+ # Disable request forgery protection in test environment.
+ config.action_controller.allow_forgery_protection = false
+
+ # Store uploaded files on the local file system in a temporary directory.
+ config.active_storage.service = :test
+
+ config.action_mailer.perform_caching = false
+
+ # Tell Action Mailer not to deliver emails to the real world.
+ # The :test delivery method accumulates sent emails in the
+ # ActionMailer::Base.deliveries array.
+ config.action_mailer.delivery_method = :test
+
+ # Print deprecation notices to the stderr.
+ config.active_support.deprecation = :stderr
+
+ # Raise exceptions for disallowed deprecations.
+ config.active_support.disallowed_deprecation = :raise
+
+ # Tell Active Support which deprecation messages to disallow.
+ config.active_support.disallowed_deprecation_warnings = []
+
+ # Raises error for missing translations.
+ # config.i18n.raise_on_missing_translations = true
+
+ # Annotate rendered view with file names.
+ # config.action_view.annotate_rendered_view_with_filenames = true
+
+ # Raise error when a before_action's only/except options reference missing actions
+ config.action_controller.raise_on_missing_callback_actions = true
+end
diff --git a/backstage-rails/test/dummy/config/initializers/assets.rb b/backstage-rails/test/dummy/config/initializers/assets.rb
new file mode 100644
index 0000000..2eeef96
--- /dev/null
+++ b/backstage-rails/test/dummy/config/initializers/assets.rb
@@ -0,0 +1,12 @@
+# Be sure to restart your server when you modify this file.
+
+# Version of your assets, change this if you want to expire all your assets.
+Rails.application.config.assets.version = "1.0"
+
+# Add additional assets to the asset load path.
+# Rails.application.config.assets.paths << Emoji.images_path
+
+# Precompile additional assets.
+# application.js, application.css, and all non-JS/CSS in the app/assets
+# folder are already added.
+# Rails.application.config.assets.precompile += %w( admin.js admin.css )
diff --git a/backstage-rails/test/dummy/config/initializers/content_security_policy.rb b/backstage-rails/test/dummy/config/initializers/content_security_policy.rb
new file mode 100644
index 0000000..b3076b3
--- /dev/null
+++ b/backstage-rails/test/dummy/config/initializers/content_security_policy.rb
@@ -0,0 +1,25 @@
+# Be sure to restart your server when you modify this file.
+
+# Define an application-wide content security policy.
+# See the Securing Rails Applications Guide for more information:
+# https://guides.rubyonrails.org/security.html#content-security-policy-header
+
+# Rails.application.configure do
+# config.content_security_policy do |policy|
+# policy.default_src :self, :https
+# policy.font_src :self, :https, :data
+# policy.img_src :self, :https, :data
+# policy.object_src :none
+# policy.script_src :self, :https
+# policy.style_src :self, :https
+# # Specify URI for violation reports
+# # policy.report_uri "/csp-violation-report-endpoint"
+# end
+#
+# # Generate session nonces for permitted importmap, inline scripts, and inline styles.
+# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
+# config.content_security_policy_nonce_directives = %w(script-src style-src)
+#
+# # Report violations without enforcing the policy.
+# # config.content_security_policy_report_only = true
+# end
diff --git a/backstage-rails/test/dummy/config/initializers/filter_parameter_logging.rb b/backstage-rails/test/dummy/config/initializers/filter_parameter_logging.rb
new file mode 100644
index 0000000..c2d89e2
--- /dev/null
+++ b/backstage-rails/test/dummy/config/initializers/filter_parameter_logging.rb
@@ -0,0 +1,8 @@
+# Be sure to restart your server when you modify this file.
+
+# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file.
+# Use this to limit dissemination of sensitive information.
+# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors.
+Rails.application.config.filter_parameters += [
+ :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
+]
diff --git a/backstage-rails/test/dummy/config/initializers/inflections.rb b/backstage-rails/test/dummy/config/initializers/inflections.rb
new file mode 100644
index 0000000..3860f65
--- /dev/null
+++ b/backstage-rails/test/dummy/config/initializers/inflections.rb
@@ -0,0 +1,16 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new inflection rules using the following format. Inflections
+# are locale specific, and you may define rules for as many different
+# locales as you wish. All of these examples are active by default:
+# ActiveSupport::Inflector.inflections(:en) do |inflect|
+# inflect.plural /^(ox)$/i, "\\1en"
+# inflect.singular /^(ox)en/i, "\\1"
+# inflect.irregular "person", "people"
+# inflect.uncountable %w( fish sheep )
+# end
+
+# These inflection rules are supported but not enabled by default:
+# ActiveSupport::Inflector.inflections(:en) do |inflect|
+# inflect.acronym "RESTful"
+# end
diff --git a/backstage-rails/test/dummy/config/initializers/permissions_policy.rb b/backstage-rails/test/dummy/config/initializers/permissions_policy.rb
new file mode 100644
index 0000000..7db3b95
--- /dev/null
+++ b/backstage-rails/test/dummy/config/initializers/permissions_policy.rb
@@ -0,0 +1,13 @@
+# Be sure to restart your server when you modify this file.
+
+# Define an application-wide HTTP permissions policy. For further
+# information see: https://developers.google.com/web/updates/2018/06/feature-policy
+
+# Rails.application.config.permissions_policy do |policy|
+# policy.camera :none
+# policy.gyroscope :none
+# policy.microphone :none
+# policy.usb :none
+# policy.fullscreen :self
+# policy.payment :self, "https://secure.example.com"
+# end
diff --git a/backstage-rails/test/dummy/config/locales/en.yml b/backstage-rails/test/dummy/config/locales/en.yml
new file mode 100644
index 0000000..6c349ae
--- /dev/null
+++ b/backstage-rails/test/dummy/config/locales/en.yml
@@ -0,0 +1,31 @@
+# Files in the config/locales directory are used for internationalization and
+# are automatically loaded by Rails. If you want to use locales other than
+# English, add the necessary files in this directory.
+#
+# To use the locales, use `I18n.t`:
+#
+# I18n.t "hello"
+#
+# In views, this is aliased to just `t`:
+#
+# <%= t("hello") %>
+#
+# To use a different locale, set it with `I18n.locale`:
+#
+# I18n.locale = :es
+#
+# This would use the information in config/locales/es.yml.
+#
+# To learn more about the API, please read the Rails Internationalization guide
+# at https://guides.rubyonrails.org/i18n.html.
+#
+# Be aware that YAML interprets the following case-insensitive strings as
+# booleans: `true`, `false`, `on`, `off`, `yes`, `no`. Therefore, these strings
+# must be quoted to be interpreted as strings. For example:
+#
+# en:
+# "yes": yup
+# enabled: "ON"
+
+en:
+ hello: "Hello world"
diff --git a/backstage-rails/test/dummy/config/puma.rb b/backstage-rails/test/dummy/config/puma.rb
new file mode 100644
index 0000000..afa809b
--- /dev/null
+++ b/backstage-rails/test/dummy/config/puma.rb
@@ -0,0 +1,35 @@
+# This configuration file will be evaluated by Puma. The top-level methods that
+# are invoked here are part of Puma's configuration DSL. For more information
+# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html.
+
+# Puma can serve each request in a thread from an internal thread pool.
+# The `threads` method setting takes two numbers: a minimum and maximum.
+# Any libraries that use thread pools should be configured to match
+# the maximum value specified for Puma. Default is set to 5 threads for minimum
+# and maximum; this matches the default thread size of Active Record.
+max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
+min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
+threads min_threads_count, max_threads_count
+
+# Specifies that the worker count should equal the number of processors in production.
+if ENV["RAILS_ENV"] == "production"
+ require "concurrent-ruby"
+ worker_count = Integer(ENV.fetch("WEB_CONCURRENCY") { Concurrent.physical_processor_count })
+ workers worker_count if worker_count > 1
+end
+
+# Specifies the `worker_timeout` threshold that Puma will use to wait before
+# terminating a worker in development environments.
+worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
+
+# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
+port ENV.fetch("PORT") { 3000 }
+
+# Specifies the `environment` that Puma will run in.
+environment ENV.fetch("RAILS_ENV") { "development" }
+
+# Specifies the `pidfile` that Puma will use.
+pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
+
+# Allow puma to be restarted by `bin/rails restart` command.
+plugin :tmp_restart
diff --git a/backstage-rails/test/dummy/config/routes.rb b/backstage-rails/test/dummy/config/routes.rb
new file mode 100644
index 0000000..943aa9a
--- /dev/null
+++ b/backstage-rails/test/dummy/config/routes.rb
@@ -0,0 +1,3 @@
+Rails.application.routes.draw do
+ mount Backstage::Rails::Engine => "/backstage-rails"
+end
diff --git a/backstage-rails/test/dummy/config/storage.yml b/backstage-rails/test/dummy/config/storage.yml
new file mode 100644
index 0000000..4942ab6
--- /dev/null
+++ b/backstage-rails/test/dummy/config/storage.yml
@@ -0,0 +1,34 @@
+test:
+ service: Disk
+ root: <%= Rails.root.join("tmp/storage") %>
+
+local:
+ service: Disk
+ root: <%= Rails.root.join("storage") %>
+
+# Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
+# amazon:
+# service: S3
+# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
+# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
+# region: us-east-1
+# bucket: your_own_bucket-<%= Rails.env %>
+
+# Remember not to checkin your GCS keyfile to a repository
+# google:
+# service: GCS
+# project: your_project
+# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
+# bucket: your_own_bucket-<%= Rails.env %>
+
+# Use bin/rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
+# microsoft:
+# service: AzureStorage
+# storage_account_name: your_account_name
+# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
+# container: your_container_name-<%= Rails.env %>
+
+# mirror:
+# service: Mirror
+# primary: local
+# mirrors: [ amazon, google, microsoft ]
diff --git a/backstage-rails/test/dummy/lib/assets/.keep b/backstage-rails/test/dummy/lib/assets/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/backstage-rails/test/dummy/log/.keep b/backstage-rails/test/dummy/log/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/backstage-rails/test/dummy/public/404.html b/backstage-rails/test/dummy/public/404.html
new file mode 100644
index 0000000..2be3af2
--- /dev/null
+++ b/backstage-rails/test/dummy/public/404.html
@@ -0,0 +1,67 @@
+
+
+
+
The page you were looking for doesn't exist (404)
+
+
+
+
+
+
+
+
+
The page you were looking for doesn't exist.
+
You may have mistyped the address or the page may have moved.
+
+
If you are the application owner check the logs for more information.
+
+
+
diff --git a/backstage-rails/test/dummy/public/422.html b/backstage-rails/test/dummy/public/422.html
new file mode 100644
index 0000000..c08eac0
--- /dev/null
+++ b/backstage-rails/test/dummy/public/422.html
@@ -0,0 +1,67 @@
+
+
+
+
The change you wanted was rejected (422)
+
+
+
+
+
+
+
+
+
The change you wanted was rejected.
+
Maybe you tried to change something you didn't have access to.
+
+
If you are the application owner check the logs for more information.
+
+
+
diff --git a/backstage-rails/test/dummy/public/500.html b/backstage-rails/test/dummy/public/500.html
new file mode 100644
index 0000000..78a030a
--- /dev/null
+++ b/backstage-rails/test/dummy/public/500.html
@@ -0,0 +1,66 @@
+
+
+
+
We're sorry, but something went wrong (500)
+
+
+
+
+
+
+
+
+
We're sorry, but something went wrong.
+
+
If you are the application owner check the logs for more information.
+
+
+
diff --git a/backstage-rails/test/dummy/public/apple-touch-icon-precomposed.png b/backstage-rails/test/dummy/public/apple-touch-icon-precomposed.png
new file mode 100644
index 0000000..e69de29
diff --git a/backstage-rails/test/dummy/public/apple-touch-icon.png b/backstage-rails/test/dummy/public/apple-touch-icon.png
new file mode 100644
index 0000000..e69de29
diff --git a/backstage-rails/test/dummy/public/favicon.ico b/backstage-rails/test/dummy/public/favicon.ico
new file mode 100644
index 0000000..e69de29
diff --git a/backstage-rails/test/fixtures/files/.keep b/backstage-rails/test/fixtures/files/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/backstage-rails/test/helpers/.keep b/backstage-rails/test/helpers/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/backstage-rails/test/integration/.keep b/backstage-rails/test/integration/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/backstage-rails/test/integration/navigation_test.rb b/backstage-rails/test/integration/navigation_test.rb
new file mode 100644
index 0000000..ebbc098
--- /dev/null
+++ b/backstage-rails/test/integration/navigation_test.rb
@@ -0,0 +1,7 @@
+require "test_helper"
+
+class NavigationTest < ActionDispatch::IntegrationTest
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/backstage-rails/test/mailers/.keep b/backstage-rails/test/mailers/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/backstage-rails/test/models/.keep b/backstage-rails/test/models/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/backstage-rails/test/test_helper.rb b/backstage-rails/test/test_helper.rb
new file mode 100644
index 0000000..9d47a1b
--- /dev/null
+++ b/backstage-rails/test/test_helper.rb
@@ -0,0 +1,15 @@
+# Configure Rails Environment
+ENV["RAILS_ENV"] = "test"
+
+require_relative "../test/dummy/config/environment"
+ActiveRecord::Migrator.migrations_paths = [File.expand_path("../test/dummy/db/migrate", __dir__)]
+ActiveRecord::Migrator.migrations_paths << File.expand_path("../db/migrate", __dir__)
+require "rails/test_help"
+
+# Load fixtures from the engine
+if ActiveSupport::TestCase.respond_to?(:fixture_paths=)
+ ActiveSupport::TestCase.fixture_paths = [File.expand_path("fixtures", __dir__)]
+ ActionDispatch::IntegrationTest.fixture_paths = ActiveSupport::TestCase.fixture_paths
+ ActiveSupport::TestCase.file_fixture_path = File.expand_path("fixtures", __dir__) + "/files"
+ ActiveSupport::TestCase.fixtures :all
+end
diff --git a/config/routes.rb b/config/routes.rb
index d34632a..4a3c27b 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -8,16 +8,39 @@
# Defines the root path route ("/")
# root "articles#index"
+ resources :terms_and_conditions, only: [:index, :show]
namespace :admin do
root to: 'dashboard#index'
- resources :users
+ resources :users do
+ post 'add_filter', on: :collection
+ end
resources :categories
resources :posts
+ resources :terms_and_conditions
# Add more admin resources as needed
end
+ post 'product_cart/add/:product_id', to: 'product_cart#add', as: 'product_cart_add'
+ get 'product_cart', to: 'product_cart#show', as: 'product_cart'
+ delete 'product_cart/remove/:product_id', to: 'product_cart#remove', as: 'product_cart_remove'
+
+ resources :product_purchases, only: [:index, :show]
+
+ resources :products do
+ member do
+ post 'add_to_cart'
+ end
+ end
+
+ resources :product_checkout, only: [:create] do
+ collection do
+ get 'success'
+ get 'cancel'
+ end
+ end
+
root to: "home#index"
@@ -73,7 +96,12 @@
# :invitations => 'users/invitations'
}
- resources :sales
+ resources :sales do
+ member do
+ get :product_show
+ post :refund
+ end
+ end
resources :event_webhooks
@@ -167,6 +195,8 @@
:index, :create, :destroy
]
+ resources :products
+
resource :podcast, controller: "podcasts"
get "followers", to: "user_follows#followers"
get "followees", to: "user_follows#followees"
diff --git a/db/migrate/20240705165027_create_products.rb b/db/migrate/20240705165027_create_products.rb
new file mode 100644
index 0000000..762cca7
--- /dev/null
+++ b/db/migrate/20240705165027_create_products.rb
@@ -0,0 +1,16 @@
+class CreateProducts < ActiveRecord::Migration[7.1]
+ def change
+ create_table :products do |t|
+ t.string :title
+ t.text :description
+ t.decimal :price
+ t.integer :stock_quantity
+ t.string :sku
+ t.string :category
+ t.string :status
+ t.references :user, null: false, foreign_key: true
+ t.references :playlist, null: true, foreign_key: true
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20240705165039_create_product_variants.rb b/db/migrate/20240705165039_create_product_variants.rb
new file mode 100644
index 0000000..6cd4471
--- /dev/null
+++ b/db/migrate/20240705165039_create_product_variants.rb
@@ -0,0 +1,12 @@
+class CreateProductVariants < ActiveRecord::Migration[7.1]
+ def change
+ create_table :product_variants do |t|
+ t.string :name
+ t.decimal :price
+ t.integer :stock_quantity
+ t.references :product, null: false, foreign_key: true
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20240705175206_add_product_options_and_new_fields_to_products.rb b/db/migrate/20240705175206_add_product_options_and_new_fields_to_products.rb
new file mode 100644
index 0000000..3c49ea7
--- /dev/null
+++ b/db/migrate/20240705175206_add_product_options_and_new_fields_to_products.rb
@@ -0,0 +1,25 @@
+class AddProductOptionsAndNewFieldsToProducts < ActiveRecord::Migration[7.0]
+ def change
+ create_table :product_options do |t|
+ t.references :product, null: false, foreign_key: true
+ t.string :name, null: false
+ t.integer :quantity
+ t.string :sku, null: false
+
+ t.timestamps
+ end
+
+ add_index :product_options, :sku, unique: true
+
+ add_column :products, :limited_edition, :boolean, default: false
+ add_column :products, :limited_edition_count, :integer
+ add_column :products, :include_digital_album, :boolean, default: false
+ add_column :products, :visibility, :string, default: 'private'
+ add_column :products, :name_your_price, :boolean, default: false
+ add_column :products, :shipping_days, :integer
+ add_column :products, :shipping_begins_on, :date
+ add_column :products, :shipping_within_country_price, :decimal, precision: 10, scale: 2
+ add_column :products, :shipping_worldwide_price, :decimal, precision: 10, scale: 2
+ add_column :products, :quantity, :integer
+ end
+end
\ No newline at end of file
diff --git a/db/migrate/20240706203114_create_product_images.rb b/db/migrate/20240706203114_create_product_images.rb
new file mode 100644
index 0000000..80bd13d
--- /dev/null
+++ b/db/migrate/20240706203114_create_product_images.rb
@@ -0,0 +1,11 @@
+class CreateProductImages < ActiveRecord::Migration[7.1]
+ def change
+ create_table :product_images do |t|
+ t.references :product, null: false, foreign_key: true
+ t.string :title
+ t.string :description
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20240706214248_create_product_shippings.rb b/db/migrate/20240706214248_create_product_shippings.rb
new file mode 100644
index 0000000..56646bc
--- /dev/null
+++ b/db/migrate/20240706214248_create_product_shippings.rb
@@ -0,0 +1,12 @@
+class CreateProductShippings < ActiveRecord::Migration[7.1]
+ def change
+ create_table :product_shippings do |t|
+ t.references :product, null: false, foreign_key: true
+ t.string :country
+ t.decimal :base_cost, precision: 10, scale: 2
+ t.decimal :additional_cost, precision: 10, scale: 2
+ t.boolean :is_default, default: false
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20240707214053_create_product_carts.rb b/db/migrate/20240707214053_create_product_carts.rb
new file mode 100644
index 0000000..bb545bc
--- /dev/null
+++ b/db/migrate/20240707214053_create_product_carts.rb
@@ -0,0 +1,9 @@
+class CreateProductCarts < ActiveRecord::Migration[7.1]
+ def change
+ create_table :product_carts do |t|
+ t.references :user, null: false, foreign_key: true
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20240707214100_create_product_cart_items.rb b/db/migrate/20240707214100_create_product_cart_items.rb
new file mode 100644
index 0000000..7b3cf4c
--- /dev/null
+++ b/db/migrate/20240707214100_create_product_cart_items.rb
@@ -0,0 +1,11 @@
+class CreateProductCartItems < ActiveRecord::Migration[7.1]
+ def change
+ create_table :product_cart_items do |t|
+ t.references :product_cart, null: false, foreign_key: true
+ t.references :product, null: false, foreign_key: true
+ t.integer :quantity
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20240707215839_create_product_purchases.rb b/db/migrate/20240707215839_create_product_purchases.rb
new file mode 100644
index 0000000..6fff9a3
--- /dev/null
+++ b/db/migrate/20240707215839_create_product_purchases.rb
@@ -0,0 +1,12 @@
+class CreateProductPurchases < ActiveRecord::Migration[7.1]
+ def change
+ create_table :product_purchases do |t|
+ t.references :user, null: false, foreign_key: true
+ t.decimal :total_amount
+ t.string :status
+ t.string :stripe_session_id
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20240707215844_create_product_purchase_items.rb b/db/migrate/20240707215844_create_product_purchase_items.rb
new file mode 100644
index 0000000..82ed2d5
--- /dev/null
+++ b/db/migrate/20240707215844_create_product_purchase_items.rb
@@ -0,0 +1,12 @@
+class CreateProductPurchaseItems < ActiveRecord::Migration[7.1]
+ def change
+ create_table :product_purchase_items do |t|
+ t.references :product_purchase, null: false, foreign_key: true
+ t.references :product, null: false, foreign_key: true
+ t.integer :quantity
+ t.decimal :price
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20240708012724_add_shipping_details_to_product_purchases.rb b/db/migrate/20240708012724_add_shipping_details_to_product_purchases.rb
new file mode 100644
index 0000000..880d766
--- /dev/null
+++ b/db/migrate/20240708012724_add_shipping_details_to_product_purchases.rb
@@ -0,0 +1,7 @@
+class AddShippingDetailsToProductPurchases < ActiveRecord::Migration[7.1]
+ def change
+ add_column :product_purchases, :shipping_address, :jsonb
+ add_column :product_purchases, :shipping_name, :string
+ add_column :product_purchases, :phone, :string
+ end
+end
diff --git a/db/migrate/20240708030328_add_shipping_cost_to_product_purchases.rb b/db/migrate/20240708030328_add_shipping_cost_to_product_purchases.rb
new file mode 100644
index 0000000..01b4fbc
--- /dev/null
+++ b/db/migrate/20240708030328_add_shipping_cost_to_product_purchases.rb
@@ -0,0 +1,5 @@
+class AddShippingCostToProductPurchases < ActiveRecord::Migration[7.1]
+ def change
+ add_column :product_purchases, :shipping_cost, :decimal
+ end
+end
diff --git a/db/migrate/20240708030342_add_shipping_cost_to_product_purchase_items.rb b/db/migrate/20240708030342_add_shipping_cost_to_product_purchase_items.rb
new file mode 100644
index 0000000..1a85bdd
--- /dev/null
+++ b/db/migrate/20240708030342_add_shipping_cost_to_product_purchase_items.rb
@@ -0,0 +1,5 @@
+class AddShippingCostToProductPurchaseItems < ActiveRecord::Migration[7.1]
+ def change
+ add_column :product_purchase_items, :shipping_cost, :decimal
+ end
+end
diff --git a/db/migrate/20240708033216_add_tracking_code_to_product_purchases.rb b/db/migrate/20240708033216_add_tracking_code_to_product_purchases.rb
new file mode 100644
index 0000000..889fa56
--- /dev/null
+++ b/db/migrate/20240708033216_add_tracking_code_to_product_purchases.rb
@@ -0,0 +1,5 @@
+class AddTrackingCodeToProductPurchases < ActiveRecord::Migration[7.1]
+ def change
+ add_column :product_purchases, :tracking_code, :string
+ end
+end
diff --git a/db/migrate/20240708055441_add_payment_intent_id_to_product_purchases.rb b/db/migrate/20240708055441_add_payment_intent_id_to_product_purchases.rb
new file mode 100644
index 0000000..2ce3823
--- /dev/null
+++ b/db/migrate/20240708055441_add_payment_intent_id_to_product_purchases.rb
@@ -0,0 +1,5 @@
+class AddPaymentIntentIdToProductPurchases < ActiveRecord::Migration[7.1]
+ def change
+ add_column :product_purchases, :payment_intent_id, :string
+ end
+end
diff --git a/db/migrate/20240708062311_add_shipping_info_to_product_purchase.rb b/db/migrate/20240708062311_add_shipping_info_to_product_purchase.rb
new file mode 100644
index 0000000..b4dc8b6
--- /dev/null
+++ b/db/migrate/20240708062311_add_shipping_info_to_product_purchase.rb
@@ -0,0 +1,6 @@
+class AddShippingInfoToProductPurchase < ActiveRecord::Migration[7.1]
+ def change
+ add_column :product_purchases, :shipping_status, :string
+ add_index :product_purchases, :shipping_status
+ end
+end
diff --git a/db/migrate/20240712053122_add_slug_to_product.rb b/db/migrate/20240712053122_add_slug_to_product.rb
new file mode 100644
index 0000000..1bb3c9c
--- /dev/null
+++ b/db/migrate/20240712053122_add_slug_to_product.rb
@@ -0,0 +1,6 @@
+class AddSlugToProduct < ActiveRecord::Migration[7.1]
+ def change
+ add_column :products, :slug, :string
+ add_index :products, :slug
+ end
+end
diff --git a/db/migrate/20240712235609_add_deleted_at_to_products.rb b/db/migrate/20240712235609_add_deleted_at_to_products.rb
new file mode 100644
index 0000000..9ea6d88
--- /dev/null
+++ b/db/migrate/20240712235609_add_deleted_at_to_products.rb
@@ -0,0 +1,6 @@
+class AddDeletedAtToProducts < ActiveRecord::Migration[7.1]
+ def change
+ add_column :products, :deleted_at, :datetime
+ add_index :products, :deleted_at
+ end
+end
diff --git a/db/migrate/20240713005046_add_seller_to_users.rb b/db/migrate/20240713005046_add_seller_to_users.rb
new file mode 100644
index 0000000..e3c41f8
--- /dev/null
+++ b/db/migrate/20240713005046_add_seller_to_users.rb
@@ -0,0 +1,6 @@
+class AddSellerToUsers < ActiveRecord::Migration[7.1]
+ def change
+ add_column :users, :seller, :boolean
+ add_index :users, :seller
+ end
+end
diff --git a/db/migrate/20240713005658_create_terms_and_conditions.rb b/db/migrate/20240713005658_create_terms_and_conditions.rb
new file mode 100644
index 0000000..effafd8
--- /dev/null
+++ b/db/migrate/20240713005658_create_terms_and_conditions.rb
@@ -0,0 +1,11 @@
+class CreateTermsAndConditions < ActiveRecord::Migration[7.1]
+ def change
+ create_table :terms_and_conditions do |t|
+ t.string :title
+ t.string :category
+ t.text :content
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 9790b6c..7bababf 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema[7.1].define(version: 2024_07_05_131631) do
+ActiveRecord::Schema[7.1].define(version: 2024_07_13_005658) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -335,6 +335,133 @@
t.datetime "updated_at", null: false
end
+ create_table "product_cart_items", force: :cascade do |t|
+ t.bigint "product_cart_id", null: false
+ t.bigint "product_id", null: false
+ t.integer "quantity"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.index ["product_cart_id"], name: "index_product_cart_items_on_product_cart_id"
+ t.index ["product_id"], name: "index_product_cart_items_on_product_id"
+ end
+
+ create_table "product_carts", force: :cascade do |t|
+ t.bigint "user_id", null: false
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.index ["user_id"], name: "index_product_carts_on_user_id"
+ end
+
+ create_table "product_images", force: :cascade do |t|
+ t.bigint "product_id", null: false
+ t.string "title"
+ t.string "description"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.index ["product_id"], name: "index_product_images_on_product_id"
+ end
+
+ create_table "product_options", force: :cascade do |t|
+ t.bigint "product_id", null: false
+ t.string "name", null: false
+ t.integer "quantity"
+ t.string "sku", null: false
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.index ["product_id"], name: "index_product_options_on_product_id"
+ t.index ["sku"], name: "index_product_options_on_sku", unique: true
+ end
+
+ create_table "product_purchase_items", force: :cascade do |t|
+ t.bigint "product_purchase_id", null: false
+ t.bigint "product_id", null: false
+ t.integer "quantity"
+ t.decimal "price"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.decimal "shipping_cost"
+ t.index ["product_id"], name: "index_product_purchase_items_on_product_id"
+ t.index ["product_purchase_id"], name: "index_product_purchase_items_on_product_purchase_id"
+ end
+
+ create_table "product_purchases", force: :cascade do |t|
+ t.bigint "user_id", null: false
+ t.decimal "total_amount"
+ t.string "status"
+ t.string "stripe_session_id"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.jsonb "shipping_address"
+ t.string "shipping_name"
+ t.string "phone"
+ t.decimal "shipping_cost"
+ t.string "tracking_code"
+ t.string "payment_intent_id"
+ t.string "shipping_status"
+ t.index ["shipping_status"], name: "index_product_purchases_on_shipping_status"
+ t.index ["user_id"], name: "index_product_purchases_on_user_id"
+ end
+
+ create_table "product_shippings", force: :cascade do |t|
+ t.bigint "product_id", null: false
+ t.string "country"
+ t.decimal "base_cost", precision: 10, scale: 2
+ t.decimal "additional_cost", precision: 10, scale: 2
+ t.boolean "is_default", default: false
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.index ["product_id"], name: "index_product_shippings_on_product_id"
+ end
+
+ create_table "product_variants", force: :cascade do |t|
+ t.string "name"
+ t.decimal "price"
+ t.integer "stock_quantity"
+ t.bigint "product_id", null: false
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.index ["product_id"], name: "index_product_variants_on_product_id"
+ end
+
+ create_table "products", force: :cascade do |t|
+ t.string "title"
+ t.text "description"
+ t.decimal "price"
+ t.integer "stock_quantity"
+ t.string "sku"
+ t.string "category"
+ t.string "status"
+ t.bigint "user_id", null: false
+ t.bigint "playlist_id"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.boolean "limited_edition", default: false
+ t.integer "limited_edition_count"
+ t.boolean "include_digital_album", default: false
+ t.string "visibility", default: "private"
+ t.boolean "name_your_price", default: false
+ t.integer "shipping_days"
+ t.date "shipping_begins_on"
+ t.decimal "shipping_within_country_price", precision: 10, scale: 2
+ t.decimal "shipping_worldwide_price", precision: 10, scale: 2
+ t.integer "quantity"
+ t.string "slug"
+ t.datetime "deleted_at"
+ t.index ["deleted_at"], name: "index_products_on_deleted_at"
+ t.index ["playlist_id"], name: "index_products_on_playlist_id"
+ t.index ["slug"], name: "index_products_on_slug"
+ t.index ["user_id"], name: "index_products_on_user_id"
+ end
+
+ create_table "products_images", force: :cascade do |t|
+ t.bigint "product_id", null: false
+ t.string "title"
+ t.string "description"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.index ["product_id"], name: "index_products_images_on_product_id"
+ end
+
create_table "purchased_items", force: :cascade do |t|
t.bigint "purchase_id", null: false
t.string "purchased_item_type", null: false
@@ -397,6 +524,14 @@
t.index ["user_id"], name: "index_spotlights_on_user_id"
end
+ create_table "terms_and_conditions", force: :cascade do |t|
+ t.string "title"
+ t.string "category"
+ t.text "content"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
create_table "tickets", force: :cascade do |t|
t.string "title"
t.decimal "price"
@@ -505,12 +640,14 @@
t.bigint "invited_by_id"
t.integer "invitations_count", default: 0
t.boolean "editor"
+ t.boolean "seller"
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["invitation_token"], name: "index_users_on_invitation_token", unique: true
t.index ["invited_by_id"], name: "index_users_on_invited_by_id"
t.index ["invited_by_type", "invited_by_id"], name: "index_users_on_invited_by"
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
+ t.index ["seller"], name: "index_users_on_seller"
t.index ["unlock_token"], name: "index_users_on_unlock_token", unique: true
end
@@ -532,6 +669,19 @@
add_foreign_key "podcaster_infos", "users"
add_foreign_key "posts", "categories"
add_foreign_key "posts", "users"
+ add_foreign_key "product_cart_items", "product_carts"
+ add_foreign_key "product_cart_items", "products"
+ add_foreign_key "product_carts", "users"
+ add_foreign_key "product_images", "products"
+ add_foreign_key "product_options", "products"
+ add_foreign_key "product_purchase_items", "product_purchases"
+ add_foreign_key "product_purchase_items", "products"
+ add_foreign_key "product_purchases", "users"
+ add_foreign_key "product_shippings", "products"
+ add_foreign_key "product_variants", "products"
+ add_foreign_key "products", "playlists"
+ add_foreign_key "products", "users"
+ add_foreign_key "products_images", "products"
add_foreign_key "purchased_items", "purchases"
add_foreign_key "purchases", "users"
add_foreign_key "reposts", "tracks"
diff --git a/spec/factories/product_images.rb b/spec/factories/product_images.rb
new file mode 100644
index 0000000..8971917
--- /dev/null
+++ b/spec/factories/product_images.rb
@@ -0,0 +1,7 @@
+FactoryBot.define do
+ factory :product_image do
+ product { nil }
+ title { "MyString" }
+ description { "MyString" }
+ end
+end
diff --git a/spec/factories/product_purchase_items.rb b/spec/factories/product_purchase_items.rb
new file mode 100644
index 0000000..a41fcc4
--- /dev/null
+++ b/spec/factories/product_purchase_items.rb
@@ -0,0 +1,8 @@
+FactoryBot.define do
+ factory :product_purchase_item do
+ product_purchase { nil }
+ product { nil }
+ quantity { 1 }
+ price { "9.99" }
+ end
+end
diff --git a/spec/factories/product_purchases.rb b/spec/factories/product_purchases.rb
new file mode 100644
index 0000000..ef0a39e
--- /dev/null
+++ b/spec/factories/product_purchases.rb
@@ -0,0 +1,8 @@
+FactoryBot.define do
+ factory :product_purchase do
+ user { nil }
+ total_amount { "9.99" }
+ status { "MyString" }
+ stripe_session_id { "MyString" }
+ end
+end
diff --git a/spec/factories/product_shippings.rb b/spec/factories/product_shippings.rb
new file mode 100644
index 0000000..f0009a0
--- /dev/null
+++ b/spec/factories/product_shippings.rb
@@ -0,0 +1,8 @@
+FactoryBot.define do
+ factory :product_shipping do
+ product { nil }
+ country { "MyString" }
+ base_cost { "9.99" }
+ additional_cost { "9.99" }
+ end
+end
diff --git a/spec/factories/product_variants.rb b/spec/factories/product_variants.rb
new file mode 100644
index 0000000..ce18fd4
--- /dev/null
+++ b/spec/factories/product_variants.rb
@@ -0,0 +1,8 @@
+FactoryBot.define do
+ factory :product_variant do
+ name { "MyString" }
+ price { "9.99" }
+ stock_quantity { 1 }
+ product { nil }
+ end
+end
diff --git a/spec/factories/products.rb b/spec/factories/products.rb
new file mode 100644
index 0000000..0378cfc
--- /dev/null
+++ b/spec/factories/products.rb
@@ -0,0 +1,12 @@
+FactoryBot.define do
+ factory :product do
+ title { "MyString" }
+ description { "MyText" }
+ price { "9.99" }
+ stock_quantity { 1 }
+ sku { "MyString" }
+ category { "MyString" }
+ status { "MyString" }
+ user { nil }
+ end
+end
diff --git a/spec/factories/terms_and_conditions.rb b/spec/factories/terms_and_conditions.rb
new file mode 100644
index 0000000..8813f3b
--- /dev/null
+++ b/spec/factories/terms_and_conditions.rb
@@ -0,0 +1,7 @@
+FactoryBot.define do
+ factory :terms_and_condition do
+ title { "MyString" }
+ category { "MyString" }
+ content { "MyText" }
+ end
+end
diff --git a/spec/helpers/product_cart_helper_spec.rb b/spec/helpers/product_cart_helper_spec.rb
new file mode 100644
index 0000000..4c5a294
--- /dev/null
+++ b/spec/helpers/product_cart_helper_spec.rb
@@ -0,0 +1,15 @@
+require 'rails_helper'
+
+# Specs in this file have access to a helper object that includes
+# the ProductCartHelper. For example:
+#
+# describe ProductCartHelper do
+# describe "string concat" do
+# it "concats two strings with spaces" do
+# expect(helper.concat_strings("this","that")).to eq("this that")
+# end
+# end
+# end
+RSpec.describe ProductCartHelper, type: :helper do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/helpers/product_checkout_helper_spec.rb b/spec/helpers/product_checkout_helper_spec.rb
new file mode 100644
index 0000000..42938df
--- /dev/null
+++ b/spec/helpers/product_checkout_helper_spec.rb
@@ -0,0 +1,15 @@
+require 'rails_helper'
+
+# Specs in this file have access to a helper object that includes
+# the ProductCheckoutHelper. For example:
+#
+# describe ProductCheckoutHelper do
+# describe "string concat" do
+# it "concats two strings with spaces" do
+# expect(helper.concat_strings("this","that")).to eq("this that")
+# end
+# end
+# end
+RSpec.describe ProductCheckoutHelper, type: :helper do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/helpers/product_purchases_helper_spec.rb b/spec/helpers/product_purchases_helper_spec.rb
new file mode 100644
index 0000000..dfeea83
--- /dev/null
+++ b/spec/helpers/product_purchases_helper_spec.rb
@@ -0,0 +1,15 @@
+require 'rails_helper'
+
+# Specs in this file have access to a helper object that includes
+# the ProductPurchasesHelper. For example:
+#
+# describe ProductPurchasesHelper do
+# describe "string concat" do
+# it "concats two strings with spaces" do
+# expect(helper.concat_strings("this","that")).to eq("this that")
+# end
+# end
+# end
+RSpec.describe ProductPurchasesHelper, type: :helper do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/helpers/product_variants_helper_spec.rb b/spec/helpers/product_variants_helper_spec.rb
new file mode 100644
index 0000000..e57df9c
--- /dev/null
+++ b/spec/helpers/product_variants_helper_spec.rb
@@ -0,0 +1,15 @@
+require 'rails_helper'
+
+# Specs in this file have access to a helper object that includes
+# the ProductVariantsHelper. For example:
+#
+# describe ProductVariantsHelper do
+# describe "string concat" do
+# it "concats two strings with spaces" do
+# expect(helper.concat_strings("this","that")).to eq("this that")
+# end
+# end
+# end
+RSpec.describe ProductVariantsHelper, type: :helper do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/helpers/products_helper_spec.rb b/spec/helpers/products_helper_spec.rb
new file mode 100644
index 0000000..40a13ae
--- /dev/null
+++ b/spec/helpers/products_helper_spec.rb
@@ -0,0 +1,15 @@
+require 'rails_helper'
+
+# Specs in this file have access to a helper object that includes
+# the ProductsHelper. For example:
+#
+# describe ProductsHelper do
+# describe "string concat" do
+# it "concats two strings with spaces" do
+# expect(helper.concat_strings("this","that")).to eq("this that")
+# end
+# end
+# end
+RSpec.describe ProductsHelper, type: :helper do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/helpers/terms_and_conditions_helper_spec.rb b/spec/helpers/terms_and_conditions_helper_spec.rb
new file mode 100644
index 0000000..d2e5a2a
--- /dev/null
+++ b/spec/helpers/terms_and_conditions_helper_spec.rb
@@ -0,0 +1,15 @@
+require 'rails_helper'
+
+# Specs in this file have access to a helper object that includes
+# the TermsAndConditionsHelper. For example:
+#
+# describe TermsAndConditionsHelper do
+# describe "string concat" do
+# it "concats two strings with spaces" do
+# expect(helper.concat_strings("this","that")).to eq("this that")
+# end
+# end
+# end
+RSpec.describe TermsAndConditionsHelper, type: :helper do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/mailers/previews/product_purchase_preview.rb b/spec/mailers/previews/product_purchase_preview.rb
new file mode 100644
index 0000000..0f30285
--- /dev/null
+++ b/spec/mailers/previews/product_purchase_preview.rb
@@ -0,0 +1,4 @@
+# Preview all emails at http://localhost:3000/rails/mailers/product_purchase
+class ProductPurchasePreview < ActionMailer::Preview
+
+end
diff --git a/spec/mailers/product_purchase_spec.rb b/spec/mailers/product_purchase_spec.rb
new file mode 100644
index 0000000..47a813a
--- /dev/null
+++ b/spec/mailers/product_purchase_spec.rb
@@ -0,0 +1,5 @@
+require "rails_helper"
+
+RSpec.describe ProductPurchaseMailer, type: :mailer do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/models/product_image_spec.rb b/spec/models/product_image_spec.rb
new file mode 100644
index 0000000..059d080
--- /dev/null
+++ b/spec/models/product_image_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe ProductImage, type: :model do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/models/product_purchase_item_spec.rb b/spec/models/product_purchase_item_spec.rb
new file mode 100644
index 0000000..5c1e1f6
--- /dev/null
+++ b/spec/models/product_purchase_item_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe ProductPurchaseItem, type: :model do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/models/product_purchase_spec.rb b/spec/models/product_purchase_spec.rb
new file mode 100644
index 0000000..ab2b2d0
--- /dev/null
+++ b/spec/models/product_purchase_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe ProductPurchase, type: :model do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/models/product_shipping_spec.rb b/spec/models/product_shipping_spec.rb
new file mode 100644
index 0000000..fa8f55e
--- /dev/null
+++ b/spec/models/product_shipping_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe ProductShipping, type: :model do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/models/product_spec.rb b/spec/models/product_spec.rb
new file mode 100644
index 0000000..f22fbfd
--- /dev/null
+++ b/spec/models/product_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe Product, type: :model do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/models/product_variant_spec.rb b/spec/models/product_variant_spec.rb
new file mode 100644
index 0000000..28dd55b
--- /dev/null
+++ b/spec/models/product_variant_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe ProductVariant, type: :model do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/models/terms_and_condition_spec.rb b/spec/models/terms_and_condition_spec.rb
new file mode 100644
index 0000000..98b5b5e
--- /dev/null
+++ b/spec/models/terms_and_condition_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe TermsAndCondition, type: :model do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/requests/product_cart_spec.rb b/spec/requests/product_cart_spec.rb
new file mode 100644
index 0000000..74a8e13
--- /dev/null
+++ b/spec/requests/product_cart_spec.rb
@@ -0,0 +1,7 @@
+require 'rails_helper'
+
+RSpec.describe "ProductCarts", type: :request do
+ describe "GET /index" do
+ pending "add some examples (or delete) #{__FILE__}"
+ end
+end
diff --git a/spec/requests/product_checkout_spec.rb b/spec/requests/product_checkout_spec.rb
new file mode 100644
index 0000000..0041121
--- /dev/null
+++ b/spec/requests/product_checkout_spec.rb
@@ -0,0 +1,7 @@
+require 'rails_helper'
+
+RSpec.describe "ProductCheckouts", type: :request do
+ describe "GET /index" do
+ pending "add some examples (or delete) #{__FILE__}"
+ end
+end
diff --git a/spec/requests/product_purchases_spec.rb b/spec/requests/product_purchases_spec.rb
new file mode 100644
index 0000000..6359320
--- /dev/null
+++ b/spec/requests/product_purchases_spec.rb
@@ -0,0 +1,7 @@
+require 'rails_helper'
+
+RSpec.describe "ProductPurchases", type: :request do
+ describe "GET /index" do
+ pending "add some examples (or delete) #{__FILE__}"
+ end
+end
diff --git a/spec/requests/product_variants_spec.rb b/spec/requests/product_variants_spec.rb
new file mode 100644
index 0000000..e27d51c
--- /dev/null
+++ b/spec/requests/product_variants_spec.rb
@@ -0,0 +1,25 @@
+require 'rails_helper'
+
+RSpec.describe "ProductVariants", type: :request do
+ describe "GET /create" do
+ it "returns http success" do
+ get "/product_variants/create"
+ expect(response).to have_http_status(:success)
+ end
+ end
+
+ describe "GET /update" do
+ it "returns http success" do
+ get "/product_variants/update"
+ expect(response).to have_http_status(:success)
+ end
+ end
+
+ describe "GET /destroy" do
+ it "returns http success" do
+ get "/product_variants/destroy"
+ expect(response).to have_http_status(:success)
+ end
+ end
+
+end
diff --git a/spec/requests/products_spec.rb b/spec/requests/products_spec.rb
new file mode 100644
index 0000000..b358aa5
--- /dev/null
+++ b/spec/requests/products_spec.rb
@@ -0,0 +1,53 @@
+require 'rails_helper'
+
+RSpec.describe "Products", type: :request do
+ describe "GET /index" do
+ it "returns http success" do
+ get "/products/index"
+ expect(response).to have_http_status(:success)
+ end
+ end
+
+ describe "GET /show" do
+ it "returns http success" do
+ get "/products/show"
+ expect(response).to have_http_status(:success)
+ end
+ end
+
+ describe "GET /new" do
+ it "returns http success" do
+ get "/products/new"
+ expect(response).to have_http_status(:success)
+ end
+ end
+
+ describe "GET /create" do
+ it "returns http success" do
+ get "/products/create"
+ expect(response).to have_http_status(:success)
+ end
+ end
+
+ describe "GET /edit" do
+ it "returns http success" do
+ get "/products/edit"
+ expect(response).to have_http_status(:success)
+ end
+ end
+
+ describe "GET /update" do
+ it "returns http success" do
+ get "/products/update"
+ expect(response).to have_http_status(:success)
+ end
+ end
+
+ describe "GET /destroy" do
+ it "returns http success" do
+ get "/products/destroy"
+ expect(response).to have_http_status(:success)
+ end
+ end
+
+end
diff --git a/spec/requests/terms_and_conditions_spec.rb b/spec/requests/terms_and_conditions_spec.rb
new file mode 100644
index 0000000..129451c
--- /dev/null
+++ b/spec/requests/terms_and_conditions_spec.rb
@@ -0,0 +1,7 @@
+require 'rails_helper'
+
+RSpec.describe "TermsAndConditions", type: :request do
+ describe "GET /index" do
+ pending "add some examples (or delete) #{__FILE__}"
+ end
+end
diff --git a/spec/views/product_variants/create.html.erb_spec.rb b/spec/views/product_variants/create.html.erb_spec.rb
new file mode 100644
index 0000000..3a5d3e3
--- /dev/null
+++ b/spec/views/product_variants/create.html.erb_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe "product_variants/create.html.erb", type: :view do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/views/product_variants/destroy.html.erb_spec.rb b/spec/views/product_variants/destroy.html.erb_spec.rb
new file mode 100644
index 0000000..984a757
--- /dev/null
+++ b/spec/views/product_variants/destroy.html.erb_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe "product_variants/destroy.html.erb", type: :view do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/views/product_variants/update.html.erb_spec.rb b/spec/views/product_variants/update.html.erb_spec.rb
new file mode 100644
index 0000000..1622a19
--- /dev/null
+++ b/spec/views/product_variants/update.html.erb_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe "product_variants/update.html.erb", type: :view do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/views/products/create.html.erb_spec.rb b/spec/views/products/create.html.erb_spec.rb
new file mode 100644
index 0000000..2889f5a
--- /dev/null
+++ b/spec/views/products/create.html.erb_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe "products/create.html.erb", type: :view do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/views/products/destroy.html.erb_spec.rb b/spec/views/products/destroy.html.erb_spec.rb
new file mode 100644
index 0000000..1a41a0e
--- /dev/null
+++ b/spec/views/products/destroy.html.erb_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe "products/destroy.html.erb", type: :view do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/views/products/edit.html.erb_spec.rb b/spec/views/products/edit.html.erb_spec.rb
new file mode 100644
index 0000000..b56900b
--- /dev/null
+++ b/spec/views/products/edit.html.erb_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe "products/edit.html.erb", type: :view do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/views/products/index.html.erb_spec.rb b/spec/views/products/index.html.erb_spec.rb
new file mode 100644
index 0000000..3a4fd3a
--- /dev/null
+++ b/spec/views/products/index.html.erb_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe "products/index.html.erb", type: :view do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/views/products/new.html.erb_spec.rb b/spec/views/products/new.html.erb_spec.rb
new file mode 100644
index 0000000..d8cdb35
--- /dev/null
+++ b/spec/views/products/new.html.erb_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe "products/new.html.erb", type: :view do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/views/products/show.html.erb_spec.rb b/spec/views/products/show.html.erb_spec.rb
new file mode 100644
index 0000000..8de347f
--- /dev/null
+++ b/spec/views/products/show.html.erb_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe "products/show.html.erb", type: :view do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/views/products/update.html.erb_spec.rb b/spec/views/products/update.html.erb_spec.rb
new file mode 100644
index 0000000..de8e5d0
--- /dev/null
+++ b/spec/views/products/update.html.erb_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe "products/update.html.erb", type: :view do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/tailwind.config.js b/tailwind.config.js
index 225add3..27bd013 100644
--- a/tailwind.config.js
+++ b/tailwind.config.js
@@ -96,7 +96,20 @@ module.exports = {
800: "#9d174d",
900: "#831843",
950: "#500724"
- }
+ },
+ link: {
+ 50: '#0053F20D',
+ 100: '#0053F21A',
+ 200: '#0053F233',
+ 300: '#0053F24D',
+ 400: '#0053F266',
+ 500: '#0053F280',
+ 600: '#0053F299',
+ 700: '#0053F2B3',
+ 800: '#0053F2CC',
+ 900: '#0053F2E6',
+ DEFAULT: '#0053F2',
+ },
},
borderColor: {