diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9ee42a7ae5..2fc6ff30a4 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -41,6 +41,7 @@ class ApplicationController < ActionController::Base end before_action do + @is_dark = !!@dark || cookies[:theme] == "dark" || (cookies[:theme] == "system" && cookies[:system_preference] == "dark") unless signed_in? @hide_seasonal_decorations = true end diff --git a/app/views/layouts/_body_suffix.html.erb b/app/views/layouts/_body_suffix.html.erb new file mode 100644 index 0000000000..fb1aae9c8a --- /dev/null +++ b/app/views/layouts/_body_suffix.html.erb @@ -0,0 +1,43 @@ +<%# locals: (skip_fullstory: false) %> +<% if Rails.env.production? && !skip_fullstory %> + <%= render "application/fullstory" if current_user&.sessions_reported %> +<% end %> + +<% if flash[:confetti] %> + + +<% end %> +<% if Flipper.enabled?(:transactions_background_2024_06_05, current_user) %> + +<% end %> diff --git a/app/views/layouts/_head.html.erb b/app/views/layouts/_head.html.erb new file mode 100644 index 0000000000..8d8e90001e --- /dev/null +++ b/app/views/layouts/_head.html.erb @@ -0,0 +1,75 @@ +<%# locals: (title_suffix: "HCB", skip_dark_js: false, custom_stylesheet: false, custom_application_js: false, skip_plausible: false, skip_console_art: false, console_art_url: nil) %> + + + + <%= yield(:title).concat(" –") if content_for?(:title) %> + <%= title_suffix %> + +<%= csrf_meta_tags %> +<%= csp_meta_tag %> +"> + + +<%= yield(:before_assets) if content_for?(:before_assets) %> + +<%= javascript_include_tag "dark", 'data-turbo-track': "reload" %> +<%= stylesheet_link_tag "application", media: "all", 'data-turbo-track': "reload" unless custom_stylesheet %> +<%= yield(:custom_stylesheet) if content_for?(:custom_stylesheet) %> +<%= javascript_include_tag "application", 'data-turbo-track': "reload", defer: true unless custom_application_js %> +<%= yield(:custom_application_js) if content_for?(:custom_application_js) %> +<%= javascript_include_tag "bundle", 'data-turbo-track': "reload", defer: true %> + +<%= yield(:additional_scripts) if content_for?(:additional_scripts) %> + +<% if Rails.env.production? && !skip_plausible %> + +<% end %> + +<% unless Rails.env.production? %> + +<% end %> + +<% if Rails.env.production? && !skip_console_art %> + +<% end %> + + + +<% if content_for?(:favicon) %> + <%= yield :favicon %> +<% elsif user_birthday? %> + +<% else %> + + +<% end %> + + + + +<%= yield(:additional_head_tags) if content_for?(:additional_head_tags) %> +<%= yield(:head) if content_for?(:head) %> diff --git a/app/views/layouts/_seasonal.html.erb b/app/views/layouts/_seasonal.html.erb new file mode 100644 index 0000000000..2ef4da07f7 --- /dev/null +++ b/app/views/layouts/_seasonal.html.erb @@ -0,0 +1,11 @@ +<%# locals: (render_snow: true) %> +<%# LET THERE BE SNOW %> +<% if winter? && render_snow %> + <%= react_component "holiday/Snow", {}, { style: "height:100%" } %> +<% end %> + +<%# ghosts and ghouls %> +<% if fall? %> + oOoOoOoOo + witch orpheus +<% end %> diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb index b798e33e79..37805a9b1f 100644 --- a/app/views/layouts/admin.html.erb +++ b/app/views/layouts/admin.html.erb @@ -1,23 +1,15 @@ -<% @is_dark = !!@dark || cookies[:theme] == "dark" || (cookies[:theme] == "system" && cookies[:system_preference] == "dark") %> - - - <%= "#{yield(:title)} –" if content_for?(:title) %> - HCB Admin - + <%= render "layouts/head", + title_suffix: "HCB Admin", + custom_stylesheet: true, + custom_application_js: true, + skip_console_art: true, + skip_plausible: true %> - <%= csrf_meta_tags %> - <%= csp_meta_tag %> - <%= javascript_include_tag "dark", 'data-turbo-track': "reload" %> <%= stylesheet_link_tag "admin", media: "all", "data-turbo-track": "reload" %> <%= javascript_include_tag "admin", "data-turbo-track": "reload", defer: true %> - <%= javascript_include_tag "bundle", 'data-turbo-track': "reload", defer: true %> - - - - <%= yield(:head) if content_for?(:head) %> Skip to main content diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 106702fd6c..eb939abde3 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,80 +1,10 @@ -<% @is_dark = !!@dark || cookies[:theme] == "dark" || (cookies[:theme] == "system" && cookies[:system_preference] == "dark") %> - - - - <%= yield(:title).concat(" –") if content_for?(:title) %> - HCB - - <%= csrf_meta_tags %> - <%= csp_meta_tag %> - "> - - <%= javascript_include_tag "dark", 'data-turbo-track': "reload" %> - <%= stylesheet_link_tag "application", media: "all", 'data-turbo-track': "reload" %> - <%= javascript_include_tag "application", 'data-turbo-track': "reload", defer: true %> - <%= javascript_include_tag "bundle", 'data-turbo-track': "reload", defer: true %> - + <%= render "layouts/head" %> <%# Web component used for TOTP / donation QR codes %> - - <% if Rails.env.production? %> - - <% end %> - <%= render "application/helpscout_beacon" %> - - <% unless Rails.env.production? %> - - <% end %> - - <% if Rails.env.production? %> - - <% end %> - - - - <% if content_for?(:favicon) %> - <%= yield :favicon %> - <% elsif user_birthday? %> - - <% else %> - - - <% end %> - - - - - - <%= render "application/seo_meta_tags" %> - <%= yield(:head) if content_for?(:head) %> class="bg-snow embedded <%= content_for :page_class %> <%= "season-#{current_season}" if current_season %>">
@@ -85,124 +15,75 @@ options: @tour&.tourable&.try(:tourable_options) || {}, back_to_tour: @back_to_tour %> -<%# LET THERE BE SNOW %> -<% if winter? %> - <%= react_component "holiday/Snow", {}, { style: "height:100%;position:fixed;top:0;left:0;width:100%;pointer-events:none;z-index:99999" } %> -<% end %> - -<%# ghosts and ghouls %> -<% if fall? %> - oOoOoOoOo - witch orpheus -<% end %> - -<% if content_for?(:nav) %> -
- <% if @event && @first_time %> -
-
-
- <%= image_tag "logo-production-dark.svg", width: 100, class: "logo-dark" %> - <%= image_tag "logo-production.svg", width: 100, class: "logo" %> -
-

