diff --git a/README.md b/README.md index 5a189d9..e67d9ea 100644 --- a/README.md +++ b/README.md @@ -395,7 +395,7 @@ linkarooie/ ## Gather Script -[GRABIT.SH](https://grabit.sh) was inspired by this script. +- [GRABIT.SH](https://grabit.sh) was inspired by this script. The `gather.sh` script is a utility for collecting project information: diff --git a/app/controllers/users/registrations_controller.rb b/app/controllers/users/registrations_controller.rb index c28410a..a6f6967 100644 --- a/app/controllers/users/registrations_controller.rb +++ b/app/controllers/users/registrations_controller.rb @@ -59,18 +59,18 @@ def update protected def configure_permitted_parameters - devise_parameter_sanitizer.permit(:sign_up, keys: [:email, :password, :password_confirmation, :username, :full_name, :tags, :avatar, :banner, :description]) - devise_parameter_sanitizer.permit(:account_update, keys: [:email, :password, :password_confirmation, :username, :full_name, :tags, :avatar, :banner, :description]) + devise_parameter_sanitizer.permit(:sign_up, keys: [:email, :password, :password_confirmation, :username, :full_name, :tags, :avatar, :banner, :description, :banner_enabled]) + devise_parameter_sanitizer.permit(:account_update, keys: [:email, :password, :password_confirmation, :username, :full_name, :tags, :avatar, :banner, :description, :banner_enabled]) end def sign_up_params - params.require(:user).permit(:email, :password, :password_confirmation, :username, :full_name, :tags, :avatar, :banner, :description).tap do |user_params| + params.require(:user).permit(:email, :password, :password_confirmation, :username, :full_name, :tags, :avatar, :banner, :description, :banner_enabled).tap do |user_params| user_params[:tags] = user_params[:tags].split(',').map(&:strip).to_json if user_params[:tags].present? end end def account_update_params - params.require(:user).permit(:email, :password, :password_confirmation, :current_password, :username, :full_name, :tags, :avatar, :banner, :description, :public_analytics).tap do |user_params| + params.require(:user).permit(:email, :password, :password_confirmation, :current_password, :username, :full_name, :tags, :avatar, :banner, :description, :banner_enabled, :public_analytics).tap do |user_params| user_params[:tags] = user_params[:tags].split(',').map(&:strip).to_json if user_params[:tags].present? end end diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index 2c3853f..e25531c 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -33,6 +33,11 @@ <%= f.text_field :banner, class: 'w-full p-1 rounded text-black' %> </div> + <div class="mb-2"> + <%= f.label :banner_enabled, class: 'block text-gray-300 mb-1' %> + <%= f.check_box :banner_enabled, class: 'rounded text-black' %> + </div> + <div class="mb-2"> <%= f.label :description, class: 'block text-gray-300 mb-1' %> <%= f.text_area :description, class: 'w-full p-1 rounded text-black' %> diff --git a/app/views/links/user_links.html.erb b/app/views/links/user_links.html.erb index 737f1c0..17808e1 100644 --- a/app/views/links/user_links.html.erb +++ b/app/views/links/user_links.html.erb @@ -1,20 +1,25 @@ <% set_open_graph_tags(@user) if @user %> -<div class="profile-header max-w-4xl mx-auto px-4 text-center"> - <div class="avatar-container flex flex-col items-center"> +<div class="profile-header max-w-2xl mx-auto px-4 text-center"> + <% if @user.banner_enabled && @user.banner.present? %> + <div class="w-full h-16 md:h-20 lg:h-24 relative overflow-hidden mb-2"> + <%= image_tag @user.banner, class: "w-full h-full object-cover object-center" %> + </div> + <% end %> + <div class="avatar-container flex flex-col items-center <%= @user.banner_enabled && @user.banner.present? ? '-mt-16' : 'mt-8' %>"> <div class="avatar"> <% local_avatar_path = "/avatars/#{@user.username}_avatar#{File.extname(@user.avatar)}" %> <% if File.exist?(Rails.root.join('public' + local_avatar_path)) %> - <%= image_tag local_avatar_path, alt: @user.email, class: "rounded-full border-4 border-white object-cover", style: "width: 8rem; height: auto;" %> + <%= image_tag local_avatar_path, alt: @user.email, class: "rounded-full border-4 border-gray-900 object-cover", style: "width: 8rem; height: 8rem;" %> <% elsif @user.avatar.present? %> - <%= image_tag @user.avatar, alt: @user.email, class: "rounded-full border-4 border-white object-cover", style: "width: 8rem; height: auto;" %> + <%= image_tag @user.avatar, alt: @user.email, class: "rounded-full border-4 border-gray-900 object-cover", style: "width: 8rem; height: 8rem;" %> <% else %> - <%= image_tag "greg.jpg", alt: @user.email, class: "rounded-full border-4 border-white object-cover", style: "width: 8rem; height: auto;" %> + <%= image_tag "greg.jpg", alt: @user.email, class: "rounded-full border-4 border-gray-900 object-cover", style: "width: 8rem; height: 8rem;" %> <% end %> </div> <div class="user-info mt-4"> - <h1 class="text-xl font-bold text-white text-stroke"><%= @user.full_name %></h1> - <h2 class="text-l font-bold text-white text-stroke"><%= @user.username %></h2> + <h1 class="text-2xl font-bold text-white text-stroke"><%= @user.full_name %></h1> + <h2 class="text-xl font-bold text-white text-stroke"><%= @user.username %></h2> <div class="tags flex flex-wrap justify-center mt-2"> <% @user.tags.each do |tag| %> <span class="tag bg-gray-700 text-white rounded px-2 py-1 m-1"><%= tag %></span> diff --git a/db/migrate/20240901125227_add_banner_enabled_to_users.rb b/db/migrate/20240901125227_add_banner_enabled_to_users.rb new file mode 100644 index 0000000..398842f --- /dev/null +++ b/db/migrate/20240901125227_add_banner_enabled_to_users.rb @@ -0,0 +1,5 @@ +class AddBannerEnabledToUsers < ActiveRecord::Migration[7.1] + def change + add_column :users, :banner_enabled, :boolean, default: true + end +end diff --git a/db/schema.rb b/db/schema.rb index ee81a33..5064c64 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_09_01_041708) do +ActiveRecord::Schema[7.1].define(version: 2024_09_01_125227) do create_table "achievement_views", force: :cascade do |t| t.integer "achievement_id", null: false t.integer "user_id", null: false @@ -134,6 +134,7 @@ t.string "full_name" t.string "tags", default: "[]" t.boolean "public_analytics", default: false + t.boolean "banner_enabled", default: true t.index ["email"], name: "index_users_on_email", unique: true t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true t.index ["username"], name: "index_users_on_username", unique: true