Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ PATH
captive-authentication (= 0.2.8)
captive-theme (= 0.2.8)
captive-theme (0.2.8)
formtastic (~> 3.1, >= 3.1.4)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -132,6 +133,8 @@ GEM
factory_bot_rails (6.2.0)
factory_bot (~> 6.2.0)
railties (>= 5.0.0)
formtastic (3.1.5)
actionpack (>= 3.2.13)
globalid (1.2.1)
activesupport (>= 6.1)
hashdiff (1.0.1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def set_params_on_sentry_context
return if params.blank?

# utilisation de `#to_unsafe_hash` car il faut transformer l'objet unpermitted params en hash
Sentry.set_context('params', params.to_unsafe_hash)
Sentry.set_context("params", params.to_unsafe_hash)
end
end
end
2 changes: 1 addition & 1 deletion captive-crash-reporter/config/initializers/sentry.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sentry_dsn = ENV.fetch("SENTRY_DSN", nil)
sentry_dsn = ENV.fetch("SENTRY_DSN", nil)

if sentry_dsn
Sentry.init do |config|
Expand Down
1 change: 1 addition & 0 deletions captive-theme/.rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--require spec_helper
4 changes: 2 additions & 2 deletions captive-theme/Rakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require "bundler/gem_tasks"
require "rspec/core/rake_task"
APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
load "rails/tasks/engine.rake"

RSpec::Core::RakeTask.new(:spec)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,18 @@ $h2: 24px;

// Shadows
$shadow-xs:
0 1px 3px rgba(0, 0, 0, 0.12),
0 1px 2px rgba(0, 0, 0, 0.24);
0 1px 3px rgb(0 0 0 / 0.12),
0 1px 2px rgb(0 0 0 / 0.24);
$shadow-s:
0 3px 6px rgba(0, 0, 0, 0.15),
0 2px 4px rgba(0, 0, 0, 0.12);
0 3px 6px rgb(0 0 0 / 0.15),
0 2px 4px rgb(0 0 0 / 0.12);
$shadow-m:
0 10px 20px rgba(0, 0, 0, 0.15),
0 3px 6px rgba(0, 0, 0, 0.1);
0 10px 20px rgb(0 0 0 / 0.15),
0 3px 6px rgb(0 0 0 / 0.1);
$shadow-l:
0 15px 25px rgba(0, 0, 0, 0.15),
0 5px 10px rgba(0, 0, 0, 0.5);
$shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.2);
0 15px 25px rgb(0 0 0 / 0.15),
0 5px 10px rgb(0 0 0 / 0.5);
$shadow-xl: 0 20px 40px rgb(0 0 0 / 0.2);

// radius
$border-radius-xs: 8px !default;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@mixin icon() {
object-fit: cover;
border-radius: 3px;
}

.icon-preview {
@include icon;
width: 78px;
height: 78px;

&__small {
@include icon;
width: 36px;
height: 36px;
}
}
8 changes: 8 additions & 0 deletions captive-theme/app/inputs/icon_file_input.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class IconFileInput < ImageFileInput
def image_preview_html_options
options = super
options[:class] ||= ""
options[:class] += " icon-preview"
options
end
end
27 changes: 27 additions & 0 deletions captive-theme/app/inputs/image_file_input.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
class ImageFileInput < Formtastic::Inputs::FileInput
def to_html
input_wrapping do
label_html <<
builder.file_field(method, input_html_options) <<
image_preview_html
end
end

def image_preview_html
if object.send(method)&.attached?
builder.template.image_tag(object.send(method), image_preview_html_options)
else
""
end
end

def input_html_options
{
accept: "image/*",
}.merge(super)
end

def image_preview_html_options
options[:image_preview_html] ||= { style: "max-width: 100%;" }
end
end
26 changes: 26 additions & 0 deletions captive-theme/bin/rails
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/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/captive/theme/engine", __dir__)
APP_PATH = File.expand_path("../spec/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"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
require "active_storage/engine"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_mailbox/engine"
require "action_text/engine"
require "action_view/railtie"
require "action_cable/engine"
# require "rails/test_unit/railtie"
require "rails/engine/commands"
5 changes: 0 additions & 5 deletions captive-theme/bin/test

This file was deleted.

6 changes: 5 additions & 1 deletion captive-theme/captive-theme.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,9 @@ Gem::Specification.new do |spec|
Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]
end

