first commit

This commit is contained in:
Simon 2022-02-18 18:17:03 +01:00
commit a54d4be5b4
32 changed files with 998 additions and 0 deletions

4
.dockerignore Normal file
View File

@ -0,0 +1,4 @@
# Ignore everything
**
!public

158
.drone.yml Normal file
View File

@ -0,0 +1,158 @@
---
# drone encrypt weko/scores.ceiba-conseil.com $REGISTRY_PASSWORD
kind: secret
name: REGISTRY_PASSWORD
data: BW8D91fKNJuWWF5k5F/CNi8GIQvmNEUocqPJJ+N57qxQ06y+G9q715PBFpys5BTKUQHPQqSd7Q6MhWpsOc5Ttn/gtCX1tbGrAqsFrEec
---
# drone encrypt weko/scores.ceiba-conseil.com $REGISTRY_USER
kind: secret
name: REGISTRY_USER
data: dlboI6U0j0jZxVQiF62p9lQkpFBg7M4QtiD6K7K3NtQmkw==
---
# drone encrypt weko/scores.ceiba-conseil.com "{\"auths\":{\"https://registry.weko.io\":{\"auth\":\"$(echo -n "$REGISTRY_USER:$REGISTRY_PASSWORD" | base64)\",\"email\":\"$REGISTRY_USER\"}}}"
kind: secret
name: REGISTRY_CONFIG
data: B0svjVRqxyDJE+MmSPPCU2hWbBzTjYHS6CnV6IAzGxrQPVNbGmEqoCWkBsG6tUFhL3JcU+fYEidV+RVHTRpYumbDWTXlBSz0q3BVsfqxvgWb2JgpvO7/X3rIxCZwECMMMm7nyRubsOeFDzFh9ic1cU4Bw2DTA+L65lWGiEGME/KqCi6yKy56KjmAC8kAoJ9ifw++KsGytvZjPI68+bbWpRFTAuwWU3SDv12y
---
# drone encrypt weko/scores.ceiba-conseil.com $DIRECTUS_URL
kind: secret
name: DIRECTUS_URL
data: Z1mUl3LdiVP6vClaVeA56nTafKHIevYaRKqqYDKycN5im+M93XvrZbK995EDreb4cttMD1jMmJaq3NQ=
---
# drone encrypt weko/scores.ceiba-conseil.com $DIRECTUS_TOKEN
kind: secret
name: DIRECTUS_TOKEN
data: C4N8jh2kDORa5vo2mqOcqbBLLBXdcnHNDq9sK6+R9gzemeyzLp3K7ENw5ZibVYAJ2VEYylQr9zvHFeFE
# ---
# kind: pipeline
# type: docker
# name: prod
#
# platform:
# os: linux
# arch: arm64
#
# steps:
# - name: install submodule
# image: drone/git
# commands:
# - git submodule update --init
#
# - name: install npm
# image: node:current-alpine
# volumes:
# - name: hugo-theme-lowtech_node_modules
# path: /drone/src/themes/hugo-theme-lowtech/node_modules
# # environment:
# # DIRECTUS_URL:
# # from_secret: DIRECTUS_URL
# # DIRECTUS_TOKEN:
# # from_secret: DIRECTUS_TOKEN
# commands:
# - (cd themes/hugo-theme-lowtech && npm i)
# # - node scripts/directus-to-markdown/index.js
#
# - name: build website
# image: jakejarvis/hugo-extended
# commands:
# - hugo --minify --environment production
#
# - name: typo
# image: node:current-alpine
# volumes:
# - name: hugo-theme-lowtech_node_modules
# path: /drone/src/themes/hugo-theme-lowtech/node_modules
# commands:
# - node themes/hugo-theme-lowtech/scripts/typo
#
# - name: push docker image on registry
# image: plugins/docker
# settings:
# username:
# from_secret: REGISTRY_USER
# password:
# from_secret: REGISTRY_PASSWORD
# repo: registry.weko.io/sisa-urfe_fr
# registry: registry.weko.io
# tags:
# - latest
#
# image_pull_secrets:
# - REGISTRY_CONFIG
#
# volumes:
# - name: hugo-theme-lowtech_node_modules
# host:
# path: /tmp/drone/cache/weko/scores.ceiba-conseil.com/themes/hugo-theme-lowtech
---
kind: pipeline
type: docker
name: staging
platform:
os: linux
arch: arm64
steps:
- name: install submodule
image: drone/git
commands:
- git submodule update --init
- name: install npm
image: node:current-alpine
volumes:
- name: hugo-theme-lowtech_node_modules
path: /drone/src/themes/hugo-theme-lowtech/node_modules
environment:
DIRECTUS_URL:
from_secret: DIRECTUS_URL
DIRECTUS_TOKEN:
from_secret: DIRECTUS_TOKEN
commands:
- (cd themes/hugo-theme-lowtech && npm i)
- node scripts/directus-to-markdown/index.js
- name: build website
image: jakejarvis/hugo-extended
environment:
HUGO_PARAMS_DIRECTUS_URL:
from_secret: DIRECTUS_URL
HUGO_PARAMS_DIRECTUS_TOKEN:
from_secret: DIRECTUS_TOKEN
commands:
- hugo --minify --buildDrafts --buildFuture --environment staging
- name: typo
image: node:current-alpine
volumes:
- name: hugo-theme-lowtech_node_modules
path: /drone/src/themes/hugo-theme-lowtech/node_modules
commands:
- node themes/hugo-theme-lowtech/scripts/typo
- name: push docker image on registry
image: plugins/docker
settings:
username:
from_secret: REGISTRY_USER
password:
from_secret: REGISTRY_PASSWORD
repo: registry.weko.io/scores_ceiba
registry: registry.weko.io
tags:
- staging
image_pull_secrets:
- REGISTRY_CONFIG
volumes:
- name: hugo-theme-lowtech_node_modules
host:
path: /tmp/drone/cache/weko/scores.ceiba-conseil.com/themes/hugo-theme-lowtech

