diff --git a/.gitignore b/.gitignore index 704df07..d80c7f0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ -html-prod/ +# Générés par deploy.sh build/ +prod/ +# Dépôt temporaire des images à convertir (originaux dans Nextcloud) +inbox/ +# Sauvegardes *.bak diff --git a/.htmlhintrc b/.htmlhintrc deleted file mode 100644 index dfa6e3d..0000000 --- a/.htmlhintrc +++ /dev/null @@ -1,6 +0,0 @@ -{ - "attr-value-double-quotes": false, - "tag-pair": true, - "id-unique": true, - "tagname-lowercase": false -} diff --git a/.lighthouserc.cjs b/.lighthouserc.cjs deleted file mode 100644 index 827a7e8..0000000 --- a/.lighthouserc.cjs +++ /dev/null @@ -1,25 +0,0 @@ -module.exports = { - ci: { - collect: { - staticDistDir: './html', - settings: { - // Ajout de --disable-storage-reset et --disable-dev-shm-usage est crucial ici - chromeFlags: '--no-sandbox --disable-dev-shm-usage --disable-gpu --headless=new --disable-software-rasterizer', - }, - numberOfRuns: 1 - }, - assert: { - // On utilise 'preset: lighthouse:recommended' ou on simplifie les assertions - assertions: { - 'categories:performance': ['warn', {minScore: 0.1}], - 'categories:accessibility': ['warn', {minScore: 0.1}], - 'categories:best-practices': ['warn', {minScore: 0.1}], - 'categories:seo': ['warn', {minScore: 0.1}], - }, - }, - upload: { - target: 'filesystem', - outputDir: './.lighthouseci', - }, - }, -}; \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 686e90a..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,137 +0,0 @@ -pipeline { - agent any - environment { - GITEA_REPO_PATH = "lucas/site-veloboomboom" - GITEA_API_URL = "https://gitea.lucasroyer.fr/api/v1" - DOCKER_HOST = "unix:///run/user/1001/docker.sock" - - TOOLBOX_PATH ="/home/lucas/services/static-sites/static-toolbox" - SOURCE_DIR = "html" - DEPLOY_ROOT = "/home/lucas/services/static-sites/site-veloboomboom" - } - stages { - stage('Check toolbox') { - steps { - sh """ - if ! docker image inspect static-toolbox >/dev/null 2>&1; then - echo "Missing toolbox, rebuild using Docker socket..." - # On crée l'image à la volée car Jenkins ne voit pas le script 'build' - echo "FROM node:25-alpine\nRUN npm install -g htmlhint\nWORKDIR /apps\nENTRYPOINT [\"htmlhint\"]" | docker build -t static-toolbox - - fi - """ - // sh """ - // if ! docker image inspect static-toolbox >/dev/null 2>&1; then - // echo "Missing toolbox, rebuild..." - // ${env.TOOLBOX_PATH}/build - // fi - // """ - } - } - stage('Lint HTML') { - steps { - echo "Check HTML files..." - sh "docker run --rm --volumes-from jenkins -w \$(pwd) static-toolbox '${env.SOURCE_DIR}/**/*.html' --config .htmlhintrc" - } - } - - stage('Lighthouse Audit') { - steps { - echo "Running Lighthouse audit..." - // Clean old report and prepare reports and npm cache folders - sh """ - docker run --rm \ - --volumes-from jenkins \ - -v /home/lucas/.npm-cache:/tmp/npm-cache \ - -w \$(pwd) \ - alpine:latest \ - sh -c " \ - rm -rf ./.lighthouseci && \ - mkdir -p ./.lighthouseci && \ - chmod 777 ./.lighthouseci && \ - mkdir -p /tmp/npm-cache && \ - chmod 777 /tmp/npm-cache \ - " - """ - - // Run - sh """ - docker run --rm \ - --volumes-from jenkins \ - -w \$(pwd) \ - -v /home/lucas/.npm-cache:/tmp/npm-cache \ - -e npm_config_cache=/tmp/npm-cache \ - -e CHROME_PATH=/usr/bin/chromium-browser \ - --entrypoint "" \ - zenika/alpine-chrome:with-node \ - npx --prefer-offline -p @lhci/cli@0.13.0 lhci autorun --config=./.lighthouserc.cjs - """ - } - } - - stage('Deploy') { - steps { - echo "Deploying via Docker mount..." - // Copy with docker alpine - sh """ - docker run --rm \ - --volumes-from jenkins \ - -v ${env.DEPLOY_ROOT}:/site-deploy \ - -w \$(pwd) \ - alpine:latest \ - sh -c " \ - mkdir -p /site-deploy/html-new && \ - cp -R html/* /site-deploy/html-new/ && \ - rm -rf /site-deploy/html-prod && \ - mv /site-deploy/html-new /site-deploy/html-prod \ - " - """ - - echo "Reloading Caddy..." - sh "docker exec caddy-reverse-proxy caddy reload --config /etc/caddy/Caddyfile" - } - } - } - post { - always { - echo "Publish Lighthouse audit..." - publishHTML([ - allowMissing: true, - alwaysLinkToLastBuild: true, - keepAll: false, - reportDir: '.lighthouseci', - reportFiles: '*.html', - reportName: 'Lighthouse Report' - ]) - - echo "Cleaning up workspace..." - sh "rm -rf ./.lighthouseci" - - script { - echo "Waiting for Gitea to be online..." - - echo "Send Gitea check..." - // Get and store SHA - def commitSha = sh(script: 'git rev-parse HEAD', returnStdout: true).trim() - - // Convert from Jenkins to Gitea API - def buildState = (currentBuild.currentResult == 'SUCCESS') ? 'success' : 'failure' - def buildDesc = (currentBuild.currentResult == 'SUCCESS') ? 'Build successful' : 'Build failed' - - // Send it to Gitea API with secret 'gitea-token' - withCredentials([string(credentialsId: 'gitea-token', variable: 'GITEA_TOKEN')]) { - // Use \$TOKEN to avoid jenkins to print token in logs - sh """ - curl -f -X POST "${GITEA_API_URL}/repos/${GITEA_REPO_PATH}/statuses/${commitSha}" \ - -H "Authorization: token \$GITEA_TOKEN" \ - -H "Content-Type: application/json" \ - -d '{"state": "${buildState}", "target_url": "${env.BUILD_URL}", "description": "${buildDesc}", "context": "jenkins-ci"}' - """ - } - } - echo "Clean unused image" - sh "docker image prune -f" - } - success { echo "Success !" } - failure { echo "Failed." } - } -} diff --git a/README.md b/README.md new file mode 100644 index 0000000..4613f3a --- /dev/null +++ b/README.md @@ -0,0 +1,20 @@ +# site-veloboomboom + +Site statique servi par Caddy (config dans vps1-containers). + +| Dossier | Rôle | Servi sur | +|----------|----------------------------------------|------------------------------------| +| `test/` | Source, éditée directement (versionnée) | veloboomboom.radtek.fr (tinyauth) | +| `build/` | Minifié, généré par `deploy.sh` | — | +| `prod/` | Copie de `build/` | veloboomboom.internantes.ovh | + +## Ajouter des images à la galerie +1. Déposer les PNG/JPG dans `inbox/` (originaux conservés dans Nextcloud) +2. `./convert-img.sh` → WebP + miniatures, lot inséré en tête de la galerie de test +3. Vérifier sur le site de test + +## Ajouter une icône +Déposer l'image dans `test/assets/icons/`, puis `./convert-icon.sh` (WebP 60×60 max). + +## Mettre en prod +`./deploy.sh` (nécessite esbuild et html-minifier-terser), puis commit + push. diff --git a/convert-icon.sh b/convert-icon.sh index b189b68..9f2d783 100755 --- a/convert-icon.sh +++ b/convert-icon.sh @@ -11,7 +11,7 @@ MAX_SIZE=60 # côté max en px (affichées en 20px → net e QUALITY=90 SCRIPT_DIR="$(dirname "$(readlink -f "$0")")" -ICON_DIR="${1:-$SCRIPT_DIR/html/assets/icons}" +ICON_DIR="${1:-$SCRIPT_DIR/test/assets/icons}" cd "$ICON_DIR" if command -v magick >/dev/null; then IM=(magick); ID=(magick identify) @@ -51,4 +51,4 @@ for f in *.webp; do fi done -echo "Converties : $converted | Redimensionnées : $resized | Déjà conformes : $ok" \ No newline at end of file +echo "Converties : $converted | Redimensionnées : $resized | Déjà conformes : $ok" diff --git a/convert-img.sh b/convert-img.sh index 291771f..2034d58 100755 --- a/convert-img.sh +++ b/convert-img.sh @@ -1,133 +1,71 @@ #!/usr/bin/env bash -# Pipeline images du site -# 1. Convertit les PNG/JPG déposés dans html/assets/img en WebP, -# renommés dans la série suivante (dernière = 18 → Post191, Post192, ...) -# 2. Vérifie que les WebP existants tiennent dans le cadre -# 3. Génère les miniatures dans thumbs/ -# 4. Affiche le HTML prêt à coller pour la nouvelle série -# -# Usage : ./convert-img.sh [--force] [dossier] -# dossier défaut : html/assets/img à côté du script -# --force régénère toutes les miniatures +# convert-img.sh — ajoute un lot d'images en tête de la galerie du site de TEST +# 1. Dépose les PNG/JPG dans inbox/ +# 2. ./convert-img.sh +# 3. Vérifie le site de test, puis déploie set -euo pipefail +ROOT="$(dirname "$(readlink -f "$0")")" +SITE="$ROOT/test" +INBOX="$ROOT/inbox" +IMG="$SITE/assets/img" +THUMBS="$IMG/thumbs" +HTML="$SITE/index.html" +ANCHOR='