Welcome to <%= @event.name %>

-
- -
- No thanks, bring me straight to HCB -
- <% end %> - <%= render "application/native_changelog" if @latest_changelog_post %> - <%= render "application/the_bin" if @the_bin %> - - - - <%= yield(:mobile_nav) %> -
+ <%= render "layouts/seasonal" %> + + <% if content_for?(:nav) %> +
+ <% if @event && @first_time %> +
+
+
+ <%= image_tag "logo-production-dark.svg", width: 100, class: "logo-dark" %> + <%= image_tag "logo-production.svg", width: 100, class: "logo" %> +
+

Welcome to <%= @event.name %>

+
+ +
+ No thanks, bring me straight to HCB +
+ <% end %> + + <%= render "application/native_changelog" if @latest_changelog_post %> + <%= render "application/the_bin" if @the_bin %> + + + + <%= yield(:mobile_nav) %> +
+ <%= render "application/banner_container" %> +
+
+ <%= render "application/flash" unless @hide_flash %> +
+ <%= yield(:container) %> + <%= yield %> + <%= render "application/footer" unless @no_app_shell || @hide_footer %> +
+
+
+ <% else %> <%= render "application/banner_container" %> -
-
- <%= render "application/flash" unless @hide_flash %> + <% unless @no_app_shell %> +
+ <%= render "application/logo" %>
- <%= yield(:container) %> + <% end %> + <%= yield(:header) %> +
+ <%= render "application/flash" unless @hide_flash %> <%= yield %> - <%= render "application/footer" unless @no_app_shell || @hide_footer %> -
-
-
-<% else %> - <%= render "application/banner_container" %> - <% unless @no_app_shell %> -
- <%= render "application/logo" %> -
- <% end %> - <%= yield(:header) %> -
- <%= render "application/flash" unless @hide_flash %> - <%= yield %> -
-<% end %> - -<% if Rails.env.production? %> - <%= render "application/fullstory" if current_user&.sessions_reported %> -<% end %> - -<% if flash[:confetti] %> - - -<% end %> -<% if Flipper.enabled?(:transactions_background_2024_06_05, current_user) %> - -<% end %> - + <%= render "layouts/body_suffix" %> + diff --git a/app/views/layouts/docs.html.erb b/app/views/layouts/docs.html.erb index 49fc346748..b2e1b72db1 100644 --- a/app/views/layouts/docs.html.erb +++ b/app/views/layouts/docs.html.erb @@ -1,72 +1,11 @@ -<% @is_dark = !!@dark || cookies[:theme] == "dark" || (cookies[:theme] == "system" && cookies[:system_preference] == "dark") %> - - - <%= yield(:title).concat(" –") if content_for?(:title) %> - HCB - - <%= csrf_meta_tags %> - <%= csp_meta_tag %> - "> - - <%= javascript_include_tag "dark", 'data-turbo-track': "reload" %> - <%= stylesheet_link_tag "application", media: "all", 'data-turbo-track': "reload" %> - <%= javascript_include_tag "bundle", 'data-turbo-track': "reload", defer: true %> - <%= javascript_include_tag "application", 'data-turbo-track': "reload", defer: true %> + <%= render "layouts/head", console_art_url: Rails.configuration.constants.hack_on_hcb_form_url %> <%# Web component used for TOTP / donation QR codes %> - - <% unless Rails.env.production? %> - - <% end %> - - <% if Rails.env.production? %> - - <% end %> - - - - <% if content_for?(:favicon) %> - <%= yield :favicon %> - <% elsif user_birthday? %> - - <% else %> - - - <% end %> - - - - - <%= yield(:head) if content_for?(:head) %> class="bg-snow embedded <%= content_for :page_class %> <%= "season-#{current_season}" if current_season %>"> <%= react_component "tour/TourOverlay", @@ -87,21 +26,12 @@

