Add file.dimensions to Build.coffee object.

This commit is contained in:
ccd0 2015-04-13 01:44:27 -07:00
parent c1f62d1612
commit 27e8c59297
3 changed files with 4 additions and 3 deletions

View File

@ -69,6 +69,7 @@ Build =
twidth: data.tn_w twidth: data.tn_w
isSpoiler: !!data.spoiler isSpoiler: !!data.spoiler
tag: data.tag tag: data.tag
o.file.dimensions = "#{o.file.width}x#{o.file.height}" unless /\.pdf$/.test o.file.url
Build.post o, suppressThumb Build.post o, suppressThumb
post: (o, suppressThumb) -> post: (o, suppressThumb) ->
### ###
@ -111,7 +112,6 @@ Build =
protocol = /^https?:(?=\/\/i\.4cdn\.org\/)/ protocol = /^https?:(?=\/\/i\.4cdn\.org\/)/
fileURL = file.url.replace protocol, '' fileURL = file.url.replace protocol, ''
shortFilename = Build.shortFilename file.name shortFilename = Build.shortFilename file.name
fileDims = if file.url[-4..] is '.pdf' then 'PDF' else "#{file.width}x#{file.height}"
fileThumb = if file.isSpoiler then Build.spoilerThumb(boardID) else file.thumbURL.replace(protocol, '') fileThumb = if file.isSpoiler then Build.spoilerThumb(boardID) else file.thumbURL.replace(protocol, '')
fileBlock = <%= importHTML('Build/File') %> fileBlock = <%= importHTML('Build/File') %>

View File

@ -4,7 +4,7 @@
<div class="fileInfo"><span class="fileText" id="fT${postID}"> <div class="fileInfo"><span class="fileText" id="fT${postID}">
File: File:
<a data-width="${file.width}" data-height="${file.height}" href="${fileURL}" target="_blank">${file.name}</a> <a data-width="${file.width}" data-height="${file.height}" href="${fileURL}" target="_blank">${file.name}</a>
-(${file.size}, ${fileDims}, ${file.tag}) -(${file.size}, ${file.dimensions}, ${file.tag})
</span></div> </span></div>
}{ }{
<div class="fileText" id="fT${postID}"?{file.isSpoiler}{ title="${file.name}"}> <div class="fileText" id="fT${postID}"?{file.isSpoiler}{ title="${file.name}"}>
@ -12,7 +12,7 @@
<a?{file.name === shortFilename || file.isSpoiler}{}{ title="${file.name}"} href="${fileURL}" target="_blank"> <a?{file.name === shortFilename || file.isSpoiler}{}{ title="${file.name}"} href="${fileURL}" target="_blank">
?{file.isSpoiler}{Spoiler Image}{${shortFilename}} ?{file.isSpoiler}{Spoiler Image}{${shortFilename}}
</a> </a>
(${file.size}, ${fileDims}) (${file.size}, ${file.dimensions || "PDF"})
</div> </div>
<a class="fileThumb?{file.isSpoiler}{ imgspoiler}{}" href="${fileURL}" target="_blank"> <a class="fileThumb?{file.isSpoiler}{ imgspoiler}{}" href="${fileURL}" target="_blank">
<img <img

View File

@ -160,6 +160,7 @@ class Fetcher
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.dimensions = "#{o.file.width}x#{o.file.height}" unless /\.pdf$/.test o.file.url
o.file.tag = JSON.parse(data.media.exif).Tag if @boardID is 'f' o.file.tag = JSON.parse(data.media.exif).Tag if @boardID is 'f'
board = g.boards[@boardID] or board = g.boards[@boardID] or