From 799e6bf61cf92bd8c4b13b6233912a8e9d4bc4e2 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sat, 28 Jun 2014 08:43:55 -0700 Subject: [PATCH] more HTML building fixes --- src/General/Build.coffee | 62 +++++++++++++++++--------------- src/General/BuildTest.coffee | 23 +++++++----- src/General/Get.coffee | 1 + src/General/html/Build/post.html | 2 +- 4 files changed, 50 insertions(+), 38 deletions(-) diff --git a/src/General/Build.coffee b/src/General/Build.coffee index 03c76100d..d870bdcac 100755 --- a/src/General/Build.coffee +++ b/src/General/Build.coffee @@ -10,8 +10,6 @@ Build = text.replace /&(amp|#039|quot|lt|gt);/g, (c) -> {'&': '&', ''': "'", '"': '"', '<': '<', '>': '>'}[c] shortFilename: (filename, isReply) -> - # FILENAME SHORTENING SCIENCE: - # The file extension is not taken into account. threshold = 30 ext = filename.match(/\.?[^\.]*$/)[0] if filename.length - ext.length > threshold @@ -70,6 +68,7 @@ Build = twidth: data.tn_w isSpoiler: !!data.spoiler isDeleted: false + tag: data.tag Build.post o post: (o, isArchived) -> ### @@ -91,9 +90,12 @@ Build = if isOP h_sideArrows = '' - h_subject = "#{E subject} " else h_sideArrows = "
>>
" + + 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 ''}" @@ -111,6 +113,9 @@ Build = h_emailStart = '' h_emailEnd = '' + unless isOP and boardID is 'f' + h_emailEnd += ' ' + switch capcode when 'admin', 'admin_highlight' h_capcodeClass = ' capcodeAdmin' @@ -135,7 +140,7 @@ Build = h_nameClass = '' if !capcode and uniqueID - h_userID = " (ID: #{E uniqueID}) " + h_userID = " (ID: #{E uniqueID})" else h_userID = '' @@ -147,14 +152,9 @@ Build = h_flag = "" if file?.isDeleted - if isOP - h_file = "
" - h_file += "File deleted." - h_file += '
' - else - h_file = "
" - h_file += "File deleted." - h_file += '
' + h_file = "
" + h_file += "File deleted." + h_file += '
' else if file fileSize = $.bytesToString file.size fileThumb = file.turl @@ -170,28 +170,31 @@ Build = else shortFilename = Build.shortFilename file.name, !isOP - if boardID is 'f' - h_imgSrc = '' - else - h_imgSrc = "" - h_imgSrc += "#{E fileSize}" - h_imgSrc += '' - if file.url[-4..] is '.pdf' h_fileDims = 'PDF' else h_fileDims = "#{+file.width}x#{+file.height}" - 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}'" + 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 += '' - h_fileInfo = "
" - h_fileInfo += "File: #{E shortFilename} (#{E fileSize}, #{h_fileDims})" - h_fileInfo += '
' + 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}
" else @@ -229,6 +232,9 @@ Build = 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' + # Fix pathnames for quote in $$ '.quotelink', container href = quote.getAttribute 'href' diff --git a/src/General/BuildTest.coffee b/src/General/BuildTest.coffee index 008661319..52836a7db 100644 --- a/src/General/BuildTest.coffee +++ b/src/General/BuildTest.coffee @@ -29,7 +29,7 @@ BuildTest = return BuildTest.firstDiff x2, y2 return [x2, y2] - runTest: (post) -> + testOne: (post) -> BuildTest.postsRemaining++ $.cache "//a.4cdn.org/#{post.board.ID}/thread/#{post.thread.ID}.json", -> {posts} = @response @@ -55,6 +55,12 @@ BuildTest = post2.isFetchedQuote = true Main.callbackNodes Post, [post2] + testAll: -> + g.posts.forEach (post) -> + unless post.isClone or post.isFetchedQuote or $ '.abbr', post.nodes.comment + BuildTest.testOne post + return + postsRemaining: 0 postsFailed: 0 @@ -65,13 +71,12 @@ BuildTest = new Notice 'success', 'All correct', 5 BuildTest.postsFailed = 0 - testOne: -> - BuildTest.runTest g.posts[@dataset.fullID] - Menu.menu.close() + cb: + testOne: -> + BuildTest.testOne g.posts[@dataset.fullID] + Menu.menu.close() - testAll: -> - g.posts.forEach (post) -> - unless post.isClone or post.isFetchedQuote or $ '.abbr', post.nodes.comment - BuildTest.runTest post - Header.menu.close() + testAll: -> + BuildTest.testAll() + Header.menu.close() <% } %> diff --git a/src/General/Get.coffee b/src/General/Get.coffee index 67faba9a6..44e45b034 100755 --- a/src/General/Get.coffee +++ b/src/General/Get.coffee @@ -210,6 +210,7 @@ Get = theight: data.media.preview_h twidth: data.media.preview_w isSpoiler: data.media.spoiler is '1' + o.file.tag = JSON.parse(data.media.exif).Tag if boardID is 'f' board = g.boards[boardID] or new Board boardID diff --git a/src/General/html/Build/post.html b/src/General/html/Build/post.html index 8d8ac2e9d..683a4229f 100755 --- a/src/General/html/Build/post.html +++ b/src/General/html/Build/post.html @@ -9,7 +9,7 @@ #{h_emailStart} #{E name} - #{h_tripcode}#{h_capcodeStart}#{h_emailEnd} #{h_capcodeIcon}#{h_userID}#{h_flag} + #{h_tripcode}#{h_capcodeStart}#{h_emailEnd}#{h_capcodeIcon}#{h_userID}#{h_flag} #{' '} #{E date}#{' '}