Skip to content

Commit

Permalink
Add signature adder (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kreijstal committed Dec 13, 2017
1 parent fa406d1 commit d5eb2a5
Show file tree
Hide file tree
Showing 6 changed files with 173 additions and 239 deletions.
3 changes: 3 additions & 0 deletions deploy.sh
Expand Up @@ -32,6 +32,9 @@ cd ..
rm -rf out/*
cd ..
# Run our compile script
wget -q https://publiccodeasia.firebaseio.com/subscribers.json?auth=tLtEcFft4F34hknRsT8sPEty0PGOqBMg1n8fLN13 -O signatures.json
node signatures.json
mv signatures.json site/data/signatures/.
doCompile
cp -r site/public/* site/out
cp -r site/static/* site/out
Expand Down
17 changes: 17 additions & 0 deletions proxy.sh
@@ -0,0 +1,17 @@
#!/bin/bash -e

if [ $# != 3 ]
then
echo "usage: $0 <src-port> <dst-host> <dst-port>"
exit 0
fi

TMP=`mktemp -d`
BACK=$TMP/pipe.back
SENT=$TMP/pipe.sent
RCVD=$TMP/pipe.rcvd
trap 'rm -rf "$TMP"' EXIT
mkfifo -m 0600 "$BACK" "$SENT" "$RCVD"
sed 's/^/ => /' <"$SENT" &
sed 's/^/<= /' <"$RCVD" &
nc -l -p "$1" <"$BACK" | tee "$SENT" | nc "$2" "$3" | tee "$RCVD" >"$BACK"
22 changes: 22 additions & 0 deletions signatures.js
@@ -0,0 +1,22 @@
var fs=require('fs');
var obj=require('./signatures.json');
function forEach(obj, fn, path) {
if (typeof obj == "object")
Object.keys(obj).forEach(function(key) {
var deepPath = path ? path + '.' + key : key;
// Note that we always use obj[key] because it might be mutated by forEach
if (fn.call(obj, obj[key], key, obj, deepPath))
forEach(obj[key], fn, deepPath);
})
}

var table = [];
forEach(obj, function(thing, key, obj, path) {
if (thing.email) {
table.push({"include_vars":thing})
return false
} else {
return true
}
});
fs.writeFile("signatures.json",JSON.stringify(table),"UTF-8",function(a){a&&console.log(a)})
237 changes: 1 addition & 236 deletions site/data/signatures/signatures.json
@@ -1,236 +1 @@
[{
"from": "admin@example.com",
"to": ["tech@example.org"],
"subject": "New signature to PMPC",
"content": {
"html": null,
"plain": "Dear FSFE,\n\nI agree to sign the open initiative, calling for implementing legislation\nrequiring that, as a default setting, publicly financed software must\nbe made publicly available under a Free Software licence.\n\nHey Max! Lets see if this works.\n\nThank you,\n\nTest Testson\nSweden"
},
"reply-to": null,
"include_vars": {
"name": "Test Testson",
"confirm": "jonas@example.com",
"country": "Sweden",
"zip": "64632",
"comment": "Hey Max! Lets see if this works.",
"permissionPriv": "yes",
"permissionNews": "yes",
"permissionPub": "yes",
"url": "",
"action": "sign"
}
}, {
"from": "admin@example.com",
"to": ["tech@example.org"],
"subject": "New signature to PMPC",
"content": {
"html": null,
"plain": "Dear FSFE,\n\nI agree to sign the open initiative, calling for implementing legislation\nrequiring that, as a default setting, publicly financed software must\nbe made publicly available under a Free Software licence.\n\nHey Max! Lets see if this works, AGAIN!\n\nThank you,\n\nTest Testson 2\nSweden"
},
"reply-to": null,
"include_vars": {
"name": "Test Testson 2",
"confirm": "jonas@example.com",
"country": "Sweden",
"zip": "64632",
"comment": "Hey Max! Lets see if this works, AGAIN!",
"permissionPriv": "yes",
"permissionNews": "yes",
"permissionPub": "yes",
"url": "",
"action": "sign"
}
}, {
"from": "admin@example.com",
"to": ["tech@example.org"],
"subject": "New signature to PMPC",
"content": {
"html": null,
"plain": "Dear FSFE,\n\nI agree to sign the open initiative, calling for implementing legislation\nrequiring that, as a default setting, publicly financed software must\nbe made publicly available under a Free Software licence.\n\nHey Max! Lets see if this works, AGAIN! With timestamp.\n\nThank you,\n\nTest Testson 2\nSweden"
},
"reply-to": null,
"include_vars": {
"name": "Test Testson 2",
"confirm": "jonas@example.com",
"country": "Sweden",
"zip": "64632",
"comment": "Hey Max! Lets see if this works, AGAIN! With timestamp.",
"permissionPriv": "yes",
"permissionNews": "yes",
"permissionPub": "yes",
"url": "",
"action": "sign"
}
}, {
"timestamp": 1504267755.763549,
"from": "admin@example.com",
"to": ["tech@example.org"],
"subject": "New signature to PMPC",
"content": {
"html": null,
"plain": "Dear FSFE,\n\nI agree to sign the open initiative, calling for implementing legislation\nrequiring that, as a default setting, publicly financed software must\nbe made publicly available under a Free Software licence.\n\nHey Max! Lets see if this works, AGAIN! With timestamp.\n\nThank you,\n\nTest Testson 2\nSweden"
},
"reply-to": null,
"include_vars": {
"name": "Test Testson 2",
"confirm": "jonas@example.com",
"country": "Sweden",
"zip": "64632",
"comment": "Hey Max! Lets see if this works, AGAIN! With timestamp.",
"permissionPriv": "yes",
"permissionNews": "yes",
"permissionPub": "yes",
"url": "",
"action": "sign"
}
}, {
"timestamp": 1504523661.6949115,
"from": "admin@example.com",
"to": ["tech@example.org"],
"subject": "New signature to PMPC",
"content": {
"html": null,
"plain": "Dear FSFE,\n\nI agree to sign the open initiative, calling for implementing legislation\nrequiring that, as a default setting, publicly financed software must\nbe made publicly available under a Free Software licence.\n\n\n\nThank you,\n\nMax1\nBelgium"
},
"reply-to": null,
"include_vars": {
"name": "Max1",
"confirm": "mail@example.org",
"country": "Belgium",
"zip": "12345",
"comment": "",
"permissionPriv": "yes",
"permissionNews": "yes",
"permissionPub": "yes",
"url": "",
"action": "sign"
}
}, {
"timestamp": 1504525516.8869548,
"from": "admin@example.com",
"to": ["tech@example.org"],
"subject": "New signature to PMPC",
"content": {
"html": null,
"plain": "Dear FSFE,\n\nI agree to sign the open initiative, calling for implementing legislation\nrequiring that, as a default setting, publicly financed software must\nbe made publicly available under a Free Software licence.\n\nmail with + and not appear in list\n\nThank you,\n\nMax3\nNetherlands"
},
"reply-to": null,
"include_vars": {
"name": "Max3",
"confirm": "tech+blah@example.org",
"country": "Netherlands",
"zip": "66816",
"comment": "mail with + and not appear in list",
"permissionPriv": "yes",
"permissionNews": "yes",
"url": "",
"action": "sign"
}
}, {
"timestamp": 1504525520.145522,
"from": "admin@example.com",
"to": ["tech@example.org"],
"subject": "New signature to PMPC",
"content": {
"html": null,
"plain": "Dear FSFE,\n\nI agree to sign the open initiative, calling for implementing legislation\nrequiring that, as a default setting, publicly financed software must\nbe made publicly available under a Free Software licence.\n\nThis is the same email as Max1\n\nThank you,\n\nMax2\nBulgaria"
},
"reply-to": null,
"include_vars": {
"name": "Max2",
"confirm": "mail@example.org",
"country": "Bulgaria",
"zip": "68168",
"comment": "This is the same email as Max1",
"permissionPriv": "yes",
"permissionNews": "yes",
"permissionPub": "yes",
"url": "",
"action": "sign"
}
}, {
"timestamp": 1504601254.3506515,
"from": "admin@example.com",
"to": ["tech@example.org"],
"subject": "New signature to PMPC",
"content": {
"html": null,
"plain": "Dear FSFE,\n\nI agree to sign the open initiative, calling for implementing legislation\nrequiring that, as a default setting, publicly financed software must\nbe made publicly available under a Free Software licence.\n\nYeah\n\nThank you,\n\nFan\nCzech Republic"
},
"reply-to": null,
"include_vars": {
"name": "Fan",
"confirm": "tech@example.org",
"country": "Czech Republic",
"zip": "26168",
"comment": "Yeah",
"permissionPriv": "yes",
"permissionPub": "yes",
"url": "",
"action": "sign"
}
}, {
"timestamp": 1504601626.4398348,
"from": "admin@example.com",
"to": ["tech@example.org"],
"subject": "New signature to PMPC",
"content": {
"html": null,
"plain": "Dear FSFE,\n\nI agree to sign the open initiative, calling for implementing legislation\nrequiring that, as a default setting, publicly financed software must\nbe made publicly available under a Free Software licence.\n\nTest again\n\nThank you,\n\nTest2\nPortugal"
},
"reply-to": null,
"include_vars": {
"name": "Test2",
"confirm": "tech+2@example.org",
"country": "Portugal",
"zip": "6168",
"comment": "Test again",
"permissionPriv": "yes",
"permissionPub": "yes",
"url": "",
"action": "sign"
}
}, {
"timestamp": 1504601726.8100023,
"from": "admin@example.com",
"to": ["tech@example.org"],
"subject": "New signature to PMPC",
"content": {
"html": null,
"plain": "Dear FSFE,\n\nI agree to sign the open initiative, calling for implementing legislation\nrequiring that, as a default setting, publicly financed software must\nbe made publicly available under a Free Software licence.\n\nCrazy <3 \"\" symbols ' // %$ \\\n\nThank you,\n\nEdge case\nLuxembourg"
},
"reply-to": null,
"include_vars": {
"name": "HIDDEN",
"confirm": "tech@example.org",
"country": "Luxembourg",
"zip": "51684168",
"comment": "Crazy <3 \"\" symbols ' // %$ \\",
"permissionPriv": "yes",
"permissionNews": "yes",
"url": "",
"action": "sign"
}
}, {
"timestamp": 1504601815.3437912,
"from": "admin@example.com",
"to": ["tech@example.org"],
"subject": "New signature to PMPC",
"content": {
"html": null,
"plain": "Dear FSFE,\n\nI agree to sign the open initiative, calling for implementing legislation\nrequiring that, as a default setting, publicly financed software must\nbe made publicly available under a Free Software licence.\n\n\u00d1\u0081\u00d1\u0082\u00d1\u0080\u00d0\u00b0\u00d0\u00bd\u00d0\u00b8\u00d1\u0086\u00d1\u008b \u00d0\u00bc\u00d0\u00be\u00d0\u00b3 \u00e5\u009f\u009f\u00e5\u0090\u008d\u00e7\u009a\u0084\u00e7\u0094\u00a8\u00e6\u0088\u00b6\u00e4\u00b8\u008d\u00e5\u008f\u0097\u00e9\u0099\u0090\u00e5\u0088\u00b6\n\nThank you,\n\n \u00ce\u0091\u00cf\u0085\u00cf\u0084\u00ce\u00ae \u00ce\u00b7 \u00cf\u0083\u00ce\u00b5\u00ce\u00bb\u00ce\u00af\u00ce\u00b4\u00ce\u00b1\n"
},
"reply-to": null,
"include_vars": {
"name": " \u00ce\u0091\u00cf\u0085\u00cf\u0084\u00ce\u00ae \u00ce\u00b7 \u00cf\u0083\u00ce\u00b5\u00ce\u00bb\u00ce\u00af\u00ce\u00b4\u00ce\u00b1",
"confirm": "mail@example.org",
"country": "",
"zip": "56165",
"comment": "\u00d1\u0081\u00d1\u0082\u00d1\u0080\u00d0\u00b0\u00d0\u00bd\u00d0\u00b8\u00d1\u0086\u00d1\u008b \u00d0\u00bc\u00d0\u00be\u00d0\u00b3 \u00e5\u009f\u009f\u00e5\u0090\u008d\u00e7\u009a\u0084\u00e7\u0094\u00a8\u00e6\u0088\u00b6\u00e4\u00b8\u008d\u00e5\u008f\u0097\u00e9\u0099\u0090\u00e5\u0088\u00b6",
"permissionPriv": "yes",
"permissionNews": "yes",
"permissionPub": "yes",
"url": "",
"action": "sign"
}
}]
[{"include_vars":{"Comment":"some comment","Country":"Austria","Organization":"orga","Region":"somewhere else","appid":"pmpc-sign","email":"top@importan.mail","hp":"","list":"3DgINxa6kL069W892X0763H1VA","name":"some name","permissionPriv":"yes","permissionPub":"undefined","submit":"sign","url":""}}]
6 changes: 3 additions & 3 deletions site/layouts/partials/sub-pages/sigtable.html
@@ -1,4 +1,4 @@
<!--{{ "<!-- SIGNATURES -/->" | safeHTML }}
{{ "<!-- SIGNATURES -->" | safeHTML }}
<section class="bg-primary" id="signatures">
<div class="container">
<div class="row">
Expand All @@ -13,7 +13,7 @@ <h2 class="section-heading">{{ . }}</h2>
<p class="text-faded">{{ .Site.Params.subpage.signatures.description | markdownify }}
<a href="{{ "#action" | relLangURL }}"><strong>{{ .Site.Params.action.form.Submit }}</strong></a></p>

<!-- If you change something here, also change layouts/shortcodes/show_signature.html -/->
<!-- If you change something here, also change layouts/shortcodes/show_signature.html -->
<table id="sigtable">
<thead>
<tr>
Expand All @@ -40,4 +40,4 @@ <h2 class="section-heading">{{ . }}</h2>
</div>
</div>
</div>
</section-->
</section>

0 comments on commit d5eb2a5

Please sign in to comment.