Fix generation of static error pages in glitch-soc

This commit is contained in:
Claire 2026-02-11 13:54:43 +01:00
parent 01b576efed
commit 2f8ecb894e
3 changed files with 11 additions and 25 deletions

View File

@ -285,8 +285,8 @@ module ApplicationHelper
end end
# glitch-soc addition to handle the multiple flavors # glitch-soc addition to handle the multiple flavors
def flavoured_vite_typescript_tag(pack_name, **) def flavoured_vite_typescript_tag(pack_name, flavour: nil, **)
vite_typescript_tag("#{Themes.instance.flavour(current_flavour)['pack_directory'].delete_prefix('app/javascript/')}/#{pack_name}", **) vite_typescript_tag("#{Themes.instance.flavour(flavour || current_flavour)['pack_directory'].delete_prefix('app/javascript/')}/#{pack_name}", **)
end end
private private

View File

@ -1,5 +1,5 @@
!!! !!!
%html{ lang: I18n.locale, 'data-contrast': 'auto', 'data-color-scheme': 'auto', 'data-user-flavour': current_flavour.parameterize } %html{ lang: I18n.locale, 'data-contrast': 'auto', 'data-color-scheme': 'auto', 'data-user-flavour': Setting.default_settings['flavour'].parameterize }
%head %head
%meta{ 'content' => 'text/html; charset=UTF-8', 'http-equiv' => 'Content-Type' }/ %meta{ 'content' => 'text/html; charset=UTF-8', 'http-equiv' => 'Content-Type' }/
%meta{ charset: 'utf-8' }/ %meta{ charset: 'utf-8' }/
@ -8,9 +8,9 @@
= vite_client_tag = vite_client_tag
= vite_react_refresh_tag = vite_react_refresh_tag
= vite_polyfills_tag = vite_polyfills_tag
= flavoured_vite_typescript_tag 'theme-selection.ts', crossorigin: 'anonymous', blocking: 'render' = flavoured_vite_typescript_tag 'theme-selection.ts', flavour: Setting.default_settings['flavour'], crossorigin: 'anonymous', blocking: 'render'
= theme_style_tags current_theme = theme_style_tags [Setting.default_settings['flavour'], Setting.default_settings['skin']]
= flavoured_vite_typescript_tag 'error.ts', crossorigin: 'anonymous' = flavoured_vite_typescript_tag 'error.ts', flavour: Setting.default_settings['flavour'], crossorigin: 'anonymous'
%body.error %body.error
.dialog .dialog
.dialog__illustration .dialog__illustration

View File

@ -1,27 +1,13 @@
# frozen_string_literal: true # frozen_string_literal: true
def render_static_page(action, dest:, **opts)
html = ApplicationController.render(action, opts)
File.write(dest, html)
end
namespace :assets do namespace :assets do
desc 'Generate static pages' desc 'Generate static pages'
task generate_static_pages: :environment do task generate_static_pages: :environment do
def render_static_page(action, dest:, **opts)
renderer = Class.new(ApplicationController) do
def current_user
nil
end
def current_flavour
Setting.default_settings['flavour']
end
def current_skin
Setting.default_settings['skin']
end
end
html = renderer.render(action, opts)
File.write(dest, html)
end
render_static_page 'errors/500', layout: 'error', dest: Rails.public_path.join('assets', '500.html') render_static_page 'errors/500', layout: 'error', dest: Rails.public_path.join('assets', '500.html')
end end
end end