From f11f85a1f43c60922a400567a6321c66cb69040a Mon Sep 17 00:00:00 2001 From: Azareal Date: Mon, 25 Mar 2019 13:30:56 +1000 Subject: [PATCH] You can now quote posts with the quote button. Back to Site now links back to the site again. Localised what to do with this topic for a single topic. Improved the margins before and after blockquotes for various scenarios including one on it's own, one with content after and one with content before. Don't bother rendering the opening post source block if it's a guest viewing the page in topic.html Removed some obsolete inline styles from topic.html Added the topic.quote_button_text phrase. Added the topic_list.what_to_do_single phrase. Added the topic.quote_tooltip phrase. Added the topic.quote_aria phrase. --- langs/english.json | 4 ++++ public/global.js | 25 +++++++++++++++++---- templates/topic.html | 24 ++++++++++++-------- templates/topic_alt.html | 6 +++-- templates/topic_alt_posts.html | 4 +++- templates/topic_posts.html | 6 +++-- themes/cosora/public/main.css | 7 ++++++ themes/cosora/public/misc.js | 7 +++++- themes/nox/overrides/panel_before_head.html | 2 +- themes/nox/public/main.css | 7 +++++- themes/nox/public/panel.css | 3 +++ themes/shadow/public/main.css | 6 ++++- themes/tempra_simple/public/main.css | 7 ++++++ 13 files changed, 86 insertions(+), 22 deletions(-) diff --git a/langs/english.json b/langs/english.json index 941ce2d8..419c4a4e 100644 --- a/langs/english.json +++ b/langs/english.json @@ -378,6 +378,7 @@ "topic.plus":"+", "topic.plus_one":"+1", "topic.gap_up":" up", + "topic.quote_button_text":"Quote", "topic.edit_button_text":"Edit", "topic.delete_button_text":"Delete", "topic.ip_button_text":"IP", @@ -553,6 +554,7 @@ "topic_list.moderate_tooltip":"Moderate", "topic_list.moderate_aria":"Moderate Posts", "topic_list.what_to_do":"What do you want to do with these {0} topics?", + "topic_list.what_to_do_single":"What do you want to do with this topic?", "topic_list.moderate_delete":"Delete them", "topic_list.moderate_lock":"Lock them", "topic_list.moderate_move":"Move them", @@ -599,6 +601,8 @@ "topic.unlike_aria":"Unlike this topic", "topic.like_tooltip":"Like", "topic.like_aria":"Like this topic", + "topic.quote_tooltip":"Quote Topic", + "topic.quote_aria":"Quote this topic", "topic.edit_tooltip":"Edit Topic", "topic.edit_aria":"Edit this topic", "topic.delete_tooltip":"Delete Topic", diff --git a/public/global.js b/public/global.js index 55ddb348..c33a5da7 100644 --- a/public/global.js +++ b/public/global.js @@ -7,6 +7,7 @@ var moreTopicCount = 0; var conn = false; var selectedTopics = []; var attachItemCallback = function(){} +var quoteItemCallback = function(){} var baseTitle = document.title; var wsBackoff = 0; @@ -749,8 +750,7 @@ function mainInit(){ // Remove any handlers already attached to the submitter $(".submit_edit").unbind("click"); - $(".submit_edit").click(function(event) - { + $(".submit_edit").click(function(event) { event.preventDefault(); var outData = {isJs: "1"} var blockParent = $(this).closest('.editable_parent'); @@ -793,6 +793,23 @@ function mainInit(){ } }); + $(".quote_item").click(function(){ + event.preventDefault(); + event.stopPropagation(); + let source = this.closest(".post_item").getElementsByClassName("edit_source")[0]; + let content = document.getElementById("input_content") + console.log("content.value", content.value); + + let item; + if(content.value == "") item = "
" + source.innerHTML + "
" + else item = "\r\n
" + source.innerHTML + "
"; + content.value = content.value + item; + console.log("content.value", content.value); + + // For custom / third party text editors + quoteItemCallback(source.innerHTML,item); + }); + $(this).click(() => { $(".selectedAlert").removeClass("selectedAlert"); $("#back").removeClass("alertActive"); @@ -935,7 +952,7 @@ function mainInit(){ else attachItem = "\r\n//" + window.location.host + "/attachs/" + hash + "." + ext; content.value = content.value + attachItem; console.log("content.value", content.value); - + // For custom / third party text editors attachItemCallback(attachItem); }); @@ -1021,7 +1038,7 @@ function mainInit(){ $(this).click(function(){ selectedTopics.push(parseInt($(this).attr("data-tid"),10)); if(selectedTopics.length==1) { - var msg = "What do you want to do with this topic?"; + var msg = phraseBox["topic_list"]["topic_list.what_to_do_single"]; } else { var msg = "What do you want to do with these "+selectedTopics.length+" topics?"; } diff --git a/templates/topic.html b/templates/topic.html index 40a72d94..07dcb8f8 100644 --- a/templates/topic.html +++ b/templates/topic.html @@ -54,26 +54,32 @@
-

