@ -7,35 +7,6 @@ const Mongo = require(__dirname+'/../db/db.js')
, uploadDirectory = require ( _ _dirname + '/files/uploadDirectory.js' )
, render = require ( _ _dirname + '/render.js' ) ;
function addBacklinks ( thread , preview ) { //preview means this is not the full thread
const postMap = new Map ( )
postMap . set ( thread . postId , thread )
for ( let i = 0 ; i < thread . replies . length ; i ++ ) {
const reply = thread . replies [ i ] ;
postMap . set ( reply . postId , reply ) ;
}
for ( let i = 0 ; i < thread . replies . length ; i ++ ) {
const reply = thread . replies [ i ] ;
if ( ! reply . quotes ) continue ;
for ( let j = 0 ; j < reply . quotes . length ; j ++ ) {
const quote = reply . quotes [ j ] ;
if ( postMap . has ( quote ) ) {
const post = postMap . get ( quote )
if ( ! post . backlinks ) {
post . backlinks = [ ] ;
}
post . backlinks . push ( reply . postId ) ;
} else if ( ! preview ) {
/ *
quote was valid on post creation , but points to postID that has been deleted
or possibly removed from cyclical thread ( whenever i implement those )
could re - markdown the post here to remove the quotes ( or convert to greentext )
* /
}
}
}
}
module . exports = {
buildBanners : async ( board ) => {
@ -67,8 +38,6 @@ console.log('building thread', `${board._id || board}/thread/${threadId}.html`);
return ; //this thread may have been an OP that was deleted
}
addBacklinks ( thread , false ) ;
return render ( ` ${ board . _id } /thread/ ${ threadId } .html ` , 'thread.pug' , {
board ,
thread ,
@ -81,10 +50,6 @@ console.log('building board page', `${board._id}/${page === 1 ? 'index' : page}.
if ( maxPage == null ) {
maxPage = Math . min ( Math . ceil ( ( await Posts . getPages ( board . _id ) ) / 10 ) , Math . ceil ( board . settings . threadLimit / 10 ) ) ;
}
for ( let k = 0 ; k < threads . length ; k ++ ) {
const thread = threads [ k ] ;
addBacklinks ( thread , true ) ;
}
return render ( ` ${ board . _id } / ${ page === 1 ? 'index' : page } .html ` , 'board.pug' , {
board ,
@ -106,10 +71,6 @@ console.log('building board page', `${board._id}/${page === 1 ? 'index' : page}.
}
const difference = endpage - startpage + 1 ; //+1 because for single pagemust be > 0
const threads = await Posts . getRecent ( board . _id , startpage , difference * Math . ceil ( board . settings . threadLimit / 10 ) ) ;
for ( let k = 0 ; k < threads . length ; k ++ ) {
const thread = threads [ k ] ;
addBacklinks ( thread , true ) ;
}
const buildArray = [ ] ;
console . log ( 'multi building board pages' , ` ${ board . _id } / ${ startpage === 1 ? 'index' : startpage } -> ${ endpage === 1 ? 'index' : endpage } .html ` ) ;