# spec.add_dependency "rails", ">= 7.1.0.alpha"
spec.add_dependency "formtastic", "~> 3.1", ">= 3.1.4"

spec.add_development_dependency "rspec-rails"
spec.add_development_dependency "rspec-mocks"
spec.add_development_dependency "rails-dummy"
end
14 changes: 14 additions & 0 deletions captive-theme/lib/captive/theme/engine.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require "rails"

module Captive
module Theme
class Engine < ::Rails::Engine
# require "formtastic"
# require "app/inputs/icon_file_input.rb"

config.generators do |g|
g.test_framework :rspec
end
end
end
end
11 changes: 11 additions & 0 deletions captive-theme/lib/templates/erb/scaffold/_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<%%= semantic_form_for @<%= singular_name %> do |f| %>
<%%= f.inputs do %>
<%- attributes.each do |attribute| -%>
<%%= f.input :<%= attribute.name %> %>
<%- end -%>
<%% end %>

<%%= f.actions do %>
<%%= f.action :submit, :as => :input %>
<%% end %>
<%% end %>
6 changes: 6 additions & 0 deletions captive-theme/spec/dummy/Rakefile
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions captive-theme/spec/dummy/app/assets/config/manifest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//= link_tree ../images
//= link_directory ../stylesheets .css
//= link captive_theme_manifest.js
Empty file.
15 changes: 15 additions & 0 deletions captive-theme/spec/dummy/app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
@@ -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
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module ApplicationCable
class Channel < ActionCable::Channel::Base
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module ApplicationCable
class Connection < ActionCable::Connection::Base
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class ApplicationController < ActionController::Base
end
Empty file.
2 changes: 2 additions & 0 deletions captive-theme/spec/dummy/app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module ApplicationHelper
end
7 changes: 7 additions & 0 deletions captive-theme/spec/dummy/app/jobs/application_job.rb
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions captive-theme/spec/dummy/app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class ApplicationMailer < ActionMailer::Base
default from: "from@example.com"
layout "mailer"
end
3 changes: 3 additions & 0 deletions captive-theme/spec/dummy/app/models/application_record.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class ApplicationRecord < ActiveRecord::Base
primary_abstract_class
end
Empty file.
15 changes: 15 additions & 0 deletions captive-theme/spec/dummy/app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<title>Dummy</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<%= csrf_meta_tags %>
<%= csp_meta_tag %>

<%= stylesheet_link_tag "application" %>
</head>

<body>
<%= yield %>
</body>
</html>
13 changes: 13 additions & 0 deletions captive-theme/spec/dummy/app/views/layouts/mailer.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
/* Email styles need to be inline */
</style>
</head>

<body>
<%= yield %>
</body>
</html>
1 change: 1 addition & 0 deletions captive-theme/spec/dummy/app/views/layouts/mailer.text.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= yield %>
4 changes: 4 additions & 0 deletions captive-theme/spec/dummy/bin/rails
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env ruby
APP_PATH = File.expand_path("../config/application", __dir__)
require_relative "../config/boot"
require "rails/commands"
4 changes: 4 additions & 0 deletions captive-theme/spec/dummy/bin/rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env ruby
require_relative "../config/boot"
require "rake"
Rake.application.run
33 changes: 33 additions & 0 deletions captive-theme/spec/dummy/bin/setup
Original file line number Diff line number Diff line change
@@ -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) || abort("\n== Command #{args} failed ==")
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
6 changes: 6 additions & 0 deletions captive-theme/spec/dummy/config.ru
Original file line number Diff line number Diff line change
@@ -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
42 changes: 42 additions & 0 deletions captive-theme/spec/dummy/config/application.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
require_relative "boot"

require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
require "active_storage/engine"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_mailbox/engine"
require "action_text/engine"
require "action_view/railtie"
require "action_cable/engine"
# require "rails/test_unit/railtie"

require "formtastic"

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
require "captive/theme"

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

# 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")

# Don't generate system test files.
config.generators.system_tests = nil
end
end
5 changes: 5 additions & 0 deletions captive-theme/spec/dummy/config/boot.rb
Original file line number Diff line number Diff line change
@@ -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__)
10 changes: 10 additions & 0 deletions captive-theme/spec/dummy/config/cable.yml
Original file line number Diff line number Diff line change
@@ -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
Loading