From 24b2bd8e15d99dbf6cf46e10d2ad982a0a6c9131 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Sat, 20 Feb 2016 09:35:20 -0500 Subject: [PATCH 1/7] add moderate example script --- contrib/tools/api/moderate.js | 51 +++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 contrib/tools/api/moderate.js diff --git a/contrib/tools/api/moderate.js b/contrib/tools/api/moderate.js new file mode 100644 index 0000000..66dac31 --- /dev/null +++ b/contrib/tools/api/moderate.js @@ -0,0 +1,51 @@ +var http = require('http'); + +var makeIpBan = function(cidr, privkey, cb) { + cb({ + message: "overchan-inet-ban "+cidr; + name: "mod#"+privkey, + frontend: "memegod.censor", + newsgroup: "ctl" + }) +} + +var makeDeletePosts = function(msgids, privkey, cb) { + cb({ + message: "\ndelete ".join(msgids) + name: "mod#"+privkey, + frontend: "memegod.censor", + newsgroup: "ctl", + }) +} + +var moderate = function(req) { + + j = JSON.stringify(req); + + var r = http.request({ + port: 8800, + method: "POST", + path: "/api/post", + auth: "user:pass", + headers: { + "Content-Type": "text/json", + "Content-Length": j.length + } + }, function (res) { + res.on('data', function (chunk) { + var r = chunk.toString(); + var rj = JSON.parse(r); + console.log(rj.id); + }); + }); + + r.write(j); + r.end(); +} + +var privateKey = "longhexgoestripcodegoeshere"; + +// ban 192.168.0.1/16 and sign with private key +moderate(makeIpBan("192.168.0.1/16", privateKey)); +// delete and and sign with private key +moderate(makeDeletPosts(["", ""], privateKey)); From 9459e1758d14ba48065f7a74f6f22e2f9587a166 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Sat, 20 Feb 2016 09:41:03 -0500 Subject: [PATCH 2/7] fix moderate.js tool --- contrib/tools/api/moderate.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/tools/api/moderate.js b/contrib/tools/api/moderate.js index 66dac31..16daf5f 100644 --- a/contrib/tools/api/moderate.js +++ b/contrib/tools/api/moderate.js @@ -1,8 +1,8 @@ var http = require('http'); -var makeIpBan = function(cidr, privkey, cb) { +var makeIpBans = function(cidrs, privkey, cb) { cb({ - message: "overchan-inet-ban "+cidr; + message: cidrs.join("\noverchan-inet-ban "), name: "mod#"+privkey, frontend: "memegod.censor", newsgroup: "ctl" @@ -11,7 +11,7 @@ var makeIpBan = function(cidr, privkey, cb) { var makeDeletePosts = function(msgids, privkey, cb) { cb({ - message: "\ndelete ".join(msgids) + message: msgids.join("\ndelete "), name: "mod#"+privkey, frontend: "memegod.censor", newsgroup: "ctl", @@ -46,6 +46,6 @@ var moderate = function(req) { var privateKey = "longhexgoestripcodegoeshere"; // ban 192.168.0.1/16 and sign with private key -moderate(makeIpBan("192.168.0.1/16", privateKey)); +moderate(makeIpBans(["192.168.0.1/16"], privateKey)); // delete and and sign with private key moderate(makeDeletPosts(["", ""], privateKey)); From f91bd642a545114d04a2d150098523a08d3e295d Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Sat, 20 Feb 2016 09:42:22 -0500 Subject: [PATCH 3/7] fix moderate.js --- contrib/tools/api/moderate.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/tools/api/moderate.js b/contrib/tools/api/moderate.js index 16daf5f..5b7c6a0 100644 --- a/contrib/tools/api/moderate.js +++ b/contrib/tools/api/moderate.js @@ -46,6 +46,6 @@ var moderate = function(req) { var privateKey = "longhexgoestripcodegoeshere"; // ban 192.168.0.1/16 and sign with private key -moderate(makeIpBans(["192.168.0.1/16"], privateKey)); +makeIpBans(["192.168.0.1/16"], privateKey, moderate); // delete and and sign with private key -moderate(makeDeletPosts(["", ""], privateKey)); +makeDeletPosts(["", ""], privateKey, moderate); From d2b9e763896f4c133afc598c85639f3ef53810f2 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Sun, 21 Feb 2016 16:51:56 -0500 Subject: [PATCH 4/7] update templates --- contrib/templates/default/board.mustache | 2 +- contrib/templates/default/modlogin.mustache | 1 + contrib/templates/default/postform.mustache | 2 ++ contrib/templates/default/thread.mustache | 3 +-- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/contrib/templates/default/board.mustache b/contrib/templates/default/board.mustache index 01dd049..71c07df 100644 --- a/contrib/templates/default/board.mustache +++ b/contrib/templates/default/board.mustache @@ -32,7 +32,7 @@
- {{{form}}} + {{{board.PostForm}}}