10
.editorconfig Normal file
View File

@ -0,0 +1,10 @@
root = true
[*]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false

3
.env Normal file
View File

@ -0,0 +1,3 @@
DOCKER_CONTEXT=vert.weko.resilien
NAME=vert.weko.resilien
URL=scores.ceiba-conseil.com

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
resources
public
.hugo_build.lock

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "themes/hugo-theme-lowtech"]
path = themes/hugo-theme-lowtech
url = https://git.weko.io/kosssi/hugo-theme-lowtech.git

4
Dockerfile Normal file
View File

@ -0,0 +1,4 @@
FROM registry.weko.io/nginx-lowtech:0.0.9
# Copie des sources du site
COPY public /usr/share/nginx/html

61
assets/js/main.js Normal file
View File

@ -0,0 +1,61 @@
if ('serviceWorker' in navigator) {
// Use the window load event to keep the page load performant
window.addEventListener('load', () => {
navigator.serviceWorker.register('/js/sw.js').then(function(reg) {
if(reg.installing) {
console.log('Service worker installing');
} else if(reg.waiting) {
console.log('Service worker installed');
} else if(reg.active) {
console.log('Service worker active');
}
}).catch(function(error) {
// registration failed
console.log('Registration failed with ' + error);
});
});
}
async function main () {
const forms = document.getElementsByClassName('form')
for (const form of forms) {
const fieldsName = [...new Set(Array.from(form.querySelectorAll("input")).map(item => item.name))]
const scoreFields = Array.from(form.querySelectorAll(".score"))
form.addEventListener('change', function() {
const fieldsValue = fieldsName.map(fieldName => {
const field = form.querySelector('input[name="' + fieldName + '"]:checked')
if (field) return field.value
}).filter(item => item !== undefined)
if (fieldsName.length == fieldsValue.length) {
const score = fieldsValue.reduce((accumulator, curr) => parseInt(accumulator) + parseInt(curr))
scoreFields.map(item => {
item.classList.remove('active')
return item
}).filter(item => {
return score >= item.dataset.min && (item.dataset.max == "" || score <= item.dataset.max)
}).map(item => {
item.classList.add('active')
console.log(item.getElementsByClassName('score_' + form.dataset.id))
Array.from(item.getElementsByClassName('score_' + form.dataset.id)).map(item => item.innerHTML = score)
})
}
var all = form.querySelectorAll("input")
const scoreField = document.getElementsByClassName('score_' + form.dataset.id)
var score = 0
for (let field of all) {
if (field.type != "submit" && field.type != "button") {
if (field.type=="radio" || field.type=="checkbox") {
if (field.checked) {
score = score + parseInt(field.value)
}
}
}
}
scoreField.innerHTML = score
});
}
}
main()

