Skip to content

Commit

Permalink
Merge branch 'hotwire' into authorization
Browse files Browse the repository at this point in the history
  • Loading branch information
spohlenz committed Jul 3, 2024
2 parents 121cad6 + 4ac83a3 commit b0ceb2b
Show file tree
Hide file tree
Showing 17 changed files with 51 additions and 84 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ group :test do
end

gem "rails", "~> 7.1.0"
gem "sassc-rails"

gem "devise"
gem "cancancan"
Expand Down
2 changes: 1 addition & 1 deletion app/assets/bundle/trestle/auth/bundle.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 12 additions & 9 deletions app/views/layouts/trestle/auth.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,29 @@
<meta content='width=device-width, initial-scale=1' name='viewport'>
<meta content='IE=edge,chrome=1' http-equiv='X-UA-Compatible'>

<% if Trestle.config.turbolinks %>
<meta content='no-cache' name='turbolinks-cache-control'>
<% end %>
<meta name='turbo-cache-control' content='no-cache'>
<meta name="turbo-prefetch" content="false" />
<meta name="turbo-root" content="<%= Trestle.config.path %>">

<%= csrf_meta_tags %>

<title><%= Trestle.config.site_title %></title>

<%= stylesheet_link_tag "trestle/admin", 'data-turbolinks-track': 'reload' %>
<%= stylesheet_link_tag "trestle/theme", 'data-turbolinks-track': 'reload' if Trestle.config.theme %>
<%= stylesheet_link_tag "trestle/custom", 'data-turbolinks-track': 'reload' %>
<%= favicon_link_tag Trestle.config.favicon if Trestle.config.favicon %>

<%= stylesheet_link_tag "trestle/auth", 'data-turbolinks-track': 'reload' %>
<%= stylesheet_link_tag "trestle/admin", 'data-turbo-track': 'reload' %>
<%= stylesheet_link_tag "trestle/icons/font-awesome", 'data-turbo-track': 'reload' if defined?(Sprockets) %>

<%= javascript_include_tag "turbolinks" if Trestle.config.turbolinks %>
<%= stylesheet_link_tag "trestle/custom", 'data-turbo-track': 'reload' %>

<%= stylesheet_link_tag "trestle/auth", 'data-turbo-track': 'reload' %>

<%= render "trestle/theme" %>

<%= hook "auth.head" %>
</head>

<body class="auth-body theme-bg-dark">
<body class="auth-body theme-bg">
<main class="container">
<%= yield %>
</main>
Expand Down
4 changes: 2 additions & 2 deletions app/views/trestle/auth/_userbox.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
<% end %>

<% if show_dropdown %>
<%= link_to content, "#", data: { toggle: 'dropdown' } %>
<%= link_to content, "#", data: { bs_toggle: 'dropdown', bs_offset: "0,7" } %>
<% else %>
<%= content %>
<% end %>

<% if show_dropdown -%>
<ul class="dropdown-menu dropdown-menu-right">
<ul class="dropdown-menu dropdown-menu-end">
<% if Trestle.config.auth.user_admin && user_admin = Trestle.lookup(Trestle.config.auth.user_admin) -%>
<li><%= admin_link_to t("admin.auth.my_account", default: "My Account"), current_user, admin: user_admin, class: "dropdown-item" %></li>
<% end -%>
Expand Down
16 changes: 6 additions & 10 deletions app/views/trestle/auth/sessions/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
<div class="form-group">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-user fa-fw"></i></span>
</div>
<span class="input-group-text"><i class="fa fa-user fa-fw"></i></span>
<%= f.text_field Trestle.config.auth.authenticate_with, placeholder: Trestle.config.auth.human_attribute_name(Trestle.config.auth.authenticate_with), class: "form-control" %>
</div>
</div>

<div class="form-group">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-lock fa-fw"></i></span>
</div>
<span class="input-group-text"><i class="fa fa-lock fa-fw"></i></span>
<%= f.password_field :password, placeholder: Trestle.config.auth.human_attribute_name(:password), class: "form-control" %>
</div>
</div>
Expand All @@ -20,13 +16,13 @@

<% if Trestle.config.auth.remember.enabled %>
<div class="form-group">
<div class="custom-control custom-checkbox remember-me">
<%= f.check_box :remember_me, class: "custom-control-input", include_hidden: false %>
<%= f.label :remember_me, t("admin.auth.remember_me", default: "Remember me"), class: "custom-control-label" %>
<div class="form-check remember-me">
<%= f.check_box :remember_me, class: "form-check-input", include_hidden: false %>
<%= f.label :remember_me, t("admin.auth.remember_me", default: "Remember me"), class: "form-check-label" %>
</div>
</div>
<% end %>

