diff --git a/.github/workflows/jekyll.yml b/.github/workflows/jekyll.yml index b2b5b5ad..0d69aa26 100644 --- a/.github/workflows/jekyll.yml +++ b/.github/workflows/jekyll.yml @@ -39,9 +39,15 @@ jobs: ruby-version: '3.1' # Not needed with a .ruby-version file bundler-cache: true # runs 'bundle install' and caches installed gems automatically cache-version: 0 # Increment this number if you need to re-download cached gems + - name: Setup Nodejs + uses: actions/setup-node@v3 + with: + node-version: '18.x' - name: Setup Pages id: pages uses: actions/configure-pages@v4 + - name: Pull in all data from https://gegevensmagazijn.tweedekamer.nl/OData/v4/2.0/ + run: ./motie-cache.sh - name: Build with Jekyll # Outputs to the './_site' directory by default run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}" diff --git a/.gitignore b/.gitignore index ecfd99f6..5a642ce1 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,5 @@ _site vendor node_modules -moties/**/moties/ +moties/ _data/moties/ \ No newline at end of file diff --git a/_includes/motie-year.html b/_includes/motie-year.html index 2eb89d3f..bd947303 100644 --- a/_includes/motie-year.html +++ b/_includes/motie-year.html @@ -1,23 +1,20 @@ - - - - - - Moties met stemmingen van de Tweede Kamer {{ page.jaar }} - - - -
-
- +
+ +

Moties met stemmingen van de Tweede Kamer in {{ year }}

+ +

Een overzicht van alle moties waarover gestemd is in de Tweede Kamer in {{ year }}.

