Skip to content

Commit b65ad70

Browse files
je-ssilverwindzeripathlunnylafriks
authored
Add the possibility to allow the user to have a favicon which differs from the main logo (go-gitea#18542)
* Changed the filename of the favicon SVG This allows the user to have a favicon which differs from the logo. * Added favicon.svg This is needed to accommodate the changes for allowing the user to have a differing logo and favicon * Adjusted page to accommodate what icon is used as favicon * Added functionality to also generate the favicon.svg via generate-images.js * Adjusted the description for the new favicon compatibility Co-authored-by: silverwind <[email protected]> * Updated generate-images.js to generate favicons from a separate favicons.svg file This belongs to PR go-gitea#18542. * Added description on how custom favicons can be generated * Replaced space indents with tabs * Synced changes with current state of the file * Synced changes with current state of the file Co-authored-by: silverwind <[email protected]> Co-authored-by: zeripath <[email protected]> Co-authored-by: Lunny Xiao <[email protected]> Co-authored-by: Lauris BH <[email protected]>
1 parent d2a91e5 commit b65ad70

File tree

4 files changed

+47
-12
lines changed

4 files changed

+47
-12
lines changed

assets/favicon.svg

+31
Loading

build/generate-images.js

+10-7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {fileURLToPath} from 'url';
88
const {readFile, writeFile} = fs.promises;
99
const __dirname = dirname(fileURLToPath(import.meta.url));
1010
const logoFile = resolve(__dirname, '../assets/logo.svg');
11+
const faviconFile = resolve(__dirname, '../assets/favicon.svg');
1112

1213
function exit(err) {
1314
if (err) console.error(err);
@@ -68,15 +69,17 @@ async function generate(svg, outputFile, {size, bg}) {
6869

6970
async function main() {
7071
const gitea = process.argv.slice(2).includes('gitea');
71-
const svg = await readFile(logoFile, 'utf8');
72+
const logoSvg = await readFile(logoFile, 'utf8');
73+
const faviconSvg = await readFile(faviconFile, 'utf8');
7274

7375
await Promise.all([
74-
generate(svg, resolve(__dirname, '../public/img/logo.svg'), {size: 32}),
75-
generate(svg, resolve(__dirname, '../public/img/logo.png'), {size: 512}),
76-
generate(svg, resolve(__dirname, '../public/img/favicon.png'), {size: 180}),
77-
generate(svg, resolve(__dirname, '../public/img/avatar_default.png'), {size: 200}),
78-
generate(svg, resolve(__dirname, '../public/img/apple-touch-icon.png'), {size: 180, bg: true}),
79-
gitea && generate(svg, resolve(__dirname, '../public/img/gitea.svg'), {size: 32}),
76+
generate(logoSvg, resolve(__dirname, '../public/img/logo.svg'), {size: 32}),
77+
generate(logoSvg, resolve(__dirname, '../public/img/logo.png'), {size: 512}),
78+
generate(faviconSvg, resolve(__dirname, '../public/img/favicon.svg'), {size: 32}),
79+
generate(faviconSvg, resolve(__dirname, '../public/img/favicon.png'), {size: 180}),
80+
generate(logoSvg, resolve(__dirname, '../public/img/avatar_default.png'), {size: 200}),
81+
generate(logoSvg, resolve(__dirname, '../public/img/apple-touch-icon.png'), {size: 180, bg: true}),
82+
gitea && generate(logoSvg, resolve(__dirname, '../public/img/gitea.svg'), {size: 32}),
8083
]);
8184
}
8285

docs/content/doc/advanced/customizing-gitea.en-us.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,15 @@ the url `http://gitea.domain.tld/assets/image.png`.
6060

6161
## Changing the logo
6262

63-
To build a custom logo clone the Gitea source repository, replace `assets/logo.svg` and run
64-
`make generate-images`. This will update below output files which you can then place in `$GITEA_CUSTOM/public/img` on your server:
63+
To build a custom logo and/or favicon clone the Gitea source repository, replace `assets/logo.svg` and/or `assets/favicon.svg` and run
64+
`make generate-images`. `assets/favicon.svg` is used for the favicon only. This will update below output files which you can then place in `$GITEA_CUSTOM/public/img` on your server:
6565

66-
- `public/img/logo.svg` - Used for favicon, site icon, app icon
66+
- `public/img/logo.svg` - Used for site icon, app icon
6767
- `public/img/logo.png` - Used for Open Graph
68-
- `public/img/favicon.png` - Used as fallback for browsers that don't support SVG favicons
6968
- `public/img/avatar_default.png` - Used as the default avatar image
7069
- `public/img/apple-touch-icon.png` - Used on iOS devices for bookmarks
70+
- `public/img/favicon.svg` - Used for favicon
71+
- `public/img/favicon.png` - Used as fallback for browsers that don't support SVG favicons
7172

7273
In case the source image is not in vector format, you can attempt to convert a raster image using tools like [this](https://www.aconvert.com/image/png-to-svg/).
7374

templates/base/head.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<link rel="alternate" type="application/atom+xml" title="" href="{{.FeedURL}}.atom">
2020
<link rel="alternate" type="application/rss+xml" title="" href="{{.FeedURL}}.rss">
2121
{{end}}
22-
<link rel="icon" href="{{AssetUrlPrefix}}/img/logo.svg" type="image/svg+xml">
22+
<link rel="icon" href="{{AssetUrlPrefix}}/img/favicon.svg" type="image/svg+xml">
2323
<link rel="alternate icon" href="{{AssetUrlPrefix}}/img/favicon.png" type="image/png">
2424
<link rel="stylesheet" href="{{AssetUrlPrefix}}/css/index.css?v={{MD5 AppVer}}">
2525
{{template "base/head_script" .}}

0 commit comments

Comments
 (0)