12
assets/js/sw.js Normal file
View File

@ -0,0 +1,12 @@
self.addEventListener('install', function(event) {
event.waitUntil(
caches.open('v1').then(function(cache) {
return cache.addAll([
'/',
'/index.html',
'/styles/main.css',
'/js/main.js'
]);
})
);
});

9
assets/styles/main.sass Normal file
View File

@ -0,0 +1,9 @@
h1, h2
text-align: center
.score
display: none
margin: 1rem
&.active
display: inherit

View File

@ -0,0 +1,42 @@
languageCode: fr-fr
title: Ceiba App
theme:
- hugo-theme-lowtech
defaultContentLanguage: fr
disableKinds:
- taxonomy
- term
# params:
# FaviconFile: /favicon.svg
# ImageSize: 1040x
# SocialImage: RESILIEN_LOGO_SLOGAN_disc_slogan.svg
outputs:
page:
- json
section:
- json
home:
- html
minify:
tdewolff:
html:
keepWhitespace: false
markup:
goldmark:
parser:
attribute:
block: true
renderer:
unsafe: true
disableHugoGeneratorInject: true
enableRobotsTXT: true

View File

@ -0,0 +1 @@
baseURL: http://localhost:1313/

View File

@ -0,0 +1 @@
baseURL: https://scores.ceiba-conseil.com/

View File

@ -0,0 +1 @@
baseURL: https://staging.scores.ceiba-conseil.com/

167
content/.drone.yml Normal file
View File

