summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorKyle D <kdumontnu@gmail.com>2020-12-18 20:17:27 -0500
committerGitHub <noreply@github.com>2020-12-18 20:17:27 -0500
commit4cd94e3689b256b6578da3c35ad52872bcea634f (patch)
tree2ae79e1fdd9ab1a11f9d361daef719f1a60fb84f /build
parente25e7b9598241947e83977b3ea6f8349cfdaa050 (diff)
downloadgitea-4cd94e3689b256b6578da3c35ad52872bcea634f.tar.gz
gitea-4cd94e3689b256b6578da3c35ad52872bcea634f.zip
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
Diffstat (limited to 'build')
-rwxr-xr-xbuild/generate-images.js37
1 files changed, 28 insertions, 9 deletions
diff --git a/build/generate-images.js b/build/generate-images.js
index c7f58f61d0..9bd40641e4 100755
--- a/build/generate-images.js
+++ b/build/generate-images.js
@@ -7,6 +7,8 @@ const {readFile, writeFile} = require('fs').promises;
const {resolve} = require('path');
const Svgo = require('svgo');
+const logoFile = resolve(__dirname, '../assets/logo.svg');
+
function exit(err) {
if (err) console.error(err);
process.exit(err ? 1 : 0);
@@ -39,6 +41,12 @@ async function generateSvgFavicon(svg, outputFile) {
await writeFile(outputFile, data);
}
+async function generateSvg(svg, outputFile) {
+ const svgo = new Svgo();
+ const {data} = await svgo.optimize(svg);
+ await writeFile(outputFile, data);
+}
+
async function generate(svg, outputFile, {size, bg}) {
const {objects, options} = await loadSvg(svg);
const canvas = new fabric.Canvas();
@@ -69,15 +77,26 @@ async function generate(svg, outputFile, {size, bg}) {
}
async function main() {
- const svg = await readFile(resolve(__dirname, '../assets/logo.svg'), 'utf8');
- await generateSvgFavicon(svg, resolve(__dirname, '../public/img/favicon.svg'));
- await generate(svg, resolve(__dirname, '../public/img/gitea-lg.png'), {size: 880});
- await generate(svg, resolve(__dirname, '../public/img/gitea-512.png'), {size: 512});
- await generate(svg, resolve(__dirname, '../public/img/gitea-192.png'), {size: 192});
- await generate(svg, resolve(__dirname, '../public/img/gitea-sm.png'), {size: 120});
- await generate(svg, resolve(__dirname, '../public/img/avatar_default.png'), {size: 200});
- await generate(svg, resolve(__dirname, '../public/img/favicon.png'), {size: 180});
- await generate(svg, resolve(__dirname, '../public/img/apple-touch-icon.png'), {size: 180, bg: true});
+ 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/favicon.png'), {size: 180}),
+ generate(svg, resolve(__dirname, '../public/img/apple-touch-icon.png'), {size: 180, bg: true}),
+ ]);
+ 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);