From fdae25dc9e24411b42eac4c21b258373a8ec5409 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sat, 25 Apr 2015 02:06:32 -0700 Subject: [PATCH] Parse comments from JSON for filter/search. Also fix post building testing skipping posts with EXIF data. --- src/Filtering/Filter.coffee | 2 +- src/General/Build.coffee | 9 +++++++++ src/General/BuildTest.coffee | 7 ++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Filtering/Filter.coffee b/src/Filtering/Filter.coffee index cb4c4cb7a..a2eeef431 100755 --- a/src/Filtering/Filter.coffee +++ b/src/Filtering/Filter.coffee @@ -126,7 +126,7 @@ Filter = tripcode: (post) -> post.info.tripcode capcode: (post) -> post.info.capcode subject: (post) -> post.info.subject - comment: (post) -> post.info.comment + comment: (post) -> post.info.comment ? Build.parseComment(post) flag: (post) -> post.info.flag filename: (post) -> post.file?.name dimensions: (post) -> post.file?.dimensions diff --git a/src/General/Build.coffee b/src/General/Build.coffee index cdd3d9691..ec33083b8 100755 --- a/src/General/Build.coffee +++ b/src/General/Build.coffee @@ -78,6 +78,15 @@ 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 + .replace(/

.*$/, '') + .replace(/^Rolled [^<]*

<\/b>/, '') + .replace(//gi, '\n') + .replace(/<[^>]*>/g, '') + o.info.comment = Build.unescape html + postFromObject: (data, boardID, suppressThumb) -> o = Build.parseJSON data, boardID Build.post o, suppressThumb diff --git a/src/General/BuildTest.coffee b/src/General/BuildTest.coffee index 4b11ad54d..8bf1c9219 100644 --- a/src/General/BuildTest.coffee +++ b/src/General/BuildTest.coffee @@ -56,7 +56,7 @@ BuildTest = c.log x.outerHTML c.log y.outerHTML - for key of Config.filter when not (key is 'comment' or key is 'MD5' and post.board.ID is 'f') + for key of Config.filter when not (key is 'MD5' and post.board.ID is 'f') val1 = Filter[key] obj val2 = Filter[key] post2 if val1 isnt val2 @@ -76,8 +76,9 @@ BuildTest = testAll: -> g.posts.forEach (post) -> - unless post.isClone or post.isFetchedQuote or $ '.abbr', post.nodes.comment - BuildTest.testOne post + unless post.isClone or post.isFetchedQuote + unless (abbr = $ '.abbr', post.nodes.comment) and /Comment too long\./.test(abbr.textContent) + BuildTest.testOne post return postsRemaining: 0