{{.Topic.ContentHTML}}

- + {{.Topic.ContentHTML}} + {{if .CurrentUser.Loggedin}}{{end}}    - {{if .CurrentUser.Perms.LikeItem}} + + {{if .CurrentUser.Loggedin}} + {{if .CurrentUser.Perms.LikeItem}} {{end}} + + {{if not .Topic.IsClosed or .CurrentUser.Perms.CloseTopic}} - {{if .CurrentUser.Perms.EditTopic}}{{end}} + {{if .CurrentUser.Perms.EditTopic}}{{end}} {{end}} - {{if .CurrentUser.Perms.DeleteTopic}}{{end}} + {{if .CurrentUser.Perms.DeleteTopic}}{{end}} - {{if .CurrentUser.Perms.CloseTopic}}{{if .Topic.IsClosed}}{{else}}{{end}}{{end}} + {{if .CurrentUser.Perms.CloseTopic}}{{if .Topic.IsClosed}}{{else}}{{end}}{{end}} - {{if .CurrentUser.Perms.PinTopic}}{{if .Topic.Sticky}}{{else}}{{end}}{{end}} - {{if .CurrentUser.Perms.ViewIPs}}{{end}} - + {{if .CurrentUser.Perms.PinTopic}}{{if .Topic.Sticky}}{{else}}{{end}}{{end}} + {{if .CurrentUser.Perms.ViewIPs}}{{end}} + {{end}} + + diff --git a/templates/topic_alt.html b/templates/topic_alt.html index 7d28f970..79e6dfa0 100644 --- a/templates/topic_alt.html +++ b/templates/topic_alt.html @@ -64,8 +64,9 @@ {{template "topic_alt_userinfo.html" .Topic }}
{{.Topic.ContentHTML}}
- {{if .CurrentUser.Loggedin}}{{if .CurrentUser.Perms.EditTopic}} + {{if .CurrentUser.Loggedin}} + {{if .CurrentUser.Perms.EditTopic}} {{if .Topic.Attachments}}
{{range .Topic.Attachments}}
@@ -88,6 +89,7 @@
{{if .CurrentUser.Loggedin}} {{if .CurrentUser.Perms.LikeItem}}{{end}} + {{if not .Topic.IsClosed or .CurrentUser.Perms.CloseTopic}} {{if .CurrentUser.Perms.EditTopic}}{{end}} {{end}} @@ -123,4 +125,4 @@ -{{template "footer.html" . }} +{{template "footer.html" . }} \ No newline at end of file diff --git a/templates/topic_alt_posts.html b/templates/topic_alt_posts.html index c8e206b4..c805c7dd 100644 --- a/templates/topic_alt_posts.html +++ b/templates/topic_alt_posts.html @@ -6,9 +6,10 @@ {{.ActionType}} {{else}}
{{.ContentHtml}}
- {{if $.CurrentUser.Loggedin}}{{if $.CurrentUser.Perms.EditReply}} + {{if $.CurrentUser.Loggedin}}
{{.Content}}
+ {{if $.CurrentUser.Perms.EditReply}} {{if .Attachments}}
{{range .Attachments}}
@@ -31,6 +32,7 @@
{{if $.CurrentUser.Loggedin}} {{if $.CurrentUser.Perms.LikeItem}}{{end}} + {{if not $.Topic.IsClosed or $.CurrentUser.Perms.CloseTopic}} {{if $.CurrentUser.Perms.EditReply}}{{end}} {{end}} diff --git a/templates/topic_posts.html b/templates/topic_posts.html index d127375c..3d149495 100644 --- a/templates/topic_posts.html +++ b/templates/topic_posts.html @@ -7,14 +7,16 @@ {{else}}
{{/** TODO: We might end up with
s in the inline editor, fix this **/}} -

{{.ContentHtml}}