@ -0,0 +1,167 @@
---
# drone encrypt weko/sisa-urfe_fr $REGISTRY_PASSWORD
kind: secret
name: REGISTRY_PASSWORD
data: g8m2Y3gcKcCC10HLLVQDTlsxIGBeAaNqAXXjOzFId3Ib88cvCGxqkE5su7Qvo97xvoqu/09jIWXjf30vecYiqum+pQv4imYfhuzzsrag
---
# drone encrypt weko/sisa-urfe_fr $REGISTRY_USER
kind: secret
name: REGISTRY_USER
data: pe0ODYOxonYnAjd2YR3O5LN/sHjWJc31Lmvom+VfnuKrrQ==
---
# drone encrypt weko/sisa-urfe_fr "{\"auths\":{\"https://registry.weko.io\":{\"auth\":\"$(echo -n "$REGISTRY_USER:$REGISTRY_PASSWORD" | base64)\",\"email\":\"$REGISTRY_USER\"}}}"
kind: secret
name: REGISTRY_CONFIG
data: i5xaNdkAH0n5IDgIn4OVRwViez97c62RHau8eELYJHnossMU797dow6bW77bGyMIx0ONwcOmdtDH92kpci/GeZmyPrCvODrXwt9pTAMEdVelQ3jy/mxpdtB/p5qJ6u+9CrUBw/S67ImY3yhr8o95pdpJFclkqWRsrjeg1BSHRF8RnEAQ9yBwXxoEXpSZBCnlSwG1z0cDY3JwFUH8LVQgldopiiaDAhk09dpk
---
# drone encrypt weko/sisa-urfe_fr $DIRECTUS_URL
kind: secret
name: DIRECTUS_URL
data: 3SzmP61E8oSo5PLSWnHRBUfUCa0Fe9cfc3C2ADXe7cvuY45sNXCn+YjVCL1M3yG5wJsEbEUh
---
# drone encrypt weko/sisa-urfe_fr $DIRECTUS_TOKEN
kind: secret
name: DIRECTUS_TOKEN
data: Dxlod5HBIa5S897CsQsaDPbZDqYLuIL7z4kQahf4jlWxyme79fsK7LhZVHPDRfQJf1HknAgGWJUUqhL3
# ---
# kind: pipeline
# type: docker
# name: prod
#
# platform:
# os: linux
# arch: arm64
#
# steps:
# - name: install submodule
# image: drone/git
# commands:
# - git submodule update --init
#
# - name: install npm
# image: node:current-alpine
# volumes:
# - name: hugo-theme-lowtech_node_modules
# path: /drone/src/themes/hugo-theme-lowtech/node_modules
# # environment:
# # DIRECTUS_URL:
# # from_secret: DIRECTUS_URL
# # DIRECTUS_TOKEN:
# # from_secret: DIRECTUS_TOKEN
# commands:
# - (cd themes/hugo-theme-lowtech && npm i)
# # - node scripts/directus-to-markdown/index.js
#
# - name: build website
# image: jakejarvis/hugo-extended
# commands:
# - hugo --minify --environment production
#
# - name: typo
# image: node:current-alpine
# volumes:
# - name: hugo-theme-lowtech_node_modules
# path: /drone/src/themes/hugo-theme-lowtech/node_modules
# commands:
# - node themes/hugo-theme-lowtech/scripts/typo
#
# - name: push docker image on registry
# image: plugins/docker
# settings:
# username:
# from_secret: REGISTRY_USER
# password:
# from_secret: REGISTRY_PASSWORD
# repo: registry.weko.io/sisa-urfe_fr
# registry: registry.weko.io
# tags:
# - latest
#
# image_pull_secrets:
# - REGISTRY_CONFIG
#
# volumes:
# - name: hugo-theme-lowtech_node_modules
# host:
# path: /tmp/drone/cache/weko/sisa-urfe_fr/themes/hugo-theme-lowtech
---
kind: pipeline
type: docker
name: staging
platform:
os: linux
arch: arm64
steps:
- name: install submodule
image: drone/git
commands:
- git submodule update --init
- name: install npm
image: node:current-alpine
volumes:
- name: hugo-theme-lowtech_node_modules
path: /drone/src/themes/hugo-theme-lowtech/node_modules
- name: assets
path: /drone/src/assets/node_modules
environment:
DIRECTUS_URL:
from_secret: DIRECTUS_URL
DIRECTUS_TOKEN:
from_secret: DIRECTUS_TOKEN
commands:
- (cd themes/hugo-theme-lowtech && npm i)
- (cd assets && npm i)
- DRAFT=true node scripts/directus-to-markdown/index.js
- name: build website
image: jakejarvis/hugo-extended
environment:
HUGO_PARAMS_DIRECTUS_URL:
from_secret: DIRECTUS_URL
HUGO_PARAMS_DIRECTUS_TOKEN:
from_secret: DIRECTUS_TOKEN
volumes:
- name: assets
path: /drone/src/assets/node_modules
commands:
- hugo --minify --buildDrafts --buildFuture --environment staging
- name: typo
image: node:current-alpine
volumes:
- name: hugo-theme-lowtech_node_modules
path: /drone/src/themes/hugo-theme-lowtech/node_modules
commands:
- node themes/hugo-theme-lowtech/scripts/typo
- name: push docker image on registry
image: plugins/docker
settings:
username:
from_secret: REGISTRY_USER
password:
from_secret: REGISTRY_PASSWORD
repo: registry.weko.io/sisa-urfe_fr
registry: registry.weko.io
tags:
- staging
image_pull_secrets:
- REGISTRY_CONFIG
volumes:
- name: assets
host:
path: /tmp/drone/cache/weko/sisa-urfe_fr/assets/node_modules
- name: hugo-theme-lowtech_node_modules
host:
path: /tmp/drone/cache/weko/sisa-urfe_fr/themes/hugo-theme-lowtech

157
content/_index.md Normal file
View File

