From bfff7f3dee5f6ea4fe2865b8d668b1dd830641a4 Mon Sep 17 00:00:00 2001 From: Azareal Date: Fri, 18 Aug 2017 16:56:36 +0100 Subject: [PATCH] Fixed an issue with relative times breaking onto multiple lines. Fixed an issue with new reports not pushing the latest time onto the report forum. Editing topics no longer crashes Gosora. Mod action posts for topic edits now update the latest relative time for the topic's parent forum. The JS for the topic editor now locks onto the parent form properly. --- mod_routes.go | 9 +++++---- public/global.js | 6 ++++-- routes.go | 4 ++-- themes/shadow/public/main.css | 3 +++ 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/mod_routes.go b/mod_routes.go index c1c36c38..8e5edf58 100644 --- a/mod_routes.go +++ b/mod_routes.go @@ -4,12 +4,14 @@ import ( //"log" //"fmt" "strconv" + "time" "net" "net/http" "html" ) func route_edit_topic(w http.ResponseWriter, r *http.Request, user User) { + //log.Print("in route_edit_topic") err := r.ParseForm() if err != nil { PreError("Bad Form",w,r) @@ -80,14 +82,13 @@ func route_edit_topic(w http.ResponseWriter, r *http.Request, user User) { InternalError(err,w) return } - - _, err = add_replies_to_topic_stmt.Exec(1, tid) + _, err = add_replies_to_topic_stmt.Exec(1, user.ID, tid) if err != nil { InternalError(err,w) return } - _, err = update_forum_cache_stmt.Exec(topic_name, tid, user.Name, user.ID, 1) - if err != nil { + err = fstore.UpdateLastTopic(topic_name,tid,user.Name,user.ID,time.Now().Format("2006-01-02 15:04:05"),old_topic.ParentID) + if err != nil && err != ErrNoRows { InternalError(err,w) return } diff --git a/public/global.js b/public/global.js index e558e322..286403f8 100644 --- a/public/global.js +++ b/public/global.js @@ -189,7 +189,7 @@ $(document).ready(function(){ else conn = false; $(".open_edit").click(function(event){ - //console.log("Clicked on edit"); + //console.log("clicked on .open_edit"); event.preventDefault(); $(".hide_on_edit").hide(); $(".show_on_edit").show(); @@ -197,6 +197,7 @@ $(document).ready(function(){ $(".topic_item .submit_edit").click(function(event){ event.preventDefault(); + console.log("clicked on .topic_item .submit_edit"); $(".topic_name").html($(".topic_name_input").val()); $(".topic_content").html($(".topic_content_input").val()); $(".topic_status_e:not(.open_edit)").html($(".topic_status_input").val()); @@ -207,9 +208,10 @@ $(document).ready(function(){ var topic_name_input = $('.topic_name_input').val(); var topic_status_input = $('.topic_status_input').val(); var topic_content_input = $('.topic_content_input').val(); - var form_action = $(this).closest('form').attr("action"); + var form_action = this.form.getAttribute("action"); //console.log("New Topic Name: " + topic_name_input); //console.log("New Topic Status: " + topic_status_input); + //console.log("New Topic Content: " + topic_content_input); //console.log("Form Action: " + form_action); $.ajax({ url: form_action, diff --git a/routes.go b/routes.go index 912e82a5..1ad526e8 100644 --- a/routes.go +++ b/routes.go @@ -1312,8 +1312,8 @@ func route_report_submit(w http.ResponseWriter, r *http.Request, user User, site InternalError(err,w) return } - _, err = update_forum_cache_stmt.Exec(title, lastId, user.Name, user.ID, fid) - if err != nil { + err = fstore.UpdateLastTopic(title,int(lastId),user.Name,user.ID,time.Now().Format("2006-01-02 15:04:05"),fid) + if err != nil && err != ErrNoRows { InternalError(err,w) return } diff --git a/themes/shadow/public/main.css b/themes/shadow/public/main.css index d666c3a9..9bec6a8b 100644 --- a/themes/shadow/public/main.css +++ b/themes/shadow/public/main.css @@ -473,6 +473,9 @@ input, select, textarea { .topic_list .rowitem:last-child { margin-bottom: 10px; } +.topic_list .lastReplyAt { + white-space: nowrap; +} /* Profiles */ #profile_left_lane {