Make Build.parseComment more general.
This commit is contained in:
parent
f92a21e9ab
commit
d5320c4aa1
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user