@ -0,0 +1,157 @@
---
id: 1
sort: null
title: Facteurs de sécurité cavité ouverte sur tronc
results:
- id: 1
sort: 0
min: 0
max: 2
facteur: Très au delà de 5
effets: Capacité de charge très supérieure à la charge de service
pde: Improbable
pde_qtra: 7
- id: 2
sort: 1
min: 2.5
max: 4.5
facteur: Au delà de 5
effets: Capacité de charge supérieure à la charge de service
pde: Très faible
pde_qtra: 6
- id: 3
sort: 2
min: 5
max: 7
facteur: Entre 4 et 5
effets: >-
Capacité de charge normalement (coef moyen) supérieure à la charge de
service
pde: Faible
pde_qtra: 5
- id: 4
sort: 3
min: 7.5
max: 9.5
facteur: Entre 2 et 4
effets: >-
Capacité de charge supérieure à la charge de service mais sous le coef
moyen
pde: Echec possible sous contraintes très anormales
pde_qtra: 4
- id: 5
sort: 4
min: 10
max: 12
facteur: Entre 1 et 2
effets: Capacité de charge s'approchant de la charge de service
pde: Echec possible sous contraintes anormales
pde_qtra: 3
- id: 6
sort: 5
min: 12.5
max: 14.5
facteur: ~ 1
effets: Capacité de charge plus ou moins égale à la charge de service
pde: Echec possible sous contraintes courantes
pde_qtra: 2
- id: 7
sort: 6
min: 15
max: null
facteur: < 1
effets: Charge de service supérieure à la capacité de charge
pde: Echec imminent sous contraintes courantes ou masse propre
pde_qtra: 1
questions:
- id: 9
sort: 0
title: Matériau résiduel (PRBS)
answers:
- id: 1
sort: 0
title: '= 25%'
weight: 1
- id: 2
sort: 1
title: de 25 à 10 %
weight: 2
- id: 3
sort: 2
title: < 10 %
weight: 4
- id: 11
sort: 1
title: Adaptations géométriques
answers:
- id: 6
sort: 0
title: Très forte croissance accrue
weight: -1
- id: 7
sort: 1
title: Forte croissance accrue
weight: 0
- id: 8
sort: 2
title: Faibles croissance accrue
weight: 2
- id: 9
sort: 3
title: Sans croissance accrue
weight: 5
- id: 12
sort: 2
title: Rapport H/D (+-20% de marge)
answers:
- id: 10
sort: 0
title: < 15
weight: 0
- id: 11
sort: 1
title: Entre 15 et 30
weight: 1
- id: 12
sort: 2
title: Entre 30 et 50
weight: 2
- id: 13
sort: 3
title: Entre 50 et 70
weight: 3
- id: 14
sort: 4
title: '> 70'
weight: 4
- id: 13
sort: 3
title: Organes de soutiens structurels
answers:
- id: 15
sort: 0
title: OSS caractérisés et intègres
weight: 1
- id: 16
sort: 1
title: OSS relatifs et intègres
weight: 2
- id: 17
sort: 2
title: OSS caractérisés, partiellement dégradés
weight: 3
- id: 18
sort: 3
title: OSS relatifs et partiellement dégradés
weight: 4
- id: 19
sort: 4
title: OSS insuffisants et intègres
weight: 5
- id: 20
sort: 5
title: OSS insuffisants et dégradés
weight: 6
---

82
data/ceiba.yml Normal file
View File

@ -0,0 +1,82 @@
---
app:
categories:
houppier:
title: Houppier
tronc:
title: Tronc
recinaire:
title: Collet et départs racinaires
kpi:
- id: form_1
title: Matériaux résiduels
choices:
- id: 1
title: 100%
weight: 4
order: 1
- id: 2
title: = 25 %
weight: 3
order: 2
- id: 3
title: De 25 à 10 %
weight: 2
order: 3
- id: 4
title: < 10 %
weight: 1
order: 4
- titles: Adaptations géométriques
choices:
- id: 5
title: Caractérisées
weight: 3
order: 1
- id: 6
title: Adaptatives
weight: 2
order: 2
- id: 7
title: Relatives
weight: 2
order: 3
- id: 8
title: Insuffisantes à nulles
weight: 1
order: 4
- titles: Rapport H/D
choices:
- title: < 15
weight: 3
order: 1
- title: Entre 15 et 30
weight: 2
order: 2
- title: Entre 30 et 50
weight: 2
order: 3
- title: Entre 50 et 70
weight: 1
order: 4
- title: > 70
weight: 0
order: 5
- titles: Symptômes de pourriture évolutive
choices:
- title: Aucun
weight: 3
order: 1
- title: Supperficiels, locaux
weight: 2
order: 2
- title: Superficiels, + de 25 %
weight: 2
order: 3
- title: Dommageables, peu compensés
weight: 1
order: 4
- title: Dommageables, non compensés/démarqués
weight: 0
order: 5

28
docker-compose.prod.yml Normal file
View File

