Skip to content
Snippets Groups Projects
Commit 0a9e27e6 authored by Steinwender, Tamara's avatar Steinwender, Tamara
Browse files

Merge branch 'master' into 'filehandling-overwrite-dialog'

# Conflicts:
#   packages/file-handling/src/dbp-nextcloud-file-picker.js
parents eba78455 5cd090f5
Branches
No related tags found
1 merge request!1Filehandling overwrite dialog
Pipeline #12667 passed
Showing
with 7517 additions and 2 deletions
node_modules node_modules
demo/dist
.idea
\ No newline at end of file
image: registry.gitlab.tugraz.at/dbp/web-components/toolkit/main:v1 image: registry.gitlab.tugraz.at/dbp/web-components/toolkit/main:v1
cache:
key: ${CI_PROJECT_PATH}
paths:
- _yarn_cache
stages: stages:
- test - test
test: test:
stage: test stage: test
script: script:
- yarn config set cache-folder "$CI_PROJECT_DIR/_yarn_cache"
- yarn install - yarn install
- yarn run test - yarn run test
# Frontend Toolkit Demo
## Setup
```bash
yarn install
```
## Local development
```bash
yarn run watch-local
```
You can then open <http://127.0.0.1:8001/>.
## Adding demo pages
1) Add demo activity path to `input` list of `rollup.config.js`
2) Create `assets/*.metadata.json` file like `assets/file-handling.metadata.json`
3) Reference in `assets/*.metadata.json` file in the `activities` part of `assets/dbp-toolkit-demo.topic.metadata.json.ejs`
DirectoryIndex <%= getUrl(name + '.html') %>
<FilesMatch "^(de|en|)$">
FallbackResource <%= getUrl(name + '.html') %>
</FilesMatch>
Header set Cache-Control "must-revalidate, max-age=60"
Header set Content-Security-Policy "default-src 'self' 'unsafe-eval' 'unsafe-inline' analytics.tugraz.at <%= keyCloakServer %> <%= entryPointURL %> httpbin.org <%= nextcloudBaseURL %> www.handy-signatur.at <%= pdfAsQualifiedlySigningServer %>; img-src * blob: data:"
# Apache adds a "-gzip" suffix to the etag when it uses gzip but doesn't
# take that into account when receiving requests.
# See https://bz.apache.org/bugzilla/show_bug.cgi?id=45023
RequestHeader edit "If-None-Match" '^"((.*)-(gzip|br))"$' '"$1", "$2"'
\ No newline at end of file
SOURCE=logo.svg
all: icon-192.png icon-512.png
icon-192.png: $(SOURCE)
inkscape $(SOURCE) --export-png $@ -w 192 -h 192
icon-512.png: $(SOURCE)
inkscape $(SOURCE) --export-png $@ -w 512 -h 512
{
"element": "dbp-common-demo",
"module_src": "dbp-common-demo.js",
"routing_name": "common",
"name": {
"de": "Common",
"en": "Common"
},
"short_name": {
"de": "Common",
"en": "Common"
},
"description": {
"de": "Gemeinsame Web Components",
"en": "Common web components"
}
}
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Favicons -->
<link rel="shortcut icon" type="image/x-icon" href="<%= getPrivateUrl('favicon.ico') %>">
<link rel="icon" type="image/svg+xml" href="<%= getPrivateUrl('favicon.svg') %>" sizes="any">
<% if (environment === "local") { -%>
<!-- XXX: Disable adoptedStyleSheets so that lit-element doesn't use it and we can edit CSS in the Chrome dev tools -->
<script>
delete Document.prototype.adoptedStyleSheets;
</script>
<% } -%>
<!-- PWA manfiest file -->
<link rel="manifest" href="<%= getUrl(name + '.manifest.json') %>">
<!-- Loading spinner -->
<script type="module">
import {Spinner} from '<%= getPrivateUrl('spinner.js') %>';
customElements.define('dbp-loading-spinner', Spinner);
</script>
<!-- App bundles-->
<script type="module" src="<%= getUrl(name + '.js') %>"></script>
<!-- Prevent Chrome/Edge from suggesting to translate the page -->
<meta name="google" content="notranslate">
<!-- Preload fonts -->
<link rel="preload" href="<%= getPrivateUrl('fonts/SourceSansPro-Light.otf.woff2') %>" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="<%= getPrivateUrl('fonts/SourceSansPro-Regular.otf.woff2') %>" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="<%= getPrivateUrl('fonts/SourceSansPro-Semibold.otf.woff2') %>" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="<%= getPrivateUrl('fonts/SourceSansPro-Bold.otf.woff2') %>" as="font" type="font/woff2" crossorigin>
<!-- Matomo -->
<script type="text/javascript">
var _paq = window._paq || [];
_paq.push(['setCustomVariable', 1, "GitCommit", "<%= buildInfo.info %>", "visit"]);
_paq.push(['enableHeartBeatTimer']);
_paq.push(['disableCookies']);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="https://analytics.tugraz.at/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '<%= matomoSiteId %>']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
// track changed locations
window.addEventListener('locationchanged', function(e) {
_paq.push(['setReferrerUrl', e.detail.referrerUrl]);
_paq.push(['setCustomUrl', location.href]);
// _paq.push(['setDocumentTitle', '']);
_paq.push(['trackPageView']);
// make Matomo aware of newly added content
var content = document.getElementById('content');
_paq.push(['MediaAnalytics::scanForMedia', content]);
_paq.push(['FormAnalytics::scanForForms', content]);
_paq.push(['trackContentImpressionsWithinNode', content]);
});
// track errors
window.addEventListener('error', function(e) {
_paq.push(['trackEvent', 'Error', e.error.message + '\n' + e.error.stack]);
});
</script>
<!-- End Matomo Code -->
<!-- Font related CSS -->
<style>
body {
font-family: 'Source Sans Pro', 'Calibri', 'Arial', 'sans-serif';
font-weight: 300;
margin: 0;
}
@font-face {
font-family: 'Source Sans Pro';
font-weight: 300;
src: url('<%= getPrivateUrl('fonts/SourceSansPro-Light.otf.woff2') %>') format('woff2');
font-display: block;
}
@font-face {
font-family: 'Source Sans Pro';
font-weight: 400;
src: url('<%= getPrivateUrl('fonts/SourceSansPro-Regular.otf.woff2') %>') format('woff2');
font-display: block;
}
@font-face {
font-family: 'Source Sans Pro';
font-weight: 600;
src: url('<%= getPrivateUrl('fonts/SourceSansPro-Semibold.otf.woff2') %>') format('woff2');
font-display: block;
}
@font-face {
font-family: 'Source Sans Pro';
font-weight: 700;
src: url('<%= getPrivateUrl('fonts/SourceSansPro-Bold.otf.woff2') %>') format('woff2');
font-display: block;
}
/* TU-Graz style override */
html {
--dbp-override-primary-bg-color: #245b78;
--dbp-override-primary-button-border: solid 1px #245b78;
--dbp-override-info-bg-color: #245b78;
--dbp-override-danger-bg-color: #e4154b;
--dbp-override-warning-bg-color: #ffe183;
--dbp-override-warning-text-color: black;
--dbp-override-success-bg-color: #259207;
}
</style>
<!-- Preloading/Preconnecting -->
<link rel="preconnect" href="<%= entryPointURL %>">
<link rel="preconnect" href="<%= keyCloakBaseURL %>">
</head>
<body>
<<%= name %>
lang="de"
src="<%= getUrl(name + '.topic.metadata.json') %>"
entry-point-url="<%= entryPointURL %>"
base-path="<%= getUrl('') %>"
keycloak-config='{"url": "<%= keyCloakBaseURL %>", "realm": "tugraz", "clientId": "<%= keyCloakClientId %>", "silentCheckSsoRedirectUri": "<%= getUrl('silent-check-sso.html') %>"}'
><dbp-loading-spinner></dbp-loading-spinner></<%= name %>>
<!-- Error handling for too old browsers -->
<script src="<%= getPrivateUrl('browser-check.js') %>" defer></script>
<noscript>Diese Applikation benötigt Javascript / This application requires Javascript</noscript>
</body>
</html>
\ No newline at end of file
{
"name": {
"de": "Toolkit Demo",
"en": "Toolkit Demo"
},
"short_name": {
"de": "Toolkit Demo",
"en": "Toolkit Demo"
},
"description": {
"de": "Mit dieser Applikation die Funktion der DBP Web Components testen",
"en": "With this application you can test the function of the DBP web components"
},
"routing_name": "toolkit-demo",
"activities": [
{"path": "file-handling.metadata.json"},
{"path": "knowledge-base-web-page-element-view.metadata.json"},
{"path": "common.metadata.json"}
],
"attributes": []
}
\ No newline at end of file
{
"element": "dbp-person-select-demo",
"module_src": "dbp-person-select-demo.js",
"routing_name": "person-select",
"name": {
"de": "Personensuche",
"en": "Person search"
},
"short_name": {
"de": "Personensuche",
"en": "Person search"
},
"description": {
"de": "Erlaubt das Suchen von Personen",
"en": "Allows searching for persons"
}
}
demo/assets/icon-192.png

