Compare commits
7 Commits
05e9a05c5e
...
master
Author | SHA1 | Date | |
---|---|---|---|
d1f0f281c0 | |||
abab24231e | |||
9bdea31ee8 | |||
c170e69d9b | |||
449bec0bb4 | |||
673b293891 | |||
dc3dbb9f64 |
61
.drone.yml
Normal file
61
.drone.yml
Normal file
@ -0,0 +1,61 @@
|
||||
---
|
||||
# drone encrypt Weko/pdf-editor $AWS_ACCESS_KEY_ID
|
||||
kind: secret
|
||||
name: AWS_ACCESS_KEY_ID
|
||||
data: /saVhwaoFWeXGk4lOiqngq+bF0G+zOiER1SJTP1LNfqddb3wyX/NXW+U380RIXOLr0UFuwCF
|
||||
|
||||
---
|
||||
# drone encrypt Weko/pdf-editor $AWS_SECRET_ACCESS_KEY
|
||||
kind: secret
|
||||
name: AWS_SECRET_ACCESS_KEY
|
||||
data: Wkomm6zPGKFdmBkihm+2up253pBGUOIHueqDlanMD/yyOekI1ss1VYCn4+/7LZ+BC24wQnAtS8n7yDI14zNlbtkINSmbWX087ziBPXKbJ3ovs49TDkCsYwkFp6Y=
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: production
|
||||
|
||||
steps:
|
||||
- name: install npm
|
||||
image: node:current-alpine
|
||||
volumes:
|
||||
- name: assets
|
||||
path: /drone/src/node_modules
|
||||
commands:
|
||||
- npm install --ignore-scripts
|
||||
- npm run test
|
||||
|
||||
- name: build website
|
||||
image: jakejarvis/hugo-extended
|
||||
environment:
|
||||
AWS_ACCESS_KEY_ID:
|
||||
from_secret: AWS_ACCESS_KEY_ID
|
||||
AWS_SECRET_ACCESS_KEY:
|
||||
from_secret: AWS_SECRET_ACCESS_KEY
|
||||
volumes:
|
||||
- name: assets
|
||||
path: /drone/src/node_modules
|
||||
- name: hugo-resources
|
||||
path: /drone/src/resources
|
||||
commands:
|
||||
- hugo --gc --minify
|
||||
- hugo deploy
|
||||
|
||||
- name: notify
|
||||
image: plugins/matrix@sha256:f1affb31b0c86963c97c6f976fa0dcb3cc84272057fd8558d609d28b3064bd7f
|
||||
settings:
|
||||
homeserver: https://converser.eu
|
||||
roomid: "QwOITmkKxRJJyCSDOZ:converser.eu"
|
||||
userid: "resilien:converser.eu"
|
||||
accesstoken:
|
||||
from_secret: MATRIX_ACCESSTOKEN
|
||||
when:
|
||||
status: [ failure ]
|
||||
|
||||
volumes:
|
||||
- name: assets
|
||||
host:
|
||||
path: /tmp/drone/cache/weko/pdf-editor/node_modules
|
||||
- name: hugo-resources
|
||||
host:
|
||||
path: /tmp/drone/cache/weko/pdf-editor/resources
|
11
.editorconfig
Normal file
11
.editorconfig
Normal 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
1
.eslintignore
Normal file
@ -0,0 +1 @@
|
||||
node_modules
|
30
.eslintrc.json
Normal file
30
.eslintrc.json
Normal 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
1
.stylelintignore
Normal file
@ -0,0 +1 @@
|
||||
node_modules
|
47
.stylelintrc.json
Normal file
47
.stylelintrc.json
Normal file
@ -0,0 +1,47 @@
|
||||
{
|
||||
"extends": "stylelint-config-standard-scss",
|
||||
"rules": {
|
||||
"no-empty-source": null,
|
||||
"scss/comment-no-empty": 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"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
12
README.md
12
README.md
@ -25,7 +25,7 @@ Le logiciel est en version alpha et donc ne fonctionne pas actuellement. Le but
|
||||
- [ ] Pouvoir ajouter/supprimer/déplacer un dessin
|
||||
- [ ] Pouvoir télécharger le fichier
|
||||
- [ ] Rendre le site léger coté Javascript (minification, suppression du code non utilisé)
|
||||
- [ ] Déployer automatiquement sur https://pdf.weko.io
|
||||
- [x] Déployer automatiquement sur https://pdf.weko.io
|
||||
- [x] Rendre le site multi-langue
|
||||
- [x] Afficher le fichier PDF dans une _modal_
|
||||
- [x] Rendre le site léger coté CSS (minification, suppression du code non utilisé)
|
||||
@ -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
|
||||
|
@ -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()
|
||||
})
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -1,8 +1,13 @@
|
||||
baseURL: http://example.org/
|
||||
baseURL: https://pdf.weko.io/
|
||||
defaultContentLanguage: en
|
||||
defaultContentLanguageInSubdir: true
|
||||
disableKinds: ["taxonomy", "term"]
|
||||
|
||||
deployment:
|
||||
targets:
|
||||
- name: production
|
||||
URL: s3://pdf.weko.io?endpoint=https://s3.garage.resilien.cloud&disableSSL=true&s3ForcePathStyle=true®ion=garage
|
||||
|
||||
params:
|
||||
brand: PDF-Editor
|
||||
|
||||
|
68
layouts/alias.html
Normal file
68
layouts/alias.html
Normal 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>
|
4062
package-lock.json
generated
4062
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
27
package.json
27
package.json
@ -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",
|
||||
"pdfjs-dist": "^3.6.172",
|
||||
"esbuild": "^0.19.9",
|
||||
"eslint": "^8.40.0",
|
||||
"hugo-installer": "^4.0.1",
|
||||
"pdfjs-dist": "^4.0.269",
|
||||
"postcss": "^8.4.23",
|
||||
"postcss-cli": "^10.1.0"
|
||||
"postcss-cli": "^11.0.0",
|
||||
"stylelint": "^16.0.2",
|
||||
"stylelint-config-standard-scss": "^12.0.0"
|
||||
},
|
||||
"otherDependencies": {
|
||||
"hugo": "0.121.1"
|
||||
},
|
||||
"comments": {
|
||||
"dependencies": {
|
||||
|
Reference in New Issue
Block a user