@ -0,0 +1,28 @@
version: "3.8"
volumes:
ceiba-log:
name: ceiba-log
ceiba-stats:
name: ceiba-stats
services:
scores_ceiba-prod:
container_name: ceiba-prod
build: .
image: registry.weko.io/scores_ceiba:latest
restart: always
labels:
traefik.enable: "true"
traefik.http.routers.ceiba.rule: "Host(`${URL}`)"
traefik.http.routers.ceiba.entrypoints: "web"
com.centurylinklabs.watchtower.enable: true
volumes:
- ceiba-log:/var/log/nginx
- ceiba-stats:/usr/share/nginx/html/stats
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
networks:
default:
name: traefik

View File

@ -0,0 +1,20 @@
version: "3.8"
networks:
default:
name: traefik
services:
scores_ceiba-staging:
container_name: ceiba-staging
build: .
image: registry.weko.io/scores_ceiba:staging
restart: always
labels:
traefik.enable: "true"
traefik.http.routers.ceiba-staging.rule: "Host(`staging.${URL}`)"
traefik.http.routers.ceiba-staging.entrypoints: "web"
com.centurylinklabs.watchtower.enable: true
volumes:
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro

View File

@ -0,0 +1,3 @@
{
"id": 1
}

View File

@ -0,0 +1,22 @@
{
"id": {{ .Params.id }},
"sort": {{ .Params.sort }},
"title": "{{ .Title }}",
"questions": [{{ range $index, $question := .Params.questions }}
{{ if $index }}, {{ end }}
{
"id": {{ $question.id }},
"sort": {{ $index }},
"title": "{{ $question.title }}",
"answers": [{{ range $i, $answer := $question.answers }}
{
"id": {{ $answer.id }},
"sort": {{ $i }},
"title": "{{ $answer.title }}",
"weight": "{{ $answer.weight }}",
}
{{ end }}]
}
{{ end }}]
"permalink" : "{{ .Permalink }}"
}

34
layouts/index.html Normal file
View File

@ -0,0 +1,34 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Hello World</title>
<link rel="apple-touch-icon" href="images/pwa-icon-256.png" />
{{ $style := resources.Get "styles/main.sass" }}
{{ with $style }}
{{ $styleCSS := . | toCSS }}
<link rel="stylesheet" href="{{ $styleCSS.Permalink }}">
{{ end }}
<link rel="manifest" href="/manifest.json" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="white" />
</head>
<body>
<h1>Ceiba App</h1>
{{ partial "scores" . }}
{{ $js := resources.Get "js/sw.js" }}
{{ with $js }}
{{ $secureJS := . | js.Build }}
<!--script src="{{ $secureJS.Permalink }}" integrity="{{ $secureJS.Data.Integrity }}"></script-->
{{ end }}
{{ $js := resources.Get "js/main.js" }}
{{ with $js }}
{{ $secureJS := . | js.Build }}
<script src="{{ $secureJS.Permalink }}" integrity="{{ $secureJS.Data.Integrity }}"></script>
{{ end }}
</body>
</html>

View File

@ -0,0 +1,29 @@
{{ $formId := .Params.id }}
<div class="forms">
<h2>{{ .Title }}</h2>
<form class="form" data-id="{{ $formId }}">
{{ range .Params.questions }}
<fieldset>
<legend>{{ .title }}</legend>
{{ $questionId := .id }}
{{ range .answers }}
<div>
<label>
<input type="radio" name="form_{{ $formId }}-question_{{ $questionId }}" value="{{ .weight }}"> {{ .title }}
</label>
</div>
{{ end }}
</fieldset>
{{ end }}
{{ range .Params.results }}
<div class="score" data-min="{{ .min }}" data-max="{{ .max }}">
Score : <span class="score_{{ $formId }}"></span><br>
Facteur de sécurité : {{ .facteur }}<br>
Effets sur la capacité de charge : {{ .effets }}<br>
Probabilité d'échec (PdE) : {{ .pde }}<br>
PdE QTRA : {{ .pde_qtra }}
</div>
{{ end }}
</form>
</div>

24
run Executable file
View File

