Do as much parsing as we can in Sauce.init.
This commit is contained in:
parent
ed246ffb1a
commit
fa3f439e62
@ -4,10 +4,8 @@ Sauce =
|
|||||||
|
|
||||||
links = []
|
links = []
|
||||||
for link in Conf['sauces'].split '\n'
|
for link in Conf['sauces'].split '\n'
|
||||||
try
|
if link[0] isnt '#' and (linkData = @parseLink link)
|
||||||
links.push link.trim() if link[0] isnt '#'
|
links.push linkData
|
||||||
catch err
|
|
||||||
# Don't add random text plz.
|
|
||||||
return unless links.length
|
return unless links.length
|
||||||
|
|
||||||
@links = links
|
@links = links
|
||||||
@ -18,9 +16,8 @@ Sauce =
|
|||||||
name: 'Sauce'
|
name: 'Sauce'
|
||||||
cb: @node
|
cb: @node
|
||||||
|
|
||||||
createSauceLink: (link, post) ->
|
parseLink: (link) ->
|
||||||
return null if not (link = link.trim())
|
return null if not (link = link.trim())
|
||||||
|
|
||||||
parts = {}
|
parts = {}
|
||||||
for part, i in link.split /;(?=(?:text|boards|types|sandbox):?)/
|
for part, i in link.split /;(?=(?:text|boards|types|sandbox):?)/
|
||||||
if i is 0
|
if i is 0
|
||||||
@ -29,7 +26,12 @@ Sauce =
|
|||||||
m = part.match /^(\w*):?(.*)$/
|
m = part.match /^(\w*):?(.*)$/
|
||||||
parts[m[1]] = m[2]
|
parts[m[1]] = m[2]
|
||||||
parts['text'] or= parts['url'].match(/(\w+)\.\w+\//)?[1] or '?'
|
parts['text'] or= parts['url'].match(/(\w+)\.\w+\//)?[1] or '?'
|
||||||
|
parts
|
||||||
|
|
||||||
|
createSauceLink: (link, post) ->
|
||||||
ext = post.file.url.match(/[^.]*$/)[0]
|
ext = post.file.url.match(/[^.]*$/)[0]
|
||||||
|
parts = {}
|
||||||
|
$.extend parts, link
|
||||||
|
|
||||||
return null unless !parts['boards'] or post.board.ID in parts['boards'].split ','
|
return null unless !parts['boards'] or post.board.ID in parts['boards'].split ','
|
||||||
return null unless !parts['types'] or ext in parts['types'].split ','
|
return null unless !parts['types'] or ext in parts['types'].split ','
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user