2.3 KiB

demo/assets/icon-512.png

5.85 KiB

{
"element": "dbp-knowledge-base-web-page-element-view-demo",
"module_src": "dbp-knowledge-base-web-page-element-view-demo.js",
"routing_name": "knowledge-base-web-page-element-view",
"name": {
"de": "dbp-knowledge-base-web-page-element-view",
"en": "dbp-knowledge-base-web-page-element-view"
},
"short_name": {
"de": "dbp-knowledge-base-web-page-element-view",
"en": "dbp-knowledge-base-web-page-element-view"
},
"description": {
"de": "Erlaubt das Einfügen von Webinhalten",
"en": "Allows the inserting of web content"
}
}
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
id="int-header-logo-img"
width="105.82501pt"
height="105.82501pt"
version="1.1"
viewBox="0 0 141.10003 141.10139"
sodipodi:docname="tu-graz-logo-white.svg"
inkscape:version="0.92.4 (5da689c313, 2019-01-14)">
<metadata
id="metadata35">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs33" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="2302"
inkscape:window-height="1379"
id="namedview31"
showgrid="false"
units="pt"
inkscape:zoom="1.4182226"
inkscape:cx="162.3796"
inkscape:cy="-160.98113"
inkscape:window-x="0"
inkscape:window-y="54"
inkscape:window-maximized="0"
inkscape:current-layer="int-header-logo-img" />
<g
transform="matrix(1.25,0,0,-1.25,0,96.4832)"
id="g28">
<g
transform="scale(0.1)"
id="g26">
<path
d="M 0,103.73 H 207.45 V 311.19 L 0,311.2 Z"
style="fill:#e4154b"
id="path2"
inkscape:connector-curvature="0" />
<path
d="M 228.19,103.73 H 435.65 V 311.19 H 228.19 Z"
style="fill:#e4154b"
id="path4"
inkscape:connector-curvature="0" />
<path
d="M 456.41,103.73 H 663.85 V 311.19 H 456.41 Z"
style="fill:#e4154b"
id="path6"
inkscape:connector-curvature="0" />
<path
d="M 103.72,0 H 311.19 V 207.46 H 103.72 Z"
style="fill:#e4154b"
id="path8"
inkscape:connector-curvature="0" />
<path
d="M 352.68,207.46 H 560.12 V 414.92 H 352.68 Z"
style="fill:#e4154b"
id="path10"
inkscape:connector-curvature="0" />
<path
d="m 751.04,277.91 h -66.426 v 33.195 h 171.19 V 277.91 H 789.397 V 104.18 h -38.359 v 173.73"
style="fill:#fffff4"
id="path12"
inkscape:connector-curvature="0" />
<path
d="m 1048.3,180.22 c 0,-12.461 -2.25,-23.711 -6.72,-33.75 -4.5,-10.039 -10.61,-18.555 -18.36,-25.567 -7.76,-7.031 -16.9,-12.421 -27.503,-16.21 -10.605,-3.809 -22.109,-5.7036 -34.551,-5.7036 -12.422,0 -23.945,1.8946 -34.551,5.7036 -10.605,3.789 -19.824,9.179 -27.656,16.21 -7.851,7.012 -13.984,15.528 -18.34,25.567 -4.394,10.039 -6.582,21.289 -6.582,33.75 v 130.89 h 38.379 V 181.52 c 0,-5.039 0.801,-10.351 2.442,-15.898 1.64,-5.547 4.336,-10.664 8.125,-15.332 3.789,-4.668 8.789,-8.516 15.039,-11.523 6.211,-3.008 13.926,-4.512 23.144,-4.512 9.199,0 16.914,1.504 23.145,4.512 6.23,3.007 11.25,6.855 15.039,11.523 3.77,4.668 6.48,9.785 8.12,15.332 1.63,5.547 2.45,10.859 2.45,15.898 v 129.59 h 38.38 V 180.22"
style="fill:#ffffff"
id="path14"
inkscape:connector-curvature="0" />
<path
d="m 832.56,75.664 c -7.597,3.2812 -17.46,4.8632 -25.332,4.8632 -22.929,0 -35.605,-14.434 -35.605,-33.184 0,-18.613 12.383,-32.637 33.34,-32.637 5.351,0 9.59,0.5274 12.969,1.3086 v 23.867 h -20.84 v 14.414 h 39.687 V 4.9988 c -10.41,-2.6172 -21.25,-4.707 -31.816,-4.707 -31.797,0 -53.906,14.805 -53.906,45.742 0,31.348 20.566,48.906 53.906,48.906 11.406,0 20.41,-1.4453 28.867,-3.8086 l -1.27,-15.469"
style="fill:#fffff8"
id="path16"
inkscape:connector-curvature="0" />
<path
d="m 856.2,69.375 h 16.758 V 54.043 h 0.293 c 0.84,6.289 8.574,16.914 19.824,16.914 1.836,0 3.828,0 5.782,-0.5273 v -17.715 c -1.68,0.918 -5.059,1.4454 -8.457,1.4454 -15.333,0 -15.333,-17.832 -15.333,-27.52 V 1.8551 H 856.2 v 67.52"
style="fill:#fffff8"
id="path18"
inkscape:connector-curvature="0" />
<path
d="m 913.75,65.84 c 7.324,3.1446 17.187,5.1172 25.215,5.1172 22.09,0 31.23,-8.5351 31.23,-28.457 v -8.6523 c 0,-6.8165 0.156,-11.934 0.293,-16.914 0.137,-5.1172 0.41,-9.8242 0.84,-15.078 h -16.602 c -0.703,3.5352 -0.703,8.0078 -0.839,10.098 h -0.293 c -4.36,-7.4618 -13.81,-11.661 -22.38,-11.661 -12.793,0 -25.332,7.207 -25.332,20.059 0,10.078 5.195,15.976 12.383,19.258 7.187,3.2812 16.464,3.9453 24.355,3.9453 h 10.41 c 0,10.879 -5.195,14.551 -16.328,14.551 -8.008,0 -16.035,-2.8907 -22.363,-7.3438 l -0.586,15.078 z m 22.11,-52.715 c 5.782,0 10.274,2.3633 13.223,6.0352 3.105,3.8086 3.945,8.6523 3.945,13.906 h -8.164 c -8.437,0 -20.957,-1.3086 -20.957,-11.68 0,-5.7617 5.195,-8.2617 11.953,-8.2617"
style="fill:#fffff8"
id="path20"
inkscape:connector-curvature="0" />
<path
d="m 985.69,69.375 h 57.422 V 54.961 l -36.04,-39.473 h 37.31 V 1.855 h -60.235 v 14.297 l 36.715,39.59 H 985.69 v 13.633"
style="fill:#fffff8"
id="path22"
inkscape:connector-curvature="0" />
<path
d="m 1059.6,0 h 69.102 V 69.121 H 1059.6 Z"
style="fill:#e4154b"
id="path24"
inkscape:connector-curvature="0" />
</g>
</g>
</svg>
{
"short_name": "Toolkit Demo",
"name": "Toolkit Demo",
"start_url": "./dbp-toolkit-demo.html",
"icons": [
{
"src": "local/dbp-toolkit-demo/icon-192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "local/dbp-toolkit-demo/icon-512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"background_color": "#245B78",
"display": "standalone",
"theme_color": "#E4154B"
}
<html>
<body>
<script>
parent.postMessage(location.href, location.origin)
</script>
</body>
</html>
\ No newline at end of file
{
"name": "dbp-toolkit-demo",
"version": "1.0.0",
"main": "src/toolkit-demo.js",
"license": "LGPL-2.1-or-later",
"private": true,
"workspaces": [
"../packages/*"
],
"devDependencies": {
"@babel/core": "^7.10.3",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-syntax-import-meta": "^7.10.1",
"@babel/plugin-transform-runtime": "^7.10.3",
"@babel/preset-env": "^7.10.3",
"@babel/runtime-corejs3": "^7.10.3",
"@rollup/plugin-babel": "^5.0.4",
"@rollup/plugin-commonjs": "^14.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^8.1.0",
"@rollup/plugin-replace": "^2.3.3",
"@rollup/plugin-url": "^5.0.1",
"babel-eslint": "^10.0.3",
"chai": "^4.2.0",
"chokidar": "^3.4.0",
"eslint": "^7.3.1",
"eslint-plugin-jsdoc": "^29.2.0",
"glob": "^7.1.6",
"i18next-scanner": "^2.10.3",
"karma": "^5.1.0",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^3.1.0",
"karma-firefox-launcher": "^1.3.0",
"karma-mocha": "^2.0.1",
"mocha": "^8.0.1",
"puppeteer": "^2.0.0",
"rollup": "^2.18.1",
"rollup-plugin-consts": "^1.0.2",
"rollup-plugin-copy": "^3.3.0",
"rollup-plugin-delete": "^2.0.0",
"rollup-plugin-emit-ejs": "^3.1.0",
"rollup-plugin-license": "^2.1.0",
"rollup-plugin-serve": "^1.0.1",
"rollup-plugin-terser": "^6.1.0",
"selfsigned": "^1.10.7"
},
"dependencies": {
"@open-wc/scoped-elements": "^1.1.1",
"dbp-app-shell": "^1.0.0",
"dbp-auth": "^1.0.0",
"dbp-common": "^1.0.0",
"dbp-file-handling": "^1.0.0",
"dbp-language-select": "^1.0.0",
"dbp-notification": "^1.0.0",
"dbp-person-profile": "^1.0.0",
"fabric": "^3.6.3",
"file-saver": "^2.0.2",
"i18next": "^19.5.1",
"jszip": "^3.5.0",
"lit-element": "^2.3.1",
"lit-html": "^1.2.1",
"pdfjs-dist": "^2.4.456",
"source-sans-pro": "^2.45.0",
"tabulator-tables": "^4.7.0",
"universal-router": "^9.0.1",
"webdav": "^3.3.0"
},
"scripts": {
"build-dev": "rollup -c --environment BUILD:development",
"build-prod": "rollup -c --environment BUILD:production",
"build-demo": "rollup -c --environment BUILD:demo",
"i18next": "i18next-scanner",
"watch": "rollup -c --watch",
"watch-local": "yarn run watch",
"watch-full": "rollup -c --watch --environment FORCE_FULL",
"test": "rollup -c --environment BUILD:test && karma start --singleRun",
"test-full": "rollup -c --environment FORCE_FULL,BUILD:test && karma start --singleRun",
"lint": "eslint ."
}
}
import path from 'path';
import fs from 'fs';
import url from 'url';
import glob from 'glob';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import copy from 'rollup-plugin-copy';
import {terser} from "rollup-plugin-terser";
import json from '@rollup/plugin-json';
import replace from "@rollup/plugin-replace";
import serve from 'rollup-plugin-serve';
import urlPlugin from "@rollup/plugin-url";
import consts from 'rollup-plugin-consts';
import license from 'rollup-plugin-license';
import del from 'rollup-plugin-delete';
import emitEJS from 'rollup-plugin-emit-ejs'
import babel from '@rollup/plugin-babel'
import selfsigned from 'selfsigned';
// -------------------------------
// Some new web APIs are only available when HTTPS is active.
// Note that this only works with a Non-HTTPS API endpoint with Chrome,
// Firefox will emit CORS errors, see https://bugzilla.mozilla.org/show_bug.cgi?id=1488740
const USE_HTTPS = false;
// -------------------------------
const pkg = require('./package.json');
const build = (typeof process.env.BUILD !== 'undefined') ? process.env.BUILD : 'local';
const watch = process.env.ROLLUP_WATCH === 'true';
const buildFull = (!watch && build !== 'test') || (process.env.FORCE_FULL !== undefined);
console.log("build: " + build);
let basePath = '';
let entryPointURL = '';
let nextcloudBaseURL = 'https://cloud.tugraz.at';
let nextcloudWebAppPasswordURL = nextcloudBaseURL + '/apps/webapppassword';
let nextcloudWebDavURL = nextcloudBaseURL + '/remote.php/dav/files';
let nextcloudName = 'TU Graz cloud';
let keyCloakServer = '';
let keyCloakBaseURL = '';
let keyCloakClientId = '';
let pdfAsQualifiedlySigningServer = '';
let matomoSiteId = 131;
let useTerser = buildFull;
let useBabel = buildFull;
let checkLicenses = buildFull;
switch (build) {
case 'local':
basePath = '/dist/';
entryPointURL = 'http://127.0.0.1:8000';
nextcloudBaseURL = 'http://localhost:8081';
nextcloudWebAppPasswordURL = nextcloudBaseURL + '/index.php/apps/webapppassword';
nextcloudWebDavURL = nextcloudBaseURL + '/remote.php/dav/files';
keyCloakServer = 'auth-dev.tugraz.at';
keyCloakBaseURL = 'https://' + keyCloakServer + '/auth';
keyCloakClientId = 'auth-dev-mw-frontend-local';
pdfAsQualifiedlySigningServer = 'sig-dev.tugraz.at';
break;
case 'development':
basePath = '/apps/toolkit-demo/';
entryPointURL = 'https://mw-dev.tugraz.at';
// "/pers" can't go here because it's not allowed in the "Content-Security-Policy"
nextcloudBaseURL = 'https://nc-dev.tugraz.at';
// "/index.php" is needed to don't get a "This origin is not allowed!" because the "target-origin" get parameter can't be read
nextcloudWebAppPasswordURL = nextcloudBaseURL + '/pers/index.php/apps/webapppassword';
nextcloudWebDavURL = nextcloudBaseURL + '/pers/remote.php/dav/files';
keyCloakServer = 'auth-dev.tugraz.at';
keyCloakBaseURL = 'https://' + keyCloakServer + '/auth';
keyCloakClientId = 'auth-dev-mw-frontend';
pdfAsQualifiedlySigningServer = 'sig-dev.tugraz.at';
break;
default:
console.error('Unknown build environment: ' + build);
process.exit(1);
}
let nextcloudFileURL = nextcloudBaseURL + '/apps/files/?dir=';
/**
* Creates a server certificate and caches it in the .cert directory
*/
function generateTLSConfig() {
fs.mkdirSync('.cert', {recursive: true});
if (!fs.existsSync('.cert/server.key') || !fs.existsSync('.cert/server.cert')) {
const attrs = [{name: 'commonName', value: 'dbp-dev.localhost'}];
const pems = selfsigned.generate(attrs, {algorithm: 'sha256', days: 9999});
fs.writeFileSync('.cert/server.key', pems.private);
fs.writeFileSync('.cert/server.cert', pems.cert);
}
return {
key: fs.readFileSync('.cert/server.key'),
cert: fs.readFileSync('.cert/server.cert')
}
}
function getBuildInfo() {
const child_process = require('child_process');
const url = require('url');
let remote = child_process.execSync('git config --get remote.origin.url').toString().trim();
let commit = child_process.execSync('git rev-parse --short HEAD').toString().trim();
let parsed = url.parse(remote);
// convert git urls
if (parsed.protocol === null) {
parsed = url.parse('git://' + remote.replace(":", "/"));
parsed.protocol = 'https:';
}
let newPath = parsed.path.slice(0, parsed.path.lastIndexOf('.'));
let newUrl = parsed.protocol + '//' + parsed.host + newPath + '/commit/' + commit;
return {
info: commit,
url: newUrl,
time: new Date().toISOString(),
env: build
}
}
export default {
input: (build != 'test') ? [
'src/' + pkg.name + '.js',
'../packages/person-select/src/dbp-person-select-demo.js',
'../packages/knowledge-base-web-page-element-view/src/dbp-knowledge-base-web-page-element-view-demo.js',
'../packages/common/dbp-common-demo.js',
] : glob.sync('test/**/*.js'),
output: {
dir: 'dist',
entryFileNames: '[name].js',
chunkFileNames: 'shared/[name].[hash].[format].js',
format: 'esm',
sourcemap: true
},
preserveEntrySignatures: false,
// external: ['zlib', 'http', 'fs', 'https', 'url'],
onwarn: function (warning, warn) {
// ignore "suggestions" warning re "use strict"
if (warning.code === 'MODULE_LEVEL_DIRECTIVE') {
return;
}
// ignore chai warnings
if (warning.code === 'CIRCULAR_DEPENDENCY') {
return;
}
// keycloak bundled code uses eval
if (warning.code === 'EVAL') {
return;
}
warn(warning);
},
watch: {
chokidar: {
usePolling: true
}
},
plugins: [
del({
targets: 'dist/*'
}),
consts({
environment: build,
buildinfo: getBuildInfo(),
nextcloudWebAppPasswordURL: nextcloudWebAppPasswordURL,
nextcloudWebDavURL: nextcloudWebDavURL,
nextcloudBaseURL: nextcloudBaseURL,
nextcloudFileURL: nextcloudFileURL,
nextcloudName: nextcloudName,
}),
emitEJS({
src: 'assets',
include: ['**/*.ejs', '**/.*.ejs'],
data: {
getUrl: (p) => {
return url.resolve(basePath, p);
},
getPrivateUrl: (p) => {
return url.resolve(`${basePath}local/${pkg.name}/`, p);
},
name: pkg.name,
entryPointURL: entryPointURL,
nextcloudBaseURL: nextcloudBaseURL,
keyCloakServer: keyCloakServer,
keyCloakBaseURL: keyCloakBaseURL,
keyCloakClientId: keyCloakClientId,
pdfAsQualifiedlySigningServer: pdfAsQualifiedlySigningServer,
environment: build,
matomoSiteId: matomoSiteId,
buildInfo: getBuildInfo()
}
}),
resolve({
customResolveOptions: {
// ignore node_modules from vendored packages
moduleDirectory: path.join(process.cwd(), 'node_modules')
},
browser: true,
preferBuiltins: true
}),
checkLicenses && license({
banner: {
commentStyle: 'ignored',
content: `
License: <%= pkg.license %>
Dependencies:
<% _.forEach(dependencies, function (dependency) { if (dependency.name) { %>
<%= dependency.name %>: <%= dependency.license %><% }}) %>
`},
thirdParty: {
allow: {
test: '(MIT OR BSD-3-Clause OR Apache-2.0 OR LGPL-2.1-or-later)',
failOnUnlicensed: true,
failOnViolation: true,
},
},
}),
commonjs({
include: 'node_modules/**',
}),
json(),
urlPlugin({
limit: 0,
include: [
"node_modules/suggestions/**/*.css",
"node_modules/select2/**/*.css",
],
emitFiles: true,
fileName: 'shared/[name].[hash][extname]'
}),
replace({
"process.env.BUILD": '"' + build + '"',
}),
useTerser ? terser() : false,
copy({
targets: [
{src: 'assets/silent-check-sso.html', dest:'dist'},
{src: 'assets/htaccess-shared', dest: 'dist/shared/', rename: '.htaccess'},
{src: 'assets/*.css', dest: 'dist/local/' + pkg.name},
{src: 'assets/*.ico', dest: 'dist/local/' + pkg.name},
{src: 'assets/*.svg', dest: 'dist/local/' + pkg.name},
{
src: 'node_modules/pdfjs-dist/build/pdf.worker.min.js',
dest: 'dist/local/' + pkg.name + '/pdfjs',
// enable signatures in pdf preview
transform: (contents) => contents.toString().replace('if("Sig"===a.fieldType){a.fieldValue=null;this.setFlags(r.AnnotationFlag.HIDDEN)}', '')
},
{src: 'node_modules/pdfjs-dist/cmaps/*', dest: 'dist/local/' + pkg.name + '/pdfjs'}, // do we want all map files?
{src: 'node_modules/source-sans-pro/WOFF2/OTF/*', dest: 'dist/local/' + pkg.name + '/fonts'},
{src: 'node_modules/dbp-common/src/spinner.js', dest: 'dist/local/' + pkg.name, rename: 'spinner.js'},
{src: 'node_modules/dbp-common/misc/browser-check.js', dest: 'dist/local/' + pkg.name, rename: 'browser-check.js'},
{src: 'assets/icon-*.png', dest: 'dist/local/' + pkg.name},
{src: 'assets/*-placeholder.png', dest: 'dist/local/' + pkg.name},
{src: 'assets/manifest.json', dest: 'dist', rename: pkg.name + '.manifest.json'},
{src: 'assets/*.metadata.json', dest: 'dist'},
{src: 'node_modules/dbp-common/assets/icons/*.svg', dest: 'dist/local/dbp-common/icons'},
{src: 'node_modules/tabulator-tables/dist/css', dest: 'dist/local/dbp-file-source/tabulator-tables'},
],
}),
useBabel && babel({
include: [
'src/**',
'node_modules/pdfjs-dist/**', // uses Promise.allSettled
],
babelHelpers: 'runtime',
babelrc: false,
presets: [[
'@babel/preset-env', {
loose: true,
bugfixes: true,
targets: {
esmodules: true
}
}
]],
plugins: [[
'@babel/plugin-transform-runtime', {
corejs: 3,
useESModules: true
}
],
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-syntax-import-meta']
}),
watch ? serve({
contentBase: '.',
host: '127.0.0.1',
port: 8001,
historyApiFallback: basePath + pkg.name + '.html',
https: USE_HTTPS ? generateTLSConfig() : false,
headers: {
'Content-Security-Policy': `default-src 'self' 'unsafe-eval' 'unsafe-inline' analytics.tugraz.at ${keyCloakServer} ${entryPointURL} httpbin.org ${nextcloudBaseURL} www.handy-signatur.at ${pdfAsQualifiedlySigningServer} ; img-src * blob: data:`
},
}) : false
]
};
import {AppShell} from 'dbp-app-shell';
import * as commonUtils from 'dbp-common/utils';
commonUtils.defineCustomElement('dbp-toolkit-demo', AppShell);
This diff is collapsed.
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
"test": "lerna run test" "test": "lerna run test"
}, },
"author": "", "author": "",
"license": "ISC", "license": "LGPL-2.1-or-later",
"devDependencies": { "devDependencies": {
"lerna": "^3.22.1" "lerna": "^3.22.1"
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment