Factor Post::parseQuote out of Post::parseQuotes

This commit is contained in:
Mayhem 2013-07-22 15:37:25 +02:00
parent a344ef4afa
commit d0dac27ca7

View File

@ -78,13 +78,17 @@ class Post
parseQuotes: -> parseQuotes: ->
@quotes = [] @quotes = []
for quotelink in $$ '.quotelink', @nodes.comment for quotelink in $$ '.quotelink', @nodes.comment
@parseQuote quotelink
return
parseQuote: (quotelink) ->
# Only add quotes that link to posts on an imageboard. # Only add quotes that link to posts on an imageboard.
# Don't add: # Don't add:
# - board links. (>>>/b/) # - board links. (>>>/b/)
# - catalog links. (>>>/b/catalog or >>>/b/search) # - catalog links. (>>>/b/catalog or >>>/b/search)
# - rules links. (>>>/a/rules) # - rules links. (>>>/a/rules)
# - text-board quotelinks. (>>>/img/1234) # - text-board quotelinks. (>>>/img/1234)
continue unless match = quotelink.href.match /// return unless match = quotelink.href.match ///
boards\.4chan\.org/ boards\.4chan\.org/
([^/]+) # boardID ([^/]+) # boardID
/res/\d+#p /res/\d+#p
@ -95,12 +99,11 @@ class Post
@nodes.quotelinks.push quotelink @nodes.quotelinks.push quotelink
# Don't count capcode replies as quotes in OPs. (Admin/Mod/Dev Replies: ...) # Don't count capcode replies as quotes in OPs. (Admin/Mod/Dev Replies: ...)
continue if @isClone or !@isReply and $.hasClass quotelink.parentNode.parentNode, 'capcodeReplies' return if @isClone or !@isReply and $.hasClass quotelink.parentNode.parentNode, 'capcodeReplies'
# ES6 Set when? # ES6 Set when?
fullID = "#{match[1]}.#{match[2]}" fullID = "#{match[1]}.#{match[2]}"
@quotes.push fullID if @quotes.indexOf(fullID) is -1 @quotes.push fullID if @quotes.indexOf(fullID) is -1
return
parseFile: (that) -> parseFile: (that) ->
return unless (fileEl = $ '.file', @nodes.post) and thumb = $ 'img[data-md5]', fileEl return unless (fileEl = $ '.file', @nodes.post) and thumb = $ 'img[data-md5]', fileEl