From 6972daa3f45c1221a7d508033fca707a51c88061 Mon Sep 17 00:00:00 2001 From: silverwind Date: Tue, 3 Oct 2023 23:57:26 +0200 Subject: [PATCH 01/26] Rename the default themes to gitea-light and gitea-dark --- custom/conf/app.example.ini | 2 +- .../config-cheat-sheet.en-us.md | 4 +- .../config-cheat-sheet.zh-cn.md | 4 +- docs/content/help/faq.en-us.md | 2 +- docs/content/help/faq.zh-cn.md | 2 +- models/migrations/migrations.go | 7 + models/migrations/v1_22/v279.go | 26 ++ modules/setting/ui.go | 2 +- web_src/css/base.css | 235 ----------------- web_src/css/themes/theme-auto.css | 3 +- ...eme-arc-green.css => theme-gitea-dark.css} | 4 +- web_src/css/themes/theme-gitea-light.css | 240 ++++++++++++++++++ 12 files changed, 286 insertions(+), 245 deletions(-) create mode 100644 models/migrations/v1_22/v279.go rename web_src/css/themes/{theme-arc-green.css => theme-gitea-dark.css} (98%) create mode 100644 web_src/css/themes/theme-gitea-light.css diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index 7db3c157c9dca..fbd41c93facf0 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -1212,7 +1212,7 @@ LEVEL = Info ;DEFAULT_THEME = auto ;; ;; All available themes. Allow users select personalized themes regardless of the value of `DEFAULT_THEME`. -;THEMES = auto,gitea,arc-green +;THEMES = auto,gitea-light,gitea-dark ;; ;; All available reactions users can choose on issues/prs and comments. ;; Values can be emoji alias (:smile:) or a unicode emoji. diff --git a/docs/content/administration/config-cheat-sheet.en-us.md b/docs/content/administration/config-cheat-sheet.en-us.md index a337ae82a05be..1acfb6354e41d 100644 --- a/docs/content/administration/config-cheat-sheet.en-us.md +++ b/docs/content/administration/config-cheat-sheet.en-us.md @@ -215,9 +215,9 @@ The following configuration set `Content-Type: application/vnd.android.package-a - `SITEMAP_PAGING_NUM`: **20**: Number of items that are displayed in a single subsitemap. - `GRAPH_MAX_COMMIT_NUM`: **100**: Number of maximum commits shown in the commit graph. - `CODE_COMMENT_LINES`: **4**: Number of line of codes shown for a code comment. -- `DEFAULT_THEME`: **auto**: \[auto, gitea, arc-green\]: Set the default theme for the Gitea install. +- `DEFAULT_THEME`: **auto**: \[auto, gitea-light, gitea-dark\]: Set the default theme for the Gitea install. - `SHOW_USER_EMAIL`: **true**: Whether the email of the user should be shown in the Explore Users page. -- `THEMES`: **auto,gitea,arc-green**: All available themes. Allow users select personalized themes. +- `THEMES`: **auto,gitea-light,gitea-dark**: All available themes. Allow users select personalized themes. regardless of the value of `DEFAULT_THEME`. - `MAX_DISPLAY_FILE_SIZE`: **8388608**: Max size of files to be displayed (default is 8MiB) - `REACTIONS`: All available reactions users can choose on issues/prs and comments diff --git a/docs/content/administration/config-cheat-sheet.zh-cn.md b/docs/content/administration/config-cheat-sheet.zh-cn.md index 2849752c0ab5f..76e9afb2c0acc 100644 --- a/docs/content/administration/config-cheat-sheet.zh-cn.md +++ b/docs/content/administration/config-cheat-sheet.zh-cn.md @@ -214,9 +214,9 @@ menu: - `SITEMAP_PAGING_NUM`: **20**: 在单个子SiteMap中显示的项数。 - `GRAPH_MAX_COMMIT_NUM`: **100**: 提交图中显示的最大commit数量。 - `CODE_COMMENT_LINES`: **4**: 在代码评论中能够显示的最大代码行数。 -- `DEFAULT_THEME`: **auto**: \[auto, gitea, arc-green\]: 在Gitea安装时候设置的默认主题。 +- `DEFAULT_THEME`: **auto**: \[auto, gitea-light, gitea-dark\]: 在Gitea安装时候设置的默认主题。 - `SHOW_USER_EMAIL`: **true**: 用户的电子邮件是否应该显示在`Explore Users`页面中。 -- `THEMES`: **auto,gitea,arc-green**: 所有可用的主题。允许用户选择个性化的主题, +- `THEMES`: **auto,gitea-light,gitea-dark**: 所有可用的主题。允许用户选择个性化的主题, 而不受DEFAULT_THEME 值的影响。 - `MAX_DISPLAY_FILE_SIZE`: **8388608**: 能够显示文件的最大大小(默认为8MiB)。 - `REACTIONS`: 用户可以在问题(Issue)、Pull Request(PR)以及评论中选择的所有可选的反应。 diff --git a/docs/content/help/faq.en-us.md b/docs/content/help/faq.en-us.md index c83f8549e20d1..d52b88f3a5b78 100644 --- a/docs/content/help/faq.en-us.md +++ b/docs/content/help/faq.en-us.md @@ -181,7 +181,7 @@ Use [Fail2Ban](administration/fail2ban-setup.md) to monitor and stop automated l ## How to add/use custom themes -Gitea supports three official themes right now, `gitea` (light), `arc-green` (dark), and `auto` (automatically switches between the previous two depending on operating system settings). +Gitea supports three official themes right now, `gitea-light`, `gitea-dark`, and `auto` (automatically switches between the previous two depending on operating system settings). To add your own theme, currently the only way is to provide a complete theme (not just color overrides) As an example, let's say our theme is `arc-blue` (this is a real theme, and can be found [in this issue](https://github.com/go-gitea/gitea/issues/6011)) diff --git a/docs/content/help/faq.zh-cn.md b/docs/content/help/faq.zh-cn.md index 36610db8e0b8e..e21a1d4c69f4c 100644 --- a/docs/content/help/faq.zh-cn.md +++ b/docs/content/help/faq.zh-cn.md @@ -185,7 +185,7 @@ Gitea不提供内置的Pages服务器。您需要一个专用的域名来提供 ## 如何添加/使用自定义主题 -Gitea 目前支持三个官方主题,分别是 `gitea`(亮色)、`arc-green`(暗色)和 `auto`(根据操作系统设置自动切换前两个主题)。 +Gitea 目前支持三个官方主题,分别是 `gitea-light`、`gitea-dark` 和 `auto`(根据操作系统设置自动切换前两个主题)。 要添加自己的主题,目前唯一的方法是提供一个完整的主题(不仅仅是颜色覆盖)。 假设我们的主题是 `arc-blue`(这是一个真实的主题,可以在[此问题](https://github.com/go-gitea/gitea/issues/6011)中找到) diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index 4527bcc1ae9ed..8733452901418 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -20,6 +20,7 @@ import ( "code.gitea.io/gitea/models/migrations/v1_19" "code.gitea.io/gitea/models/migrations/v1_20" "code.gitea.io/gitea/models/migrations/v1_21" + "code.gitea.io/gitea/models/migrations/v1_22" "code.gitea.io/gitea/models/migrations/v1_6" "code.gitea.io/gitea/models/migrations/v1_7" "code.gitea.io/gitea/models/migrations/v1_8" @@ -538,6 +539,12 @@ var migrations = []Migration{ NewMigration("Add Index to issue_user.issue_id", v1_21.AddIndexToIssueUserIssueID), // v278 -> v279 NewMigration("Add Index to comment.dependent_issue_id", v1_21.AddIndexToCommentDependentIssueID), + + // Gitea 1.21.0 ends at 279 + + // v279 -> v280 + NewMigration("Rename user themes", v1_22.RenameUserThemes), + } // GetCurrentDBVersion returns the current db version diff --git a/models/migrations/v1_22/v279.go b/models/migrations/v1_22/v279.go new file mode 100644 index 0000000000000..699caad9549c9 --- /dev/null +++ b/models/migrations/v1_22/v279.go @@ -0,0 +1,26 @@ +// Copyright 2023 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package v1_22 //nolint + +import ( + "xorm.io/xorm" +) + +func RenameUserThemes(x *xorm.Engine) error { + sess := x.NewSession() + defer sess.Close() + + if err := sess.Begin(); err != nil { + return err + } + + if _, err := sess.Exec(`UPDATE user SET theme = 'gitea-light' WHERE theme = 'gitea'`); err != nil { + return err + } + if _, err := sess.Exec(`UPDATE user SET theme = 'gitea-dark' WHERE theme = 'arc-green'`); err != nil { + return err + } + + return sess.Commit() +} diff --git a/modules/setting/ui.go b/modules/setting/ui.go index 41438db40d5e7..1b7207b1caee1 100644 --- a/modules/setting/ui.go +++ b/modules/setting/ui.go @@ -77,7 +77,7 @@ var UI = struct { ReactionMaxUserNum: 10, MaxDisplayFileSize: 8388608, DefaultTheme: `auto`, - Themes: []string{`auto`, `gitea`, `arc-green`}, + Themes: []string{`auto`, `gitea-light`, `gitea-dark`}, Reactions: []string{`+1`, `-1`, `laugh`, `hooray`, `confused`, `heart`, `rocket`, `eyes`}, CustomEmojis: []string{`git`, `gitea`, `codeberg`, `gitlab`, `github`, `gogs`}, CustomEmojisMap: map[string]string{"git": ":git:", "gitea": ":gitea:", "codeberg": ":codeberg:", "gitlab": ":gitlab:", "github": ":github:", "gogs": ":gogs:"}, diff --git a/web_src/css/base.css b/web_src/css/base.css index c1ebc959d550a..0ac49ab20d577 100644 --- a/web_src/css/base.css +++ b/web_src/css/base.css @@ -22,241 +22,6 @@ --opacity-disabled: 0.55; --height-loading: 16rem; --tab-size: 4; - /* base colors */ - --color-primary: #4183c4; - --color-primary-contrast: #ffffff; - --color-primary-dark-1: #3876b3; - --color-primary-dark-2: #31699f; - --color-primary-dark-3: #2b5c8b; - --color-primary-dark-4: #254f77; - --color-primary-dark-5: #193450; - --color-primary-dark-6: #0c1a28; - --color-primary-dark-7: #04080c; - --color-primary-light-1: #548fca; - --color-primary-light-2: #679cd0; - --color-primary-light-3: #7aa8d6; - --color-primary-light-4: #8db5dc; - --color-primary-light-5: #b3cde7; - --color-primary-light-6: #d9e6f3; - --color-primary-light-7: #f4f8fb; - --color-primary-alpha-10: #4183c419; - --color-primary-alpha-20: #4183c433; - --color-primary-alpha-30: #4183c44b; - --color-primary-alpha-40: #4183c466; - --color-primary-alpha-50: #4183c480; - --color-primary-alpha-60: #4183c499; - --color-primary-alpha-70: #4183c4b3; - --color-primary-alpha-80: #4183c4cc; - --color-primary-alpha-90: #4183c4e1; - --color-primary-hover: var(--color-primary-dark-1); - --color-primary-active: var(--color-primary-dark-2); - --color-secondary: #dedede; - --color-secondary-dark-1: #cecece; - --color-secondary-dark-2: #bfbfbf; - --color-secondary-dark-3: #a0a0a0; - --color-secondary-dark-4: #909090; - --color-secondary-dark-5: #818181; - --color-secondary-dark-6: #717171; - --color-secondary-dark-7: #626262; - --color-secondary-dark-8: #525252; - --color-secondary-dark-9: #434343; - --color-secondary-dark-10: #333333; - --color-secondary-dark-11: #242424; - --color-secondary-dark-12: #141414; - --color-secondary-dark-13: #040404; - --color-secondary-light-1: #e5e5e5; - --color-secondary-light-2: #ebebeb; - --color-secondary-light-3: #f2f2f2; - --color-secondary-light-4: #f8f8f8; - --color-secondary-alpha-10: #dedede19; - --color-secondary-alpha-20: #dedede33; - --color-secondary-alpha-30: #dedede4b; - --color-secondary-alpha-40: #dedede66; - --color-secondary-alpha-50: #dedede80; - --color-secondary-alpha-60: #dedede99; - --color-secondary-alpha-70: #dededeb3; - --color-secondary-alpha-80: #dededecc; - --color-secondary-alpha-90: #dededee1; - --color-secondary-button: var(--color-secondary-dark-4); - --color-secondary-hover: var(--color-secondary-dark-5); - --color-secondary-active: var(--color-secondary-dark-6); - /* console colors - used for actions console and console files */ - --color-console-fg: #eeeff2; - --color-console-fg-subtle: #959cab; - --color-console-bg: #262936; - --color-console-border: #383c47; - --color-console-hover-bg: #ffffff16; - --color-console-active-bg: #454a57; - --color-console-menu-bg: #383c47; - --color-console-menu-border: #5c6374; - /* named colors */ - --color-red: #db2828; - --color-orange: #f2711c; - --color-yellow: #fbbd08; - --color-olive: #b5cc18; - --color-green: #21ba45; - --color-teal: #00b5ad; - --color-blue: #2185d0; - --color-violet: #6435c9; - --color-purple: #a333c8; - --color-pink: #e03997; - --color-brown: #a5673f; - --color-black: #1b1c1d; - /* light variants - produced via Sass scale-color(color, $lightness: +25%) */ - --color-red-light: #e45e5e; - --color-orange-light: #f59555; - --color-yellow-light: #fcce46; - --color-olive-light: #d3e942; - --color-green-light: #46de6a; - --color-teal-light: #08fff4; - --color-blue-light: #51a5e3; - --color-violet-light: #8b67d7; - --color-purple-light: #bb64d8; - --color-pink-light: #e86bb1; - --color-brown-light: #c58b66; - --color-black-light: #525558; - /* dark 1 variants - produced via Sass scale-color(color, $lightness: -10%) */ - --color-red-dark-1: #c82121; - --color-orange-dark-1: #e6630d; - --color-yellow-dark-1: #e5ac04; - --color-olive-dark-1: #a3b816; - --color-green-dark-1: #1ea73e; - --color-teal-dark-1: #00a39c; - --color-blue-dark-1: #1e78bb; - --color-violet-dark-1: #5a30b5; - --color-purple-dark-1: #932eb4; - --color-pink-dark-1: #db228a; - --color-brown-dark-1: #955d39; - --color-black-dark-1: #18191a; - /* dark 2 variants - produced via Sass scale-color(color, $lightness: -20%) */ - --color-red-dark-2: #b11e1e; - --color-orange-dark-2: #cc580c; - --color-yellow-dark-2: #cc9903; - --color-olive-dark-2: #91a313; - --color-green-dark-2: #1a9537; - --color-teal-dark-2: #00918a; - --color-blue-dark-2: #1a6aa6; - --color-violet-dark-2: #502aa1; - --color-purple-dark-2: #8229a0; - --color-pink-dark-2: #c21e7b; - --color-brown-dark-2: #845232; - --color-black-dark-2: #161617; - /* ansi colors used for actions console and console files */ - --color-ansi-black: var(--color-black); - --color-ansi-red: var(--color-red); - --color-ansi-green: var(--color-green); - --color-ansi-yellow: var(--color-yellow); - --color-ansi-blue: var(--color-blue); - --color-ansi-magenta: var(--color-pink); - --color-ansi-cyan: var(--color-teal); - --color-ansi-white: var(--color-console-fg-subtle); - --color-ansi-bright-black: var(--color-black-light); - --color-ansi-bright-red: var(--color-red-light); - --color-ansi-bright-green: var(--color-green-light); - --color-ansi-bright-yellow: var(--color-yellow-light); - --color-ansi-bright-blue: var(--color-blue-light); - --color-ansi-bright-magenta: var(--color-pink-light); - --color-ansi-bright-cyan: var(--color-teal-light); - --color-ansi-bright-white: var(--color-console-fg); - /* other colors */ - --color-grey: #707070; - --color-grey-light: #838383; - --color-gold: #a1882b; - --color-white: #ffffff; - --color-diff-removed-word-bg: #fdb8c0; - --color-diff-added-word-bg: #acf2bd; - --color-diff-removed-row-bg: #ffeef0; - --color-diff-moved-row-bg: #f1f8d1; - --color-diff-added-row-bg: #e6ffed; - --color-diff-removed-row-border: #f1c0c0; - --color-diff-moved-row-border: #d0e27f; - --color-diff-added-row-border: #e6ffed; - --color-diff-inactive: #f2f2f2; - --color-error-border: #e0b4b4; - --color-error-bg: #fff6f6; - --color-error-bg-active: #fbb; - --color-error-bg-hover: #fdd; - --color-error-text: #9f3a38; - --color-success-border: #a3c293; - --color-success-bg: #fcfff5; - --color-success-text: #2c662d; - --color-warning-border: #c9ba9b; - --color-warning-bg: #fffaf3; - --color-warning-text: #573a08; - --color-info-border: #a9d5de; - --color-info-bg: #f8ffff; - --color-info-text: #276f86; - --color-red-badge: #db2828; - --color-red-badge-bg: #db28281a; - --color-red-badge-hover-bg: #db28284d; - --color-green-badge: #21ba45; - --color-green-badge-bg: #21ba451a; - --color-green-badge-hover-bg: #21ba454d; - --color-yellow-badge: #fbbd08; - --color-yellow-badge-bg: #fbbd081a; - --color-yellow-badge-hover-bg: #fbbd084d; - --color-orange-badge: #f2711c; - --color-orange-badge-bg: #f2711c1a; - --color-orange-badge-hover-bg: #f2711c4d; - --color-git: #f05133; - /* target-based colors */ - --color-body: #ffffff; - --color-text-dark: #080808; - --color-text: #212121; - --color-text-light: #555555; - --color-text-light-1: #6a6a6a; - --color-text-light-2: #808080; - --color-text-light-3: #a0a0a0; - --color-box-header: #f7f7f7; - --color-box-body: #ffffff; - --color-box-body-highlight: #fafafa; - --color-footer: #ffffff; - --color-timeline: #ececec; - --color-input-text: #212121; - --color-input-background: #fafafa; - --color-input-toggle-background: #dedede; - --color-input-border: var(--color-secondary); - --color-input-border-hover: var(--color-secondary-dark-1); - --color-header-wrapper: transparent; - --color-light: #00000006; - --color-light-mimic-enabled: rgba(0, 0, 0, calc(6 / 255 * 222 / 255 / var(--opacity-disabled))); - --color-light-border: #0000001d; - --color-hover: #00000014; - --color-active: #0000001b; - --color-menu: #fafafa; - --color-card: #fafafa; - --color-markup-table-row: #00000008; - --color-markup-code-block: #00000010; - --color-button: #fafafa; - --color-code-bg: #ffffff; - --color-code-sidebar-bg: #f5f5f5; - --color-shadow: #00000026; - --color-secondary-bg: #f4f4f4; - --color-expand-button: #d8efff; - --color-placeholder-text: #aaa; - --color-editor-line-highlight: var(--color-primary-light-6); - --color-project-board-bg: var(--color-secondary-light-4); - --color-project-board-dark-label: #111111; - --color-project-board-light-label: #eeeeee; - --color-caret: var(--color-text-dark); - --color-reaction-bg: #0000000a; - --color-reaction-hover-bg: var(--color-primary-light-5); - --color-reaction-active-bg: var(--color-primary-light-6); - --color-tooltip-text: #ffffff; - --color-tooltip-bg: #000000f0; - --color-nav-bg: #ffffff; - --color-nav-hover-bg: #ebebeb; - --color-nav-text: var(--color-text); - --color-label-text: #232323; - --color-label-bg: #cacaca5b; - --color-label-hover-bg: #cacacaa0; - --color-label-active-bg: #cacacaff; - --color-accent: var(--color-primary-light-1); - --color-small-accent: var(--color-primary-light-6); - --color-active-line: #fffbdd; - --color-overlay-backdrop: #080808c0; - accent-color: var(--color-accent); - color-scheme: light; } :root * { diff --git a/web_src/css/themes/theme-auto.css b/web_src/css/themes/theme-auto.css index e0d31e2cfbb70..509889e80225b 100644 --- a/web_src/css/themes/theme-auto.css +++ b/web_src/css/themes/theme-auto.css @@ -1 +1,2 @@ -@import "./theme-arc-green.css" (prefers-color-scheme: dark); +@import "./theme-gitea-light.css" (prefers-color-scheme: light); +@import "./theme-gitea-dark.css" (prefers-color-scheme: dark); diff --git a/web_src/css/themes/theme-arc-green.css b/web_src/css/themes/theme-gitea-dark.css similarity index 98% rename from web_src/css/themes/theme-arc-green.css rename to web_src/css/themes/theme-gitea-dark.css index 96d9f5821c389..bac002e3db5eb 100644 --- a/web_src/css/themes/theme-arc-green.css +++ b/web_src/css/themes/theme-gitea-dark.css @@ -212,11 +212,12 @@ --color-code-sidebar-bg: #232834; --color-shadow: #00000058; --color-secondary-bg: #2a2e3a; - --color-text-focus: #fff; --color-expand-button: #3c404d; --color-placeholder-text: #8a8e99; --color-editor-line-highlight: var(--color-primary-light-5); --color-project-board-bg: var(--color-secondary-light-2); + --color-project-board-dark-label: #111111; + --color-project-board-light-label: #eeeeee; --color-caret: var(--color-text); /* should ideally be --color-text-dark, see #15651 */ --color-reaction-bg: #ffffff12; --color-reaction-hover-bg: var(--color-primary-light-4); @@ -225,6 +226,7 @@ --color-tooltip-bg: #000000f0; --color-nav-bg: #232834; --color-nav-hover-bg: #383c47; + --color-nav-text: var(--color-text); --color-label-text: #dfe3ec; --color-label-bg: #7c84974b; --color-label-hover-bg: #7c8497a0; diff --git a/web_src/css/themes/theme-gitea-light.css b/web_src/css/themes/theme-gitea-light.css new file mode 100644 index 0000000000000..ca5d15cd25bae --- /dev/null +++ b/web_src/css/themes/theme-gitea-light.css @@ -0,0 +1,240 @@ +@import "../chroma/light.css"; +@import "../codemirror/light.css"; + +:root { + --is-dark-theme: false; + --color-primary: #4183c4; + --color-primary-contrast: #ffffff; + --color-primary-dark-1: #3876b3; + --color-primary-dark-2: #31699f; + --color-primary-dark-3: #2b5c8b; + --color-primary-dark-4: #254f77; + --color-primary-dark-5: #193450; + --color-primary-dark-6: #0c1a28; + --color-primary-dark-7: #04080c; + --color-primary-light-1: #548fca; + --color-primary-light-2: #679cd0; + --color-primary-light-3: #7aa8d6; + --color-primary-light-4: #8db5dc; + --color-primary-light-5: #b3cde7; + --color-primary-light-6: #d9e6f3; + --color-primary-light-7: #f4f8fb; + --color-primary-alpha-10: #4183c419; + --color-primary-alpha-20: #4183c433; + --color-primary-alpha-30: #4183c44b; + --color-primary-alpha-40: #4183c466; + --color-primary-alpha-50: #4183c480; + --color-primary-alpha-60: #4183c499; + --color-primary-alpha-70: #4183c4b3; + --color-primary-alpha-80: #4183c4cc; + --color-primary-alpha-90: #4183c4e1; + --color-primary-hover: var(--color-primary-dark-1); + --color-primary-active: var(--color-primary-dark-2); + --color-secondary: #dedede; + --color-secondary-dark-1: #cecece; + --color-secondary-dark-2: #bfbfbf; + --color-secondary-dark-3: #a0a0a0; + --color-secondary-dark-4: #909090; + --color-secondary-dark-5: #818181; + --color-secondary-dark-6: #717171; + --color-secondary-dark-7: #626262; + --color-secondary-dark-8: #525252; + --color-secondary-dark-9: #434343; + --color-secondary-dark-10: #333333; + --color-secondary-dark-11: #242424; + --color-secondary-dark-12: #141414; + --color-secondary-dark-13: #040404; + --color-secondary-light-1: #e5e5e5; + --color-secondary-light-2: #ebebeb; + --color-secondary-light-3: #f2f2f2; + --color-secondary-light-4: #f8f8f8; + --color-secondary-alpha-10: #dedede19; + --color-secondary-alpha-20: #dedede33; + --color-secondary-alpha-30: #dedede4b; + --color-secondary-alpha-40: #dedede66; + --color-secondary-alpha-50: #dedede80; + --color-secondary-alpha-60: #dedede99; + --color-secondary-alpha-70: #dededeb3; + --color-secondary-alpha-80: #dededecc; + --color-secondary-alpha-90: #dededee1; + --color-secondary-button: var(--color-secondary-dark-4); + --color-secondary-hover: var(--color-secondary-dark-5); + --color-secondary-active: var(--color-secondary-dark-6); + /* console colors - used for actions console and console files */ + --color-console-fg: #eeeff2; + --color-console-fg-subtle: #959cab; + --color-console-bg: #262936; + --color-console-border: #383c47; + --color-console-hover-bg: #ffffff16; + --color-console-active-bg: #454a57; + --color-console-menu-bg: #383c47; + --color-console-menu-border: #5c6374; + /* named colors */ + --color-red: #db2828; + --color-orange: #f2711c; + --color-yellow: #fbbd08; + --color-olive: #b5cc18; + --color-green: #21ba45; + --color-teal: #00b5ad; + --color-blue: #2185d0; + --color-violet: #6435c9; + --color-purple: #a333c8; + --color-pink: #e03997; + --color-brown: #a5673f; + --color-black: #1b1c1d; + /* light variants - produced via Sass scale-color(color, $lightness: +25%) */ + --color-red-light: #e45e5e; + --color-orange-light: #f59555; + --color-yellow-light: #fcce46; + --color-olive-light: #d3e942; + --color-green-light: #46de6a; + --color-teal-light: #08fff4; + --color-blue-light: #51a5e3; + --color-violet-light: #8b67d7; + --color-purple-light: #bb64d8; + --color-pink-light: #e86bb1; + --color-brown-light: #c58b66; + --color-black-light: #525558; + /* dark 1 variants - produced via Sass scale-color(color, $lightness: -10%) */ + --color-red-dark-1: #c82121; + --color-orange-dark-1: #e6630d; + --color-yellow-dark-1: #e5ac04; + --color-olive-dark-1: #a3b816; + --color-green-dark-1: #1ea73e; + --color-teal-dark-1: #00a39c; + --color-blue-dark-1: #1e78bb; + --color-violet-dark-1: #5a30b5; + --color-purple-dark-1: #932eb4; + --color-pink-dark-1: #db228a; + --color-brown-dark-1: #955d39; + --color-black-dark-1: #18191a; + /* dark 2 variants - produced via Sass scale-color(color, $lightness: -20%) */ + --color-red-dark-2: #b11e1e; + --color-orange-dark-2: #cc580c; + --color-yellow-dark-2: #cc9903; + --color-olive-dark-2: #91a313; + --color-green-dark-2: #1a9537; + --color-teal-dark-2: #00918a; + --color-blue-dark-2: #1a6aa6; + --color-violet-dark-2: #502aa1; + --color-purple-dark-2: #8229a0; + --color-pink-dark-2: #c21e7b; + --color-brown-dark-2: #845232; + --color-black-dark-2: #161617; + /* ansi colors used for actions console and console files */ + --color-ansi-black: var(--color-black); + --color-ansi-red: var(--color-red); + --color-ansi-green: var(--color-green); + --color-ansi-yellow: var(--color-yellow); + --color-ansi-blue: var(--color-blue); + --color-ansi-magenta: var(--color-pink); + --color-ansi-cyan: var(--color-teal); + --color-ansi-white: var(--color-console-fg-subtle); + --color-ansi-bright-black: var(--color-black-light); + --color-ansi-bright-red: var(--color-red-light); + --color-ansi-bright-green: var(--color-green-light); + --color-ansi-bright-yellow: var(--color-yellow-light); + --color-ansi-bright-blue: var(--color-blue-light); + --color-ansi-bright-magenta: var(--color-pink-light); + --color-ansi-bright-cyan: var(--color-teal-light); + --color-ansi-bright-white: var(--color-console-fg); + /* other colors */ + --color-grey: #707070; + --color-grey-light: #838383; + --color-gold: #a1882b; + --color-white: #ffffff; + --color-diff-removed-word-bg: #fdb8c0; + --color-diff-added-word-bg: #acf2bd; + --color-diff-removed-row-bg: #ffeef0; + --color-diff-moved-row-bg: #f1f8d1; + --color-diff-added-row-bg: #e6ffed; + --color-diff-removed-row-border: #f1c0c0; + --color-diff-moved-row-border: #d0e27f; + --color-diff-added-row-border: #e6ffed; + --color-diff-inactive: #f2f2f2; + --color-error-border: #e0b4b4; + --color-error-bg: #fff6f6; + --color-error-bg-active: #fbb; + --color-error-bg-hover: #fdd; + --color-error-text: #9f3a38; + --color-success-border: #a3c293; + --color-success-bg: #fcfff5; + --color-success-text: #2c662d; + --color-warning-border: #c9ba9b; + --color-warning-bg: #fffaf3; + --color-warning-text: #573a08; + --color-info-border: #a9d5de; + --color-info-bg: #f8ffff; + --color-info-text: #276f86; + --color-red-badge: #db2828; + --color-red-badge-bg: #db28281a; + --color-red-badge-hover-bg: #db28284d; + --color-green-badge: #21ba45; + --color-green-badge-bg: #21ba451a; + --color-green-badge-hover-bg: #21ba454d; + --color-yellow-badge: #fbbd08; + --color-yellow-badge-bg: #fbbd081a; + --color-yellow-badge-hover-bg: #fbbd084d; + --color-orange-badge: #f2711c; + --color-orange-badge-bg: #f2711c1a; + --color-orange-badge-hover-bg: #f2711c4d; + --color-git: #f05133; + /* target-based colors */ + --color-body: #ffffff; + --color-box-header: #f7f7f7; + --color-box-body: #ffffff; + --color-box-body-highlight: #fafafa; + --color-text-dark: #080808; + --color-text: #212121; + --color-text-light: #555555; + --color-text-light-1: #6a6a6a; + --color-text-light-2: #808080; + --color-text-light-3: #a0a0a0; + --color-footer: #ffffff; + --color-timeline: #ececec; + --color-input-text: #212121; + --color-input-background: #fafafa; + --color-input-toggle-background: #dedede; + --color-input-border: var(--color-secondary); + --color-input-border-hover: var(--color-secondary-dark-1); + --color-header-wrapper: transparent; + --color-light: #00000006; + --color-light-mimic-enabled: rgba(0, 0, 0, calc(6 / 255 * 222 / 255 / var(--opacity-disabled))); + --color-light-border: #0000001d; + --color-hover: #00000014; + --color-active: #0000001b; + --color-menu: #fafafa; + --color-card: #fafafa; + --color-markup-table-row: #00000008; + --color-markup-code-block: #00000010; + --color-button: #fafafa; + --color-code-bg: #ffffff; + --color-code-sidebar-bg: #f5f5f5; + --color-shadow: #00000026; + --color-secondary-bg: #f4f4f4; + --color-expand-button: #d8efff; + --color-placeholder-text: #aaa; + --color-editor-line-highlight: var(--color-primary-light-6); + --color-project-board-bg: var(--color-secondary-light-4); + --color-project-board-dark-label: #111111; + --color-project-board-light-label: #eeeeee; + --color-caret: var(--color-text-dark); + --color-reaction-bg: #0000000a; + --color-reaction-hover-bg: var(--color-primary-light-5); + --color-reaction-active-bg: var(--color-primary-light-6); + --color-tooltip-text: #ffffff; + --color-tooltip-bg: #000000f0; + --color-nav-bg: #ffffff; + --color-nav-hover-bg: #ebebeb; + --color-nav-text: var(--color-text); + --color-label-text: #232323; + --color-label-bg: #cacaca5b; + --color-label-hover-bg: #cacacaa0; + --color-label-active-bg: #cacacaff; + --color-accent: var(--color-primary-light-1); + --color-small-accent: var(--color-primary-light-6); + --color-active-line: #fffbdd; + --color-overlay-backdrop: #080808c0; + accent-color: var(--color-accent); + color-scheme: light; +} From 22d55395e1d3a95088ee4916975fcb2a306a48af Mon Sep 17 00:00:00 2001 From: silverwind Date: Wed, 4 Oct 2023 00:11:50 +0200 Subject: [PATCH 02/26] update comments --- web_src/css/base.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web_src/css/base.css b/web_src/css/base.css index 0ac49ab20d577..0727526140620 100644 --- a/web_src/css/base.css +++ b/web_src/css/base.css @@ -11,11 +11,11 @@ --font-weight-bold: 700; /* line-height: use the default value as "modules/normalize.css" */ --line-height-default: normal; - /* backgrounds */ + /* icons */ --checkbox-mask-checked: url('data:image/svg+xml;utf8,'); --checkbox-mask-indeterminate: url('data:image/svg+xml;utf8,'); --octicon-chevron-right: url('data:image/svg+xml;utf8,'); - /* non-color variables */ + /* other variables */ --border-radius: 4px; --border-radius-medium: 6px; --border-radius-circle: 50%; From ad15442fa1134691c64ce919351c18d3e7570f43 Mon Sep 17 00:00:00 2001 From: silverwind Date: Wed, 4 Oct 2023 00:13:44 +0200 Subject: [PATCH 03/26] remove unnecessary imports --- web_src/css/index.css | 4 ---- 1 file changed, 4 deletions(-) diff --git a/web_src/css/index.css b/web_src/css/index.css index d399f073d557f..c1360bb19446c 100644 --- a/web_src/css/index.css +++ b/web_src/css/index.css @@ -32,11 +32,7 @@ @import "./markup/asciicast.css"; @import "./chroma/base.css"; -@import "./chroma/light.css"; - @import "./codemirror/base.css"; -@import "./codemirror/light.css"; - @import "./font_i18n.css"; @import "./base.css"; @import "./home.css"; From 8236639d2c5b3b6af155343f00621759bbc8aac1 Mon Sep 17 00:00:00 2001 From: silverwind Date: Wed, 4 Oct 2023 00:19:26 +0200 Subject: [PATCH 04/26] fmt --- models/migrations/migrations.go | 1 - 1 file changed, 1 deletion(-) diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index 8733452901418..85ef9c68cc7d4 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -544,7 +544,6 @@ var migrations = []Migration{ // v279 -> v280 NewMigration("Rename user themes", v1_22.RenameUserThemes), - } // GetCurrentDBVersion returns the current db version From 7d054ad1bb4f881f62d0231f2e4ef6416bc207b1 Mon Sep 17 00:00:00 2001 From: silverwind Date: Wed, 4 Oct 2023 00:32:08 +0200 Subject: [PATCH 05/26] quote postgres reserved name 'user' --- models/migrations/v1_22/v279.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/migrations/v1_22/v279.go b/models/migrations/v1_22/v279.go index 699caad9549c9..5fb381edb331e 100644 --- a/models/migrations/v1_22/v279.go +++ b/models/migrations/v1_22/v279.go @@ -15,10 +15,10 @@ func RenameUserThemes(x *xorm.Engine) error { return err } - if _, err := sess.Exec(`UPDATE user SET theme = 'gitea-light' WHERE theme = 'gitea'`); err != nil { + if _, err := sess.Exec("UPDATE `user` SET theme = 'gitea-light' WHERE theme = 'gitea'"); err != nil { return err } - if _, err := sess.Exec(`UPDATE user SET theme = 'gitea-dark' WHERE theme = 'arc-green'`); err != nil { + if _, err := sess.Exec("UPDATE `user` SET theme = 'gitea-dark' WHERE theme = 'arc-green'"); err != nil { return err } From 35b7f19e6d136d3040bf81cbdbae4dd63695751e Mon Sep 17 00:00:00 2001 From: silverwind Date: Wed, 4 Oct 2023 00:41:24 +0200 Subject: [PATCH 06/26] quote everything --- models/migrations/v1_22/v279.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/migrations/v1_22/v279.go b/models/migrations/v1_22/v279.go index 5fb381edb331e..9da9ac83066b7 100644 --- a/models/migrations/v1_22/v279.go +++ b/models/migrations/v1_22/v279.go @@ -15,10 +15,10 @@ func RenameUserThemes(x *xorm.Engine) error { return err } - if _, err := sess.Exec("UPDATE `user` SET theme = 'gitea-light' WHERE theme = 'gitea'"); err != nil { + if _, err := sess.Exec("UPDATE `user` SET `theme` = 'gitea-light' WHERE `theme` = 'gitea'"); err != nil { return err } - if _, err := sess.Exec("UPDATE `user` SET theme = 'gitea-dark' WHERE theme = 'arc-green'"); err != nil { + if _, err := sess.Exec("UPDATE `user` SET `theme` = 'gitea-dark' WHERE `theme` = 'arc-green'"); err != nil { return err } From f4a07f32f469a9ec882177cd9a1c87ca18a3e09e Mon Sep 17 00:00:00 2001 From: silverwind Date: Wed, 4 Oct 2023 01:08:45 +0200 Subject: [PATCH 07/26] change comment --- web_src/css/base.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_src/css/base.css b/web_src/css/base.css index 0727526140620..efb2553db4c88 100644 --- a/web_src/css/base.css +++ b/web_src/css/base.css @@ -11,7 +11,7 @@ --font-weight-bold: 700; /* line-height: use the default value as "modules/normalize.css" */ --line-height-default: normal; - /* icons */ + /* images */ --checkbox-mask-checked: url('data:image/svg+xml;utf8,'); --checkbox-mask-indeterminate: url('data:image/svg+xml;utf8,'); --octicon-chevron-right: url('data:image/svg+xml;utf8,'); From fa0ec534fe56d1790226ee22c5c477d13e1f84db Mon Sep 17 00:00:00 2001 From: silverwind Date: Wed, 4 Oct 2023 23:29:08 +0200 Subject: [PATCH 08/26] add changes --- custom/conf/app.example.ini | 2 +- docs/content/administration/config-cheat-sheet.en-us.md | 4 ++-- docs/content/administration/config-cheat-sheet.zh-cn.md | 4 ++-- docs/content/help/faq.en-us.md | 2 +- docs/content/help/faq.zh-cn.md | 2 +- modules/setting/ui.go | 2 +- templates/base/head.tmpl | 2 +- templates/base/head_style.tmpl | 8 +------- 8 files changed, 10 insertions(+), 16 deletions(-) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index fbd41c93facf0..99ea16156909a 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -1212,7 +1212,7 @@ LEVEL = Info ;DEFAULT_THEME = auto ;; ;; All available themes. Allow users select personalized themes regardless of the value of `DEFAULT_THEME`. -;THEMES = auto,gitea-light,gitea-dark +;THEMES = gitea-auto,gitea-light,gitea-dark ;; ;; All available reactions users can choose on issues/prs and comments. ;; Values can be emoji alias (:smile:) or a unicode emoji. diff --git a/docs/content/administration/config-cheat-sheet.en-us.md b/docs/content/administration/config-cheat-sheet.en-us.md index 1acfb6354e41d..8bb2b19c280f5 100644 --- a/docs/content/administration/config-cheat-sheet.en-us.md +++ b/docs/content/administration/config-cheat-sheet.en-us.md @@ -215,9 +215,9 @@ The following configuration set `Content-Type: application/vnd.android.package-a - `SITEMAP_PAGING_NUM`: **20**: Number of items that are displayed in a single subsitemap. - `GRAPH_MAX_COMMIT_NUM`: **100**: Number of maximum commits shown in the commit graph. - `CODE_COMMENT_LINES`: **4**: Number of line of codes shown for a code comment. -- `DEFAULT_THEME`: **auto**: \[auto, gitea-light, gitea-dark\]: Set the default theme for the Gitea install. +- `DEFAULT_THEME`: **gitea-auto**: \[gitea-auto, gitea-light, gitea-dark\]: Set the default theme for the Gitea installation. - `SHOW_USER_EMAIL`: **true**: Whether the email of the user should be shown in the Explore Users page. -- `THEMES`: **auto,gitea-light,gitea-dark**: All available themes. Allow users select personalized themes. +- `THEMES`: **gitea-auto,gitea-light,gitea-dark**: All available themes. Allow users select personalized themes. regardless of the value of `DEFAULT_THEME`. - `MAX_DISPLAY_FILE_SIZE`: **8388608**: Max size of files to be displayed (default is 8MiB) - `REACTIONS`: All available reactions users can choose on issues/prs and comments diff --git a/docs/content/administration/config-cheat-sheet.zh-cn.md b/docs/content/administration/config-cheat-sheet.zh-cn.md index 76e9afb2c0acc..fbd65a1919a60 100644 --- a/docs/content/administration/config-cheat-sheet.zh-cn.md +++ b/docs/content/administration/config-cheat-sheet.zh-cn.md @@ -214,9 +214,9 @@ menu: - `SITEMAP_PAGING_NUM`: **20**: 在单个子SiteMap中显示的项数。 - `GRAPH_MAX_COMMIT_NUM`: **100**: 提交图中显示的最大commit数量。 - `CODE_COMMENT_LINES`: **4**: 在代码评论中能够显示的最大代码行数。 -- `DEFAULT_THEME`: **auto**: \[auto, gitea-light, gitea-dark\]: 在Gitea安装时候设置的默认主题。 +- `DEFAULT_THEME`: **gitea-auto**: \[gitea-auto, gitea-light, gitea-dark\]: 在Gitea安装时候设置的默认主题。 - `SHOW_USER_EMAIL`: **true**: 用户的电子邮件是否应该显示在`Explore Users`页面中。 -- `THEMES`: **auto,gitea-light,gitea-dark**: 所有可用的主题。允许用户选择个性化的主题, +- `THEMES`: **gitea-auto,gitea-light,gitea-dark**: 所有可用的主题。允许用户选择个性化的主题, 而不受DEFAULT_THEME 值的影响。 - `MAX_DISPLAY_FILE_SIZE`: **8388608**: 能够显示文件的最大大小(默认为8MiB)。 - `REACTIONS`: 用户可以在问题(Issue)、Pull Request(PR)以及评论中选择的所有可选的反应。 diff --git a/docs/content/help/faq.en-us.md b/docs/content/help/faq.en-us.md index d52b88f3a5b78..b4f5171bcfd92 100644 --- a/docs/content/help/faq.en-us.md +++ b/docs/content/help/faq.en-us.md @@ -181,7 +181,7 @@ Use [Fail2Ban](administration/fail2ban-setup.md) to monitor and stop automated l ## How to add/use custom themes -Gitea supports three official themes right now, `gitea-light`, `gitea-dark`, and `auto` (automatically switches between the previous two depending on operating system settings). +Gitea supports three official themes right now, `gitea-light`, `gitea-dark`, and `gitea-auto` (automatically switches between the previous two depending on operating system settings). To add your own theme, currently the only way is to provide a complete theme (not just color overrides) As an example, let's say our theme is `arc-blue` (this is a real theme, and can be found [in this issue](https://github.com/go-gitea/gitea/issues/6011)) diff --git a/docs/content/help/faq.zh-cn.md b/docs/content/help/faq.zh-cn.md index e21a1d4c69f4c..ff53fc1d03969 100644 --- a/docs/content/help/faq.zh-cn.md +++ b/docs/content/help/faq.zh-cn.md @@ -185,7 +185,7 @@ Gitea不提供内置的Pages服务器。您需要一个专用的域名来提供 ## 如何添加/使用自定义主题 -Gitea 目前支持三个官方主题,分别是 `gitea-light`、`gitea-dark` 和 `auto`(根据操作系统设置自动切换前两个主题)。 +Gitea 目前支持三个官方主题,分别是 `gitea-light`、`gitea-dark` 和 `gitea-auto`(根据操作系统设置自动切换前两个主题)。 要添加自己的主题,目前唯一的方法是提供一个完整的主题(不仅仅是颜色覆盖)。 假设我们的主题是 `arc-blue`(这是一个真实的主题,可以在[此问题](https://github.com/go-gitea/gitea/issues/6011)中找到) diff --git a/modules/setting/ui.go b/modules/setting/ui.go index 1b7207b1caee1..70178eb47d77f 100644 --- a/modules/setting/ui.go +++ b/modules/setting/ui.go @@ -77,7 +77,7 @@ var UI = struct { ReactionMaxUserNum: 10, MaxDisplayFileSize: 8388608, DefaultTheme: `auto`, - Themes: []string{`auto`, `gitea-light`, `gitea-dark`}, + Themes: []string{`gitea-auto`, `gitea-light`, `gitea-dark`}, Reactions: []string{`+1`, `-1`, `laugh`, `hooray`, `confused`, `heart`, `rocket`, `eyes`}, CustomEmojis: []string{`git`, `gitea`, `codeberg`, `gitlab`, `github`, `gogs`}, CustomEmojisMap: map[string]string{"git": ":git:", "gitea": ":gitea:", "codeberg": ":codeberg:", "gitlab": ":gitlab:", "github": ":github:", "gogs": ":gogs:"}, diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index c3645209cd604..78d35648e7b4f 100644 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -1,5 +1,5 @@ - + {{if .Title}}{{.Title | RenderEmojiPlain}} - {{end}}{{if .Repository.Name}}{{.Repository.Name}} - {{end}}{{AppName}} diff --git a/templates/base/head_style.tmpl b/templates/base/head_style.tmpl index 7e8cba2aedde0..5e24c787dd0c8 100644 --- a/templates/base/head_style.tmpl +++ b/templates/base/head_style.tmpl @@ -1,8 +1,2 @@ -{{if .IsSigned}} - {{if ne .SignedUser.Theme "gitea"}} - - {{end}} -{{else if ne DefaultTheme "gitea"}} - -{{end}} + From ae579f9706279d5d79ffe19abe1181e575f219db Mon Sep 17 00:00:00 2001 From: silverwind Date: Wed, 4 Oct 2023 23:30:31 +0200 Subject: [PATCH 09/26] format --- models/migrations/v1_22/v280.go | 1 - 1 file changed, 1 deletion(-) diff --git a/models/migrations/v1_22/v280.go b/models/migrations/v1_22/v280.go index ca7663906b213..a8ee4a3bf7dac 100644 --- a/models/migrations/v1_22/v280.go +++ b/models/migrations/v1_22/v280.go @@ -21,7 +21,6 @@ func RenameUserThemes(x *xorm.Engine) error { if _, err := sess.Exec("UPDATE `user` SET `theme` = 'gitea-dark' WHERE `theme` = 'arc-green'"); err != nil { return err } - if _, err := sess.Exec("UPDATE `user` SET `theme` = 'gitea-auto' WHERE `theme` = 'auto'"); err != nil { return err } From ec00837594b540e0035075403165e53d9910a006 Mon Sep 17 00:00:00 2001 From: silverwind Date: Wed, 4 Oct 2023 23:35:48 +0200 Subject: [PATCH 10/26] share a sub-template for theme name --- templates/base/head.tmpl | 2 +- templates/base/head_style.tmpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index 78d35648e7b4f..aa1cbcd46a0d2 100644 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -1,5 +1,5 @@ - + {{if .Title}}{{.Title | RenderEmojiPlain}} - {{end}}{{if .Repository.Name}}{{.Repository.Name}} - {{end}}{{AppName}} diff --git a/templates/base/head_style.tmpl b/templates/base/head_style.tmpl index 5e24c787dd0c8..0369b603a8e63 100644 --- a/templates/base/head_style.tmpl +++ b/templates/base/head_style.tmpl @@ -1,2 +1,2 @@ - + From 0a6bc051f447f3f807db58f723bbf897e5f603b9 Mon Sep 17 00:00:00 2001 From: silverwind Date: Wed, 4 Oct 2023 23:36:11 +0200 Subject: [PATCH 11/26] add file --- templates/shared/misc/theme_name.tmpl | 1 + 1 file changed, 1 insertion(+) create mode 100644 templates/shared/misc/theme_name.tmpl diff --git a/templates/shared/misc/theme_name.tmpl b/templates/shared/misc/theme_name.tmpl new file mode 100644 index 0000000000000..1bdd3e8030536 --- /dev/null +++ b/templates/shared/misc/theme_name.tmpl @@ -0,0 +1 @@ +theme-{{if and .SignedUser .SignedUser.Theme}}{{.SignedUser.Theme | PathEscape}}{{else}}{{DefaultTheme | PathEscape}}{{end}} From 9ae37a81815b2e3b12dc2e9b75fb50cdc505150c Mon Sep 17 00:00:00 2001 From: silverwind Date: Wed, 4 Oct 2023 23:40:50 +0200 Subject: [PATCH 12/26] move shared/misc to misc --- templates/base/head.tmpl | 2 +- templates/base/head_style.tmpl | 2 +- templates/{shared => }/misc/theme_name.tmpl | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename templates/{shared => }/misc/theme_name.tmpl (100%) diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index aa1cbcd46a0d2..892f8b524ed86 100644 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -1,5 +1,5 @@ - + {{if .Title}}{{.Title | RenderEmojiPlain}} - {{end}}{{if .Repository.Name}}{{.Repository.Name}} - {{end}}{{AppName}} diff --git a/templates/base/head_style.tmpl b/templates/base/head_style.tmpl index 0369b603a8e63..e6414194866e5 100644 --- a/templates/base/head_style.tmpl +++ b/templates/base/head_style.tmpl @@ -1,2 +1,2 @@ - + diff --git a/templates/shared/misc/theme_name.tmpl b/templates/misc/theme_name.tmpl similarity index 100% rename from templates/shared/misc/theme_name.tmpl rename to templates/misc/theme_name.tmpl From 6f278431260dd9e0bb0a0c17885c85115b621474 Mon Sep 17 00:00:00 2001 From: silverwind Date: Wed, 4 Oct 2023 23:59:10 +0200 Subject: [PATCH 13/26] fix DEFAULT_THEME in app.example.ini --- custom/conf/app.example.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index 99ea16156909a..a4ff78fb358f8 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -1209,7 +1209,7 @@ LEVEL = Info ;SHOW_USER_EMAIL = true ;; ;; Set the default theme for the Gitea install -;DEFAULT_THEME = auto +;DEFAULT_THEME = gitea-auto ;; ;; All available themes. Allow users select personalized themes regardless of the value of `DEFAULT_THEME`. ;THEMES = gitea-auto,gitea-light,gitea-dark From e34f2c35d117ccbaa68230ae2603b769675e3f72 Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 5 Oct 2023 00:00:25 +0200 Subject: [PATCH 14/26] fix DefaultTheme in ui.go --- modules/setting/ui.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/setting/ui.go b/modules/setting/ui.go index 70178eb47d77f..231698bf60589 100644 --- a/modules/setting/ui.go +++ b/modules/setting/ui.go @@ -76,7 +76,7 @@ var UI = struct { CodeCommentLines: 4, ReactionMaxUserNum: 10, MaxDisplayFileSize: 8388608, - DefaultTheme: `auto`, + DefaultTheme: `gitea-auto`, Themes: []string{`gitea-auto`, `gitea-light`, `gitea-dark`}, Reactions: []string{`+1`, `-1`, `laugh`, `hooray`, `confused`, `heart`, `rocket`, `eyes`}, CustomEmojis: []string{`git`, `gitea`, `codeberg`, `gitlab`, `github`, `gogs`}, From a6b176f37f7b66e01bec3b006f5df192eadfdff4 Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 5 Oct 2023 00:06:39 +0200 Subject: [PATCH 15/26] more doc updates --- docs/content/administration/customizing-gitea.en-us.md | 5 +++-- docs/content/administration/customizing-gitea.zh-cn.md | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/content/administration/customizing-gitea.en-us.md b/docs/content/administration/customizing-gitea.en-us.md index 4c2d7ed0c418b..d122fb4bfaac0 100644 --- a/docs/content/administration/customizing-gitea.en-us.md +++ b/docs/content/administration/customizing-gitea.en-us.md @@ -370,7 +370,8 @@ A full list of supported emoji's is at [emoji list](https://gitea.com/gitea/gite ## Customizing the look of Gitea -The default built-in themes are `gitea` (light), `arc-green` (dark), and `auto` (chooses light or dark depending on operating system settings). +The built-in themes are `gitea-light`, `gitea-dark`, and `gitea-auto` (which automatically adapts to OS settings). + The default theme can be changed via `DEFAULT_THEME` in the [ui](administration/config-cheat-sheet.md#ui-ui) section of `app.ini`. Gitea also has support for user themes, which means every user can select which theme should be used. @@ -384,7 +385,7 @@ To make a custom theme available to all users: Community themes are listed in [gitea/awesome-gitea#themes](https://gitea.com/gitea/awesome-gitea#themes). -The `arc-green` theme source can be found [here](https://github.com/go-gitea/gitea/blob/main/web_src/css/themes/theme-arc-green.css). +The default theme sources can be found [here](https://github.com/go-gitea/gitea/blob/main/web_src/css/themes). If your custom theme is considered a dark theme, set the global css variable `--is-dark-theme` to `true`. This allows Gitea to adjust the Monaco code editor's theme accordingly. diff --git a/docs/content/administration/customizing-gitea.zh-cn.md b/docs/content/administration/customizing-gitea.zh-cn.md index 2babf03da79bf..d828704557cfa 100644 --- a/docs/content/administration/customizing-gitea.zh-cn.md +++ b/docs/content/administration/customizing-gitea.zh-cn.md @@ -86,5 +86,6 @@ Gitea 引用 `custom` 目录中的自定义配置文件来覆盖配置、模板 ## 更改 Gitea 外观 -Gitea 目前由两种内置主题,分别为默认 `gitea` 主题和深色主题 `arc-green`,您可以通过修改 -`app.ini` [ui](administration/config-cheat-sheet.md#ui-ui) 部分的 `DEFAULT_THEME` 的值来变更至一个可用的 Gitea 外观。 +内置主题是“gitea-light”、“gitea-dark”和“gitea-auto”(自动适应操作系统设置)。 + +默认主题可以通过 `app.ini` 的 [ui](administration/config-cheat-sheet.md#ui-ui) 部分中的 `DEFAULT_THEME` 进行更改。 From 4bb8ac16ee9a2d83a91e17dee33e76a49fee666a Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 5 Oct 2023 00:35:28 +0200 Subject: [PATCH 16/26] use helper function --- modules/templates/helper.go | 6 +++++- templates/base/head.tmpl | 2 +- templates/base/head_style.tmpl | 2 +- templates/misc/theme_name.tmpl | 1 - templates/status/500.tmpl | 4 ++-- 5 files changed, 9 insertions(+), 6 deletions(-) delete mode 100644 templates/misc/theme_name.tmpl diff --git a/modules/templates/helper.go b/modules/templates/helper.go index bb1411cbfdb3e..5ff51e4a08d3a 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -131,9 +131,13 @@ func NewFuncMap() template.FuncMap { "DisableImportLocal": func() bool { return !setting.ImportLocalPaths }, - "DefaultTheme": func() string { + "ThemeName": func(userTheme string) string { + if userTheme != "" { + return userTheme + } return setting.UI.DefaultTheme }, + "NotificationSettings": func() map[string]any { return map[string]any{ "MinTimeout": int(setting.UI.Notification.MinTimeout / time.Millisecond), diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index 892f8b524ed86..eeddc955f2961 100644 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -1,5 +1,5 @@ - + {{if .Title}}{{.Title | RenderEmojiPlain}} - {{end}}{{if .Repository.Name}}{{.Repository.Name}} - {{end}}{{AppName}} diff --git a/templates/base/head_style.tmpl b/templates/base/head_style.tmpl index e6414194866e5..5521586b9eaa2 100644 --- a/templates/base/head_style.tmpl +++ b/templates/base/head_style.tmpl @@ -1,2 +1,2 @@ - + diff --git a/templates/misc/theme_name.tmpl b/templates/misc/theme_name.tmpl deleted file mode 100644 index 1bdd3e8030536..0000000000000 --- a/templates/misc/theme_name.tmpl +++ /dev/null @@ -1 +0,0 @@ -theme-{{if and .SignedUser .SignedUser.Theme}}{{.SignedUser.Theme | PathEscape}}{{else}}{{DefaultTheme | PathEscape}}{{end}} diff --git a/templates/status/500.tmpl b/templates/status/500.tmpl index 5488976da2884..8e27bc0f7f26b 100644 --- a/templates/status/500.tmpl +++ b/templates/status/500.tmpl @@ -1,12 +1,12 @@ {{/* This page should only depend the minimal template functions/variables, to avoid triggering new panics. -* base template functions: AppName, AssetUrlPrefix, AssetVersion, AppSubUrl, DefaultTheme, Str2html +* base template functions: AppName, AssetUrlPrefix, AssetVersion, AppSubUrl, ThemeName, Str2html * locale * Flash * ErrorMsg * SignedUser (optional) */}} - + Internal Server Error - {{AppName}} From ad21ba11d73c0cc1ac882147e772cc45f9963b62 Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 5 Oct 2023 00:38:42 +0200 Subject: [PATCH 17/26] format --- modules/templates/helper.go | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/templates/helper.go b/modules/templates/helper.go index 5ff51e4a08d3a..ca6bb664c759c 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -137,7 +137,6 @@ func NewFuncMap() template.FuncMap { } return setting.UI.DefaultTheme }, - "NotificationSettings": func() map[string]any { return map[string]any{ "MinTimeout": int(setting.UI.Notification.MinTimeout / time.Millisecond), From c2eff828690e9352102f1d2931f7d38f13da3f14 Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 5 Oct 2023 00:54:03 +0200 Subject: [PATCH 18/26] move theme name to data-theme --- templates/base/head.tmpl | 2 +- templates/status/500.tmpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index eeddc955f2961..d5be13e5740f6 100644 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -1,5 +1,5 @@ - + {{if .Title}}{{.Title | RenderEmojiPlain}} - {{end}}{{if .Repository.Name}}{{.Repository.Name}} - {{end}}{{AppName}} diff --git a/templates/status/500.tmpl b/templates/status/500.tmpl index 8e27bc0f7f26b..1f844bf74c0e9 100644 --- a/templates/status/500.tmpl +++ b/templates/status/500.tmpl @@ -6,7 +6,7 @@ * SignedUser (optional) */}} - + Internal Server Error - {{AppName}} From 913b659b1a53c89bb651f1f009698f1c0e21686c Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 5 Oct 2023 02:29:53 +0200 Subject: [PATCH 19/26] fix ThemeName when nil is passed --- modules/templates/helper.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/templates/helper.go b/modules/templates/helper.go index ca6bb664c759c..7423a697e2ad5 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -9,6 +9,7 @@ import ( "html" "html/template" "net/url" + "reflect" "strings" "time" @@ -131,9 +132,9 @@ func NewFuncMap() template.FuncMap { "DisableImportLocal": func() bool { return !setting.ImportLocalPaths }, - "ThemeName": func(userTheme string) string { - if userTheme != "" { - return userTheme + "ThemeName": func(userTheme any) string { + if reflect.ValueOf(userTheme).Kind() == reflect.String && userTheme != "" { + return userTheme.(string) } return setting.UI.DefaultTheme }, From 9f4e6c7d57be7edb4f43dc8379339eb84d62419b Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 5 Oct 2023 15:22:22 +0200 Subject: [PATCH 20/26] Update modules/templates/helper.go Co-authored-by: Lunny Xiao --- modules/templates/helper.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/templates/helper.go b/modules/templates/helper.go index 7423a697e2ad5..79283452aaec4 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -133,8 +133,8 @@ func NewFuncMap() template.FuncMap { return !setting.ImportLocalPaths }, "ThemeName": func(userTheme any) string { - if reflect.ValueOf(userTheme).Kind() == reflect.String && userTheme != "" { - return userTheme.(string) + if themeName, ok := userTheme.(string) && ok && themeName != "" { + return themeName } return setting.UI.DefaultTheme }, From d8e0f142fde0031e591a43023871bdb7e7dd0df3 Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 5 Oct 2023 15:24:59 +0200 Subject: [PATCH 21/26] Update modules/templates/helper.go --- modules/templates/helper.go | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/templates/helper.go b/modules/templates/helper.go index 79283452aaec4..ecbdc43051807 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -9,7 +9,6 @@ import ( "html" "html/template" "net/url" - "reflect" "strings" "time" From 4073392a873909bbe680de2ea6b9e3264f843249 Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 5 Oct 2023 23:29:57 +0200 Subject: [PATCH 22/26] fix syntax --- modules/templates/helper.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/templates/helper.go b/modules/templates/helper.go index ecbdc43051807..570ffe464e3f7 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -132,7 +132,7 @@ func NewFuncMap() template.FuncMap { return !setting.ImportLocalPaths }, "ThemeName": func(userTheme any) string { - if themeName, ok := userTheme.(string) && ok && themeName != "" { + if themeName, ok := userTheme.(string); ok && themeName != "" { return themeName } return setting.UI.DefaultTheme From 5ff07a9a04819b98415b969590e718fdb48c76c9 Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 5 Oct 2023 23:38:46 +0200 Subject: [PATCH 23/26] pass in user into ThemeName --- modules/templates/helper.go | 9 +++++---- templates/base/head.tmpl | 2 +- templates/base/head_style.tmpl | 2 +- templates/status/500.tmpl | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/modules/templates/helper.go b/modules/templates/helper.go index 570ffe464e3f7..471ff68b63bfa 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -21,6 +21,7 @@ import ( "code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/services/gitdiff" + user_model "code.gitea.io/gitea/models/user" ) // NewFuncMap returns functions for injecting to templates @@ -131,11 +132,11 @@ func NewFuncMap() template.FuncMap { "DisableImportLocal": func() bool { return !setting.ImportLocalPaths }, - "ThemeName": func(userTheme any) string { - if themeName, ok := userTheme.(string); ok && themeName != "" { - return themeName + "ThemeName": func(user *user_model.User) string { + if user == nil || user.Theme == "" { + return setting.UI.DefaultTheme } - return setting.UI.DefaultTheme + return user.Theme }, "NotificationSettings": func() map[string]any { return map[string]any{ diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index d5be13e5740f6..876b42d512b18 100644 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -1,5 +1,5 @@ - + {{if .Title}}{{.Title | RenderEmojiPlain}} - {{end}}{{if .Repository.Name}}{{.Repository.Name}} - {{end}}{{AppName}} diff --git a/templates/base/head_style.tmpl b/templates/base/head_style.tmpl index 5521586b9eaa2..0793eaca20dc4 100644 --- a/templates/base/head_style.tmpl +++ b/templates/base/head_style.tmpl @@ -1,2 +1,2 @@ - + diff --git a/templates/status/500.tmpl b/templates/status/500.tmpl index 1f844bf74c0e9..e5570bde738da 100644 --- a/templates/status/500.tmpl +++ b/templates/status/500.tmpl @@ -6,7 +6,7 @@ * SignedUser (optional) */}} - + Internal Server Error - {{AppName}} From dbb6ae81d824ae1e7372177a297053426cf6c48e Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 5 Oct 2023 23:42:52 +0200 Subject: [PATCH 24/26] remove useless PathEscape, go does it fine --- templates/base/head_style.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/base/head_style.tmpl b/templates/base/head_style.tmpl index 0793eaca20dc4..8a9ed1618e251 100644 --- a/templates/base/head_style.tmpl +++ b/templates/base/head_style.tmpl @@ -1,2 +1,2 @@ - + From f6917af20777ac9a57f05bb9d4e102065b574959 Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 5 Oct 2023 23:50:52 +0200 Subject: [PATCH 25/26] PathEscape still needed for slashes --- templates/base/head_style.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/base/head_style.tmpl b/templates/base/head_style.tmpl index 8a9ed1618e251..0793eaca20dc4 100644 --- a/templates/base/head_style.tmpl +++ b/templates/base/head_style.tmpl @@ -1,2 +1,2 @@ - + From b97ab3461f5ae8e7ec0e8d0b636b236358c3cfab Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 5 Oct 2023 23:56:41 +0200 Subject: [PATCH 26/26] fmt --- modules/templates/helper.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/templates/helper.go b/modules/templates/helper.go index 471ff68b63bfa..235fd96b73d8f 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -12,6 +12,7 @@ import ( "strings" "time" + user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/emoji" "code.gitea.io/gitea/modules/markup" @@ -21,7 +22,6 @@ import ( "code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/services/gitdiff" - user_model "code.gitea.io/gitea/models/user" ) // NewFuncMap returns functions for injecting to templates