diff options
author | silverwind <me@silverwind.io> | 2021-01-01 20:04:35 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-01 14:04:35 -0500 |
commit | 1bf7d71a0a82bc19945bc816df57b8ad61bdace4 (patch) | |
tree | 012d2f4060785956d46ef3f0a4b4a2678f46801e /build/generate-images.js | |
parent | 21adeaad70ba2386673e00e69147b1cc40551b76 (diff) | |
download | gitea-1bf7d71a0a82bc19945bc816df57b8ad61bdace4.tar.gz gitea-1bf7d71a0a82bc19945bc816df57b8ad61bdace4.zip |
Consolidate Logos and update README header (#14136)
* Consolidate Logos and update README header
- Remove unused `logo-lg.png`, `logo-sm.png` and `logo-192.png`.
- Consolidate `favicon.svg` and `logo.svg` to just `logo.svg`.
- Remove Safari Mask icon, it seems to work fine with just `favicon.png` (no SVG support).
- Remove Fluid Icon. It only served Firefox and SVG works just fine there.
- Update customization instructions.
- Update README.md to use SVG icon, increase logo size and center it and badges.
* Update README_ZH.md
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Update README_ZH.md
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'build/generate-images.js')
-rwxr-xr-x | build/generate-images.js | 57 |
1 files changed, 18 insertions, 39 deletions
diff --git a/build/generate-images.js b/build/generate-images.js index 9bd40641e4..c9108ce713 100755 --- a/build/generate-images.js +++ b/build/generate-images.js @@ -2,10 +2,10 @@ 'use strict'; const imageminZopfli = require('imagemin-zopfli'); +const Svgo = require('svgo'); const {fabric} = require('fabric'); const {readFile, writeFile} = require('fs').promises; const {resolve} = require('path'); -const Svgo = require('svgo'); const logoFile = resolve(__dirname, '../assets/logo.svg'); @@ -22,32 +22,20 @@ function loadSvg(svg) { }); } -async function generateSvgFavicon(svg, outputFile) { - const svgo = new Svgo({ - plugins: [ - {removeDimensions: true}, - { - addAttributesToSVGElement: { - attributes: [ - {'width': '32'}, - {'height': '32'}, - ], - }, - }, - ], - }); - - const {data} = await svgo.optimize(svg); - await writeFile(outputFile, data); -} +async function generate(svg, outputFile, {size, bg}) { + if (outputFile.endsWith('.svg')) { + const svgo = new Svgo({ + plugins: [ + {removeDimensions: true}, + {addAttributesToSVGElement: {attributes: [{width: size}, {height: size}]}}, + ], + }); -async function generateSvg(svg, outputFile) { - const svgo = new Svgo(); - const {data} = await svgo.optimize(svg); - await writeFile(outputFile, data); -} + const {data} = await svgo.optimize(svg); + await writeFile(outputFile, data); + return; + } -async function generate(svg, outputFile, {size, bg}) { const {objects, options} = await loadSvg(svg); const canvas = new fabric.Canvas(); canvas.setDimensions({width: size, height: size}); @@ -78,25 +66,16 @@ async function generate(svg, outputFile, {size, bg}) { async function main() { const gitea = process.argv.slice(2).includes('gitea'); - const svg = await readFile(logoFile, 'utf8'); + await Promise.all([ - generateSvgFavicon(svg, resolve(__dirname, '../public/img/favicon.svg')), - generateSvg(svg, resolve(__dirname, '../public/img/logo.svg')), - generate(svg, resolve(__dirname, '../public/img/logo-lg.png'), {size: 880}), - generate(svg, resolve(__dirname, '../public/img/logo-512.png'), {size: 512}), - generate(svg, resolve(__dirname, '../public/img/logo-192.png'), {size: 192}), - generate(svg, resolve(__dirname, '../public/img/logo-sm.png'), {size: 120}), - generate(svg, resolve(__dirname, '../public/img/avatar_default.png'), {size: 200}), + generate(svg, resolve(__dirname, '../public/img/logo.svg'), {size: 32}), + generate(svg, resolve(__dirname, '../public/img/logo.png'), {size: 512}), generate(svg, resolve(__dirname, '../public/img/favicon.png'), {size: 180}), + generate(svg, resolve(__dirname, '../public/img/avatar_default.png'), {size: 200}), generate(svg, resolve(__dirname, '../public/img/apple-touch-icon.png'), {size: 180, bg: true}), + gitea && generate(svg, resolve(__dirname, '../public/img/gitea.svg'), {size: 32}), ]); - if (gitea) { - await Promise.all([ - generateSvg(svg, resolve(__dirname, '../public/img/gitea.svg')), - generate(svg, resolve(__dirname, '../public/img/gitea-192.png'), {size: 192}), - ]); - } } main().then(exit).catch(exit); |