diff --git a/contrib/templates/default/modlogin.mustache b/contrib/templates/default/modlogin.mustache index fb8e584..5f9643c 100644 --- a/contrib/templates/default/modlogin.mustache +++ b/contrib/templates/default/modlogin.mustache @@ -9,6 +9,7 @@ + {{{csrfField}}} diff --git a/contrib/templates/default/postform.mustache b/contrib/templates/default/postform.mustache index 4edf3a4..6a5370e 100644 --- a/contrib/templates/default/postform.mustache +++ b/contrib/templates/default/postform.mustache @@ -6,8 +6,10 @@ - reference ( the post we are replying to, or empty string if it's an op ) - button ( the text for the reply button ) - files ( bool, do we allow attachments ? ) + - csrf ( csrf token ) }}
+ {{{csrf}}}
diff --git a/contrib/templates/default/thread.mustache b/contrib/templates/default/thread.mustache index 8a9234e..ecbf3b9 100644 --- a/contrib/templates/default/thread.mustache +++ b/contrib/templates/default/thread.mustache @@ -3,7 +3,6 @@ template parameters: - board ( the Board Model of the board this thread was posted in ) - thread ( the Thread Model of the current thread being rendered ) - - form ( the post form markup ) Thread Model attributes: - OP , the Post Model of the original poster @@ -32,7 +31,7 @@
{{thread.Board}}
- {{{form}}} + {{{thread.PostForm}}}

From 7c7d07434d1152392ba8add2765cb0c7234f7cdb Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Sun, 21 Feb 2016 17:08:38 -0500 Subject: [PATCH 5/7] undo changes with post form --- contrib/templates/default/board.mustache | 2 +- contrib/templates/default/thread.mustache | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/templates/default/board.mustache b/contrib/templates/default/board.mustache index 71c07df..01dd049 100644 --- a/contrib/templates/default/board.mustache +++ b/contrib/templates/default/board.mustache @@ -32,7 +32,7 @@
- {{{board.PostForm}}} + {{{form}}}

diff --git a/contrib/templates/default/thread.mustache b/contrib/templates/default/thread.mustache index ecbf3b9..8bf06ad 100644 --- a/contrib/templates/default/thread.mustache +++ b/contrib/templates/default/thread.mustache @@ -31,7 +31,7 @@
{{thread.Board}}
- {{{thread.PostForm}}} + {{{form}}}

From 64e4c3320d69e954f5ace30cb19a966e0a4b312f Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Mon, 22 Feb 2016 07:32:49 -0500 Subject: [PATCH 6/7] fix front page --- contrib/templates/default/frontpage.mustache | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/contrib/templates/default/frontpage.mustache b/contrib/templates/default/frontpage.mustache index bc6b27b..b7c4f85 100644 --- a/contrib/templates/default/frontpage.mustache +++ b/contrib/templates/default/frontpage.mustache @@ -1,9 +1,9 @@ {{! frontpage.mustache -- template for index.html template parameters: - - boardgraph ( a boardPageRows instance, see srnd/model.go ) - - postgraph ( a postsGraph instance , see srnd/model.go ) - - overview ( an overviewModel instance, see srnd/model.go ) + - boardgraph ( markup of boardPageRows instance, see srnd/model.go ) + - postgraph ( markup of postsGraph instance , see srnd/model.go ) + - overview ( markup of overviewModel instance , see srnd/model.go ) - totalposts ( the number of total posts we have ever seen ) - frontend ( the name of the frontend ) - prefix ( the site's prefix ) @@ -36,7 +36,7 @@ - {{{postsgraph.Render}}} + {{{postsgraph}}} {{! todo: move boardgraph into its own file like postsgraph }} @@ -72,7 +72,7 @@ - {{{overview.Render}}} + {{{overview}}}
From b695d97e82fd4a2940f7890b17b58686771fffe8 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Mon, 22 Feb 2016 07:39:06 -0500 Subject: [PATCH 7/7] even out front page --- contrib/static/site.css | 4 ---- 1 file changed, 4 deletions(-) diff --git a/contrib/static/site.css b/contrib/static/site.css index cd812e3..b300530 100644 --- a/contrib/static/site.css +++ b/contrib/static/site.css @@ -234,10 +234,6 @@ a, a:visited { margin-top: 1em; } -#board_graph { - margin-top: 5em; -} - .navLinks { padding-bottom: 50px; }