+ +{% if site.data.moties[year] != null %} + {% assign motiesSorted = site.data.moties[year] | group_by_exp: "motie", "motie[1].Zaak[0].GestartOp | slice: 0,10" | sort: "name" | reverse %} +
{% assign previousDate = "" %} {% for motieDateGroup in motiesSorted %} {% assign currentDate = motieDateGroup.name %} @@ -35,54 +32,33 @@ {% include symbol-down1.html %}
- {% for kv in motieDateGroup.items %} - {% assign currentId = kv[0] %} - {% assign motie = kv[1] %} - - {% endfor %}
- + {% for kv in motieDateGroup.items %} + {% assign currentId = kv[0] %} +
+ {% endfor %} {% assign previousDate = currentDate %} {% endfor %} + + +{% endif %} + - - + +{% if site.data.moties[year] != null %} + - +{% endif %} diff --git a/_layouts/default.html b/_layouts/default.html new file mode 100644 index 00000000..27f55481 --- /dev/null +++ b/_layouts/default.html @@ -0,0 +1,11 @@ + + + + + + Moties met stemmingen van de Tweede Kamer + + + +{{ content }} + diff --git a/_templates/year-index-front.html b/_templates/year-index-front.html new file mode 100644 index 00000000..dd8a76b2 --- /dev/null +++ b/_templates/year-index-front.html @@ -0,0 +1,8 @@ +--- +layout: default +redirect_from: / +--- + +{% assign year = page.path | split: "/" | slice: 1 | append: "" | slice: 2,4 %} + +{% include motie-year.html %} \ No newline at end of file diff --git a/_templates/year-index.html b/_templates/year-index.html index b28a14bc..d1cab432 100644 --- a/_templates/year-index.html +++ b/_templates/year-index.html @@ -1,4 +1,5 @@ --- +layout: default --- {% assign year = page.path | split: "/" | slice: 1 | append: "" | slice: 2,4 %} diff --git a/assets/js/load-moties.js b/assets/js/load-moties.js new file mode 100644 index 00000000..897feaa5 --- /dev/null +++ b/assets/js/load-moties.js @@ -0,0 +1,30 @@ +async function fixDateseparators() { + const dateSeparators = document.querySelectorAll('.date-separator'); + dateSeparators[0].parentNode.childNodes[1].childNodes[1].href = '#'; + for (var idx = 0; idx < dateSeparators.length - 1; idx += 1) { + dateSeparators[idx].parentNode.childNodes[5].childNodes[1].href = dateSeparators[idx+1].childNodes[1].href; + } +} + +async function loadMoties() { + let motieCounter = 0; + let moties = [...document.querySelectorAll('.motie-placeholder')]; + moties.forEach(elem => { + const year = elem.getAttribute('year'); + const Id = elem.getAttribute('motieId'); + fetch(`http://localhost:4000/moties/${year}/moties/${Id}.html`) + .then(response => { + if (response.status != 200) { + console.log(response) + } + return response; + }) + .then(response => response.text()) + .then(response => { + motieCounter += 1; + elem.insertAdjacentHTML('beforeend', response); + document.querySelector('#progressMoties').children[0] + .style.width = `${100 * motieCounter / moties.length}%`; + }) + }); +}; \ No newline at end of file diff --git a/get-last-api-timestamp.js b/get-last-api-timestamp.js deleted file mode 100644 index 7cd4b16c..00000000 --- a/get-last-api-timestamp.js +++ /dev/null @@ -1,47 +0,0 @@ -/* - - Drop each motie per year in _data/{year}.json. - - Create a page in moties/{year}/{id}.html - */ - - - const urlApi = 'https://gegevensmagazijn.tweedekamer.nl/OData/v4/2.0'; - - const motieExpand = ` - Besluit( - $expand=Stemming( - $filter=Verwijderd eq false - ;$select=Id) - ;$filter=Verwijderd eq false and StemmingsSoort ne null - ;$select=Id - )` - - const motieFilter = ` - Verwijderd eq false and Soort eq 'Motie' and Besluit/any( - a: a/Verwijderd eq false and a/StemmingsSoort ne null - )` - - const motieSelect = `Id,ApiGewijzigdOp` - - const url = `${urlApi} - /Zaak? - &$top=1 - &$orderby=ApiGewijzigdOp desc - &$count=true - &$expand=${motieExpand} - &$filter=${motieFilter} - &$select=${motieSelect}`; - - console.log(url); - - - fetch(url) - .then(response => { - if (response.status != 200) { - console.log(response) - } - return response; - }) - .then(response => response.json()) - .then(odata => { - console.log(odata); - }); \ No newline at end of file diff --git a/motie-cache.sh b/motie-cache.sh index a2025b56..1db76576 100755 --- a/motie-cache.sh +++ b/motie-cache.sh @@ -1,8 +1,14 @@ +echo "Set up dirs" + +mkdir -p _data/moties/ + for year in $(seq 2007 2024); do mkdir -p moties/$year/moties; cp _templates/year-index.html moties/$year/index.html; done +cp _templates/year-index-front.html moties/2023/index.html; + echo "Start caching from https://gegevensmagazijn.tweedekamer.nl/OData/v4/2.0" -node motie-cache2.js \ No newline at end of file +node motie-cache2.js 10 \ No newline at end of file diff --git a/motie-cache2.js b/motie-cache2.js index 794a6150..ac1e0a0f 100644 --- a/motie-cache2.js +++ b/motie-cache2.js @@ -3,14 +3,20 @@ - Create a page in moties/{year}/{id}.html */ - var fs = require('fs'); +const topVal = process.argv[2]; +let top = '' +if (typeof topVal !== 'undefined') { + top = `&$top=${topVal}`; +} + const urlApi = 'https://gegevensmagazijn.tweedekamer.nl/OData/v4/2.0'; const motieQuery = ` Besluit? &$orderby=ApiGewijzigdOp desc +${top} &$count=true &$expand=Zaak( $expand=ZaakActor( diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index 65568fd0..00000000 --- a/package-lock.json +++ /dev/null @@ -1,150 +0,0 @@ -{ - "name": "tkmoties", - "version": "1.0.0", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "tkmoties", - "version": "1.0.0", - "license": "ISC", - "dependencies": { - "odata": "^2.0.0" - } - }, - "node_modules/cross-fetch": { - "version": "3.1.8", - "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.8.tgz", - "integrity": "sha512-cvA+JwZoU0Xq+h6WkMvAUqPEYy92Obet6UdKLfW60qn99ftItKjB5T+BkyWOFWe2pUyfQ+IJHmpOTznqk1M6Kg==", - "dependencies": { - "node-fetch": "^2.6.12" - } - }, - "node_modules/hasurl": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/hasurl/-/hasurl-1.0.0.tgz", - "integrity": "sha512-43ypUd3DbwyCT01UYpA99AEZxZ4aKtRxWGBHEIbjcOsUghd9YUON0C+JF6isNjaiwC/UF5neaUudy6JS9jZPZQ==", - "engines": { - "node": ">= 4" - } - }, - "node_modules/lodash.sortby": { - "version": "4.7.0", - "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", - "integrity": "sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA==" - }, - "node_modules/node-fetch": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", - "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", - "dependencies": { - "whatwg-url": "^5.0.0" - }, - "engines": { - "node": "4.x || >=6.0.0" - }, - "peerDependencies": { - "encoding": "^0.1.0" - }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } - } - }, - "node_modules/odata": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/odata/-/odata-2.0.0.tgz", - "integrity": "sha512-b4zXI/RWR29n0J7M+p96y2wAv2bxOX9qafmbdXBhGod5CvGWkM7vZ1upx1mAWkq0BLoJOtXJIgQQ+esNKaFbhQ==", - "dependencies": { - "cross-fetch": "^3.0.6", - "odata-query": "^7.0.4", - "tslib": "^1.9.3", - "universal-url": "2.0.0" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/odata-query": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/odata-query/-/odata-query-7.0.4.tgz", - "integrity": "sha512-/Zq6xZMWEoMpWgpUg1MIeAUoqSzQBmvnci+eqXvySjVn9MN0R67xpLf75gpswRkbK2/u9hHltYsKOGu7WGlq8g==", - "dependencies": { - "tslib": "^2.4.0" - } - }, - "node_modules/odata-query/node_modules/tslib": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", - "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" - }, - "node_modules/punycode": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", - "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", - "engines": { - "node": ">=6" - } - }, - "node_modules/tr46": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" - }, - "node_modules/tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" - }, - "node_modules/universal-url": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/universal-url/-/universal-url-2.0.0.tgz", - "integrity": "sha512-3DLtXdm/G1LQMCnPj+Aw7uDoleQttNHp2g5FnNQKR6cP6taNWS1b/Ehjjx4PVyvejKi3TJyu8iBraKM4q3JQPg==", - "dependencies": { - "hasurl": "^1.0.0", - "whatwg-url": "^7.0.0" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/universal-url/node_modules/tr46": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-1.0.1.tgz", - "integrity": "sha512-dTpowEjclQ7Kgx5SdBkqRzVhERQXov8/l9Ft9dVM9fmg0W0KQSVaXX9T4i6twCPNtYiZM53lpSSUAwJbFPOHxA==", - "dependencies": { - "punycode": "^2.1.0" - } - }, - "node_modules/universal-url/node_modules/webidl-conversions": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-4.0.2.tgz", - "integrity": "sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==" - }, - "node_modules/universal-url/node_modules/whatwg-url": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-7.1.0.tgz", - "integrity": "sha512-WUu7Rg1DroM7oQvGWfOiAK21n74Gg+T4elXEQYkOhtyLeWiJFoOGLXPKI/9gzIie9CtwVLm8wtw6YJdKyxSjeg==", - "dependencies": { - "lodash.sortby": "^4.7.0", - "tr46": "^1.0.1", - "webidl-conversions": "^4.0.2" - } - }, - "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" - } - } - } -} diff --git a/package.json b/package.json deleted file mode 100644 index 546da221..00000000 --- a/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "tkmoties", - "version": "1.0.0", - "description": "", - "main": "motie-cache.js", - "scripts": { - "start": "node motie-cache.js", - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "odata": "^2.0.0" - } -}