diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f90df16 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +signatures.json diff --git a/build/build.sh b/build/build.sh new file mode 100755 index 0000000..3346360 --- /dev/null +++ b/build/build.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +basedir="${0%/*}/.." +sigdb="$1" + +# Clean signatures database +"$basedir/build/clean_database.py" "$sigdb" "$basedir/data/signatures/signatures_clean.json" + +# Execute hugo buildrun +cd "$basedir" +hugo diff --git a/build/clean_database.py b/build/clean_database.py new file mode 100755 index 0000000..c404009 --- /dev/null +++ b/build/clean_database.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 +import json +import sys + +injson = str(sys.argv[1]) +outjson = str(sys.argv[2]) + +def remove_error_info(d): + if not isinstance(d, (dict, list)): + return d + if isinstance(d, list): + return [remove_error_info(v) for v in d] + return {k: remove_error_info(v) for k, v in d.items() + if k not in {'email', 'code', 'permPriv', 'permNews' }} + +with open(injson) as json_data: + sigs_full = json.load(json_data) + +sigs_clean = remove_error_info(sigs_full) + +with open(outjson, 'w') as outfile: + json.dump(sigs_clean, outfile, indent=2) diff --git a/static/userdata/.gitignore b/data/signatures/.gitignore similarity index 100% rename from static/userdata/.gitignore rename to data/signatures/.gitignore diff --git a/data/signatures/signatures.json b/data/signatures/signatures.json deleted file mode 100644 index 0e72078..0000000 --- a/data/signatures/signatures.json +++ /dev/null @@ -1,42 +0,0 @@ -[ - { - "id": 0, - "name": "Max", - "email": "mail@example.com", - "country": "Deutschland", - "zip": "86367", - "perm": "yes", - "code": "630691407558d1cc36a6abb", - "confirmed": "yes" - }, - { - "id": 1, - "name": "Cooler Name", - "email": "tech@web.de", - "country": "Schweiz", - "zip": "4404", - "perm": "yes", - "code": "759321396558d1cc8bb57fe", - "confirmed": "yes" - }, - { - "id": 2, - "name": "Hengst", - "email": "test@test.com", - "country": "", - "zip": "", - "perm": "yes", - "code": "691034870458d1cd0fdfb2f", - "confirmed": "yes" - }, - { - "id": 3, - "name": "Richard Bruce Kopp", - "email": "kopp@test.de", - "country": "Germany ", - "zip": "71522", - "perm": "yes", - "code": "557271457758d1ff356910f", - "confirmed": "no" - } -] diff --git a/layouts/partials/page-signatures.html b/layouts/partials/page-signatures.html index 55b2fa6..6321324 100644 --- a/layouts/partials/page-signatures.html +++ b/layouts/partials/page-signatures.html @@ -13,9 +13,9 @@ {{ .Site.Params.Subpage.Signatures.country }} {{ .Site.Params.Subpage.Signatures.zip }} - {{ range $.Site.Data.signatures }} - {{ range . }} - {{ if eq .confirmed "yes" }} + {{ range .Site.Data.signatures }} + {{ range sort . "id" "desc" }} + {{ if (eq .confirmed "yes") | and (eq .permPub "yes") }} {{ .id }} {{ .name }} diff --git a/static/cgi/sign.php b/static/cgi/sign.php index 64c84e6..36839c9 100644 --- a/static/cgi/sign.php +++ b/static/cgi/sign.php @@ -3,7 +3,7 @@ $codemod = 2138367; // modificator with which the confirmation ID will be obfuscated $output = ""; $selfurl = "http://pmpc-test.mehl.mx/cgi/sign.php"; // absolute URL of this PHP script -$db = "../userdata/signatures.json"; // Signature database path +$db = "../../signatures.json"; // Signature database path // Get info from form $action = isset($_GET['action']) ? $_GET['action'] : false;