Compare commits

...

5 Commits

Author SHA1 Message Date
Simon 9bdea31ee8 docs: Add command documentation 2023-05-17 17:08:45 +02:00
Simon c170e69d9b feat: Add start command 2023-05-17 17:03:07 +02:00
Simon 449bec0bb4 feat: Add test command 2023-05-17 16:45:50 +02:00
Simon 673b293891 feat: Add language redirection 2023-05-17 16:44:49 +02:00
Simon dc3dbb9f64 feat: Add lint to normalize file syntaxe 2023-05-17 16:44:21 +02:00
11 changed files with 3510 additions and 66 deletions

11
.editorconfig Normal file
View File

@ -0,0 +1,11 @@
# editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

1
.eslintignore Normal file
View File

@ -0,0 +1 @@
node_modules

30
.eslintrc.json Normal file
View File

@ -0,0 +1,30 @@
{
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"globals": {
"bootstrap": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"rules": {
"no-console": 0,
"quotes": ["error", "single"],
"comma-dangle": [
"error",
{
"arrays": "always-multiline",
"objects": "always-multiline",
"imports": "always-multiline",
"exports": "always-multiline",
"functions": "ignore"
}
]
}
}

1
.stylelintignore Normal file
View File

@ -0,0 +1 @@
node_modules

48
.stylelintrc.json Normal file
View File

@ -0,0 +1,48 @@
{
"extends": "stylelint-config-standard-scss",
"rules": {
"no-empty-source": null,
"scss/comment-no-empty": null,
"max-line-length": null,
"scss/at-extend-no-missing-placeholder": null,
"scss/dollar-variable-colon-space-after": null,
"scss/dollar-variable-empty-line-before": null,
"media-feature-range-notation": null,
"color-function-notation": null,
"alpha-value-notation": null,
"selector-id-pattern": null,
"selector-class-pattern": null,
"scss/no-global-function-names": null,
"number-max-precision": null,
"hue-degree-notation": null,
"value-no-vendor-prefix": null,
"property-no-vendor-prefix": null,
"at-rule-no-unknown": [
true,
{
"ignoreAtRules": [
"extend",
"at-root",
"debug",
"warn",
"error",
"if",
"else",
"for",
"each",
"while",
"mixin",
"include",
"content",
"return",
"function",
"tailwind",
"apply",
"responsive",
"variants",
"screen"
]
}
]
}
}

View File

@ -38,10 +38,20 @@ Le logiciel est grandement inspiré de l'outil [signaturepdf](https://github.com
## Technologies
Le projet utilise :
- [Node](https://nodejs.org/fr) pour le téléchargement des dépendances avec [NPM](https://www.npmjs.com/)
- [Hugo](https://gohugo.io/) pour la génération du site statique ainsi que son déploiement
- [Bootstrap](https://getbootstrap.com/) pour le design du site (MIT)
- [PDF.js](https://mozilla.github.io/pdf.js/) pour le rendu des PDFs (Apache-2.0)
## Commandes
Il faut avoir Node.js (dernière LTS) d'installé sur son ordinateur pour importer les dépendances et lancer la construction du site.
- Installation des dépendances : `npm install`
- Lancement du site en mode développement : `npm run start`
- Lancement des tests : `npm run test`
- Construction du site : `npm run build`
## License
Logiciel libre sous license AGPL V3

View File

@ -1,7 +1,7 @@
const pdfFileField = document.getElementById("pdfFile")
const pdfModal = document.getElementById("pdfModal")
const pdfModalLabel = document.getElementById("pdfModalLabel")
const pdfModalContent = document.getElementById("pdfModalContent")
const pdfFileField = document.getElementById('pdfFile')
const pdfModal = document.getElementById('pdfModal')
const pdfModalLabel = document.getElementById('pdfModalLabel')
const pdfModalContent = document.getElementById('pdfModalContent')
// FILE
@ -10,11 +10,11 @@ function pdfFileGetName() {
}
function pdfFileClear() {
pdfFileField.value = ""
pdfFileField.value = ''
}
async function pdfFileToBlob() {
return new Promise((resolve, reject) => {
return new Promise((resolve) => {
const fr = new FileReader()
const file = pdfFileField.files[0]
fr.readAsArrayBuffer(file)
@ -30,12 +30,12 @@ async function pdfFileToBlob() {
function pdfModalShow() {
pdfModalLabelUpdate();
pdfModalContentclear()
new bootstrap.Modal("#pdfModal").show()
new bootstrap.Modal('#pdfModal').show()
pdfModalContentLoad()
}
function pdfModalContentclear() {
pdfModalContent.innerHTML = ""
pdfModalContent.innerHTML = ''
}
async function pdfModalContentLoad() {
@ -69,7 +69,7 @@ async function pdfModalContentLoad() {
// Render PDF page into canvas context
var renderContext = {
canvasContext: context,
viewport: viewport
viewport: viewport,
};
var renderTask = page.render(renderContext);
renderTask.promise.then(function () {
@ -92,11 +92,11 @@ function pdfModalLabelUpdate() {
// START
async function start() {
pdfFileField.addEventListener('change', async function(event) {
pdfFileField.addEventListener('change', async function() {
pdfModalShow()
})
pdfModal.addEventListener('hidden.bs.modal', event => {
pdfModal.addEventListener('hidden.bs.modal', () => {
pdfFileClear()
})

View File

@ -48,6 +48,7 @@ body {
color: #fff;
border-bottom-color: #fff;
}
.bd-placeholder-img {
font-size: 1.125rem;
text-anchor: middle;
@ -78,7 +79,7 @@ body {
.bi {
vertical-align: -.125em;
fill: currentColor;
fill: currentcolor;
}
.nav-scroller {

68
layouts/alias.html Normal file
View File

@ -0,0 +1,68 @@
<!DOCTYPE html>
{{ $defaultLanguage := (index (first 1 (where site.Home.AllTranslations "Permalink" .Permalink)) 0).Language.Lang }}
<html lang="{{ $defaultLanguage }}">
<head>
<title>{{ i18n "title" }}</title>
<meta name="description" content="{{ i18n "description" }}">
<link rel="canonical" href="{{ .Permalink }}"/>
<meta name="robots" content="noindex">
<meta charset="utf-8"/>
<noscript>
<meta http-equiv="refresh" content="0; url={{ .Permalink }}"/>
</noscript>
<script>
;(function () {
// Only do i18n at root,
// otherwise, redirect immediately
if (window.location.pathname !== '/') {
window.location.replace('{{ .Permalink }}')
return
}
var getFirstBrowserLanguage = function () {
var nav = window.navigator,
browserLanguagePropertyKeys = ['language', 'browserLanguage', 'systemLanguage', 'userLanguage'],
i,
language
if (Array.isArray(nav.languages)) {
for (i = 0; i < nav.languages.length; i++) {
language = nav.languages[i]
if (language && language.length) {
return language
}
}
}
// support for other well known properties in browsers
for (i = 0; i < browserLanguagePropertyKeys.length; i++) {
language = nav[browserLanguagePropertyKeys[i]]
if (language && language.length) {
return language
}
}
return '{{ $defaultLanguage }}'
}
var preferLang = getFirstBrowserLanguage()
{{ range $index, $elem := site.Home.AllTranslations }}
{{ if ne $index 0 }}else {{end}}if (preferLang.indexOf('{{ $elem.Lang }}') !== -1) {
window.location.replace('{{ $elem.Permalink }}')
}
{{ end }}
else {
{{- range site.Home.AllTranslations -}}
{{- if eq $defaultLanguage .Lang }}
window.location.replace('{{ .Permalink }}')
{{ end -}}
{{ end -}}
}
})()
</script>
</head>
<body>
<h1>{{ i18n "title" }}</h1>
<p>You should be rerouted in a jiff, if not, <a href="{{ .Permalink }}">click here</a>.</p>
</body>
</html>

3359
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -5,19 +5,34 @@
"author": "Weko",
"version": "1.0.0",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"prebuild": "npm run clean",
"build": "node_modules/.bin/hugo/hugo --gc --minify",
"prestart": "npm run clean",
"start": "node_modules/.bin/hugo/hugo server --bind=0.0.0.0 --disableFastRender",
"clean": "rm -rf public resources",
"lint": "npm run -s lint:scripts && npm run -s lint:styles",
"lint:scripts": "eslint assets/scripts",
"lint:styles": "stylelint \"assets/styles/**/*.{css,sass,scss,sss,less}\"",
"test": "npm run -s lint",
"postinstall": "hugo-installer --version otherDependencies.hugo --extended --destination node_modules/.bin/hugo"
},
"dependencies": {
"devDependencies": {
"@fullhuman/postcss-purgecss": "^5.0.0",
"autoprefixer": "^10.4.14",
"bootstrap": "^5.2.3",
"bootstrap-icons": "^1.10.5",
"cssnano": "^6.0.1",
"cssnano-preset-advanced": "^6.0.1",
"esbuild": "^0.17.19",
"eslint": "^8.40.0",
"hugo-installer": "^4.0.1",
"pdfjs-dist": "^3.6.172",
"postcss": "^8.4.23",
"postcss-cli": "^10.1.0"
"postcss-cli": "^10.1.0",
"stylelint": "^15.6.2",
"stylelint-config-standard-scss": "^9.0.0"
},
"otherDependencies": {
"hugo": "0.111.3"
},
"comments": {
"dependencies": {