@ -0,0 +1,24 @@
#!/bin/bash
# -e Exit immediately if a command exits with a non-zero status.
# -u Treat unset variables as an error when substituting.
set -eu
. ./.env
. ./themes/hugo-theme-lowtech/scripts/run
echo " ____ _ _ _ "
echo "| _ \ ___ ___(_) | (_) ___ _ __ "
echo "| |_) / _ \/ __| | | | |/ _ \ '_ \ "
echo "| _ < __/\__ \ | |___| | __/ | | |"
echo "|_| \_\___||___/_|_____|_|\___|_| |_|"
echo
echo
if [ $# -ge 1 ]; then
$@
else
help_generic
fi
end

View File

@ -0,0 +1,81 @@
import DirectusToMarkdown from '@resilien/directus-to-markdown'
import urlslug from 'url-slug'
const getTranslation = (translations, lang, field) => {
const match = translations.filter(translation => translation.languages_code == lang || translation.languages_id == lang)
return match.length > 0 ? match[0][field] : undefined
}
const formatQuestions = (questions, lang) => {
const formated = []
for (const [i, question] of questions.entries()) {
formated.push({
id: question.questions_id.id,
sort: question.sort,
title: getTranslation(question.questions_id.translations, lang, 'title'),
answers: formatAnswers(question.questions_id.answers, lang)
})
}
return formated
}
const formatAnswers = (answers, lang) => {
const formated = []
for (const [i, answer] of answers.entries()) {
formated.push({
id: answer.answers_id.id,
sort: answer.sort,
title: getTranslation(answer.answers_id.translations, lang, 'title'),
weight: answer.answers_id.weight
})
}
return formated
}
const formatScore = (score, lang) => {
score.title = getTranslation(score.translations, lang, 'title')
delete score.translations
return score
}
const formatResults = (results, lang) => {
const formated = []
for (const [i, result] of results.entries()) {
formated.push({
id: result.results_id.id,
sort: result.sort,
min: result.results_id.min,
max: result.results_id.max,
facteur: getTranslation(result.results_id.translations, lang, 'facteur'),
effets: getTranslation(result.results_id.translations, lang, 'effets'),
pde: getTranslation(result.results_id.translations, lang, 'pde'),
pde_qtra: result.results_id.pde_qtra,
})
}
return formated
}
const config = {
collections: {
scores: {
readByQueryOption: {
fields: ['*', 'translations.*', 'questions.sort', 'questions.questions_id.*', 'questions.questions_id.translations.*', 'questions.questions_id.answers.*', 'questions.questions_id.answers.answers_id.*', 'questions.questions_id.answers.answers_id.translations.*', 'results.*', 'results.results_id.*', 'results.results_id.translations.*']
},
pathBuilder: (score) => {
const lang = 'fr-FR'
score = formatScore(score, lang)
score.questions = formatQuestions(score.questions, lang)
score.results = formatResults(score.results, lang)
return `./content`;
},
deleteFields: ['path']
}
}
}
new DirectusToMarkdown(config).export();

View File

@ -0,0 +1 @@
../../../../themes/hugo-theme-lowtech/node_modules/@resilien/directus-to-markdown

1
scripts/directus-to-markdown/node_modules/url-slug generated vendored Symbolic link
View File

@ -0,0 +1 @@
../../../themes/hugo-theme-lowtech/node_modules/url-slug

View File

@ -0,0 +1,11 @@
{
"name": "directus-to-markdown",
"version": "0.0.0",
"description": "Translates content from Directus.io to gohugo.io",
"main": "index.js",
"type": "module",
"dependencies": {
"@resilien/directus-to-markdown": "file:../../themes/hugo-theme-lowtech/node_modules/@resilien/directus-to-markdown",
"url-slug": "file:../../themes/hugo-theme-lowtech/node_modules/url-slug"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

25
static/manifest.json Normal file
View File

@ -0,0 +1,25 @@
{
"name": "My First Progressive Web app",
"short_name": "First PWA",
"theme_color": "#eb5252",
"background_color": "#000000",
"display": "fullscreen",
"Scope": "/",
"orientation": "portrait",
"icons": [
{
"src": "/images/pwa-icon-256.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "any maskable"
},
{
"src": "/images/pwa-icon-512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "any maskable"
}
],
"lang": "fr-FR",
"start_url": "index.html"
}

@ -0,0 +1 @@
Subproject commit d5c0ebda145e1c4c6c474d0e58823332ab3d8b1e