Skip to content

Commit 4a58a8c

Browse files
authored
Make the 500 page load themes (#24953)
The 500 page was not loading theme CSS, so always appeared in light theme. This extracts the stylesheets into a shared template used by all pages. <img width="1262" alt="image" src="https://github.com/go-gitea/gitea/assets/115237/72222b8d-a523-40d0-aa91-b9db32e5625d"> Small related rant: I think there should only be one `<head>` in all of the templates, but I see it was deliberatly done that the 500 page has its own `<head>` because "it should only depend the minimal template functions", but I disagree because we are missing a lot of things that are in the regular `<head>`.
1 parent 7de46b0 commit 4a58a8c

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

templates/base/head.tmpl

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
{{end}}
2121
<link rel="icon" href="{{AssetUrlPrefix}}/img/favicon.svg" type="image/svg+xml">
2222
<link rel="alternate icon" href="{{AssetUrlPrefix}}/img/favicon.png" type="image/png">
23-
<link rel="stylesheet" href="{{AssetUrlPrefix}}/css/index.css?v={{AssetVersion}}">
2423
{{template "base/head_script" .}}
2524
<noscript>
2625
<style>
@@ -63,15 +62,9 @@
6362
<meta property="og:url" content="{{AppUrl}}">
6463
<meta property="og:description" content="{{MetaDescription}}">
6564
{{end}}
66-
<meta property="og:site_name" content="{{AppName}}">
67-
{{if .IsSigned}}
68-
{{if ne .SignedUser.Theme "gitea"}}
69-
<link rel="stylesheet" href="{{AssetUrlPrefix}}/css/theme-{{.SignedUser.Theme | PathEscape}}.css?v={{AssetVersion}}">
70-
{{end}}
71-
{{else if ne DefaultTheme "gitea"}}
72-
<link rel="stylesheet" href="{{AssetUrlPrefix}}/css/theme-{{DefaultTheme | PathEscape}}.css?v={{AssetVersion}}">
73-
{{end}}
74-
{{template "custom/header" .}}
65+
<meta property="og:site_name" content="{{AppName}}">
66+
{{template "base/stylesheets" .}}
67+
{{template "custom/header" .}}
7568
</head>
7669
<body>
7770
{{template "custom/body_outer_pre" .}}

templates/base/stylesheets.tmpl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<link rel="stylesheet" href="{{AssetUrlPrefix}}/css/index.css?v={{AssetVersion}}">
2+
{{if .IsSigned}}
3+
{{if ne .SignedUser.Theme "gitea"}}
4+
<link rel="stylesheet" href="{{AssetUrlPrefix}}/css/theme-{{.SignedUser.Theme | PathEscape}}.css?v={{AssetVersion}}">
5+
{{end}}
6+
{{else if ne DefaultTheme "gitea"}}
7+
<link rel="stylesheet" href="{{AssetUrlPrefix}}/css/theme-{{DefaultTheme | PathEscape}}.css?v={{AssetVersion}}">
8+
{{end}}

templates/status/500.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<title>Internal Server Error - {{AppName}}</title>
1212
<link rel="icon" href="{{AssetUrlPrefix}}/img/favicon.svg" type="image/svg+xml">
1313
<link rel="alternate icon" href="{{AssetUrlPrefix}}/img/favicon.png" type="image/png">
14-
<link rel="stylesheet" href="{{AssetUrlPrefix}}/css/index.css?v={{AssetVersion}}">
14+
{{template "base/stylesheets" .}}
1515
</head>
1616
<body>
1717
<div class="full height">

0 commit comments

Comments
 (0)