more HTML building fixes

This commit is contained in:
ccd0 2014-06-28 08:43:55 -07:00
parent 3f7a042f40
commit 799e6bf61c
4 changed files with 50 additions and 38 deletions

View File

@ -10,8 +10,6 @@ Build =
text.replace /&(amp|#039|quot|lt|gt);/g, (c) -> text.replace /&(amp|#039|quot|lt|gt);/g, (c) ->
{'&amp;': '&', '&#039;': "'", '&quot;': '"', '&lt;': '<', '&gt;': '>'}[c] {'&amp;': '&', '&#039;': "'", '&quot;': '"', '&lt;': '<', '&gt;': '>'}[c]
shortFilename: (filename, isReply) -> shortFilename: (filename, isReply) ->
# FILENAME SHORTENING SCIENCE:
# The file extension is not taken into account.
threshold = 30 threshold = 30
ext = filename.match(/\.?[^\.]*$/)[0] ext = filename.match(/\.?[^\.]*$/)[0]
if filename.length - ext.length > threshold if filename.length - ext.length > threshold
@ -70,6 +68,7 @@ Build =
twidth: data.tn_w twidth: data.tn_w
isSpoiler: !!data.spoiler isSpoiler: !!data.spoiler
isDeleted: false isDeleted: false
tag: data.tag
Build.post o Build.post o
post: (o, isArchived) -> post: (o, isArchived) ->
### ###
@ -91,9 +90,12 @@ Build =
if isOP if isOP
h_sideArrows = '' h_sideArrows = ''
h_subject = "<span class='subject'>#{E subject}</span> "
else else
h_sideArrows = "<div class='sideArrows' id='sa#{+postID}'>&gt;&gt;</div>" h_sideArrows = "<div class='sideArrows' id='sa#{+postID}'>&gt;&gt;</div>"
if isOP or boardID is 'f'
h_subject = "<span class='subject'>#{E subject}</span> "
else
h_subject = '' h_subject = ''
h_postClass = "post #{if isOP then 'op' else 'reply'}#{if capcode is 'admin_highlight' then ' highlightPost' else ''}" 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_emailStart = ''
h_emailEnd = '' h_emailEnd = ''
unless isOP and boardID is 'f'
h_emailEnd += ' '
switch capcode switch capcode
when 'admin', 'admin_highlight' when 'admin', 'admin_highlight'
h_capcodeClass = ' capcodeAdmin' h_capcodeClass = ' capcodeAdmin'
@ -147,13 +152,8 @@ Build =
h_flag = "<span title='#{E flagName}' class='flag flag-#{E flagCode.toLowerCase()}'></span>" h_flag = "<span title='#{E flagName}' class='flag flag-#{E flagCode.toLowerCase()}'></span>"
if file?.isDeleted if file?.isDeleted
if isOP
h_file = "<div class='file' id='f#{+postID}'><span class='fileThumb'>" h_file = "<div class='file' id='f#{+postID}'><span class='fileThumb'>"
h_file += "<img src='#{h_staticPath}filedeleted#{h_gifIcon}' alt='File deleted.' class='fileDeleted'>" h_file += "<img src='#{h_staticPath}filedeleted-res#{h_gifIcon}' alt='File deleted.' class='fileDeletedRes retina'>"
h_file += '</span></div>'
else
h_file = "<div class='file' id='f#{+postID}'><span class='fileThumb'>"
h_file += "<img src='#{h_staticPath}filedeleted-res#{h_gifIcon}' alt='File deleted.' class='fileDeletedRes'>"
h_file += '</span></div>' h_file += '</span></div>'
else if file else if file
fileSize = $.bytesToString file.size fileSize = $.bytesToString file.size
@ -170,18 +170,21 @@ Build =
else else
shortFilename = Build.shortFilename file.name, !isOP shortFilename = Build.shortFilename file.name, !isOP
if boardID is 'f'
h_imgSrc = ''
else
h_imgSrc = "<a class='fileThumb#{if file.isSpoiler then ' imgspoiler' else ''}' href='#{E file.url}' target='_blank'>"
h_imgSrc += "<img src='#{E fileThumb}' alt='#{E fileSize}' data-md5='#{E file.MD5}' style='height: #{+file.theight}px; width: #{+file.twidth}px;'>"
h_imgSrc += '</a>'
if file.url[-4..] is '.pdf' if file.url[-4..] is '.pdf'
h_fileDims = 'PDF' h_fileDims = 'PDF'
else else
h_fileDims = "#{+file.width}x#{+file.height}" h_fileDims = "#{+file.width}x#{+file.height}"
if boardID is 'f'
h_imgSrc = ''
h_fileInfo = "<div class='fileInfo'><span class='fileText' id='fT#{+postID}'>"
h_fileInfo += "File: <a data-width='#{+file.width}' data-height='#{+file.height}' href='#{E file.url}' target='_blank'>#{E file.name}</a>-(#{E fileSize}, #{h_fileDims}, #{E file.tag})"
h_fileInfo += '</span></div>'
else
h_imgSrc = "<a class='fileThumb#{if file.isSpoiler then ' imgspoiler' else ''}' href='#{E file.url}' target='_blank'>"
h_imgSrc += "<img src='#{E fileThumb}' alt='#{E fileSize}' data-md5='#{E file.MD5}' style='height: #{+file.theight}px; width: #{+file.twidth}px;'>"
h_imgSrc += '</a>'
h_fileTitle1 = '' h_fileTitle1 = ''
h_fileTitle2 = '' h_fileTitle2 = ''
if file.isSpoiler if file.isSpoiler
@ -229,6 +232,9 @@ Build =
id: "pc#{postID}" id: "pc#{postID}"
innerHTML: <%= grunt.file.read('src/General/html/Build/post.html').replace(/\r?\n\s*/g, '') %> 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 # Fix pathnames
for quote in $$ '.quotelink', container for quote in $$ '.quotelink', container
href = quote.getAttribute 'href' href = quote.getAttribute 'href'

View File

@ -29,7 +29,7 @@ BuildTest =
return BuildTest.firstDiff x2, y2 return BuildTest.firstDiff x2, y2
return [x2, y2] return [x2, y2]
runTest: (post) -> testOne: (post) ->
BuildTest.postsRemaining++ BuildTest.postsRemaining++
$.cache "//a.4cdn.org/#{post.board.ID}/thread/#{post.thread.ID}.json", -> $.cache "//a.4cdn.org/#{post.board.ID}/thread/#{post.thread.ID}.json", ->
{posts} = @response {posts} = @response
@ -55,6 +55,12 @@ BuildTest =
post2.isFetchedQuote = true post2.isFetchedQuote = true
Main.callbackNodes Post, [post2] 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 postsRemaining: 0
postsFailed: 0 postsFailed: 0
@ -65,13 +71,12 @@ BuildTest =
new Notice 'success', 'All correct', 5 new Notice 'success', 'All correct', 5
BuildTest.postsFailed = 0 BuildTest.postsFailed = 0
cb:
testOne: -> testOne: ->
BuildTest.runTest g.posts[@dataset.fullID] BuildTest.testOne g.posts[@dataset.fullID]
Menu.menu.close() Menu.menu.close()
testAll: -> testAll: ->
g.posts.forEach (post) -> BuildTest.testAll()
unless post.isClone or post.isFetchedQuote or $ '.abbr', post.nodes.comment
BuildTest.runTest post
Header.menu.close() Header.menu.close()
<% } %> <% } %>

View File

@ -210,6 +210,7 @@ Get =
theight: data.media.preview_h theight: data.media.preview_h
twidth: data.media.preview_w twidth: data.media.preview_w
isSpoiler: data.media.spoiler is '1' isSpoiler: data.media.spoiler is '1'
o.file.tag = JSON.parse(data.media.exif).Tag if boardID is 'f'
board = g.boards[boardID] or board = g.boards[boardID] or
new Board boardID new Board boardID