Add a legal notices page

This commit is contained in:
Tom Wiesing 2023-01-05 17:00:40 +01:00
parent 34bdb3cf24
commit 009d649ea6
No known key found for this signature in database
34 changed files with 3048 additions and 5 deletions

View file

@ -3,6 +3,7 @@ package cmd
import ( import (
wisski_distillery "github.com/FAU-CDI/wisski-distillery" wisski_distillery "github.com/FAU-CDI/wisski-distillery"
"github.com/FAU-CDI/wisski-distillery/internal/cli" "github.com/FAU-CDI/wisski-distillery/internal/cli"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/control/static"
) )
// License is the 'wdcli license' command. // License is the 'wdcli license' command.
@ -27,7 +28,7 @@ func (license) AfterParse() error {
} }
func (license) Run(context wisski_distillery.Context) error { func (license) Run(context wisski_distillery.Context) error {
context.Printf(stringLicenseInfo, wisski_distillery.License, cli.LegalNotices) context.Printf(stringLicenseInfo, wisski_distillery.License, cli.LegalNotices, static.AssetsDisclaimer)
return nil return nil
} }
@ -43,4 +44,9 @@ wdcli is licensed under the terms of the AGPL Version 3.0 License:
Furthermore, this executable may include code from the following projects: Furthermore, this executable may include code from the following projects:
%s %s
================================================================================
Finally, the web frontend may contain additional code.
%s
` `

View file

