Compare commits

...

8 Commits

16 changed files with 83 additions and 227 deletions

1
.gitignore vendored
View File

@ -2,6 +2,7 @@
dist*
node_modules/
assets/icons
assets/favicons
bin/
*.hi
*.o

View File

@ -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/
@ -36,6 +36,11 @@ release:
git commit -m "chore(release): ${VERSION}"
git push
.PHONY: %-shell
%-shell:
@echo "TODO: build specified container, run it and drop into bash"
exit 1
##### GENERAL TARGETS #####
###########################
@ -105,17 +110,15 @@ node_modules: package.json package-lock.json
package-lock.json: package.json
npm install --cache .npm --prefer-offline
assets: node_modules
assets: assets/favicons assets/icons
assets/favicons:
./utils/faviconize.pl assets/favicon.svg long assets/favicons
assets/icons: node_modules
./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:
# no-op target
well-known: node_modules assets well-known/.well-known
well-known: node_modules assets
npx webpack --progress
touch well-known/.well-known
well-known/.well-known:
# no-op target
##### FRONTEND TARGETS #####
############################
@ -196,6 +199,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

View File

@ -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

View File

@ -1,3 +0,0 @@
SPDX-FileCopyrightText: 2022 Fraport AG
SPDX-License-Identifier: LicenseRef-Fraport-Corporate-Design

View File

@ -1,3 +0,0 @@
SPDX-FileCopyrightText: 2022 Fraport AG
SPDX-License-Identifier: LicenseRef-Fraport-Corporate-Design

View File

@ -1,41 +0,0 @@
{
"name": "App",
"icons": [
{
"src": "\/android-icon-36x36.png",
"sizes": "36x36",
"type": "image\/png",
"density": "0.75"
},
{
"src": "\/android-icon-48x48.png",
"sizes": "48x48",
"type": "image\/png",
"density": "1.0"
},
{
"src": "\/android-icon-72x72.png",
"sizes": "72x72",
"type": "image\/png",
"density": "1.5"
},
{
"src": "\/android-icon-96x96.png",
"sizes": "96x96",
"type": "image\/png",
"density": "2.0"
},
{
"src": "\/android-icon-144x144.png",
"sizes": "144x144",
"type": "image\/png",
"density": "3.0"
},
{
"src": "\/android-icon-192x192.png",
"sizes": "192x192",
"type": "image\/png",
"density": "4.0"
}
]
}

View File

@ -1,3 +0,0 @@
SPDX-FileCopyrightText: 2022 Steffen Jost <jost@cip.ifi.lmu.de>
SPDX-License-Identifier: AGPL-3.0-or-later

View File

@ -1,76 +0,0 @@
{
"masterPicture": "assets/favicon.svg",
"design": {
"desktop_browser": {},
"ios": {
"picture_aspect": "background_and_margin",
"margin": "5%",
"background_color": "#ffffff",
"startup_image": {
"background_color": "#ffffff"
},
"app_name": "FRADrive",
"assets": {
"ios6_and_prior_icons": false,
"ios7_and_later_icons": true,
"precomposed_icons": true,
"declare_only_default_icon": true
}
},
"windows": {
"picture_aspect": "white_silhouette",
"background_color": "#0a9342",
"app_name": "FRADrive"
},
"firefox_app": {
"picture_aspect": "circle",
"keep_picture_in_circle": false,
"circle_inner_margin": "5%",
"background_color": "#ffffff",
"overlay": false,
"manifest": {
"app_name": "FRADrive",
"app_description": {
"_i18n": true,
"de-de-formal": "Ein webbasiertes Schulungsverwaltungssystem",
"en-eu": "A web based training management system"
},
"developer_name": "Uni2work-Team",
"developer_url": "https://uni2work.ifi.lmu.de/info",
"display": "browser",
"start_url": "/"
}
},
"android_chrome": {
"picture_aspect": "shadow",
"manifest": {
"name": "FRADrive",
"display": "browser",
"orientation": "portrait",
"start_url": "/"
},
"assets": {
"legacy_icon": true,
"low_resolution_icons": false
}
},
"safari_pinned_tab": {
"picture_aspect": "silhouette",
"theme_color": "#0a9342"
},
"coast": {
"picture_aspect": "background_and_margin",
"background_color": "#ffffff",
"margin": "10%"
},
"open_graph": {
"picture_aspect": "background_and_margin",
"background_color": "#ffffff",
"margin": "10%",
"ratio": "square"
}
},
"settings": {
"html_code_file": true
}
}

View File

@ -1,3 +0,0 @@
SPDX-FileCopyrightText: 2022 Gregor Kleen <gregor.kleen@ifi.lmu.de>,Steffen Jost <jost@tcs.ifi.lmu.de>
SPDX-License-Identifier: AGPL-3.0-or-later

View File

@ -5,6 +5,7 @@ RUN apt-get -y update && apt-get -y install curl npm
# Build and watch dependencies
RUN apt-get -y update && apt-get -y install exiftool
RUN apt-get -y update && apt-get -y install imagemagick
# Test dependencies
RUN apt-get -y update && apt-get -y install chromium

View File

