commit a54d4be5b462b7f644ae2d5a971563d02037f46b Author: Simon C Date: Fri Feb 18 18:17:03 2022 +0100 first commit diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..f205c0b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +# Ignore everything +** + +!public diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..e71f59e --- /dev/null +++ b/.drone.yml @@ -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 diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..0bf5d83 --- /dev/null +++ b/.editorconfig @@ -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 \ No newline at end of file diff --git a/.env b/.env new file mode 100644 index 0000000..8ba6b27 --- /dev/null +++ b/.env @@ -0,0 +1,3 @@ +DOCKER_CONTEXT=vert.weko.resilien +NAME=vert.weko.resilien +URL=scores.ceiba-conseil.com diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..026173a --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +resources +public +.hugo_build.lock diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..b426a68 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "themes/hugo-theme-lowtech"] + path = themes/hugo-theme-lowtech + url = https://git.weko.io/kosssi/hugo-theme-lowtech.git diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3f66d28 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,4 @@ +FROM registry.weko.io/nginx-lowtech:0.0.9 + +# Copie des sources du site +COPY public /usr/share/nginx/html diff --git a/assets/js/main.js b/assets/js/main.js new file mode 100644 index 0000000..bd44980 --- /dev/null +++ b/assets/js/main.js @@ -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() diff --git a/assets/js/sw.js b/assets/js/sw.js new file mode 100644 index 0000000..5c99487 --- /dev/null +++ b/assets/js/sw.js @@ -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' + ]); + }) + ); +}); diff --git a/assets/styles/main.sass b/assets/styles/main.sass new file mode 100644 index 0000000..3794f44 --- /dev/null +++ b/assets/styles/main.sass @@ -0,0 +1,9 @@ +h1, h2 + text-align: center + +.score + display: none + margin: 1rem + + &.active + display: inherit diff --git a/config/_default/config.yml b/config/_default/config.yml new file mode 100644 index 0000000..9aa4ad4 --- /dev/null +++ b/config/_default/config.yml @@ -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 diff --git a/config/development/config.yml b/config/development/config.yml new file mode 100644 index 0000000..a0a27dc --- /dev/null +++ b/config/development/config.yml @@ -0,0 +1 @@ +baseURL: http://localhost:1313/ diff --git a/config/production/config.yml b/config/production/config.yml new file mode 100644 index 0000000..13c9e93 --- /dev/null +++ b/config/production/config.yml @@ -0,0 +1 @@ +baseURL: https://scores.ceiba-conseil.com/ diff --git a/config/staging/config.yml b/config/staging/config.yml new file mode 100644 index 0000000..adf54de --- /dev/null +++ b/config/staging/config.yml @@ -0,0 +1 @@ +baseURL: https://staging.scores.ceiba-conseil.com/ diff --git a/content/.drone.yml b/content/.drone.yml new file mode 100644 index 0000000..2020627 --- /dev/null +++ b/content/.drone.yml @@ -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 diff --git a/content/_index.md b/content/_index.md new file mode 100644 index 0000000..dda1889 --- /dev/null +++ b/content/_index.md @@ -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 +--- + + diff --git a/data/ceiba.yml b/data/ceiba.yml new file mode 100644 index 0000000..080ce9a --- /dev/null +++ b/data/ceiba.yml @@ -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 diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml new file mode 100644 index 0000000..a02d18d --- /dev/null +++ b/docker-compose.prod.yml @@ -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 diff --git a/docker-compose.staging.yml b/docker-compose.staging.yml new file mode 100644 index 0000000..1e86fa3 --- /dev/null +++ b/docker-compose.staging.yml @@ -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 diff --git a/layouts/_default/question.json.json b/layouts/_default/question.json.json new file mode 100644 index 0000000..41f0996 --- /dev/null +++ b/layouts/_default/question.json.json @@ -0,0 +1,3 @@ + { + "id": 1 + } diff --git a/layouts/api/item.json.json b/layouts/api/item.json.json new file mode 100644 index 0000000..f54af3e --- /dev/null +++ b/layouts/api/item.json.json @@ -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 }}" + } diff --git a/layouts/index.html b/layouts/index.html new file mode 100644 index 0000000..38b1b95 --- /dev/null +++ b/layouts/index.html @@ -0,0 +1,34 @@ + + + + + Hello World + + {{ $style := resources.Get "styles/main.sass" }} + {{ with $style }} + {{ $styleCSS := . | toCSS }} + + {{ end }} + + + + + +

