From 4f3bacb182ef1c5ed520e813e55cf769334741ab Mon Sep 17 00:00:00 2001 From: vtyeh Date: Tue, 15 Oct 2024 16:23:28 -0700 Subject: [PATCH 1/3] Fix broken links in drafts loaded with "load more" by dynamically creating edit link based on single_user bool in config.ini --- static/js/posts.js | 4 ++-- templates/user/articles.tmpl | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/static/js/posts.js b/static/js/posts.js index dfc30b7..17a31a8 100644 --- a/static/js/posts.js +++ b/static/js/posts.js @@ -188,7 +188,7 @@ var movePostHTML = function(postID) { } return $tmpl.innerHTML.replace(/POST_ID/g, postID); } -var createPostEl = function(post, owned) { +var createPostEl = function(post, owned, singleUser) { var $post = document.createElement('div'); let p = H.createPost(post.id, "", post.body) var title = (post.title || p.title || post.id); @@ -202,7 +202,7 @@ var createPostEl = function(post, owned) { posted = getFormattedDate(new Date(post.created)) } var hasDraft = H.exists('draft' + post.id); - $post.innerHTML += '

' + posted + ' edit' + (hasDraft ? 'ed' : '') + ' delete '+movePostHTML(post.id)+'

'; + $post.innerHTML += '

' + posted + ' edit' + (hasDraft ? 'ed' : '') + ' delete '+movePostHTML(post.id)+'

'; if (post.error) { $post.innerHTML += '

Sync error: ' + post.error + '

'; diff --git a/templates/user/articles.tmpl b/templates/user/articles.tmpl index 92f9c40..3e50863 100644 --- a/templates/user/articles.tmpl +++ b/templates/user/articles.tmpl @@ -202,8 +202,9 @@ function loadMorePosts() { if (http.readyState == 4) { if (http.status == 200) { var data = JSON.parse(http.responseText); + var singleUser = {{ .SingleUser }}; for (var i=0; i Date: Tue, 22 Oct 2024 13:42:17 -0700 Subject: [PATCH 2/3] Update title link to be dynamic with new singleUser bool --- static/js/posts.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/static/js/posts.js b/static/js/posts.js index 17a31a8..c3c91e3 100644 --- a/static/js/posts.js +++ b/static/js/posts.js @@ -193,16 +193,17 @@ var createPostEl = function(post, owned, singleUser) { let p = H.createPost(post.id, "", post.body) var title = (post.title || p.title || post.id); title = title.replace(/' + title + ''; + $post.innerHTML = '

' + title + '

'; var posted = ""; if (post.created) { posted = getFormattedDate(new Date(post.created)) } var hasDraft = H.exists('draft' + post.id); - $post.innerHTML += '

' + posted + ' edit' + (hasDraft ? 'ed' : '') + ' delete '+movePostHTML(post.id)+'

'; + $post.innerHTML += '

' + posted + ' edit' + (hasDraft ? 'ed' : '') + ' delete '+movePostHTML(post.id)+'

'; if (post.error) { $post.innerHTML += '

Sync error: ' + post.error + '

'; From 82de4558de297098be66bfbfcac99abadace4ac1 Mon Sep 17 00:00:00 2001 From: vtyeh Date: Wed, 23 Oct 2024 10:32:04 -0700 Subject: [PATCH 3/3] Link title directly to post page --- static/js/posts.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static/js/posts.js b/static/js/posts.js index c3c91e3..d44f19c 100644 --- a/static/js/posts.js +++ b/static/js/posts.js @@ -193,7 +193,7 @@ var createPostEl = function(post, owned, singleUser) { let p = H.createPost(post.id, "", post.body) var title = (post.title || p.title || post.id); title = title.replace(/' + title + ''; @@ -203,7 +203,7 @@ var createPostEl = function(post, owned, singleUser) { posted = getFormattedDate(new Date(post.created)) } var hasDraft = H.exists('draft' + post.id); - $post.innerHTML += '

' + posted + ' edit' + (hasDraft ? 'ed' : '') + ' delete '+movePostHTML(post.id)+'

'; + $post.innerHTML += '

' + posted + ' edit' + (hasDraft ? 'ed' : '') + ' delete '+movePostHTML(post.id)+'

'; if (post.error) { $post.innerHTML += '

Sync error: ' + post.error + '

';