@ -1,17 +1,4 @@
{
"app-manifest-webpack-plugin for \"../../config/favicon.json\"": [
{
"chunks": {
"byName": {},
"bySource": {},
"usedIds": []
},
"modules": {
"byIdentifier": {},
"usedIds": {}
}
}
],
"app-manifest-webpack-plugin for \"/home/gkleen/projects/uni2work/static/wp-4.41/iconstats-[hash].json\"": [
{
"chunks": {

View File

@ -15,7 +15,8 @@ spec = withApp $ do
it "has correct User-agent" $ do
get $ WellKnownR RobotsTxt
bodyContains "User-agent: *"
describe "favicon.ico" $ do
it "gives a 200" $ do
get $ WellKnownR FaviconIco
statusIs 200
-- FIXME: deprecated, check for assets/favicons instead!
--describe "favicon.ico" $ do
-- it "gives a 200" $ do
-- get $ WellKnownR FaviconIco
-- statusIs 200

46
utils/faviconize.pl Executable file
View File

@ -0,0 +1,46 @@
#!/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);
my $dir = undef;
opendir($dir, $faviconDir) or die "Could not read directory '$faviconDir', because: $!\n";
while(my $fn = readdir($dir)) {
unlink("$faviconDir/$fn") if -d "$faviconDir/$fn"
}
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;

View File

@ -20,7 +20,6 @@ import TerserPlugin from 'terser-webpack-plugin';
import yaml from 'js-yaml';
import postcssPresetEnv from 'postcss-preset-env';
import RemovePlugin from 'remove-files-webpack-plugin';
import RealFaviconPlugin from 'real-favicon-webpack-plugin';
import crypto from 'crypto';
// import { version as webpackVersion } from 'webpack/package.json' assert { type: 'json' }; // version.split('.').slice(0, 2).join('.');
@ -31,21 +30,9 @@ const webpackVersion = webpackJson.version.split('.').slice(0, 2).join('.');
import packageJson from './package.json' assert { type: "json" };
const packageVersion = packageJson.version;
import faviconJson from './config/favicon.json' assert { type: 'json' };
async function webpackConfig() {
const wellKnownCacheDir = resolve('.cache/well-known');
const assetsDirectory = resolve('assets');
let faviconApiVersion = undefined;
if (!fs.existsSync(wellKnownCacheDir)) {
try {
const faviconApiChangelog = await axios.get('https://realfavicongenerator.net/api/versions');
faviconApiVersion = faviconApiChangelog.data.filter(vObj => vObj.relevance.automated_update).slice(-1)[0].version;
} catch(e) {
console.error(e);
}
}
return {
module: {
@ -142,6 +129,7 @@ async function webpackConfig() {
new webpack.DefinePlugin({
VERSION: JSON.stringify(packageVersion)
}),
/* TODO: deprecated due to removal of online favicon generation; is this still needed?
...(() => {
const langs = new Set();
function findLangs(json) {
@ -201,68 +189,28 @@ async function webpackConfig() {
console.error(e);
}
if (faviconApiVersion) {
cacheHash.update(faviconApiVersion);
}
const versionDigest = cacheHash.digest('hex');
return Array.from(langs).map(lang => {
const faviconConfig = { versioning: { param_name: 'v', param_value: versionDigest.substr(0,10) }, ...langJsons[lang] };
const tmpobj = tmp.fileSync({ postfix: ".json" });
fs.writeSync(tmpobj.fd, JSON.stringify(faviconConfig));
fs.close(tmpobj.fd);
const cacheDirectory = resolve('.well-known-cache', `${cacheDigest}-${lang}`);
if (fs.existsSync(wellKnownCacheDir)) {
console.log("Using favicons generated by nix");
return [
new CopyPlugin({
patterns: [
{ from: resolve(wellKnownCacheDir, lang), to: resolve('well-known', lang) }
]
return [
new CopyPlugin({
patterns: [
{ from: 'config/robots.txt', to: resolve('well-known', lang, 'robots.txt') },
]
}),
{ apply: compiler => compiler.hooks.afterEmit.tap('AfterEmitPlugin', compilation => {
const imgFiles = globSync(resolve('well-known', lang) + '/*.@(png)');
const imgFilesArgs = Array.from(imgFiles).join(" ");
execSync(`exiftool -overwrite_original -all= ${imgFilesArgs}`, { stdio: 'inherit' });
})
];
} else if (fs.existsSync(cacheDirectory) && (!faviconApiVersion || faviconApiVersion === cachedVersion)) {
console.log(`Using cached well-known from ${cacheDirectory} for ${lang}`);
return [
new CopyPlugin({
patterns: [
{ from: cacheDirectory, to: resolve('well-known', lang) }
]
})
];
} else {
const tmpobj = tmp.fileSync({ postfix: ".json" });
fs.writeSync(tmpobj.fd, JSON.stringify(faviconConfig));
fs.close(tmpobj.fd);
return [
new RealFaviconPlugin({
faviconJson: relative(".", tmpobj.name),
outputPath: resolve('well-known', lang),
inject: false
}),
new CopyPlugin({
patterns: [
{ from: 'config/robots.txt', to: resolve('well-known', lang, 'robots.txt') },
]
}),
{ apply: compiler => compiler.hooks.afterEmit.tap('AfterEmitPlugin', compilation => {
const imgFiles = globSync(resolve('well-known', lang) + '/*.@(png)');
const imgFilesArgs = Array.from(imgFiles).join(" ");
execSync(`exiftool -overwrite_original -all= ${imgFilesArgs}`, { stdio: 'inherit' });
})
},
{ apply: compiler => compiler.hooks.afterEmit.tap('AfterEmitPlugin', compilation => {
fs.ensureDirSync('.well-known-cache');
fs.copySync(resolve('well-known', lang), cacheDirectory);
if (!fs.existsSync(versionFile)) {
fs.writeFileSync(versionFile, faviconApiVersion, { encoding: 'utf8' });
}
})
}
];
}
}
];
}).flat(1);
})()
})() */
],
output: {
@ -303,4 +251,4 @@ async function webpackConfig() {
};
}
export default webpackConfig;
export default webpackConfig;