ajax POST: return whole thread
This commit is contained in:
parent
408e9ce30e
commit
e9228892fa
|
@ -2303,6 +2303,8 @@ function buildThread($id, $return = false, $mod = false) {
|
||||||
|
|
||||||
$action = generation_strategy('sb_thread', array($board['uri'], $id));
|
$action = generation_strategy('sb_thread', array($board['uri'], $id));
|
||||||
|
|
||||||
|
$rendered_thread = null;
|
||||||
|
|
||||||
if ($action == 'rebuild' || $return || $mod) {
|
if ($action == 'rebuild' || $return || $mod) {
|
||||||
$query = prepare(sprintf("SELECT *,'%s' as board FROM ``posts_%s`` WHERE (`thread` IS NULL AND `id` = :id) OR `thread` = :id ORDER BY `thread`,`id`", $board['uri'],$board['uri']));
|
$query = prepare(sprintf("SELECT *,'%s' as board FROM ``posts_%s`` WHERE (`thread` IS NULL AND `id` = :id) OR `thread` = :id ORDER BY `thread`,`id`", $board['uri'],$board['uri']));
|
||||||
$query->bindValue(':id', $id, PDO::PARAM_INT);
|
$query->bindValue(':id', $id, PDO::PARAM_INT);
|
||||||
|
@ -2323,10 +2325,12 @@ function buildThread($id, $return = false, $mod = false) {
|
||||||
$hasnoko50 = $thread->postCount() >= $config['noko50_min'];
|
$hasnoko50 = $thread->postCount() >= $config['noko50_min'];
|
||||||
$antibot = $mod || $return ? false : create_antibot($board['uri'], $id);
|
$antibot = $mod || $return ? false : create_antibot($board['uri'], $id);
|
||||||
|
|
||||||
|
$rendered_thread = $thread->build();
|
||||||
|
|
||||||
$body = Element('thread.html', array(
|
$body = Element('thread.html', array(
|
||||||
'board' => $board,
|
'board' => $board,
|
||||||
'thread' => $thread,
|
'thread' => $thread,
|
||||||
'body' => $thread->build(),
|
'body' => $rendered_thread,
|
||||||
'config' => $config,
|
'config' => $config,
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
'mod' => $mod,
|
'mod' => $mod,
|
||||||
|
@ -2364,6 +2368,8 @@ function buildThread($id, $return = false, $mod = false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
file_write($board['dir'] . $config['dir']['res'] . link_for($thread), $body);
|
file_write($board['dir'] . $config['dir']['res'] . link_for($thread), $body);
|
||||||
|
|
||||||
|
return $rendered_thread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -236,22 +236,18 @@ $().ready(() => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const post_dom = parser.parseFromString(
|
const thread_dom = parser.parseFromString(
|
||||||
post_response['post'],
|
post_response['thread'],
|
||||||
"text/html");
|
"text/html");
|
||||||
|
|
||||||
const post_elem = post_dom.querySelector(".postcontainer");
|
|
||||||
console.log(post_elem);
|
|
||||||
const post_container = LCNPostContainer.assign(post_elem);
|
|
||||||
console.log("lcn_post_container:", post_container);
|
|
||||||
|
|
||||||
const thread_id_sel = "#thread_" + post_response['thread_id'];
|
const thread_id_sel = "#thread_" + post_response['thread_id'];
|
||||||
const thread = document.querySelector(thread_id_sel);
|
const post_containers = [...thread_dom.querySelectorAll(`${thread_id_sel} > .postcontainer`)]
|
||||||
console.log("thread:", thread);
|
.map(elem => LCNPostContainer.assign(elem));
|
||||||
const lcn_thread = new LCNThread(thread);
|
|
||||||
console.log("lcn_thread: ", lcn_thread);
|
|
||||||
|
|
||||||
updateThreadFn(lcn_thread, [ post_container ]);
|
const thread_elem = document.querySelector(thread_id_sel);
|
||||||
|
const lcn_thread = new LCNThread(thread_elem);
|
||||||
|
|
||||||
|
updateThreadFn(lcn_thread, post_containers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
6
post.php
6
post.php
|
@ -1477,7 +1477,7 @@ function handle_post(){
|
||||||
|
|
||||||
$thread_id = $post['op'] ? $id : $post['thread'];
|
$thread_id = $post['op'] ? $id : $post['thread'];
|
||||||
|
|
||||||
buildThread($thread_id);
|
$rendered_thread = buildThread($thread_id);
|
||||||
|
|
||||||
if ($config['syslog'])
|
if ($config['syslog'])
|
||||||
_syslog(LOG_INFO, 'New post: /' . $board['dir'] . $config['dir']['res'] .
|
_syslog(LOG_INFO, 'New post: /' . $board['dir'] . $config['dir']['res'] .
|
||||||
|
@ -1494,8 +1494,8 @@ function handle_post(){
|
||||||
'redirect' => $redirect,
|
'redirect' => $redirect,
|
||||||
'noko' => $noko,
|
'noko' => $noko,
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
'post' => (new Post($post))->build(),
|
'thread_id' => $thread_id,
|
||||||
'thread_id' => $thread_id
|
'thread' => $rendered_thread
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue