summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpep <yes@peepee.me>2020-07-28 21:29:32 +0000
committerpep <yes@peepee.me>2020-07-28 21:29:32 +0000
commita7aea69687eb268807aa4a86d9188004fe5cb6c7 (patch)
treed91ffe93b934f5e61cb6aa02e92030e00a5d13f2
parentd051c6d71f2d2e24ca113f127ff7e0b143d0042a (diff)
fixed minor thing
-rw-r--r--bucky/app/bucky.js11
-rw-r--r--public/assets/js/lib/views/details/commentform.js1
-rw-r--r--public/assets/js/lib/views/details/files.js2
-rw-r--r--public/assets/js/lib/views/details/settings.js48
-rw-r--r--public/assets/js/util/format.js4
5 files changed, 32 insertions, 34 deletions
diff --git a/bucky/app/bucky.js b/bucky/app/bucky.js
index f104e3b..244b219 100644
--- a/bucky/app/bucky.js
+++ b/bucky/app/bucky.js
@@ -517,15 +517,12 @@ var bucky = module.exports = {
console.log(data)
//this library encodes things twice so have to do it yourself
url = `http://media.spermwhale.info/bucky/data/${data.thread}/${encodeURI(data.filename)}`
- req.body.comment = (req.body.comment.length) ? req.body.comment + "<hr>\n" + url + "\n" + file.originalname : url+"\n"+file.originalname
+ var comment_footer = url + "\n" + file.originalname
+ req.body.comment = (req.body.comment) ? req.body.comment + "\n<hr>" + comment_footer : comment_footer
db.createFile(data).then(function(file){
+ console.log(file)
resolve(file)
- }).catch( (err) => reject(err) ).then(
- function(){
- console.log("about to call createComment")
- bucky.createComment(req, res, function(){})
-
- })
+ }).catch( (err) => reject(err) )
}
})
})
diff --git a/public/assets/js/lib/views/details/commentform.js b/public/assets/js/lib/views/details/commentform.js
index 51295cb..f3d79ac 100644
--- a/public/assets/js/lib/views/details/commentform.js
+++ b/public/assets/js/lib/views/details/commentform.js
@@ -54,6 +54,7 @@ var CommentForm = FormView.extend({
// window.location.reload()
console.log(this)
console.log(this.parent)
+ console.log("this is data")
console.log(data)
data.comment && this.parent.comments.load([data.comment])
data.files && this.parent.files.load(data.files)
diff --git a/public/assets/js/lib/views/details/files.js b/public/assets/js/lib/views/details/files.js
index 98b9350..915f90b 100644
--- a/public/assets/js/lib/views/details/files.js
+++ b/public/assets/js/lib/views/details/files.js
@@ -21,7 +21,7 @@ var FilesView = FormView.extend({
}
var total = 0, has_music = false
- this.files = files || this.files
+ this.files = this.files.concat(files)
this.thread = thread || this.thread
this.files.forEach(function(file){
if (is_image(file.filename)) {
diff --git a/public/assets/js/lib/views/details/settings.js b/public/assets/js/lib/views/details/settings.js
index a027b12..b270f02 100644
--- a/public/assets/js/lib/views/details/settings.js
+++ b/public/assets/js/lib/views/details/settings.js
@@ -316,32 +316,32 @@ var ThreadSettingsForm = FormView.extend({
file_names.join("\n")
var should_remove = confirm(msg)
if (should_remove) {
- }
- var promises = inputs_checked.map(node => {
- return new Promise((resolve, reject) => {
- $.ajax({
- method: "DELETE",
- url: "/api/file/" + node.value,
- headers: { "csrf-token": $("[name=_csrf]").attr("value") },
- data: JSON.stringify({ csrf: csrf() }),
- dataType: "json",
- success: function(data){
- console.log(data)
- $(node).closest('.file').remove()
- },
- error: function(){
- console.log('error deleting file', node.value)
- reject()
- }
+ var promises = inputs_checked.map(node => {
+ return new Promise((resolve, reject) => {
+ $.ajax({
+ method: "DELETE",
+ url: "/api/file/" + node.value,
+ headers: { "csrf-token": $("[name=_csrf]").attr("value") },
+ data: JSON.stringify({ csrf: csrf() }),
+ dataType: "json",
+ success: function(data){
+ console.log(data)
+ $(node).closest('.file').remove()
+ },
+ error: function(){
+ console.log('error deleting file', node.value)
+ reject()
+ }
+ })
})
})
- })
- Promise.all(promises).then( () => {
- window.location.href = '/details/' + thread_id
- }).catch(() =>{
- console.error('whaaaaa')
- alert('there was a problem deleting the files...')
- })
+ Promise.all(promises).then( () => {
+ window.location.href = '/details/' + thread_id
+ }).catch(() =>{
+ console.error('whaaaaa')
+ alert('there was a problem deleting the files...')
+ })
+ }
},
deleteThread: function(e){
diff --git a/public/assets/js/util/format.js b/public/assets/js/util/format.js
index 441430e..28c659b 100644
--- a/public/assets/js/util/format.js
+++ b/public/assets/js/util/format.js
@@ -213,7 +213,7 @@ function get_age (t, long) {
}
function tidy_urls (s, short_urls) {
- var ret = s.split("\n").map(function(line){
+ var ret = s.split(/(<[bh]r\/?>|\n)/).map(function(line){
if (line.indexOf("<") !== -1) {
return line
@@ -230,7 +230,7 @@ function tidy_urls (s, short_urls) {
}
});
})
- .join("\n")
+ .join("")
.replace(/\r/g, "")
.replace(/<code>\n/g, "<code>")
.replace(/<\/code>\n/g, "</code>")