Make Build.parseComment more general.

This commit is contained in:
ccd0 2016-01-30 16:36:18 -08:00
parent f92a21e9ab
commit d5320c4aa1
2 changed files with 4 additions and 4 deletions

View File

@ -139,7 +139,7 @@ Filter =
tripcode: (post) -> post.info.tripcode
capcode: (post) -> post.info.capcode
subject: (post) -> post.info.subject
comment: (post) -> post.info.comment ? Build.parseComment(post)
comment: (post) -> (post.info.comment ?= Build.parseComment post.info.commentHTML.innerHTML)
flag: (post) -> post.info.flag
filename: (post) -> post.file?.name
dimensions: (post) -> post.file?.dimensions

View File

@ -79,14 +79,14 @@ Build =
o.file.dimensions = "#{o.file.width}x#{o.file.height}" unless /\.pdf$/.test o.file.url
o
parseComment: (o) ->
html = o.info.commentHTML.innerHTML
parseComment: (html) ->
html = html
.replace(/<br\b[^<]*>/gi, '\n')
.replace(/\n\n<span\b[^<]* class="abbr"[^]*$/i, '') # EXIF data (/p/)
.replace(/^<b\b[^<]*>Rolled [^<]*<\/b>/i, '') # Rolls (/tg/)
.replace(/<span\b[^<]* class="fortune"[^]*$/i, '') # Fortunes (/s4s/)
.replace(/<[^>]*>/g, '')
o.info.comment = Build.unescape html
Build.unescape html
postFromObject: (data, boardID, suppressThumb) ->
o = Build.parseJSON data, boardID