From 536b1161c94e3e2149912ada6479886f15ce10e3 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Sat, 31 Dec 2016 08:36:28 -0500 Subject: [PATCH] more --- build-js.sh | 2 +- contrib/js/neochan/board_init.js | 24 +++++++++++++++ contrib/js/neochan/init.coffee.js | 5 ---- contrib/js/neochan/post.js | 23 +++++++++++++++ contrib/js/neochan/postify.js | 37 ++++++++++++++++++++++++ contrib/js/neochan/readme.md | 2 -- contrib/static/site.css | 2 +- contrib/templates/neochan/board.mustache | 31 ++++---------------- contrib/templates/neochan/post.mustache | 20 +++++++------ 9 files changed, 103 insertions(+), 43 deletions(-) create mode 100644 contrib/js/neochan/board_init.js delete mode 100644 contrib/js/neochan/init.coffee.js create mode 100644 contrib/js/neochan/post.js create mode 100644 contrib/js/neochan/postify.js diff --git a/build-js.sh b/build-js.sh index c24b0cb..427501d 100755 --- a/build-js.sh +++ b/build-js.sh @@ -113,7 +113,7 @@ if [ "$neochan" == "yes" ] ; then for f in ./contrib/js/neochan/*.less ; do css "$f" "$neochan_css_outfile" done - + fi echo echo "ok" diff --git a/contrib/js/neochan/board_init.js b/contrib/js/neochan/board_init.js new file mode 100644 index 0000000..2b59d43 --- /dev/null +++ b/contrib/js/neochan/board_init.js @@ -0,0 +1,24 @@ + + +/** + * @brief initialize a board page + */ +function neochan_board_init(root, board) { + + var thread_init = function (j) { + var elem = document.createElement("div"); + for(var idx = 0; idx < j.length; idx ++) { + var post = j[idx]; + neochan_post_fadein(elem, post); + } + return elem; + } + // inject threads + onready(function() { + for (var idx = 0; idx < board.posts.length; idx ++) { + var posts = board.posts[idx]; + var elem = thread_init(posts); + root.appendChild(elem); + } + }); +} diff --git a/contrib/js/neochan/init.coffee.js b/contrib/js/neochan/init.coffee.js deleted file mode 100644 index 49caa98..0000000 --- a/contrib/js/neochan/init.coffee.js +++ /dev/null @@ -1,5 +0,0 @@ -// Generated by CoffeeScript 1.11.1 -(function() { - - -}).call(this); diff --git a/contrib/js/neochan/post.js b/contrib/js/neochan/post.js new file mode 100644 index 0000000..91900ee --- /dev/null +++ b/contrib/js/neochan/post.js @@ -0,0 +1,23 @@ + + +function neochan_post_new(j) { + var post = document.createElement("div"); + post.id = j.PostHash; + post.setAttribute("class", "neochan-post-wrapper"); + var header = document.createElement("div"); + header.setAttribute("class", "neochan-post-header"); + post.appendChild(header); + + var body = document.createElement("div"); + body.setAttribute("class", "neochan-post-body"); + + neochan_postify(body, j.Message); + + return post; +} + +function neochan_post_fadein(elem, j) { + var post = neochan_post_new(j); + $(post).fadein(); + elem.appendChild(post); +} diff --git a/contrib/js/neochan/postify.js b/contrib/js/neochan/postify.js new file mode 100644 index 0000000..d5a9425 --- /dev/null +++ b/contrib/js/neochan/postify.js @@ -0,0 +1,37 @@ + + +function _neochan_filter_boardlink(match) { + match = match.toLowerCase(); + var a = document.createElement("a"); + a.href = "/" + match + "-0.html"; + match = ">>>/" + match + "/"; + a.appendChild(document.createTextNode(match)); + return a; +} + +function _neochan_filter_postlink(match) { + +} + +var _neochan_post_filters = [ + [/>>>\/(overchan\\.[a-zA-z0-9\\.]+[a-zA-Z0-9])\//g, _neochan_filter_boardlink], + [/>>? ([a-fA-F0-9])/g, _neochan_filter_postlink], + [/==(.+)==/g, _neochan_filter_redtext], + [/@@(.+)@@/g, _neochan_filter_psytext], + [/^>/g, _neochan_filter_greentext], +]; + +/** + * @brief create post body from raw text + */ +function neochan_postify(elem, text) { + $.each(_neochan_post_filters, function(idx, ent) { + var re = ent[0]; + var func = ent[1]; + text = text.replace(re, function(m) { + var e = func(m); + + return ""; + }); + }); +} diff --git a/contrib/js/neochan/readme.md b/contrib/js/neochan/readme.md index 000bf58..f99e678 100644 --- a/contrib/js/neochan/readme.md +++ b/contrib/js/neochan/readme.md @@ -1,3 +1 @@ # neochan javascript directory - -sass files for neochan templates diff --git a/contrib/static/site.css b/contrib/static/site.css index f0ef1a8..f26bea9 100644 --- a/contrib/static/site.css +++ b/contrib/static/site.css @@ -295,7 +295,7 @@ a, a:visited, .navbar-link > label { } .navbar-link > label { - text-decoration: underline; + text-decoration: underline; } #postform_container { diff --git a/contrib/templates/neochan/board.mustache b/contrib/templates/neochan/board.mustache index b58713f..be44969 100644 --- a/contrib/templates/neochan/board.mustache +++ b/contrib/templates/neochan/board.mustache @@ -29,37 +29,18 @@
-
{{board.Board}}
-
{{#i18n.Translations}}{{catalog_label}}{{/i18n.Translations}}
- -
- {{{form}}} -
-
-
- {{#board.Threads}} -
-
-
- {{{OP.Truncate.RenderPost}}} - {{#Truncate.Replies}} - {{{Truncate.RenderPost}}} - {{/Truncate.Replies}} -
-
- {{/board.Threads}} -
-
{{# board.PageList }}[ {{Text}} ] {{/ board.PageList }} - - | - - {{#i18n.Translations}}{{catalog_label}}{{/i18n.Translations}} +

diff --git a/contrib/templates/neochan/post.mustache b/contrib/templates/neochan/post.mustache index b349cdc..2e29774 100644 --- a/contrib/templates/neochan/post.mustache +++ b/contrib/templates/neochan/post.mustache @@ -18,7 +18,7 @@ data-origin="clearnet" {{/post.IsClearnet}} data-posturl="{{post.PostURL}}"> - +
{{#post.IsI2P}} @@ -46,17 +46,19 @@
Date:
- +

{{#post.Attachments}} -
-
- {{#i18n.Translations}}{{download_prompt}}{{/i18n.Translations}} - {{Filename}} - {{Filename}} -
-
+
+ +
{{/post.Attachments}}