<div class="form-group">
<%= f.submit t("admin.auth.login", default: "Login"), class: "btn btn-primary btn-block btn-lg" %>
<%= f.submit t("admin.auth.login", default: "Login"), class: "btn btn-primary btn-lg d-block w-100" %>
</div>
22 changes: 9 additions & 13 deletions frontend/_form.scss
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
.login-form {
.form-control, .input-group-text {
.input-group > * {
background: $auth-form-control-bg;
border: $auth-form-control-border;
margin-left: 0 !important;
}

.form-control {
color: $auth-form-control-color;
font-size: 1.1rem;

padding: 1.75rem 0.75rem;
padding: 1rem 0.75rem;

&:focus {
outline-color: transparent;
Expand All @@ -29,10 +30,6 @@
}
}

.input-group-prepend {
margin-right: 0;
}

.input-group-text {
color: $auth-form-control-icon-color;
padding: 0.375rem 0.25rem 0.375rem 1rem;
Expand All @@ -55,7 +52,12 @@

padding-left: 0;

.custom-control-label {
.form-check-input {
margin-left: 1em;
margin-top: 0.825em;
}

.form-check-label {
display: block;
cursor: pointer;

Expand All @@ -68,12 +70,6 @@
&:hover {
background: opacify($auth-remember-me-bg, 0.05);
}

&::before,
&::after {
top: 0.175em + 0.75em;
left: 1.1em;
}
}
}
}
4 changes: 1 addition & 3 deletions gemfiles/rails-5.2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ group :test do
end

gem "rails", "~> 5.2.0"

gem "sprockets-rails"
gem "sqlite3", "~> 1.3.13"
gem "sassc-rails"

gem "devise"
gem "cancancan"
gem "pundit"
Expand Down
4 changes: 1 addition & 3 deletions gemfiles/rails-6.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ group :test do
end

gem "rails", "~> 6.0.0"

gem "sprockets-rails"
gem "sqlite3", "~> 1.4"
gem "sassc-rails"

gem "devise"
gem "cancancan"
gem "pundit"
Expand Down
4 changes: 1 addition & 3 deletions gemfiles/rails-6.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ group :test do
end

gem "rails", "~> 6.1.0"

gem "sprockets-rails"
gem "sqlite3", "~> 1.4"
gem "sassc-rails"

gem "devise"
gem "cancancan"
gem "pundit"
Expand Down
4 changes: 1 addition & 3 deletions gemfiles/rails-7.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ group :test do
end

gem "rails", "~> 7.0.0"

gem "sprockets-rails"
gem "sqlite3", "~> 1.4"
gem "sassc-rails"

gem "devise"
gem "cancancan"
gem "pundit"
Expand Down
4 changes: 1 addition & 3 deletions gemfiles/rails-7.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ group :test do
end

gem "rails", "~> 7.1.0"

gem "sprockets-rails"
gem "sqlite3", "~> 1.4"
gem "sassc-rails"

gem "devise"
gem "cancancan"
gem "pundit"
Expand Down
1 change: 0 additions & 1 deletion spec/dummy/app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@
* 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
*/
8 changes: 8 additions & 0 deletions spec/dummy/app/assets/stylesheets/trestle/_custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* This file may be used for providing additional customizations to the Trestle
* admin. It will be automatically included within all admin pages.
*
* For organizational purposes, you may wish to define your customizations
* within individual partials in this folder and they'll be required below.
*
*= require_tree .
*/
8 changes: 0 additions & 8 deletions spec/dummy/app/assets/stylesheets/trestle/_custom.scss

This file was deleted.

13 changes: 0 additions & 13 deletions spec/dummy/app/assets/stylesheets/trestle/_theme.scss

This file was deleted.

14 changes: 8 additions & 6 deletions spec/dummy/config/initializers/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,14 @@
# so you need to do it manually. For the users scope, it would be:
# config.omniauth_path_prefix = '/my_engine/users/auth'

# ==> Turbolinks configuration
# If your app is using Turbolinks, Turbolinks::Controller needs to be included to make redirection work correctly:
#
# ActiveSupport.on_load(:devise_failure_app) do
# include Turbolinks::Controller
# end
# ==> Hotwire/Turbo configuration
# When using Devise with Hotwire/Turbo, the http status for error responses
# and some redirects must match the following. The default in Devise for existing
# apps is `200 OK` and `302 Found` respectively, but new apps are generated with
# these new defaults that match Hotwire/Turbo behavior.
# Note: These might become the new default in future versions of Devise.
config.responder.error_status = :unprocessable_entity
config.responder.redirect_status = :see_other

# ==> Configuration for :registerable

Expand Down
5 changes: 0 additions & 5 deletions spec/dummy/config/initializers/trestle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,6 @@
# stylesheet_link_tag "custom"
# end

# Toggle whether Turbolinks is enabled within the admin.
# Defaults to true if Turbolinks is available.
#
# config.turbolinks = false

# Specify the parameters that should persist across requests when
# paginating or reordering. Defaults to [:sort, :order, :scope].
#
Expand Down

0 comments on commit b0ceb2b

Please sign in to comment.