1
0
Fork 0
mirror of https://github.com/GuerillaStudio/compteur-de-greve.git synced 2024-12-18 05:41:56 +00:00

Post-mortem commit

This commit is contained in:
Tixie Salander 2023-05-24 16:28:57 +02:00
parent 053f52c249
commit 68d837cf60
8 changed files with 17 additions and 182 deletions

View file

@ -1,11 +1,6 @@
const { EleventyServerlessBundlerPlugin } = require("@11ty/eleventy");
const eleventySass = require("@11tyrocks/eleventy-plugin-sass-lightningcss") const eleventySass = require("@11tyrocks/eleventy-plugin-sass-lightningcss")
module.exports = function (eleventyConfig) { module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(EleventyServerlessBundlerPlugin, {
name: "serverless",
functionsDir: "./netlify/functions/",
});
eleventyConfig.addPlugin(eleventySass) eleventyConfig.addPlugin(eleventySass)

View file

@ -1,10 +1,3 @@
[build] [build]
publish = "public" publish = "public"
command = "npm run build" command = "npm run build"
[[redirects]]
from = "/"
to = "/.netlify/functions/serverless"
status = 200
force = true
_generated_by_eleventy_serverless = "serverless"

View file

@ -1,58 +0,0 @@
const { EleventyServerless } = require("@11ty/eleventy");
// Explicit dependencies for the bundler from config file and global data.
// The file is generated by the Eleventy Serverless Bundler Plugin.
require("./eleventy-bundler-modules.js");
async function handler(event) {
let elev = new EleventyServerless("serverless", {
path: new URL(event.rawUrl).pathname,
singleTemplateScope: false,
query: event.multiValueQueryStringParameters || event.queryStringParameters,
functionsDir: "./netlify/functions/",
});
try {
let [page] = await elev.getOutput();
// If you want some of the data cascade available in `page.data`, use `eleventyConfig.dataFilterSelectors`.
// Read more: https://www.11ty.dev/docs/config/#data-filter-selectors
return {
statusCode: 200,
headers: {
"Content-Type": "text/html; charset=UTF-8",
},
body: page.content,
};
} catch (error) {
// Only console log for matching serverless paths
// (otherwise youll see a bunch of BrowserSync 404s for non-dynamic URLs during --serve)
if (elev.isServerlessUrl(event.path)) {
console.log("Serverless Error:", error);
}
return {
statusCode: error.httpStatusCode || 500,
body: JSON.stringify(
{
error: error.message,
},
null,
2
),
};
}
}
// Choose one:
// * Runs on each request: AWS Lambda, Netlify Function
// * Runs on first request only: Netlify On-demand Builder
// 1. Dont forget to `npm install @netlify/functions`
// 2. Also use `redirects: "netlify-toml-builders"` in your config files serverless bundler options:
// https://www.11ty.dev/docs/plugins/serverless/#bundler-options
// exports.handler = handler;
const { builder } = require("@netlify/functions");
exports.handler = builder(handler);

80
package-lock.json generated
View file

@ -10,10 +10,7 @@
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@11ty/eleventy": "^2.0.0", "@11ty/eleventy": "^2.0.0",
"@11tyrocks/eleventy-plugin-sass-lightningcss": "^1.0.0", "@11tyrocks/eleventy-plugin-sass-lightningcss": "^1.0.0"
"@netlify/functions": "^1.4.0",
"alpinejs": "^3.11.1",
"node-fetch": "^2.6.9"
}, },
"devDependencies": { "devDependencies": {
"stylelint": "^14.11.0", "stylelint": "^14.11.0",
@ -295,22 +292,6 @@
"resolved": "https://registry.npmjs.org/@iarna/toml/-/toml-2.2.5.tgz", "resolved": "https://registry.npmjs.org/@iarna/toml/-/toml-2.2.5.tgz",
"integrity": "sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==" "integrity": "sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg=="
}, },
"node_modules/@netlify/functions": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/@netlify/functions/-/functions-1.4.0.tgz",
"integrity": "sha512-gy7ULTIRroc2/jyFVGx1djCmmBMVisIwrvkqggq5B6iDcInRSy2Tpkm+V5C63hKJVkNRskKWtLQKm9ecCaQTjA==",
"dependencies": {
"is-promise": "^4.0.0"
},
"engines": {
"node": ">=8.3.0"
}
},
"node_modules/@netlify/functions/node_modules/is-promise": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz",
"integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ=="
},
"node_modules/@nodelib/fs.scandir": { "node_modules/@nodelib/fs.scandir": {
"version": "2.1.5", "version": "2.1.5",
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
@ -404,19 +385,6 @@
"integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==", "integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==",
"dev": true "dev": true
}, },
"node_modules/@vue/reactivity": {
"version": "3.1.5",
"resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.1.5.tgz",
"integrity": "sha512-1tdfLmNjWG6t/CsPldh+foumYFo3cpyCHgBYQ34ylaMsJ+SNHQ1kApMIa8jN+i593zQuaw3AdWH0nJTARzCFhg==",
"dependencies": {
"@vue/shared": "3.1.5"
}
},
"node_modules/@vue/shared": {
"version": "3.1.5",
"resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.1.5.tgz",
"integrity": "sha512-oJ4F3TnvpXaQwZJNF3ZK+kLPHKarDmJjJ6jyzVNDKH9md1dptjC7lWR//jrGuLdek/U6iltWxqAnYOu8gCiOvA=="
},
"node_modules/a-sync-waterfall": { "node_modules/a-sync-waterfall": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/a-sync-waterfall/-/a-sync-waterfall-1.0.1.tgz", "resolved": "https://registry.npmjs.org/a-sync-waterfall/-/a-sync-waterfall-1.0.1.tgz",
@ -449,14 +417,6 @@
"url": "https://github.com/sponsors/epoberezkin" "url": "https://github.com/sponsors/epoberezkin"
} }
}, },
"node_modules/alpinejs": {
"version": "3.11.1",
"resolved": "https://registry.npmjs.org/alpinejs/-/alpinejs-3.11.1.tgz",
"integrity": "sha512-0Y+4WKQcEZrvpfS98qeSOXCPXFPorULQ+1hc8lQrx+1HHzkUofD4HzjTfz+wimA5tSsGnpXz/SoF2P9saiXZCw==",
"dependencies": {
"@vue/reactivity": "~3.1.1"
}
},
"node_modules/ansi-regex": { "node_modules/ansi-regex": {
"version": "5.0.1", "version": "5.0.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
@ -2492,25 +2452,6 @@
"resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz",
"integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==" "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw=="
}, },
"node_modules/node-fetch": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.9.tgz",
"integrity": "sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg==",
"dependencies": {
"whatwg-url": "^5.0.0"
},
"engines": {
"node": "4.x || >=6.0.0"
},
"peerDependencies": {
"encoding": "^0.1.0"
},
"peerDependenciesMeta": {
"encoding": {
"optional": true
}
}
},
"node_modules/node-releases": { "node_modules/node-releases": {
"version": "2.0.8", "version": "2.0.8",
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.8.tgz", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.8.tgz",
@ -3773,11 +3714,6 @@
"resolved": "https://registry.npmjs.org/token-stream/-/token-stream-1.0.0.tgz", "resolved": "https://registry.npmjs.org/token-stream/-/token-stream-1.0.0.tgz",
"integrity": "sha512-VSsyNPPW74RpHwR8Fc21uubwHY7wMDeJLys2IX5zJNih+OnAnaifKHo+1LHT7DAdloQ7apeaaWg8l7qnf/TnEg==" "integrity": "sha512-VSsyNPPW74RpHwR8Fc21uubwHY7wMDeJLys2IX5zJNih+OnAnaifKHo+1LHT7DAdloQ7apeaaWg8l7qnf/TnEg=="
}, },
"node_modules/tr46": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="
},
"node_modules/trim-newlines": { "node_modules/trim-newlines": {
"version": "3.0.1", "version": "3.0.1",
"resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-3.0.1.tgz", "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-3.0.1.tgz",
@ -3888,20 +3824,6 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/webidl-conversions": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ=="
},
"node_modules/whatwg-url": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
"dependencies": {
"tr46": "~0.0.3",
"webidl-conversions": "^3.0.0"
}
},
"node_modules/which": { "node_modules/which": {
"version": "2.0.2", "version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",

View file

@ -13,10 +13,7 @@
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@11ty/eleventy": "^2.0.0", "@11ty/eleventy": "^2.0.0",
"@11tyrocks/eleventy-plugin-sass-lightningcss": "^1.0.0", "@11tyrocks/eleventy-plugin-sass-lightningcss": "^1.0.0"
"@netlify/functions": "^1.4.0",
"alpinejs": "^3.11.1",
"node-fetch": "^2.6.9"
}, },
"devDependencies": { "devDependencies": {
"stylelint": "^14.11.0", "stylelint": "^14.11.0",

View file

@ -7,9 +7,9 @@
<link rel="stylesheet" href="{{ '/css/style.css' | url }}" /> <link rel="stylesheet" href="{{ '/css/style.css' | url }}" />
<link rel="preload" href="{{ '/css/style.css' | url }}" as="style" /> <link rel="preload" href="{{ '/css/style.css' | url }}" as="style" />
<style>[x-cloak] { display: none !important; }</style> <style>[x-cloak] { display: none !important; }</style>
<script src="{{ '/js/alpine.js' | url }}" defer></script> {# <script src="{{ '/js/alpine.js' | url }}" defer></script> #}
{# <link rel="preload" href="{{ '/js/alpine.js' | url }}" as="script" /> #} {# <link rel="preload" href="{{ '/js/alpine.js' | url }}" as="script" /> #}
<script src="{{ '/js/script.js' | url }}"></script> {# <script src="{{ '/js/script.js' | url }}"></script> #}
{# <link rel="preload" href="{{ '/js/script.js' | url }}" as="script" /> #} {# <link rel="preload" href="{{ '/js/script.js' | url }}" as="script" /> #}

View file

@ -1,7 +1,4 @@
const fetch = require("node-fetch")
module.exports = async function() { module.exports = function() {
const response = await fetch("https://c.compteurdegreve.fr/val") return {count: 18014}
const data = await response.json()
return {count: data.value}
} }

View file

@ -1,10 +1,8 @@
--- ---
layout: base.njk layout: base.njk
title: Compteur de grève title: Compteur de grève
permalink:
serverless: /
--- ---
<section class="banner" x-data="counter" data-initial-count="{{count}}"> <section class="banner">
<div class="banner-layout"> <div class="banner-layout">
<div class="counter-container"> <div class="counter-container">
<article class="counter"> <article class="counter">
@ -13,32 +11,23 @@ permalink:
<span class="color-pink-2 pb05 inline-block counter-content">Contre la réforme des retraites,</span><br> <span class="color-pink-2 pb05 inline-block counter-content">Contre la réforme des retraites,</span><br>
À lappel de lensemble des organisations syndicales, <span class="color-purple-1">le 7 mars</span> À lappel de lensemble des organisations syndicales, <span class="color-purple-1">le 7 mars</span>
<span aria-live="polite"> <span aria-live="polite">
<strong class="counter-number" x-bind="counter">{{count | formatNumber}}</strong> <strong class="counter-number">{{count | formatNumber}}</strong>
<span class="separator counter-content">personnes seront</span> <span class="separator counter-content">personnes étaient</span>
<em class="counter-strikeeeee-lol highlighter-zigzag">en grève<span class="visually-hidden"> !</span></em> <em class="counter-strikeeeee-lol highlighter-zigzag">en grève<span class="visually-hidden"> !</span></em>
</span> </span>
</p> </p>
</article> </article>
</div> </div>
<article class="w100 maxw380px sm:maxw100 text-center"> <article class="w100 maxw380px sm:maxw100 text-center">
<h2 class="title-1 mt0">Et <span class="highlighter-underline">vous</span>&nbsp;?</h2> <h2 class="title-1 mt0 visually-hidden">Et <span class="highlighter-underline">vous</span>&nbsp;?</h2>
<div class="flex flex-col"> <div class="flex flex-col">
{# <div class="notif notif--error mb2" x-bind="error" x-cloak>Message d'erreur à faire</div> #} <div class="notif notif--success mb15">
<div class="gridstack mb15"> <p>
<form action="/" method="post" class="flex" x-bind="form"> <strong class="block text-bold text-big mb1">Merci pour votre participation&nbsp;!&nbsp;<span aria-hidden="true">✨</span></strong>
<button class="btn btn--big btn--icoYellow w100" x-bind="button"> Le 6 mais est passé mais le site est toujours là avec avec <span aria-hidden="true">↓</span><a class="text-bold text-underline" href="#savoir-plus">ses ressources</a> si besoin.
{% include 'icons/plus-one.svg' %} Je fais grève </p>
</button> <p class="mb0">À très bientôt pour les prochaines mobilisations&nbsp;! <span aria-hidden="true">✊</span></p>
</form>
<div class="notif notif--success notif--successPlusOne" x-bind="thanks" x-cloak>
<strong class="block text-bold text-big mb1">Merci pour votre participation&nbsp;!&nbsp;✨</strong>
<span aria-hidden="true">↓</span>&nbsp;Nous avons <a class="text-bold text-underline" href="#partager">besoin de vous</a> pour faire du <em class="text-bold">7 mars</em> une journée de mobilisation qui restera dans les mémoires&nbsp;!
</div>
</div> </div>
<a href="#partager" class="btn btn--secondary w100 mb15">
{% include 'icons/megaphone.svg' %} Je partage le compteur
</a>
<a href="#savoir-plus" class="btn btn--tertiary w100 mb15"> <a href="#savoir-plus" class="btn btn--tertiary w100 mb15">
{% include 'icons/question.svg' %} En savoir plus {% include 'icons/question.svg' %} En savoir plus
</a> </a>
@ -65,7 +54,7 @@ permalink:
<div class="flex flex-col justify-center align-items-center"> <div class="flex flex-col justify-center align-items-center">
<a class="btn btn--light mb25 md:w100" href="https://formdivers.typeform.com/to/rcucJg13" target="_blank">✉️&nbsp;<span><span class="text-bold">Envoyer un mail</span> aux collègues</span></a> <a class="btn btn--light mb25 md:w100" href="https://formdivers.typeform.com/to/rcucJg13" target="_blank">✉️&nbsp;<span><span class="text-bold">Envoyer un mail</span> aux collègues</span></a>
<a class="btn btn--light mb25 md:w100" href="https://www.change.org/p/retraites-non-%C3%A0-cette-r%C3%A9forme-injuste-et-brutale-reformesdesretraites" target="_blank">✒️&nbsp;<span><span class="text-bold">Signer</span> la pétition</span></a> <a class="btn btn--light mb25 md:w100" href="https://www.change.org/p/retraites-non-%C3%A0-cette-r%C3%A9forme-injuste-et-brutale-reformesdesretraites" target="_blank">✒️&nbsp;<span><span class="text-bold">Signer</span> la pétition</span></a>
<a class="btn btn--light mb25 md:w100" href="https://www.leetchi.com/c/solidarite-cgt-mobilisation" target="_blank">❤&nbsp;<span><span class="text-bold">Faire un don</span> à une caisse de grève</span></a> <a class="btn btn--light mb25 md:w100" href="https://caissedegreve.fr/" target="_blank">❤&nbsp;<span><span class="text-bold">Faire un don</span> à une caisse de grève</span></a>
</div> </div>
</section> </section>