summaryrefslogtreecommitdiffstats
path: root/templates
diff options
context:
space:
mode:
authorLanre Adelowo <adelowomailbox@gmail.com>2019-01-09 18:22:57 +0100
committertechknowlogick <hello@techknowlogick.com>2019-01-09 12:22:57 -0500
commit8d2c24f7f9b9bce3a806e4748623bd3b2742025b (patch)
tree2010e6ffaf542d0828c496c31afa56f816c069d5 /templates
parentea518681d95c9ef8ae5ed71d6d8cd7cfb6994a50 (diff)
downloadgitea-8d2c24f7f9b9bce3a806e4748623bd3b2742025b.tar.gz
gitea-8d2c24f7f9b9bce3a806e4748623bd3b2742025b.zip
Allow for user specific themes (#5668)
* add migration and basic UI for changing a user's theme * update user themem * use right text on button * load theme based on users' selection * load theme based on users' selection in pwa too * update sample config * delete older theme loading * implement AfterLoad to set users' theme properly * set up default theme when creating a user. This uses the installation wide theme * use flash messages for error * set default theme when creating a user from the cli * fix @lunny review
Diffstat (limited to 'templates')
-rw-r--r--templates/base/head.tmpl8
-rw-r--r--templates/pwa/serviceworker_js.tmpl10
-rw-r--r--templates/user/settings/account.tmpl38
3 files changed, 51 insertions, 5 deletions
diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl
index 47c0d6b473..b6afe94bb4 100644
--- a/templates/base/head.tmpl
+++ b/templates/base/head.tmpl
@@ -6,7 +6,7 @@
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>{{if .Title}}{{.Title}} - {{end}}{{AppName}}</title>
<link rel="manifest" href="{{AppSubUrl}}/manifest.json">
-
+
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', function() {
@@ -147,7 +147,11 @@
<meta property="og:url" content="{{AppUrl}}" />
<meta property="og:description" content="{{MetaDescription}}">
{{end}}
-{{if ne DefaultTheme "gitea"}}
+{{if .IsSigned }}
+ {{ if ne .SignedUser.Theme "gitea" }}
+ <link rel="stylesheet" href="{{AppSubUrl}}/css/theme-{{.SignedUser.Theme}}.css">
+ {{end}}
+{{else if ne DefaultTheme "gitea"}}
<link rel="stylesheet" href="{{AppSubUrl}}/css/theme-{{DefaultTheme}}.css">
{{end}}
{{template "custom/header" .}}
diff --git a/templates/pwa/serviceworker_js.tmpl b/templates/pwa/serviceworker_js.tmpl
index 5e5860ebb0..f109d06300 100644
--- a/templates/pwa/serviceworker_js.tmpl
+++ b/templates/pwa/serviceworker_js.tmpl
@@ -32,10 +32,14 @@ var urlsToCache = [
'{{AppSubUrl}}/vendor/plugins/jquery.minicolors/jquery.minicolors.css',
'{{AppSubUrl}}/vendor/plugins/jquery.datetimepicker/jquery.datetimepicker.css',
'{{AppSubUrl}}/vendor/plugins/dropzone/dropzone.css',
-{{if ne DefaultTheme "gitea"}}
- '{{AppSubUrl}}/css/theme-{{DefaultTheme}}.css',
+{{if .IsSigned }}
+ {{ if ne .SignedUser.Theme "gitea" }}
+ '{{AppSubUrl}}/css/theme-{{.SignedUser.Theme}}.css'
+ {{end}}
+{{else if ne DefaultTheme "gitea"}}
+ '{{AppSubUrl}}/css/theme-{{DefaultTheme}}.css'
{{end}}
-
+
// img
'{{AppSubUrl}}/img/gitea-sm.png',
'{{AppSubUrl}}/img/gitea-lg.png',
diff --git a/templates/user/settings/account.tmpl b/templates/user/settings/account.tmpl
index 56c3df7f84..778103e44d 100644
--- a/templates/user/settings/account.tmpl
+++ b/templates/user/settings/account.tmpl
@@ -85,6 +85,44 @@
</form>
</div>
+ <h4 class="ui top attached header">
+ {{.i18n.Tr "settings.manage_themes"}}
+ </h4>
+ <div class="ui attached segment">
+ <div class="ui email list">
+ <div class="item">
+ {{.i18n.Tr "settings.theme_desc"}}
+ </div>
+
+ <form class="ui form" action="{{.Link}}/theme" method="post">
+ {{.CsrfTokenHtml}}
+ <div class="field">
+ <label for="ui">{{.i18n.Tr "settings.ui"}}</label>
+ <div class="ui selection dropdown" id="ui">
+ <input name="theme" type="hidden" value="{{.SignedUser.Theme}}">
+ <i class="dropdown icon"></i>
+ <div class="text">
+ {{range $i,$a := .AllThemes}}
+ {{if eq $.SignedUser.Theme $a}}{{$a}}{{end}}
+ {{end}}
+ </div>
+
+ <div class="menu">
+ {{range $i,$a := .AllThemes}}
+ <div class="item{{if eq $.SignedUser.Theme $a}} active selected{{end}}" data-value="{{$a}}">
+ {{$a}}
+ </div>
+ {{end}}
+ </div>
+ </div>
+ </div>
+
+ <div class="field">
+ <button class="ui green button">{{$.i18n.Tr "settings.update_theme"}}</button>
+ </div>
+ </form>
+ </div>
+ </div>
<h4 class="ui top attached warning header">
{{.i18n.Tr "settings.delete_account"}}
</h4>