- {{if $.CurrentUser.Loggedin}}{{if $.CurrentUser.Perms.EditReply}}
{{.Content}}
{{end}}{{end}} + {{.ContentHtml}} + {{if $.CurrentUser.Loggedin}}
{{.Content}}
{{end}}    {{if $.CurrentUser.Perms.LikeItem}}{{if .Liked}}{{else}}{{end}}{{end}} + + {{if not $.Topic.IsClosed or $.CurrentUser.Perms.CloseTopic}} {{if $.CurrentUser.Perms.EditReply}}{{end}} {{end}} diff --git a/themes/cosora/public/main.css b/themes/cosora/public/main.css index cb89e1cf..e283cd23 100644 --- a/themes/cosora/public/main.css +++ b/themes/cosora/public/main.css @@ -1001,8 +1001,12 @@ blockquote { margin: 0px; background-color: #EEEEEE; padding: 12px; + margin-top: 12px; margin-bottom: -3px; } +blockquote:first-child { + margin-top: 0px; +} .post_item { display: flex; margin-bottom: 16px; @@ -1120,6 +1124,9 @@ blockquote { .button_container .open_edit:after, .edit_item:after{ content: "{{lang "topic.edit_button_text" . }}"; } +.quote_item:after { + content: "{{lang "topic.quote_button_text" . }}"; +} .delete_item:after { content: "{{lang "topic.delete_button_text" . }}"; } diff --git a/themes/cosora/public/misc.js b/themes/cosora/public/misc.js index 2b98f134..6415d017 100644 --- a/themes/cosora/public/misc.js +++ b/themes/cosora/public/misc.js @@ -6,16 +6,21 @@ console.log("af") let loggedIn = document.head.querySelector("[property='x-loggedin']").content; if(loggedIn) { + if(navigator.userAgent.indexOf("Firefox") != -1) $.trumbowyg.svgPath = "/static/trumbowyg/ui/icons.svg"; + // Is there we way we can append instead? Maybe, an editor plugin? attachItemCallback = function(attachItem) { let currentContent = $('#input_content').trumbowyg('html'); $('#input_content').trumbowyg('html', currentContent); } + quoteItemCallback = function() { + let currentContent = $('#input_content').trumbowyg('html'); + $('#input_content').trumbowyg('html', currentContent); + } $(".topic_name_row").click(function(){ $(".topic_create_form").addClass("selectedInput"); }); - //$.trumbowyg.svgPath = false; // TODO: Bind this to the viewport resize event var btnlist = []; diff --git a/themes/nox/overrides/panel_before_head.html b/themes/nox/overrides/panel_before_head.html index cb7af928..a213cb28 100644 --- a/themes/nox/overrides/panel_before_head.html +++ b/themes/nox/overrides/panel_before_head.html @@ -1,5 +1,5 @@
-
{{lang "panel_back_to_site"}}
+
{{lang "panel_welcome"}}{{.CurrentUser.Name}}
diff --git a/themes/nox/public/main.css b/themes/nox/public/main.css index 7826f3f0..e8126da2 100644 --- a/themes/nox/public/main.css +++ b/themes/nox/public/main.css @@ -735,14 +735,19 @@ blockquote { border-radius: 3px; padding: 8px; margin: 0px; + margin-top: 8px; margin-bottom: 8px; } blockquote + br { display: none; } blockquote:only-child { + margin-top: 0px; margin-bottom: 0px; } +blockquote:first-child { + margin-top: 0px; +} .post_item { display: flex; margin-bottom: 12px; @@ -903,7 +908,7 @@ input[type=checkbox]:checked + label .sel { .ip_item_button:after { content: "{{lang "topic.ip_button_text" . }}"; }{{$p := .}} -{{range (toArr "delete" "lock" "unlock" "pin" "unpin" "report")}} +{{range (toArr "quote" "delete" "lock" "unlock" "pin" "unpin" "report")}} .{{.}}_item:after { content: "{{lang (concat "topic." . "_button_text") ($p) }}"; }{{end}} diff --git a/themes/nox/public/panel.css b/themes/nox/public/panel.css index 0b952302..a7db5435 100644 --- a/themes/nox/public/panel.css +++ b/themes/nox/public/panel.css @@ -41,6 +41,9 @@ margin-top: 16px; font-size: 18px; } +.above_right .left_bit a { + color: #bbbbbb; +} .above_right .right_bit { margin-left: auto; display: flex; diff --git a/themes/shadow/public/main.css b/themes/shadow/public/main.css index f0bb18c7..504438cd 100644 --- a/themes/shadow/public/main.css +++ b/themes/shadow/public/main.css @@ -303,7 +303,7 @@ h1, h2, h3 { .like_label:before { content: "{{lang "topic.plus_one" . }}"; }{{$out := .}} -{{range (toArr "edit" "delete" "pin" "lock" "unlock" "unpin" "ip" "flag")}} +{{range (toArr "quote" "edit" "delete" "pin" "lock" "unlock" "unpin" "ip" "flag")}} .{{.}}_label:before { content: "{{lang (concat "topic." . "_button_text") ($out) }}"; }{{end}} @@ -891,8 +891,12 @@ input[type=checkbox]:checked + label.poll_option_label .sel { blockquote { background-color: rgb(71,71,71); margin: 0px; + margin-top: 10px; padding: 10px; } +blockquote:first-child { + margin-top: 0px; +} /* Profiles */ #profile_left_lane { diff --git a/themes/tempra_simple/public/main.css b/themes/tempra_simple/public/main.css index c86162d5..b7f5b627 100644 --- a/themes/tempra_simple/public/main.css +++ b/themes/tempra_simple/public/main.css @@ -709,6 +709,9 @@ button.username { font-size: 17px; } +.quote_label:before { + content: "💬"; +} .edit_label:before { content: "🖊️"; } @@ -760,8 +763,12 @@ blockquote { margin: 0px; display: inline-block; width: 100%; + margin-top: 8px; margin-bottom: 8px; } +blockquote:first-child { + margin-top: 0px; +} .level { float: right; color: #505050;