@ -1,7 +1,7 @@
package cli package cli
// =========================================================================================================== // ===========================================================================================================
// This file was generated automatically at 04-01-2023 14:54:26 using gogenlicense. // This file was generated automatically at 05-01-2023 15:41:35 using gogenlicense.
// Do not edit manually, as changes may be overwritten. // Do not edit manually, as changes may be overwritten.
// =========================================================================================================== // ===========================================================================================================
@ -2189,7 +2189,7 @@ package cli
// # Generation // # Generation
// //
// This variable and the associated documentation have been automatically generated using the 'gogenlicense' tool. // This variable and the associated documentation have been automatically generated using the 'gogenlicense' tool.
// It was last updated at 04-01-2023 14:54:26. // It was last updated at 05-01-2023 15:41:35.
var LegalNotices string var LegalNotices string
func init() { func init() {

View file

@ -0,0 +1,58 @@
package legal
import (
"context"
"net/http"
"github.com/FAU-CDI/wisski-distillery/internal/cli"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/control"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/control/static"
"github.com/FAU-CDI/wisski-distillery/pkg/httpx"
_ "embed"
)
type Legal struct {
component.Base
}
var (
_ component.Routeable = (*Legal)(nil)
)
//go:embed "legal.html"
var legalTemplateString string
var legalTemplate = static.AssetsLegal.MustParseShared("legal.html", legalTemplateString)
func (legal *Legal) Routes() component.Routes {
return component.Routes{
Paths: []string{"/legal/"},
CSRF: false,
}
}
func (legal *Legal) HandleRoute(ctx context.Context, route string) (http.Handler, error) {
return httpx.HTMLHandler[legalContext]{
Handler: legal.context,
Template: legalTemplate,
}, nil
}
type legalContext struct {
LegalNotices string
CSRFCookie string
SessionCookie string
AssetsDisclaimer string
}
func (legal *Legal) context(r *http.Request) (legalContext, error) {
return legalContext{
LegalNotices: cli.LegalNotices,
CSRFCookie: control.CSRFCookie,
SessionCookie: control.SessionCookie,
AssetsDisclaimer: static.AssetsDisclaimer,
}, nil
}

View file

@ -0,0 +1,79 @@
{{ template "_base.html" . }}
{{ define "title" }}Legal{{ end }}
{{ define "header/time" }}
<!-- no header/time -->
{{ end }}
{{ define "header"}}
<!-- no header -->
{{ end }}
{{ define "content" }}
<div class="pure-u-1">
<h2 id="cookies">Cookie Usage</h2>
<p>
Parts of this site use cookies for essential purposes.
<a href="https://en.wikipedia.org/wiki/HTTP_cookie">Wikipedia</a> says that
</p>
<blockquote>
<p>A […] cookie (also called web cookie, Internet cookie, browser cookie, or simply cookie) is a small piece of data sent from a website and stored on the users computer by the users web browser while the user is browsing.</p>
</blockquote>
<p>
This site only uses cookies where necessary; in particular they are only used on access protected sites.
Public sites are cookie-free.
For signed in users only two cookies are used.
<ol>
<li>
The cookie named <code>{{ .CSRFCookie }}</code> is used to prevent <a href="https://en.wikipedia.org/wiki/Cross-site_request_forgery">Cross-site request forgery</a>.
</li>
<li>
The cookie named <code>{{ .SessionCookie }}</code> is used to track a distillery user session, so that a user does not constantly have to login again.
It is automatically deleted once a user signs out.
</li>
</ol>
Neither cookie is used beyond the purposes they are required for.
In particular, they are not used for analytics or any other kind of tracking.
</p>
</div>
<div class="pure-u-1">
<h2 id="notices">Legal Notices</h2>
<ul>
<li><a href="#license.backend">Backend</a></li>
<li><a href="#license.frontend">Frontend</a></li>
</ul>
<p>
This site is powered by the <a href="https://github.com/FAU-CDI/wisski-distillery" target="_blank" rel="noopener noreferer">WissKI Distillery</a>.
The project is licensed under the terms of the AGPL Version 3.0 License.
</p>
</div>
<div class="pure-u-1">
<h3 id="license.backend">Backend</h2>
<p>
<small><a href="#notices">Back to Notices</a></small>
</p>
<p>
The backend may contain code from the following projects:
</p>
<pre>{{ .LegalNotices }}</pre>
</div>
<div class="pure-u-1">
<h3 id="license.frontend">Frontend</h2>
<p>
<small><a href="#notices">Back to Notices</a></small>
</p>
<pre>{{ .AssetsDisclaimer }}</pre>
</div>
{{ end }}

View file

@ -21,7 +21,7 @@ type Assets struct {
Styles string // <link> tags inserted by the asset Styles string // <link> tags inserted by the asset
} }
//go:generate node build.mjs Home User Admin //go:generate node build.mjs Home User Admin Legal
// MustParse parses a new template from the given source // MustParse parses a new template from the given source
// and calls [RegisterAssoc] on it. // and calls [RegisterAssoc] on it.

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,12 @@
package static package static
import _ "embed"
// This file was automatically generated. Do not edit. // This file was automatically generated. Do not edit.
//go:embed "assets_disclaimer.txt"
var AssetsDisclaimer string
// AssetsHome contains assets for the 'Home' entrypoint. // AssetsHome contains assets for the 'Home' entrypoint.
var AssetsHome = Assets{ var AssetsHome = Assets{
Scripts: `<script type="module" src="/static/Home.38d394c2.js"></script><script src="/static/Home.38d394c2.js" nomodule="" defer></script><script type="module" src="/static/Home.38d394c2.js"></script><script src="/static/Home.38d394c2.js" nomodule="" defer></script>`, Scripts: `<script type="module" src="/static/Home.38d394c2.js"></script><script src="/static/Home.38d394c2.js" nomodule="" defer></script><script type="module" src="/static/Home.38d394c2.js"></script><script src="/static/Home.38d394c2.js" nomodule="" defer></script>`,
@ -19,3 +24,9 @@ var AssetsAdmin = Assets{
Scripts: `<script nomodule="" defer src="/static/User.30d54198.js"></script><script type="module" src="/static/User.4197014b.js"></script><script type="module" src="/static/Home.38d394c2.js"></script><script src="/static/Home.38d394c2.js" nomodule="" defer></script><script type="module" src="/static/Admin.4ca3cb6f.js"></script><script src="/static/Admin.9750ba9c.js" nomodule="" defer></script>`, Scripts: `<script nomodule="" defer src="/static/User.30d54198.js"></script><script type="module" src="/static/User.4197014b.js"></script><script type="module" src="/static/Home.38d394c2.js"></script><script src="/static/Home.38d394c2.js" nomodule="" defer></script><script type="module" src="/static/Admin.4ca3cb6f.js"></script><script src="/static/Admin.9750ba9c.js" nomodule="" defer></script>`,
Styles: `<link rel="stylesheet" href="/static/Home.9f00501f.css"><link rel="stylesheet" href="/static/Admin.6d59e220.css"><link rel="stylesheet" href="/static/User.38d394c2.css"><link rel="stylesheet" href="/static/Admin.6d2ae968.css">`, Styles: `<link rel="stylesheet" href="/static/Home.9f00501f.css"><link rel="stylesheet" href="/static/Admin.6d59e220.css"><link rel="stylesheet" href="/static/User.38d394c2.css"><link rel="stylesheet" href="/static/Admin.6d2ae968.css">`,
} }
// AssetsLegal contains assets for the 'Legal' entrypoint.
var AssetsLegal = Assets{
Scripts: `<script type="module" src="/static/Home.38d394c2.js"></script><script src="/static/Home.38d394c2.js" nomodule="" defer></script><script type="module" src="/static/Legal.38d394c2.js"></script><script src="/static/Legal.38d394c2.js" nomodule="" defer></script>`,
Styles: `<link rel="stylesheet" href="/static/Home.9f00501f.css"><link rel="stylesheet" href="/static/Legal.d1531eba.css"><link rel="stylesheet" href="/static/Legal.20259812.css">`,
}

View file

@ -2,6 +2,7 @@ import { Parcel } from "@parcel/core"
import { mkdir, rm, writeFile, readFile, unlink, rmdir, } from "fs/promises" import { mkdir, rm, writeFile, readFile, unlink, rmdir, } from "fs/promises"
import { join } from "path" import { join } from "path"
import { parse as parseHTML } from 'node-html-parser'; import { parse as parseHTML } from 'node-html-parser';
import { spawnSync } from 'child_process'
// //
// PARAMETERS // PARAMETERS
@ -13,6 +14,11 @@ const DIST_DIR = join('.', 'dist')
const PUBLIC_DIR = '/static/' const PUBLIC_DIR = '/static/'
const DEST_PACKAGE = process.env.GOPACKAGE ?? 'static' const DEST_PACKAGE = process.env.GOPACKAGE ?? 'static'
const DEST_DISCLAIMER = (() => {
const source = (process.env.GOFILE ?? 'assets.go')
const base = source.substring(0, source.length - '.go'.length)
return base + '_disclaimer.txt'
})()
const DEST_FILE = (() => { const DEST_FILE = (() => {
const source = (process.env.GOFILE ?? 'assets.go') const source = (process.env.GOFILE ?? 'assets.go')
const base = source.substring(0, source.length - '.go'.length) const base = source.substring(0, source.length - '.go'.length)
@ -31,6 +37,30 @@ await Promise.all([
console.log(' Done.') console.log(' Done.')
//
// Write the disclaimer
//
process.stdout.write('Generating legal disclaimer ...')
const disclaimer = await new Promise((r, e) => {
var child = spawnSync("yarn", ["licenses", "generate-disclaimer"], { encoding : 'utf8' });
if (child.error) {
e(child.stderr)
return
}
r(child.stdout)
});
console.log(' Done.')
process.stdout.write(`Writing ${DEST_DISCLAIMER} ...`)
await writeFile(DEST_DISCLAIMER, disclaimer)
console.log(' Done.')
// //
// WRITE ENTRY POINTS // WRITE ENTRY POINTS
// //
@ -79,7 +109,6 @@ const bundler = new Parcel({
const { bundleGraph } = await bundler.run() const { bundleGraph } = await bundler.run()
console.log(' Done.') console.log(' Done.')
// //
// FIND ASSETS IN OUTPUT // FIND ASSETS IN OUTPUT
// //
@ -118,8 +147,13 @@ var Assets${name} = Assets{
}).join('\n\n') }).join('\n\n')
const goSource = `package ${DEST_PACKAGE} const goSource = `package ${DEST_PACKAGE}
import _ "embed"
// This file was automatically generated. Do not edit. // This file was automatically generated. Do not edit.
//go:embed ${JSON.stringify(DEST_DISCLAIMER)}
var AssetsDisclaimer string
${goAssets} ${goAssets}
`; `;

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1 @@
html{background-color:#87a485}body{max-width:80vw!important}

File diff suppressed because one or more lines are too long

View file

@ -5,6 +5,7 @@
"private": true, "private": true,
"dependencies": { "dependencies": {
"dayjs": "^1.11.5", "dayjs": "^1.11.5",
"latex.css": "^1.8.0",
"node-html-parser": "^6.1.1", "node-html-parser": "^6.1.1",
"parcel": "^2.7.0", "parcel": "^2.7.0",
"purecss": "^2.1.0" "purecss": "^2.1.0"

View file

@ -0,0 +1,7 @@
html {
background-color: #87A485;
}
body {
max-width: 80vw !important;
}

View file

@ -0,0 +1 @@
import "latex.css/style.min.css"

View file

@ -1093,6 +1093,11 @@ json5@^2.2.0, json5@^2.2.1:
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.1.tgz#655d50ed1e6f95ad1a3caababd2b0efda10b395c" resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.1.tgz#655d50ed1e6f95ad1a3caababd2b0efda10b395c"
integrity sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA== integrity sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==
latex.css@^1.8.0:
version "1.8.0"
resolved "https://registry.yarnpkg.com/latex.css/-/latex.css-1.8.0.tgz#463f77c844900825f5a53bd3aa0457473a293cba"
integrity sha512-3mUWF6M2/3eqEhekJ2i3GWQbJQpGIQ3JDKtd3GwsmQCifxqCFS3UkOlkvsAOB6C+AN/O2y9kPOVbs/kR2O5sDg==
lightningcss-darwin-arm64@1.16.0: lightningcss-darwin-arm64@1.16.0:
version "1.16.0" version "1.16.0"
resolved "https://registry.yarnpkg.com/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.16.0.tgz#f3318a2e64ca160610977675ee1a7e611f4a3617" resolved "https://registry.yarnpkg.com/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.16.0.tgz#f3318a2e64ca160610977675ee1a7e611f4a3617"

View file

@ -14,6 +14,7 @@ import (
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/control/admin" "github.com/FAU-CDI/wisski-distillery/internal/dis/component/control/admin"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/control/cron" "github.com/FAU-CDI/wisski-distillery/internal/dis/component/control/cron"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/control/home" "github.com/FAU-CDI/wisski-distillery/internal/dis/component/control/home"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/control/legal"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/control/static" "github.com/FAU-CDI/wisski-distillery/internal/dis/component/control/static"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/exporter" "github.com/FAU-CDI/wisski-distillery/internal/dis/component/exporter"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/exporter/logger" "github.com/FAU-CDI/wisski-distillery/internal/dis/component/exporter/logger"
@ -161,6 +162,7 @@ func (dis *Distillery) allComponents() []initFunc {
manual(func(admin *admin.Admin) { manual(func(admin *admin.Admin) {
admin.Analytics = &dis.pool.Analytics admin.Analytics = &dis.pool.Analytics
}), }),
auto[*legal.Legal],
// Cron // Cron
auto[*cron.Cron], auto[*cron.Cron],