mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	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>`.
This commit is contained in:
		@@ -20,7 +20,6 @@
 | 
				
			|||||||
{{end}}
 | 
					{{end}}
 | 
				
			||||||
	<link rel="icon" href="{{AssetUrlPrefix}}/img/favicon.svg" type="image/svg+xml">
 | 
						<link rel="icon" href="{{AssetUrlPrefix}}/img/favicon.svg" type="image/svg+xml">
 | 
				
			||||||
	<link rel="alternate icon" href="{{AssetUrlPrefix}}/img/favicon.png" type="image/png">
 | 
						<link rel="alternate icon" href="{{AssetUrlPrefix}}/img/favicon.png" type="image/png">
 | 
				
			||||||
	<link rel="stylesheet" href="{{AssetUrlPrefix}}/css/index.css?v={{AssetVersion}}">
 | 
					 | 
				
			||||||
	{{template "base/head_script" .}}
 | 
						{{template "base/head_script" .}}
 | 
				
			||||||
	<noscript>
 | 
						<noscript>
 | 
				
			||||||
		<style>
 | 
							<style>
 | 
				
			||||||
@@ -64,13 +63,7 @@
 | 
				
			|||||||
	<meta property="og:description" content="{{MetaDescription}}">
 | 
						<meta property="og:description" content="{{MetaDescription}}">
 | 
				
			||||||
{{end}}
 | 
					{{end}}
 | 
				
			||||||
	<meta property="og:site_name" content="{{AppName}}">
 | 
						<meta property="og:site_name" content="{{AppName}}">
 | 
				
			||||||
{{if .IsSigned}}
 | 
						{{template "base/stylesheets" .}}
 | 
				
			||||||
	{{if ne .SignedUser.Theme "gitea"}}
 | 
					 | 
				
			||||||
		<link rel="stylesheet" href="{{AssetUrlPrefix}}/css/theme-{{.SignedUser.Theme | PathEscape}}.css?v={{AssetVersion}}">
 | 
					 | 
				
			||||||
	{{end}}
 | 
					 | 
				
			||||||
{{else if ne DefaultTheme "gitea"}}
 | 
					 | 
				
			||||||
	<link rel="stylesheet" href="{{AssetUrlPrefix}}/css/theme-{{DefaultTheme | PathEscape}}.css?v={{AssetVersion}}">
 | 
					 | 
				
			||||||
{{end}}
 | 
					 | 
				
			||||||
	{{template "custom/header" .}}
 | 
						{{template "custom/header" .}}
 | 
				
			||||||
</head>
 | 
					</head>
 | 
				
			||||||
<body>
 | 
					<body>
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										8
									
								
								templates/base/stylesheets.tmpl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								templates/base/stylesheets.tmpl
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
				
			|||||||
 | 
					<link rel="stylesheet" href="{{AssetUrlPrefix}}/css/index.css?v={{AssetVersion}}">
 | 
				
			||||||
 | 
					{{if .IsSigned}}
 | 
				
			||||||
 | 
						{{if ne .SignedUser.Theme "gitea"}}
 | 
				
			||||||
 | 
							<link rel="stylesheet" href="{{AssetUrlPrefix}}/css/theme-{{.SignedUser.Theme | PathEscape}}.css?v={{AssetVersion}}">
 | 
				
			||||||
 | 
						{{end}}
 | 
				
			||||||
 | 
					{{else if ne DefaultTheme "gitea"}}
 | 
				
			||||||
 | 
						<link rel="stylesheet" href="{{AssetUrlPrefix}}/css/theme-{{DefaultTheme | PathEscape}}.css?v={{AssetVersion}}">
 | 
				
			||||||
 | 
					{{end}}
 | 
				
			||||||
@@ -11,7 +11,7 @@
 | 
				
			|||||||
	<title>Internal Server Error - {{AppName}}</title>
 | 
						<title>Internal Server Error - {{AppName}}</title>
 | 
				
			||||||
	<link rel="icon" href="{{AssetUrlPrefix}}/img/favicon.svg" type="image/svg+xml">
 | 
						<link rel="icon" href="{{AssetUrlPrefix}}/img/favicon.svg" type="image/svg+xml">
 | 
				
			||||||
	<link rel="alternate icon" href="{{AssetUrlPrefix}}/img/favicon.png" type="image/png">
 | 
						<link rel="alternate icon" href="{{AssetUrlPrefix}}/img/favicon.png" type="image/png">
 | 
				
			||||||
	<link rel="stylesheet" href="{{AssetUrlPrefix}}/css/index.css?v={{AssetVersion}}">
 | 
						{{template "base/stylesheets" .}}
 | 
				
			||||||
</head>
 | 
					</head>
 | 
				
			||||||
<body>
 | 
					<body>
 | 
				
			||||||
	<div class="full height">
 | 
						<div class="full height">
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user