more HTML building fixes
This commit is contained in:
parent
3f7a042f40
commit
799e6bf61c
@ -10,8 +10,6 @@ Build =
|
|||||||
text.replace /&(amp|#039|quot|lt|gt);/g, (c) ->
|
text.replace /&(amp|#039|quot|lt|gt);/g, (c) ->
|
||||||
{'&': '&', ''': "'", '"': '"', '<': '<', '>': '>'}[c]
|
{'&': '&', ''': "'", '"': '"', '<': '<', '>': '>'}[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}'>>></div>"
|
h_sideArrows = "<div class='sideArrows' id='sa#{+postID}'>>></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'
|
||||||
@ -135,7 +140,7 @@ Build =
|
|||||||
h_nameClass = ''
|
h_nameClass = ''
|
||||||
|
|
||||||
if !capcode and uniqueID
|
if !capcode and uniqueID
|
||||||
h_userID = " <span class='posteruid id_#{E uniqueID}'>(ID: <span class='hand' title='Highlight posts by this ID'>#{E uniqueID}</span>)</span> "
|
h_userID = " <span class='posteruid id_#{E uniqueID}'>(ID: <span class='hand' title='Highlight posts by this ID'>#{E uniqueID}</span>)</span>"
|
||||||
else
|
else
|
||||||
h_userID = ''
|
h_userID = ''
|
||||||
|
|
||||||
@ -147,14 +152,9 @@ 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-res#{h_gifIcon}' alt='File deleted.' class='fileDeletedRes retina'>"
|
||||||
h_file += "<img src='#{h_staticPath}filedeleted#{h_gifIcon}' alt='File deleted.' class='fileDeleted'>"
|
h_file += '</span></div>'
|
||||||
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>'
|
|
||||||
else if file
|
else if file
|
||||||
fileSize = $.bytesToString file.size
|
fileSize = $.bytesToString file.size
|
||||||
fileThumb = file.turl
|
fileThumb = file.turl
|
||||||
@ -170,28 +170,31 @@ 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}"
|
||||||
|
|
||||||
h_fileTitle1 = ''
|
if boardID is 'f'
|
||||||
h_fileTitle2 = ''
|
h_imgSrc = ''
|
||||||
if file.isSpoiler
|
h_fileInfo = "<div class='fileInfo'><span class='fileText' id='fT#{+postID}'>"
|
||||||
h_fileTitle1 = " title='#{E file.name}'"
|
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})"
|
||||||
else if file.name isnt shortFilename
|
h_fileInfo += '</span></div>'
|
||||||
h_fileTitle2 = " title='#{E file.name}'"
|
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_fileInfo = "<div class='fileText' id='fT#{+postID}' #{h_fileTitle1}>"
|
h_fileTitle1 = ''
|
||||||
h_fileInfo += "File: <a #{h_fileTitle2} href='#{E file.url}' target='_blank'>#{E shortFilename}</a> (#{E fileSize}, #{h_fileDims})"
|
h_fileTitle2 = ''
|
||||||
h_fileInfo += '</div>'
|
if file.isSpoiler
|
||||||
|
h_fileTitle1 = " title='#{E file.name}'"
|
||||||
|
else if file.name isnt shortFilename
|
||||||
|
h_fileTitle2 = " title='#{E file.name}'"
|
||||||
|
|
||||||
|
h_fileInfo = "<div class='fileText' id='fT#{+postID}' #{h_fileTitle1}>"
|
||||||
|
h_fileInfo += "File: <a #{h_fileTitle2} href='#{E file.url}' target='_blank'>#{E shortFilename}</a> (#{E fileSize}, #{h_fileDims})"
|
||||||
|
h_fileInfo += '</div>'
|
||||||
|
|
||||||
h_file = "<div class='file' id='f#{+postID}'>#{h_fileInfo}#{h_imgSrc}</div>"
|
h_file = "<div class='file' id='f#{+postID}'>#{h_fileInfo}#{h_imgSrc}</div>"
|
||||||
else
|
else
|
||||||
@ -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'
|
||||||
|
|||||||
@ -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
|
||||||
|
|
||||||
testOne: ->
|
cb:
|
||||||
BuildTest.runTest g.posts[@dataset.fullID]
|
testOne: ->
|
||||||
Menu.menu.close()
|
BuildTest.testOne g.posts[@dataset.fullID]
|
||||||
|
Menu.menu.close()
|
||||||
|
|
||||||
testAll: ->
|
testAll: ->
|
||||||
g.posts.forEach (post) ->
|
BuildTest.testAll()
|
||||||
unless post.isClone or post.isFetchedQuote or $ '.abbr', post.nodes.comment
|
Header.menu.close()
|
||||||
BuildTest.runTest post
|
|
||||||
Header.menu.close()
|
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
<span class='nameBlock#{h_capcodeClass}'>
|
<span class='nameBlock#{h_capcodeClass}'>
|
||||||
#{h_emailStart}
|
#{h_emailStart}
|
||||||
<span class='name#{h_nameClass}'>#{E name}</span>
|
<span class='name#{h_nameClass}'>#{E name}</span>
|
||||||
#{h_tripcode}#{h_capcodeStart}#{h_emailEnd} #{h_capcodeIcon}#{h_userID}#{h_flag}
|
#{h_tripcode}#{h_capcodeStart}#{h_emailEnd}#{h_capcodeIcon}#{h_userID}#{h_flag}
|
||||||
</span>#{' '}
|
</span>#{' '}
|
||||||
<span class='dateTime' data-utc='#{+dateUTC}'>#{E date}</span>#{' '}
|
<span class='dateTime' data-utc='#{+dateUTC}'>#{E date}</span>#{' '}
|
||||||
<span class='postNum desktop'>
|
<span class='postNum desktop'>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user