feat: restrict repository file browsing and commit history to authenticated users via conditional template blocks

This commit is contained in:
2024-12-23 01:10:53 +00:00
parent 99e5421464
commit 837faafd6b
7 changed files with 437 additions and 84 deletions
+6
View File
@@ -1,3 +1,5 @@
{{if false}}
{{/* to make html structure "likely" complete to prevent IDE warnings */}}
<html>
@@ -14,6 +16,10 @@
{{template "base/footer_content" .}}
<script src="{{AssetUrlPrefix}}/js/index.js?v={{AssetVersion}}" onerror="alert('Failed to load asset files from ' + this.src + '. Please make sure the asset files can be accessed.')"></script>
<script>
</script>
{{template "custom/footer" .}}
</body>
@@ -1,7 +1,7 @@
<footer class="page-footer" role="group" aria-label="{{ctx.Locale.Tr "aria.footer"}}">
<div class="left-links" role="contentinfo" aria-label="{{ctx.Locale.Tr "aria.footer.software"}}">
{{if ShowFooterPoweredBy}}
{{end}}
{{if and .IsSigned ShowFooterPoweredBy}}
{{if (or .ShowFooterVersion .PageIsAdmin)}}
{{ctx.Locale.Tr "version"}}:
{{if .IsAdmin}}
@@ -10,15 +10,18 @@
{{AppVer}}
{{end}}
{{end}}
{{end}}
{{if and .TemplateLoadTimes ShowFooterTemplateLoadTime}}
{{ctx.Locale.Tr "page"}}: <strong>{{LoadTimes .PageStartTime}}</strong>
Response time: <strong>{{LoadTimes .PageStartTime}}</strong>
{{end}}
</div>
<div class="right-links" role="group" aria-label="{{ctx.Locale.Tr "aria.footer.links"}}">
{{ if false }}
<div class="ui dropdown upward language">
<!--
<span class="flex-text-inline">{{svg "octicon-globe" 14}} {{ctx.Locale.LangName}}</span>
<div class="menu language-menu">
{{range .AllLangs}}
@@ -26,9 +29,10 @@
{{end}}
</div>
-->
</div>
{{ end }}
<a href="https://mail.molodetz.nl/SOGo/">Mail</a>
<a href="{{AssetUrlPrefix}}/licenses.txt">{{ctx.Locale.Tr "licenses"}}</a>
{{if .EnableSwagger}}<a href="{{AppSubUrl}}/api/swagger">API</a>{{end}}
+15 -2
View File
@@ -2,7 +2,7 @@
<html lang="{{ctx.Locale.Lang}}" data-theme="{{UserThemeName .SignedUser}}">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{if .Title}}{{.Title}} - {{end}}{{if .Repository.Name}}{{.Repository.Name}} - {{end}}{{AppName}}</title>
<title>{{if and false .Title}}{{.Title}} - {{end}}{{if .Repository.Name}}{{.Repository.Name}} - {{end}}{{ if false }}{{AppName}}{{ end }}Molodetz Institute</title>
{{if .ManifestData}}<link rel="manifest" href="data:{{.ManifestData}}">{{end}}
<meta name="author" content="{{if .Repository}}{{.Owner.Name}}{{else}}{{MetaAuthor}}{{end}}">
<meta name="description" content="{{if .Repository}}{{.Repository.Name}}{{if .Repository.Description}} - {{.Repository.Description}}{{end}}{{else}}{{MetaDescription}}{{end}}">
@@ -20,6 +20,7 @@
<link rel="alternate icon" href="{{AssetUrlPrefix}}/img/favicon.png" type="image/png">
{{template "base/head_script" .}}
{{template "base/terms_script" .}}
<noscript>
<style>
.dropdown:hover > .menu { display: block; }
@@ -27,13 +28,25 @@
</style>
</noscript>
{{template "base/head_opengraph" .}}
{{template "base/head_style" .}}
{{template "base/head_style2" .}}
{{template "custom/header" .}}
</head>
<body hx-headers='{"x-csrf-token": "{{.CsrfToken}}"}' hx-swap="outerHTML" hx-ext="morph" hx-push-url="false">
{{template "custom/body_outer_pre" .}}
<div class="full height">
<div class="full height" style="padding:0;">
<noscript>{{ctx.Locale.Tr "enable_javascript"}}</noscript>
{{template "custom/body_inner_pre" .}}