Ceiba App

+ + {{ partial "scores" . }} + + {{ $js := resources.Get "js/sw.js" }} + {{ with $js }} + {{ $secureJS := . | js.Build }} + + {{ end }} + + {{ $js := resources.Get "js/main.js" }} + {{ with $js }} + {{ $secureJS := . | js.Build }} + + {{ end }} + + + diff --git a/layouts/partials/scores.html b/layouts/partials/scores.html new file mode 100644 index 0000000..833aa33 --- /dev/null +++ b/layouts/partials/scores.html @@ -0,0 +1,29 @@ +{{ $formId := .Params.id }} +
+

{{ .Title }}

+
+ {{ range .Params.questions }} +
+ {{ .title }} + {{ $questionId := .id }} + {{ range .answers }} +
+ +
+ {{ end }} +
+ {{ end }} + + {{ range .Params.results }} +
+ Score :
+ Facteur de sécurité : {{ .facteur }}
+ Effets sur la capacité de charge : {{ .effets }}
+ Probabilité d'échec (PdE) : {{ .pde }}
+ PdE QTRA : {{ .pde_qtra }} +
+ {{ end }} +
+
diff --git a/run b/run new file mode 100755 index 0000000..bf27f5c --- /dev/null +++ b/run @@ -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 diff --git a/scripts/directus-to-markdown/index.js b/scripts/directus-to-markdown/index.js new file mode 100644 index 0000000..57c6781 --- /dev/null +++ b/scripts/directus-to-markdown/index.js @@ -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(); diff --git a/scripts/directus-to-markdown/node_modules/@resilien/directus-to-markdown b/scripts/directus-to-markdown/node_modules/@resilien/directus-to-markdown new file mode 120000 index 0000000..fceff24 --- /dev/null +++ b/scripts/directus-to-markdown/node_modules/@resilien/directus-to-markdown @@ -0,0 +1 @@ +../../../../themes/hugo-theme-lowtech/node_modules/@resilien/directus-to-markdown \ No newline at end of file diff --git a/scripts/directus-to-markdown/node_modules/url-slug b/scripts/directus-to-markdown/node_modules/url-slug new file mode 120000 index 0000000..44b3fc9 --- /dev/null +++ b/scripts/directus-to-markdown/node_modules/url-slug @@ -0,0 +1 @@ +../../../themes/hugo-theme-lowtech/node_modules/url-slug \ No newline at end of file diff --git a/scripts/directus-to-markdown/package.json b/scripts/directus-to-markdown/package.json new file mode 100644 index 0000000..007610d --- /dev/null +++ b/scripts/directus-to-markdown/package.json @@ -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" + } +} diff --git a/static/images/pwa-icon-256.png b/static/images/pwa-icon-256.png new file mode 100644 index 0000000..ef5b41d Binary files /dev/null and b/static/images/pwa-icon-256.png differ diff --git a/static/images/pwa-icon-512.png b/static/images/pwa-icon-512.png new file mode 100644 index 0000000..26e9fa2 Binary files /dev/null and b/static/images/pwa-icon-512.png differ diff --git a/static/manifest.json b/static/manifest.json new file mode 100644 index 0000000..2848777 --- /dev/null +++ b/static/manifest.json @@ -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" +} diff --git a/themes/hugo-theme-lowtech b/themes/hugo-theme-lowtech new file mode 160000 index 0000000..d5c0ebd --- /dev/null +++ b/themes/hugo-theme-lowtech @@ -0,0 +1 @@ +Subproject commit d5c0ebda145e1c4c6c474d0e58823332ab3d8b1e