diff --git a/src/General/Build.coffee b/src/General/Build.coffee index 7be733988..a0605a48f 100755 --- a/src/General/Build.coffee +++ b/src/General/Build.coffee @@ -13,6 +13,12 @@ Build = "#{filename[...threshold - 5]}(...)#{ext}" else filename + spoilerThumb: (boardID) -> + if spoilerRange = Build.spoilerRange[boardID] + # Randomize the spoiler image. + "#{Build.staticPath}spoiler-#{boardID}#{Math.floor 1 + spoilerRange * Math.random()}.png" + else + "#{Build.staticPath}spoiler.png" sameThread: (boardID, threadID) -> g.VIEW is 'thread' and g.BOARD.ID is boardID and g.THREADID is +threadID postURL: (boardID, threadID, postID) -> @@ -81,70 +87,19 @@ Build = isOP = postID is threadID {staticPath, gifIcon} = Build - ### Name Block ### - - switch capcode - when 'admin', 'admin_highlight' - capcodeClass = ' capcodeAdmin' - capcodeStart = <%= html(' ## Admin') %> - capcodeIcon = <%= html(' Admin Icon') %> - when 'mod' - capcodeClass = ' capcodeMod' - capcodeStart = <%= html(' ## Mod') %> - capcodeIcon = <%= html(' Mod Icon') %> - when 'developer' - capcodeClass = ' capcodeDeveloper' - capcodeStart = <%= html(' ## Developer') %> - capcodeIcon = <%= html(' Developer Icon') %> - when 'manager' - capcodeClass = ' capcodeManager' - capcodeStart = <%= html(' ## Manager') %> - capcodeIcon = <%= html(' Manager Icon') %> - when 'admin_emeritus' - capcodeClass = ' capcodeAdmin' - capcodeStart = <%= html(' ## Admin Emeritus') %> - capcodeIcon = <%= html(' Admin Icon') %> - else - capcodeClass = '' - capcodeStart = <%= html('') %> - capcodeIcon = if isOP and boardID is 'f' then <%= html('') %> else <%= html(' ') %> - - nameClass = if capcode then ' capcode' else '' - - tripcodeField = if tripcode - <%= html(' ${tripcode}') %> - else - <%= html('') %> - - emailField = <%= html('${name}&{tripcodeField}&{capcodeStart}') %> - if email - emailProcessed = encodeURIComponent(email).replace /%40/g, '@' - emailField = <%= html('&{emailField}') %> - - userID = if !capcode and uniqueID - <%= html(' (ID: ${uniqueID})') %> - else - <%= html('') %> - - flag = unless flagCode - <%= html('') %> - else - <%= html(' ') %> - - nameBlock = <%= html( - '' + - '&{emailField}&{capcodeIcon}&{userID}&{flag}' + - ' ' - ) %> - ### Post Info ### - subjectField = if isOP or boardID is 'f' - <%= html('${subject} ') %> - else - <%= html('') %> - - desktop2 = if isOP and boardID is 'f' then '' else ' desktop' + if capcode + capcodeLC = capcode.split('_')[0] + capcodeUC = capcodeLC[0].toUpperCase() + capcodeLC[1..] + capcodeText = capcodeUC + capcodeLong = {'Admin': 'Administrator', 'Mod': 'Moderator'}[capcodeUC] or capcodeUC + capcodePlural = "#{capcodeLong}s" + capcodeDescription = "a 4chan #{capcodeLong}" + if capcode is 'admin_emeritus' + capcodeText = 'Admin Emeritus' + capcodePlural = 'the Administrator Emeritus' + capcodeDescription = "4chan's founding Administrator" postLink = Build.postURL boardID, threadID, postID quoteLink = if Build.sameThread boardID, threadID @@ -152,104 +107,86 @@ Build = else "/#{boardID}/thread/#{threadID}#q#{postID}" - icons = for type in ['Sticky', 'Closed', 'Archived'] when o["is#{type}"] and !(type is 'Closed' and o.isArchived) - typeLC = type.toLowerCase() - <%= html(' ${type}') %> - - replyLink = if isOP and g.VIEW is 'index' - <%= html('   [Reply]') %> - else - <%= html('') %> - postInfo = <%= html( '
' + ' ' + - '&{subjectField}' + - '&{nameBlock}' + + '?{isOP || boardID === "f"}{${subject} }' + + '' + + '?{email}{}' + + '${name}' + + '?{tripcode}{ ${tripcode}}' + + '?{capcode}{ ## ${capcodeText}}' + + '?{email}{}' + + '?{boardID === "f" && isOP || capcode}{}{ }' + + '?{capcode}{ ${capcodeUC} Icon}' + + '?{uniqueID && !capcode}{ (ID: ${uniqueID})}' + + '?{flagCode}{ }' + + ' ' + '${date} ' + - '' + + '' + 'No.' + '${postID}' + - '@{icons}&{replyLink}' + + '?{o.isSticky}{ Sticky}' + + '?{o.isClosed && !o.isArchived}{ Closed}' + + '?{o.isArchived}{ Archived}' + + '?{isOP && g.VIEW === "index"}{   [Reply]}' + '' + '
' ) %> ### File Info ### - fileCont = if file?.isDeleted - <%= html( - '' + - 'File deleted.' + - '' - ) %> - else if file and boardID is 'f' - <%= html( - '
' + - 'File: ${file.name}' + - '-(${$.bytesToString(file.size)}, ${file.width}x${file.height}, ${file.tag})' + - '
' - ) %> - else if file - if file.isSpoiler - shortFilename = 'Spoiler Image' - if spoilerRange = Build.spoilerRange[boardID] - # Randomize the spoiler image. - fileThumb = "#{staticPath}spoiler-#{boardID}#{Math.floor 1 + spoilerRange * Math.random()}.png" - else - fileThumb = "#{staticPath}spoiler.png" - file.twidth = file.theight = 100 - else - shortFilename = Build.shortFilename file.name, !isOP - fileThumb = file.turl - + if file and not file.isDeleted + shortFilename = Build.shortFilename file.name fileSize = $.bytesToString file.size fileDims = if file.url[-4..] is '.pdf' then 'PDF' else "#{file.width}x#{file.height}" - fileLink = if file.isSpoiler or file.name is shortFilename - <%= html('${shortFilename}') %> - else - <%= html('${shortFilename}') %> - - fileText = if file.isSpoiler - <%= html('
File: &{fileLink} (${fileSize}, ${fileDims})
') %> - else - <%= html('
File: &{fileLink} (${fileSize}, ${fileDims})
') %> - - <%= html( - '&{fileText}' + - '' + - '${fileSize}' + - '' - ) %> - - fileBlock = if file - <%= html('
&{fileCont}
') %> - else - <%= html('') %> + fileBlock = <%= html( + '?{file}{
' + + '?{file.isDeleted}{' + + '' + + 'File deleted.' + + '' + + '}{?{boardID === "f"}{' + + '
' + + 'File: ' + + '${file.name}' + + '-(${fileSize}, ${fileDims}, ${file.tag})' + + '
' + + '}{' + + '
' + + 'File: ' + + '' + + '?{file.isSpoiler}{Spoiler Image}{${shortFilename}}' + + ' ' + + '(${fileSize}, ${fileDims})' + + '
' + + '' + + '' + + '' + + '}}' + + '
}' + ) %> ### Whole Post ### - highlightPost = if capcode is 'admin_highlight' then ' highlightPost' else '' + postClass = if isOP then 'op' else 'reply' - message = <%= html('
&{comment}
') %> - - wholePost = if isOP - <%= html( - '
' + - '&{fileBlock}&{postInfo}&{message}' + - '
' - ) %> - else - <%= html( - '
>>
' + - '
' + - '&{postInfo}&{fileBlock}&{message}' + - '
' - ) %> + wholePost = <%= html( + '?{!isOP}{
>>
}' + + '
' + + '?{isOP}{&{fileBlock}&{postInfo}}{&{postInfo}&{fileBlock}}' + + '
&{comment}
' + + '
' + ) %> container = $.el 'div', - className: "postContainer #{if isOP then 'op' else 'reply'}Container" + className: "postContainer #{postClass}Container" id: "pc#{postID}" $.extend container, wholePost