From 79ef398b32215a9f181e81948daecf915ff0e8a2 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sat, 28 Jun 2014 21:33:06 -0700 Subject: [PATCH] reorganize Build.post --- src/General/Build.coffee | 232 ++++++++++++++++++------------- src/General/html/Build/post.html | 26 ---- 2 files changed, 138 insertions(+), 120 deletions(-) delete mode 100755 src/General/html/Build/post.html diff --git a/src/General/Build.coffee b/src/General/Build.coffee index d870bdcac..28d0b6d93 100755 --- a/src/General/Build.coffee +++ b/src/General/Build.coffee @@ -1,6 +1,5 @@ Build = - h_staticPath: '//s.4cdn.org/image/' - h_gifIcon: if window.devicePixelRatio >= 2 then '@2x.gif' else '.gif' + initPixelRatio: window.devicePixelRatio spoilerRange: {} h_escape: (text) -> (text+'').replace /[&"'<>]/g, (c) -> @@ -80,55 +79,33 @@ Build = postID, threadID, boardID name, capcode, tripcode, uniqueID, email, subject, flagCode, flagName, date, dateUTC isSticky, isClosed - h_comment file } = o name or= '' subject or= '' + h_comment = o.h_comment isOP = postID is threadID - {h_staticPath, h_gifIcon} = Build - if isOP - h_sideArrows = '' + if Build.initPixelRatio >= 2 + h_retina = '@2x' else - h_sideArrows = "
>>
" + h_retina = '' - if isOP or boardID is 'f' - h_subject = "#{E subject} " - else - h_subject = '' - - h_postClass = "post #{if isOP then 'op' else 'reply'}#{if capcode is 'admin_highlight' then ' highlightPost' else ''}" - - if tripcode - h_tripcode = " #{E tripcode}" - else - h_tripcode = '' - - if email - emailProcessed = encodeURIComponent(email).replace(/%40/g, '@') - h_emailStart = "" - h_emailEnd = '' - else - h_emailStart = '' - h_emailEnd = '' - - unless isOP and boardID is 'f' - h_emailEnd += ' ' + ### Name Block ### switch capcode when 'admin', 'admin_highlight' h_capcodeClass = ' capcodeAdmin' h_capcodeStart = ' ## Admin' - h_capcodeIcon = "Admin Icon" + h_capcodeIcon = "Admin Icon" when 'mod' h_capcodeClass = ' capcodeMod' h_capcodeStart = ' ## Mod' - h_capcodeIcon = "Mod Icon" + h_capcodeIcon = "Mod Icon" when 'developer' h_capcodeClass = ' capcodeDeveloper' h_capcodeStart = ' ## Developer' - h_capcodeIcon = "Developer Icon" + h_capcodeIcon = "Developer Icon" else h_capcodeClass = '' h_capcodeStart = '' @@ -139,6 +116,20 @@ Build = else h_nameClass = '' + if tripcode + h_tripcode = " #{E tripcode}" + else + h_tripcode = '' + + h_emailCont = "#{E name}#{h_tripcode}#{h_capcodeStart}" + if email + emailProcessed = encodeURIComponent(email).replace /%40/g, '@' + h_email = "#{h_emailCont}" + else + h_email = h_emailCont + unless isOP and boardID is 'f' + h_email += ' ' + if !capcode and uniqueID h_userID = " (ID: #{E uniqueID})" else @@ -146,59 +137,28 @@ Build = unless flagCode h_flag = '' - else if boardID is 'pol' - h_flag = "#{E flagCode}" else - h_flag = "" - - if file?.isDeleted - h_file = "
" - h_file += "File deleted." - h_file += '
' - else if file - fileSize = $.bytesToString file.size - fileThumb = file.turl - if file.isSpoiler - unless isArchived - fileThumb = "#{h_staticPath}spoiler" - if spoilerRange = Build.spoilerRange[boardID] - # Randomize the spoiler image. - fileThumb += "-#{boardID}" + Math.floor 1 + spoilerRange * Math.random() - fileThumb += '.png' - file.twidth = file.theight = 100 - shortFilename = 'Spoiler Image' + flagCodeLC = flagCode.toLowerCase() + if boardID is 'pol' + h_flag = "#{E flagCode}" else - shortFilename = Build.shortFilename file.name, !isOP + h_flag = "" - if file.url[-4..] is '.pdf' - h_fileDims = 'PDF' - else - h_fileDims = "#{+file.width}x#{+file.height}" + h_nameBlock = "" + h_nameBlock += "#{h_email}#{h_capcodeIcon}#{h_userID}#{h_flag}" + h_nameBlock += ' ' - if boardID is 'f' - h_imgSrc = '' - h_fileInfo = "
" - h_fileInfo += "File: #{E file.name}-(#{E fileSize}, #{h_fileDims}, #{E file.tag})" - h_fileInfo += '
' - else - h_imgSrc = "" - h_imgSrc += "#{E fileSize}" - h_imgSrc += '' + ### Post Info ### - h_fileTitle1 = '' - h_fileTitle2 = '' - if file.isSpoiler - h_fileTitle1 = " title='#{E file.name}'" - else if file.name isnt shortFilename - h_fileTitle2 = " title='#{E file.name}'" - - h_fileInfo = "
" - h_fileInfo += "File: #{E shortFilename} (#{E fileSize}, #{h_fileDims})" - h_fileInfo += '
' - - h_file = "
#{h_fileInfo}#{h_imgSrc}
" + if isOP or boardID is 'f' + h_subject = "#{E subject} " else - h_file = '' + h_subject = '' + + if isOP and boardID is 'f' + h_desktop2 = '' + else + h_desktop2 = ' desktop' postLink = Build.postURL boardID, threadID, postID quoteLink = if Build.sameThread boardID, threadID @@ -206,34 +166,118 @@ Build = else "/#{boardID}/thread/#{threadID}\#q#{postID}" - if isSticky - h_sticky = " Sticky" - else - h_sticky = '' - - if isClosed - h_closed = " Closed" - else - h_closed = '' - if isOP and g.VIEW is 'index' and Conf['JSON Navigation'] pageNum = Math.floor(Index.liveThreadIDs.indexOf(postID) / Index.threadsNumPerPage) + 1 h_pageIcon = " [#{+pageNum}]" else h_pageIcon = '' + if isSticky + h_sticky = " Sticky" + else + h_sticky = '' + + if isClosed + h_closed = " Closed" + else + h_closed = '' + if isOP and g.VIEW is 'index' h_replyLink = "   [Reply]" else h_replyLink = '' + h_postInfo = "
" + h_postInfo += " " + h_postInfo += h_subject + h_postInfo += h_nameBlock + h_postInfo += "#{E date} " + h_postInfo += "" + h_postInfo += "No." + h_postInfo += "#{+postID}" + h_postInfo += "#{h_pageIcon}#{h_sticky}#{h_closed}#{h_replyLink}" + h_postInfo += '' + h_postInfo += '
' + + ### File Info ### + + if file?.isDeleted + h_fileCont = '' + h_fileCont += "File deleted." + h_fileCont += '' + else if file and boardID is 'f' + fileSize = $.bytesToString file.size + h_fileCont = "
" + h_fileCont += "File: #{E file.name}" + h_fileCont += "-(#{E fileSize}, #{+file.width}x#{+file.height}, #{E file.tag})" + h_fileCont += '
' + else if file + if file.isSpoiler + h_fileTitle1 = "title='#{E file.name}'" + shortFilename = 'Spoiler Image' + h_spoilerClass = ' imgspoiler' + else + h_fileTitle1 = '' + shortFilename = Build.shortFilename file.name, !isOP + h_spoilerClass = '' + + if file.isSpoiler or file.name is shortFilename + h_fileTitle2 = '' + else + h_fileTitle2 = "title='#{E file.name}'" + + fileSize = $.bytesToString file.size + + if file.url[-4..] is '.pdf' + h_fileDims = 'PDF' + else + h_fileDims = "#{+file.width}x#{+file.height}" + + if file.isSpoiler and !isArchived + if spoilerRange = Build.spoilerRange[boardID] + # Randomize the spoiler image. + fileThumb = "//s.4cdn.org/image/spoiler-#{boardID}#{Math.floor 1 + spoilerRange * Math.random()}.png" + else + fileThumb = '//s.4cdn.org/image/spoiler.png' + file.twidth = file.theight = 100 + else + fileThumb = file.turl + + h_fileCont = "
" + h_fileCont += "File: #{E shortFilename} (#{E fileSize}, #{h_fileDims})" + h_fileCont += '
' + h_fileCont += "" + h_fileCont += "#{E fileSize}" + h_fileCont += '' + + if file + h_file = "
#{h_fileCont}
" + else + h_file = '' + + ### Whole Post ### + + if capcode is 'admin_highlight' + h_highlightPost = ' highlightPost' + else + h_highlightPost = '' + + h_message = "
#{h_comment}
" + + if isOP + h_post = "
" + h_post += "#{h_file}#{h_postInfo}#{h_message}" + h_post += '
' + else + h_post = "
>>
" + h_post += "
" + h_post += "#{h_postInfo}#{h_file}#{h_message}" + h_post += '
' + container = $.el 'div', className: "postContainer #{if isOP then 'op' else 'reply'}Container" - id: "pc#{postID}" - innerHTML: <%= grunt.file.read('src/General/html/Build/post.html').replace(/\r?\n\s*/g, '') %> - - if isOP and boardID is 'f' - $.rmClass $('.postNum', container), 'desktop' + id: "pc#{postID}" + innerHTML: h_post # Fix pathnames for quote in $$ '.quotelink', container diff --git a/src/General/html/Build/post.html b/src/General/html/Build/post.html deleted file mode 100755 index 683a4229f..000000000 --- a/src/General/html/Build/post.html +++ /dev/null @@ -1,26 +0,0 @@ -"""#{h_sideArrows} -
- - #{if isOP then h_file else ''} - - - - #{if isOP then '' else h_file} - -
#{h_comment}
- -
"""