Merge branch 'dev'
This commit is contained in:
commit
24526105b0
@ -110,7 +110,7 @@ Sauce =
|
||||
formatters:
|
||||
TURL: (post, file) -> file.thumbURL
|
||||
URL: (post, file) -> file.url
|
||||
IMG: (post, file, ext) -> if ext in ['gif', 'jpg', 'png'] then file.url else file.thumbURL
|
||||
IMG: (post, file, ext) -> if ext in ['gif', 'jpg', 'jpeg', 'png'] then file.url else file.thumbURL
|
||||
MD5: (post, file) -> file.MD5
|
||||
sMD5: (post, file) -> file.MD5?.replace /[+/=]/g, (c) -> ({'+': '-', '/': '_', '=': ''})[c]
|
||||
hMD5: (post, file) -> if file.MD5 then ("0#{c.charCodeAt(0).toString(16)}"[-2..] for c in atob file.MD5).join('')
|
||||
|
||||
@ -162,11 +162,8 @@ ThreadWatcher =
|
||||
if Conf['Auto Prune'] or not (data and typeof data is 'object') # corrupt data
|
||||
db.delete {boardID, threadID}
|
||||
nKilled++
|
||||
else if ThreadWatcher.unreadEnabled and Conf['Show Unread Count']
|
||||
ThreadWatcher.fetchStatus {siteID, boardID, threadID, data}
|
||||
else
|
||||
db.extend {boardID, threadID, val: {isDead: true, page: undefined, lastPage: undefined, unread: undefined, quotingYou: undefined}}
|
||||
nKilled++
|
||||
ThreadWatcher.fetchStatus {siteID, boardID, threadID, data}
|
||||
ThreadWatcher.refresh() if nKilled
|
||||
onThreadRefresh: (e) ->
|
||||
thread = g.threads.get(e.detail.threadID)
|
||||
@ -340,12 +337,12 @@ ThreadWatcher =
|
||||
if @status is 200 and @response
|
||||
last = @response.posts[@response.posts.length-1].no
|
||||
replies = @response.posts.length-1
|
||||
isDead = !!@response.posts[0].archived
|
||||
isDead = isArchived = !!@response.posts[0].archived
|
||||
if isDead and Conf['Auto Prune']
|
||||
ThreadWatcher.rm siteID, boardID, threadID
|
||||
return
|
||||
|
||||
return if last is data.last and isDead is data.isDead
|
||||
return if last is data.last and isDead is data.isDead and isArchived is data.isArchived
|
||||
|
||||
lastReadPost = ThreadWatcher.unreaddb.get {siteID, boardID, threadID, defaultValue: 0}
|
||||
unread = data.unread or 0
|
||||
@ -379,7 +376,7 @@ ThreadWatcher =
|
||||
quotingYou = postObj.no if quotesYou
|
||||
|
||||
newData or= {}
|
||||
$.extend newData, {last, replies, isDead, unread, quotingYou}
|
||||
$.extend newData, {last, replies, isDead, isArchived, unread, quotingYou}
|
||||
ThreadWatcher.update siteID, boardID, threadID, newData
|
||||
|
||||
else if @status is 404
|
||||
@ -508,7 +505,7 @@ ThreadWatcher =
|
||||
ThreadWatcher.rm siteID, boardID, threadID
|
||||
return
|
||||
if newData.isDead or newData.last is -1
|
||||
for key in ['page', 'lastPage', 'unread', 'quotingyou'] when key not of newData
|
||||
for key in ['isArchived', 'page', 'lastPage', 'unread', 'quotingyou'] when key not of newData
|
||||
newData[key] = undefined
|
||||
if newData.last? and newData.last < data.last
|
||||
newData.modified = undefined
|
||||
@ -528,8 +525,8 @@ ThreadWatcher =
|
||||
if Conf['Auto Prune']
|
||||
ThreadWatcher.db.delete {boardID, threadID}
|
||||
return cb()
|
||||
return cb() if data.isDead and not (data.page? or data.lastPage? or data.unread? or data.quotingYou?)
|
||||
ThreadWatcher.db.extend {boardID, threadID, val: {isDead: true, page: undefined, lastPage: undefined, unread: undefined, quotingYou: undefined}}, cb
|
||||
return cb() if data.isDead and not (data.isArchived? or data.page? or data.lastPage? or data.unread? or data.quotingYou?)
|
||||
ThreadWatcher.db.extend {boardID, threadID, val: {isDead: true, isArchived: undefined, page: undefined, lastPage: undefined, unread: undefined, quotingYou: undefined}}, cb
|
||||
|
||||
toggle: (thread) ->
|
||||
siteID = g.SITE.ID
|
||||
|
||||
@ -138,11 +138,20 @@ class DataBoard
|
||||
$.cache threadsList, ->
|
||||
return unless @status is 200
|
||||
archiveList = g.SITE.urls.archiveListJSON?({siteID, boardID})
|
||||
return that.ajaxCleanParse(boardID, @response) unless archiveList
|
||||
archiveListHTML = g.SITE.urls.archive?({siteID, boardID})
|
||||
response1 = @response
|
||||
$.cache archiveList, ->
|
||||
return unless @status is 200
|
||||
that.ajaxCleanParse(boardID, response1, @response)
|
||||
if archiveList
|
||||
$.cache archiveList, ->
|
||||
return unless @status is 200
|
||||
that.ajaxCleanParse(boardID, response1, @response)
|
||||
else if g.SITE.archiveListParse and archiveListHTML
|
||||
$.cache archiveListHTML, ->
|
||||
return unless @status is 200 or @status is 404
|
||||
response2 = if @status is 404 then [] else g.SITE.archiveListParse(@response)
|
||||
that.ajaxCleanParse(boardID, response1, response2)
|
||||
, {responseType: 'document'}
|
||||
else
|
||||
that.ajaxCleanParse(boardID, @response)
|
||||
|
||||
ajaxCleanParse: (boardID, response1, response2) ->
|
||||
siteID = g.SITE.ID
|
||||
|
||||
@ -23,7 +23,8 @@ class Post
|
||||
if not @isReply
|
||||
@thread.OP = @
|
||||
for key in ['isSticky', 'isClosed', 'isArchived']
|
||||
@thread[key] = if (selector = g.SITE.selectors.icons[key]) then !!$(selector, @nodes.info) else false
|
||||
if (selector = g.SITE.selectors.icons[key])
|
||||
@thread[key] = !!$(selector, @nodes.info)
|
||||
if @thread.isArchived
|
||||
@thread.isClosed = true
|
||||
@thread.kill()
|
||||
|
||||
@ -145,6 +145,10 @@ Main =
|
||||
else if pathname[2] in ['thread', 'res']
|
||||
r.VIEW = 'thread'
|
||||
r.threadID = r.THREADID = +pathname[3].replace(/\.\w+$/, '')
|
||||
else if pathname[2] is 'archive' and pathname[3] is 'res'
|
||||
r.VIEW = 'thread'
|
||||
r.threadID = r.THREADID = +pathname[4].replace(/\.\w+$/, '')
|
||||
r.threadArchived = true
|
||||
else if /^(?:catalog|archive)(?:\.\w+)?$/.test(pathname[2])
|
||||
r.VIEW = pathname[2].replace(/\.\w+$/, '')
|
||||
else if /^(?:index|\d*)(?:\.\w+)?$/.test(pathname[2])
|
||||
@ -348,6 +352,7 @@ Main =
|
||||
Main.handleErrors errors if errors.length
|
||||
|
||||
if g.VIEW is 'thread'
|
||||
threads[0].isArchived = true if g.threadArchived
|
||||
g.SITE.parseThreadMetadata?(threads[0])
|
||||
|
||||
Main.callbackNodes 'Thread', threads
|
||||
|
||||
@ -208,7 +208,7 @@ $.whenModified = (url, bucket, cb, options={}) ->
|
||||
do ->
|
||||
reqs = $.dict()
|
||||
$.cache = (url, cb, options={}) ->
|
||||
{ajax} = options
|
||||
{ajax, responseType} = options
|
||||
if (req = reqs[url])
|
||||
if req.callbacks
|
||||
req.callbacks.push cb
|
||||
@ -221,7 +221,7 @@ do ->
|
||||
for cb in @callbacks
|
||||
do (cb) => $.queueTask => cb.call @, {isCached: false}
|
||||
delete @callbacks
|
||||
req = (ajax or $.ajax) url, {onloadend}
|
||||
req = (ajax or $.ajax) url, {onloadend, responseType}
|
||||
req.callbacks = [cb]
|
||||
reqs[url] = req
|
||||
$.cleanCache = (testf) ->
|
||||
|
||||
@ -45,6 +45,7 @@ SW.tinyboard =
|
||||
post: ({postID}) -> "##{postID}"
|
||||
index: ({siteID, boardID}) -> "#{Conf['siteProperties'][siteID]?.root or "http://#{siteID}/"}#{boardID}/"
|
||||
catalog: ({siteID, boardID}) -> "#{Conf['siteProperties'][siteID]?.root or "http://#{siteID}/"}#{boardID}/catalog.html"
|
||||
archive: ({siteID, boardID}) -> "#{Conf['siteProperties'][siteID]?.root or "http://#{siteID}/"}#{boardID}/archive/"
|
||||
threadJSON: ({siteID, boardID, threadID}) ->
|
||||
root = Conf['siteProperties'][siteID]?.root
|
||||
if root then "#{root}#{boardID}/res/#{threadID}.json" else ''
|
||||
@ -107,6 +108,7 @@ SW.tinyboard =
|
||||
nav:
|
||||
prev: '.pages > form > [value=Previous]'
|
||||
next: '.pages > form > [value=Next]'
|
||||
archiveThreadID: '#archive-list td:first-of-type'
|
||||
|
||||
classes:
|
||||
highlight: 'highlighted'
|
||||
@ -206,3 +208,6 @@ SW.tinyboard =
|
||||
|
||||
catalogPin: (threadRoot) ->
|
||||
threadRoot.dataset.sticky = 'true'
|
||||
|
||||
archiveListParse: (response) ->
|
||||
$$(SW.tinyboard.selectors.archiveThreadID, response).map((x) -> +x.textContent)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user