Skip to content

Commit 4cd94e3

Browse files
authored
gitea png to logo (#13974)
* gitea png to logo.svg * gitea safari svg to logo * minify svgs * Update english docs * Update missing section on customizing logo
1 parent e25e7b9 commit 4cd94e3

20 files changed

+52
-25
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ generate-gitignore:
699699
.PHONY: generate-images
700700
generate-images:
701701
npm install --no-save --no-package-lock fabric imagemin-zopfli
702-
node build/generate-images.js
702+
node build/generate-images.js $(TAGS)
703703

704704
.PHONY: pr\#%
705705
pr\#%: clean-all

build/generate-images.js

+28-9
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ const {readFile, writeFile} = require('fs').promises;
77
const {resolve} = require('path');
88
const Svgo = require('svgo');
99

10+
const logoFile = resolve(__dirname, '../assets/logo.svg');
11+
1012
function exit(err) {
1113
if (err) console.error(err);
1214
process.exit(err ? 1 : 0);
@@ -39,6 +41,12 @@ async function generateSvgFavicon(svg, outputFile) {
3941
await writeFile(outputFile, data);
4042
}
4143

44+
async function generateSvg(svg, outputFile) {
45+
const svgo = new Svgo();
46+
const {data} = await svgo.optimize(svg);
47+
await writeFile(outputFile, data);
48+
}
49+
4250
async function generate(svg, outputFile, {size, bg}) {
4351
const {objects, options} = await loadSvg(svg);
4452
const canvas = new fabric.Canvas();
@@ -69,15 +77,26 @@ async function generate(svg, outputFile, {size, bg}) {
6977
}
7078

7179
async function main() {
72-
const svg = await readFile(resolve(__dirname, '../assets/logo.svg'), 'utf8');
73-
await generateSvgFavicon(svg, resolve(__dirname, '../public/img/favicon.svg'));
74-
await generate(svg, resolve(__dirname, '../public/img/gitea-lg.png'), {size: 880});
75-
await generate(svg, resolve(__dirname, '../public/img/gitea-512.png'), {size: 512});
76-
await generate(svg, resolve(__dirname, '../public/img/gitea-192.png'), {size: 192});
77-
await generate(svg, resolve(__dirname, '../public/img/gitea-sm.png'), {size: 120});
78-
await generate(svg, resolve(__dirname, '../public/img/avatar_default.png'), {size: 200});
79-
await generate(svg, resolve(__dirname, '../public/img/favicon.png'), {size: 180});
80-
await generate(svg, resolve(__dirname, '../public/img/apple-touch-icon.png'), {size: 180, bg: true});
80+
const gitea = process.argv.slice(2).includes('gitea');
81+
82+
const svg = await readFile(logoFile, 'utf8');
83+
await Promise.all([
84+
generateSvgFavicon(svg, resolve(__dirname, '../public/img/favicon.svg')),
85+
generateSvg(svg, resolve(__dirname, '../public/img/logo.svg')),
86+
generate(svg, resolve(__dirname, '../public/img/logo-lg.png'), {size: 880}),
87+
generate(svg, resolve(__dirname, '../public/img/logo-512.png'), {size: 512}),
88+
generate(svg, resolve(__dirname, '../public/img/logo-192.png'), {size: 192}),
89+
generate(svg, resolve(__dirname, '../public/img/logo-sm.png'), {size: 120}),
90+
generate(svg, resolve(__dirname, '../public/img/avatar_default.png'), {size: 200}),
91+
generate(svg, resolve(__dirname, '../public/img/favicon.png'), {size: 180}),
92+
generate(svg, resolve(__dirname, '../public/img/apple-touch-icon.png'), {size: 180, bg: true}),
93+
]);
94+
if (gitea) {
95+
await Promise.all([
96+
generateSvg(svg, resolve(__dirname, '../public/img/gitea.svg')),
97+
generate(svg, resolve(__dirname, '../public/img/gitea-192.png'), {size: 192}),
98+
]);
99+
}
81100
}
82101

83102
main().then(exit).catch(exit);

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

+4
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ To make Gitea serve custom public files (like pages and images), use the folder
5757
For example, a file `image.png` stored in `custom/public/`, can be accessed with
5858
the url `http://gitea.domain.tld/image.png`.
5959

60+
## Changing the default logo
61+
62+
To automatically update custom logo png and svg files replace `assets/logo.svg` and run `make generate-images`. This will update the user-designated logo files served in `public/img`. Alternatively, you can manually update each `logo-X.png` and `logo.svg` file in `public/img`.
63+
6064
## Changing the default avatar
6165

6266
Place the png image at the following path: `custom/public/img/avatar_default.png`

docs/content/doc/developers/hacking-on-gitea.en-us.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,9 @@ SVG icons are built using the `make svg` target which compiles the icon sources
185185

186186
### Building the Logo
187187

188-
The PNG versions of the logo are built from a single SVG source file `assets/logo.svg` using the `make generate-images` target. To run it, Node.js and npm must be available. The same process can also be used to generate a custom logo PNGs from a SVG source file. It's possible to remove parts of the SVG logo for the favicon build by adding a `detail-remove` class to the SVG nodes to be removed.
188+
The PNG and SVG versions of the gitea logo are built from a single SVG source file `assets/logo.svg` using the `TAGS="gitea" make generate-images` target. To run it, Node.js and npm must be available.
189+
190+
The same process can also be used to generate custom logo PNGs from a SVG source file by updating `assets/logo.svg` and running `make generate-images`. Omitting the `gitea` tag will update only the user-designated logo files.
189191

190192
### Updating the API
191193

public/img/gitea.svg

+1
Loading

public/img/logo-192.png

4.64 KB
Loading
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

public/img/logo.svg

+1
Loading

snap/snapcraft.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ description: |
66
an independent binary distribution across ALL platforms that Go supports,
77
including Linux, Mac OS X, Windows and ARM.
88
9-
icon: public/img/gitea-lg.png
9+
icon: public/img/logo-lg.png
1010
confinement: strict
1111
base: core18
1212
adopt-info: gitea

templates/admin/hook_new.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
{{end}}
1212
<div class="ui right">
1313
{{if eq .HookType "gitea"}}
14-
<img width="26" height="26" src="{{StaticUrlPrefix}}/img/gitea-sm.png">
14+
<img width="26" height="26" src="{{StaticUrlPrefix}}/img/gitea.svg">
1515
{{else if eq .HookType "gogs"}}
1616
<img width="26" height="26" src="{{StaticUrlPrefix}}/img/gogs.ico">
1717
{{else if eq .HookType "slack"}}

templates/base/head.tmpl

+3-3
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@
6060
</script>
6161
<link rel="icon" href="{{StaticUrlPrefix}}/img/favicon.svg" type="image/svg+xml">
6262
<link rel="alternate icon" href="{{StaticUrlPrefix}}/img/favicon.png" type="image/png">
63-
<link rel="mask-icon" href="{{StaticUrlPrefix}}/img/gitea-safari.svg" color="#609926">
64-
<link rel="fluid-icon" href="{{StaticUrlPrefix}}/img/gitea-lg.png" title="{{AppName}}">
63+
<link rel="mask-icon" href="{{StaticUrlPrefix}}/img/logo-safari.svg" color="#609926">
64+
<link rel="fluid-icon" href="{{StaticUrlPrefix}}/img/logo-lg.png" title="{{AppName}}">
6565
{{if .RequireSimpleMDE}}
6666
<link rel="stylesheet" href="{{StaticUrlPrefix}}/css/easymde.css?v={{MD5 AppVer}}">
6767
{{end}}
@@ -104,7 +104,7 @@
104104
{{else}}
105105
<meta property="og:title" content="{{AppName}}">
106106
<meta property="og:type" content="website" />
107-
<meta property="og:image" content="{{StaticUrlPrefix}}/img/gitea-lg.png" />
107+
<meta property="og:image" content="{{StaticUrlPrefix}}/img/logo-lg.png" />
108108
<meta property="og:url" content="{{AppUrl}}" />
109109
<meta property="og:description" content="{{MetaDescription}}">
110110
{{end}}

templates/base/head_navbar.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div class="ui container" id="navbar">
22
<div class="item brand" style="justify-content: space-between;">
33
<a href="{{AppSubUrl}}/">
4-
<img class="ui mini image" src="{{StaticUrlPrefix}}/img/gitea-sm.png">
4+
<img class="ui mini image" src="{{StaticUrlPrefix}}/img/logo.svg">
55
</a>
66
<div class="ui basic icon button mobile-only" id="navbar-expand-toggle">
77
<i class="sidebar icon"></i>

templates/home.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<div class="ui stackable middle very relaxed page grid">
44
<div class="sixteen wide center aligned centered column">
55
<div>
6-
<img class="logo" src="{{StaticUrlPrefix}}/img/gitea-lg.png" />
6+
<img class="logo" src="{{StaticUrlPrefix}}/img/logo.svg" />
77
</div>
88
<div class="hero">
99
<h1 class="ui icon header title">

templates/org/settings/hook_new.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{{if .PageIsSettingsHooksNew}}{{.i18n.Tr "repo.settings.add_webhook"}}{{else}}{{.i18n.Tr "repo.settings.update_webhook"}}{{end}}
1111
<div class="ui right">
1212
{{if eq .HookType "gitea"}}
13-
<img width="26" height="26" src="{{StaticUrlPrefix}}/img/gitea-sm.png">
13+
<img width="26" height="26" src="{{StaticUrlPrefix}}/img/gitea.svg">
1414
{{else if eq .HookType "gogs"}}
1515
<img width="26" height="26" src="{{StaticUrlPrefix}}/img/gogs.ico">
1616
{{else if eq .HookType "slack"}}

templates/pwa/manifest_json.tmpl

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
"name": "Gitea - Git with a cup of tea",
44
"icons": [
55
{
6-
"src": "{{StaticUrlPrefix}}/img/gitea-lg.png",
6+
"src": "{{StaticUrlPrefix}}/img/logo-lg.png",
77
"type": "image/png",
88
"sizes": "880x880"
99
},
1010
{
11-
"src": "{{StaticUrlPrefix}}/img/gitea-sm.png",
11+
"src": "{{StaticUrlPrefix}}/img/logo-sm.png",
1212
"type": "image/png",
1313
"sizes": "120x120"
1414
},
1515
{
16-
"src": "{{StaticUrlPrefix}}/img/gitea-512.png",
16+
"src": "{{StaticUrlPrefix}}/img/logo-512.png",
1717
"type": "image/png",
1818
"sizes": "512x512"
1919
},
2020
{
21-
"src": "{{StaticUrlPrefix}}/img/gitea-192.png",
21+
"src": "{{StaticUrlPrefix}}/img/logo-192.png",
2222
"type": "image/png",
2323
"sizes": "192x192"
2424
}

templates/repo/settings/webhook/list.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<div class="ui blue tiny button">{{.i18n.Tr "repo.settings.add_webhook"}}</div>
77
<div class="menu">
88
<a class="item" href="{{.BaseLink}}/gitea/new">
9-
<img width="20" height="20" src="{{StaticUrlPrefix}}/img/gitea-sm.png">Gitea
9+
<img width="20" height="20" src="{{StaticUrlPrefix}}/img/gitea.svg">Gitea
1010
</a>
1111
<a class="item" href="{{.BaseLink}}/gogs/new">
1212
<img width="20" height="20" src="{{StaticUrlPrefix}}/img/gogs.ico">Gogs

templates/repo/settings/webhook/new.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
{{if .PageIsSettingsHooksNew}}{{.i18n.Tr "repo.settings.add_webhook"}}{{else}}{{.i18n.Tr "repo.settings.update_webhook"}}{{end}}
99
<div class="ui right">
1010
{{if eq .HookType "gitea"}}
11-
<img width="26" height="26" src="{{StaticUrlPrefix}}/img/gitea-sm.png">
11+
<img width="26" height="26" src="{{StaticUrlPrefix}}/img/gitea.svg">
1212
{{else if eq .HookType "gogs"}}
1313
<img width="26" height="26" src="{{StaticUrlPrefix}}/img/gogs.ico">
1414
{{else if eq .HookType "slack"}}

0 commit comments

Comments
 (0)