This HCB organization has made their finances public. - Hey, <%= link_to "what’s HCB?", "https://hackclub.com/fiscal-sponsorship/", target: "_blank", class: "primary" %> + Hey, <%= link_to "what's HCB?", "https://hackclub.com/fiscal-sponsorship/", target: "_blank", class: "primary" %>

<% end %> - <%# LET THERE BE SNOW %> - <% if winter? %> - <%= react_component "holiday/Snow", {}, { style: "height:100%;position:fixed;top:0;left:0;width:100%;pointer-events:none;z-index:99999" } %> - <% end %> - - <%# ghosts and ghouls %> - <% if fall? %> - oOoOoOoOo - witch orpheus - <% end %> + <%= render "layouts/seasonal" %> <% if content_for?(:nav) %>
@@ -129,32 +59,6 @@ <% end %> <%= render "application/fullstory" %> - - <% if flash[:confetti] %> - - - <% end %> - <% if Flipper.enabled?(:transactions_background_2024_06_05, current_user) %> - - <% end %> + <%= render "layouts/body_suffix", skip_fullstory: true %> diff --git a/app/views/layouts/login.html.erb b/app/views/layouts/login.html.erb index ca998241e9..0b56cf5852 100644 --- a/app/views/layouts/login.html.erb +++ b/app/views/layouts/login.html.erb @@ -1,68 +1,9 @@ -<% @is_dark = !!@dark || cookies[:theme] == "dark" || (cookies[:theme] == "system" && cookies[:system_preference] == "dark") %> <% @home_size = 50 %> <% page_full %> - - - <%= yield(:title).concat(" –") if content_for?(:title) %> - HCB - - <%= csrf_meta_tags %> - <%= csp_meta_tag %> - "> - <%= javascript_include_tag "dark", 'data-turbo-track': "reload" %> - <%= stylesheet_link_tag "application", media: "all", 'data-turbo-track': "reload" %> - <%= javascript_include_tag "application", 'data-turbo-track': "reload", defer: true %> - <%= javascript_include_tag "bundle", 'data-turbo-track': "reload", defer: true %> - <% if Rails.env.production? %> - - <% end %> - <% unless Rails.env.production? %> - - <% end %> - <% if Rails.env.production? %> - - <% end %> - - - <% if content_for?(:favicon) %> - <%= yield :favicon %> - <% elsif user_birthday? %> - - <% else %> - - - <% end %> - - - - + <%= render "layouts/head" %> + <% img = "/brand/hcb-icon-icon-original.png" %> + + + + + + + + + + <%= yield(:head) if content_for?(:head) %> <%= render "application/seo_meta_tags" %> class="bg-snow embedded <%= content_for :page_class %> <%= "season-#{current_season}" if current_season %>"> - <%# LET THERE BE SNOW %> - <% if winter? %> - <%= react_component "holiday/Snow", {}, { style: "height:0px" } %> - <% end %> - <%# ghosts and ghouls %> - <% if fall? %> - oOoOoOoOo - witch orpheus - <% end %> + <%= render "layouts/seasonal", render_snow: false %> <%= yield(:header) %>