build(frontend): generate favicons based on svg using local tooling
This commit is contained in:
parent
6bc83f1418
commit
d063f6827c
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,6 +2,7 @@
|
||||
dist*
|
||||
node_modules/
|
||||
assets/icons
|
||||
assets/favicons
|
||||
bin/
|
||||
*.hi
|
||||
*.o
|
||||
|
||||
7
Makefile
7
Makefile
@ -23,7 +23,7 @@ all:
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -rf node_modules .npm .cache assets/icons well-known static/
|
||||
rm -rf node_modules .npm .cache assets/icons assets/favicons well-known static/
|
||||
rm -rf .stack .stack-work .stack-work-build .stack-work-run .stack-work-test .stack-work-doc
|
||||
rm -rf bin/
|
||||
|
||||
@ -105,7 +105,11 @@ node_modules: package.json package-lock.json
|
||||
package-lock.json: package.json
|
||||
npm install --cache .npm --prefer-offline
|
||||
|
||||
# FIXME: refraining from targets below assets/ (e.g. assets/icons, assets/favicon) to avoid / in target name for now (and maybe to avoid target name pollution)
|
||||
assets: node_modules
|
||||
# favicons
|
||||
./utils/faviconize.pl assets/favicon.svg long assets/favicons
|
||||
# site icons
|
||||
./utils/renamer.pl node_modules/@fortawesome/fontawesome-free/svgs/solid utils/rename-fa.json assets/icons/fradrive
|
||||
./utils/renamer.pl node_modules/@fortawesome/fontawesome-free/svgs/regular utils/rename-fa.json assets/icons/fradrive
|
||||
assets/.assets:
|
||||
@ -196,6 +200,7 @@ serve-database: --containerized-database
|
||||
|
||||
.PHONY: --containerized-database
|
||||
--containerized-database: FRADRIVE_SERVICE=database
|
||||
# port forwarding is disabled in --network=host mode; nevertheless it is stated here for documentation reasons
|
||||
--containerized-database: CONTAINER_PORTS=-p 5432:5432 --network="host"
|
||||
--containerized-database: --image-build
|
||||
if [ "$(IN_CONTAINER)" == "false" ] ; then \
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 10 KiB |
@ -1,3 +0,0 @@
|
||||
SPDX-FileCopyrightText: 2022 Fraport AG
|
||||
|
||||
SPDX-License-Identifier: LicenseRef-Fraport-Corporate-Design
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 KiB |
@ -1,3 +0,0 @@
|
||||
SPDX-FileCopyrightText: 2022 Fraport AG
|
||||
|
||||
SPDX-License-Identifier: LicenseRef-Fraport-Corporate-Design
|
||||
@ -1,3 +0,0 @@
|
||||
SPDX-FileCopyrightText: 2022 Fraport AG
|
||||
|
||||
SPDX-License-Identifier: LicenseRef-Fraport-Corporate-Design
|
||||
42
utils/faviconize.pl
Executable file
42
utils/faviconize.pl
Executable file
@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my ($file, $sizes, $faviconDir) = @ARGV;
|
||||
|
||||
die "usage: $0 [origfile] [sizes] [faviconDir] (sizes is ,-seperated list of side length or short, medium or long\n" unless defined $file and defined $sizes and defined $faviconDir;
|
||||
|
||||
die "File '$file' not found!\n" unless -e $file;
|
||||
|
||||
$sizes = '16,32' if 'short' eq $sizes;
|
||||
$sizes = '16,32,48,64,128,256' if 'medium' eq $sizes;
|
||||
$sizes = '16,32,48,64,128,192,228,230,256,512' if 'long' eq $sizes;
|
||||
|
||||
my @sizes = split m/,/, $sizes;
|
||||
|
||||
my $include = "";
|
||||
|
||||
mkdir($faviconDir);
|
||||
system("rm $faviconDir/*");
|
||||
for my $s(@sizes) {
|
||||
resize($s, "favicon-${s}x$s.png");
|
||||
}
|
||||
|
||||
resize(180, "apple-touch-icon.png");
|
||||
|
||||
sub resize {
|
||||
my ($size, $newfile) = @_;
|
||||
my $ret = system("convert '$file' -resize '${size}x$size' '$faviconDir/$newfile'");
|
||||
die "$0: convert exited with error code $ret on generating '$faviconDir/$newfile'\n" if $ret;
|
||||
die "$0: output file '$faviconDir/$newfile' could not be generated\n" unless -e "$faviconDir/$newfile";
|
||||
my $icon = "icon";
|
||||
$icon = "apple-touch-icon" if $newfile=~m#apple#;
|
||||
$include .= qq#<link rel="$icon" sizes="${size}x$size" href="/$newfile">#
|
||||
}
|
||||
|
||||
my $wh = undef;
|
||||
open($wh, '>', "$faviconDir/include.html") or die "Could not write '$faviconDir/include.html', because: $!";
|
||||
print $wh $include;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user