Merge branch 'dev'

This commit is contained in:
ccd0 2019-12-13 01:37:09 -08:00
commit 24526105b0
7 changed files with 35 additions and 18 deletions

View File

@ -110,7 +110,7 @@ Sauce =
formatters: formatters:
TURL: (post, file) -> file.thumbURL TURL: (post, file) -> file.thumbURL
URL: (post, file) -> file.url 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 MD5: (post, file) -> file.MD5
sMD5: (post, file) -> file.MD5?.replace /[+/=]/g, (c) -> ({'+': '-', '/': '_', '=': ''})[c] 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('') hMD5: (post, file) -> if file.MD5 then ("0#{c.charCodeAt(0).toString(16)}"[-2..] for c in atob file.MD5).join('')

View File

@ -162,11 +162,8 @@ ThreadWatcher =
if Conf['Auto Prune'] or not (data and typeof data is 'object') # corrupt data if Conf['Auto Prune'] or not (data and typeof data is 'object') # corrupt data
db.delete {boardID, threadID} db.delete {boardID, threadID}
nKilled++ nKilled++
else if ThreadWatcher.unreadEnabled and Conf['Show Unread Count']
ThreadWatcher.fetchStatus {siteID, boardID, threadID, data}
else else
db.extend {boardID, threadID, val: {isDead: true, page: undefined, lastPage: undefined, unread: undefined, quotingYou: undefined}} ThreadWatcher.fetchStatus {siteID, boardID, threadID, data}
nKilled++
ThreadWatcher.refresh() if nKilled ThreadWatcher.refresh() if nKilled
onThreadRefresh: (e) -> onThreadRefresh: (e) ->
thread = g.threads.get(e.detail.threadID) thread = g.threads.get(e.detail.threadID)
@ -340,12 +337,12 @@ ThreadWatcher =
if @status is 200 and @response if @status is 200 and @response
last = @response.posts[@response.posts.length-1].no last = @response.posts[@response.posts.length-1].no
replies = @response.posts.length-1 replies = @response.posts.length-1
isDead = !!@response.posts[0].archived isDead = isArchived = !!@response.posts[0].archived
if isDead and Conf['Auto Prune'] if isDead and Conf['Auto Prune']
ThreadWatcher.rm siteID, boardID, threadID ThreadWatcher.rm siteID, boardID, threadID
return 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} lastReadPost = ThreadWatcher.unreaddb.get {siteID, boardID, threadID, defaultValue: 0}
unread = data.unread or 0 unread = data.unread or 0
@ -379,7 +376,7 @@ ThreadWatcher =
quotingYou = postObj.no if quotesYou quotingYou = postObj.no if quotesYou
newData or= {} newData or= {}
$.extend newData, {last, replies, isDead, unread, quotingYou} $.extend newData, {last, replies, isDead, isArchived, unread, quotingYou}
ThreadWatcher.update siteID, boardID, threadID, newData ThreadWatcher.update siteID, boardID, threadID, newData
else if @status is 404 else if @status is 404
@ -508,7 +505,7 @@ ThreadWatcher =
ThreadWatcher.rm siteID, boardID, threadID ThreadWatcher.rm siteID, boardID, threadID
return return
if newData.isDead or newData.last is -1 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 newData[key] = undefined
if newData.last? and newData.last < data.last if newData.last? and newData.last < data.last
newData.modified = undefined newData.modified = undefined
@ -528,8 +525,8 @@ ThreadWatcher =
if Conf['Auto Prune'] if Conf['Auto Prune']
ThreadWatcher.db.delete {boardID, threadID} ThreadWatcher.db.delete {boardID, threadID}
return cb() return cb()
return cb() if data.isDead and not (data.page? or data.lastPage? or data.unread? or data.quotingYou?) 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, page: undefined, lastPage: undefined, unread: undefined, quotingYou: undefined}}, cb ThreadWatcher.db.extend {boardID, threadID, val: {isDead: true, isArchived: undefined, page: undefined, lastPage: undefined, unread: undefined, quotingYou: undefined}}, cb
toggle: (thread) -> toggle: (thread) ->
siteID = g.SITE.ID siteID = g.SITE.ID

View File

@ -138,11 +138,20 @@ class DataBoard
$.cache threadsList, -> $.cache threadsList, ->
return unless @status is 200 return unless @status is 200
archiveList = g.SITE.urls.archiveListJSON?({siteID, boardID}) archiveList = g.SITE.urls.archiveListJSON?({siteID, boardID})
return that.ajaxCleanParse(boardID, @response) unless archiveList archiveListHTML = g.SITE.urls.archive?({siteID, boardID})
response1 = @response response1 = @response
$.cache archiveList, -> if archiveList
return unless @status is 200 $.cache archiveList, ->
that.ajaxCleanParse(boardID, response1, @response) 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) -> ajaxCleanParse: (boardID, response1, response2) ->
siteID = g.SITE.ID siteID = g.SITE.ID

View File

@ -23,7 +23,8 @@ class Post
if not @isReply if not @isReply
@thread.OP = @ @thread.OP = @
for key in ['isSticky', 'isClosed', 'isArchived'] 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 if @thread.isArchived
@thread.isClosed = true @thread.isClosed = true
@thread.kill() @thread.kill()

View File

@ -145,6 +145,10 @@ Main =
else if pathname[2] in ['thread', 'res'] else if pathname[2] in ['thread', 'res']
r.VIEW = 'thread' r.VIEW = 'thread'
r.threadID = r.THREADID = +pathname[3].replace(/\.\w+$/, '') 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]) else if /^(?:catalog|archive)(?:\.\w+)?$/.test(pathname[2])
r.VIEW = pathname[2].replace(/\.\w+$/, '') r.VIEW = pathname[2].replace(/\.\w+$/, '')
else if /^(?:index|\d*)(?:\.\w+)?$/.test(pathname[2]) else if /^(?:index|\d*)(?:\.\w+)?$/.test(pathname[2])
@ -348,6 +352,7 @@ Main =
Main.handleErrors errors if errors.length Main.handleErrors errors if errors.length
if g.VIEW is 'thread' if g.VIEW is 'thread'
threads[0].isArchived = true if g.threadArchived
g.SITE.parseThreadMetadata?(threads[0]) g.SITE.parseThreadMetadata?(threads[0])
Main.callbackNodes 'Thread', threads Main.callbackNodes 'Thread', threads

View File

@ -208,7 +208,7 @@ $.whenModified = (url, bucket, cb, options={}) ->
do -> do ->
reqs = $.dict() reqs = $.dict()
$.cache = (url, cb, options={}) -> $.cache = (url, cb, options={}) ->
{ajax} = options {ajax, responseType} = options
if (req = reqs[url]) if (req = reqs[url])
if req.callbacks if req.callbacks
req.callbacks.push cb req.callbacks.push cb
@ -221,7 +221,7 @@ do ->
for cb in @callbacks for cb in @callbacks
do (cb) => $.queueTask => cb.call @, {isCached: false} do (cb) => $.queueTask => cb.call @, {isCached: false}
delete @callbacks delete @callbacks
req = (ajax or $.ajax) url, {onloadend} req = (ajax or $.ajax) url, {onloadend, responseType}
req.callbacks = [cb] req.callbacks = [cb]
reqs[url] = req reqs[url] = req
$.cleanCache = (testf) -> $.cleanCache = (testf) ->

View File

@ -45,6 +45,7 @@ SW.tinyboard =
post: ({postID}) -> "##{postID}" post: ({postID}) -> "##{postID}"
index: ({siteID, boardID}) -> "#{Conf['siteProperties'][siteID]?.root or "http://#{siteID}/"}#{boardID}/" index: ({siteID, boardID}) -> "#{Conf['siteProperties'][siteID]?.root or "http://#{siteID}/"}#{boardID}/"
catalog: ({siteID, boardID}) -> "#{Conf['siteProperties'][siteID]?.root or "http://#{siteID}/"}#{boardID}/catalog.html" 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}) -> threadJSON: ({siteID, boardID, threadID}) ->
root = Conf['siteProperties'][siteID]?.root root = Conf['siteProperties'][siteID]?.root
if root then "#{root}#{boardID}/res/#{threadID}.json" else '' if root then "#{root}#{boardID}/res/#{threadID}.json" else ''
@ -107,6 +108,7 @@ SW.tinyboard =
nav: nav:
prev: '.pages > form > [value=Previous]' prev: '.pages > form > [value=Previous]'
next: '.pages > form > [value=Next]' next: '.pages > form > [value=Next]'
archiveThreadID: '#archive-list td:first-of-type'
classes: classes:
highlight: 'highlighted' highlight: 'highlighted'
@ -206,3 +208,6 @@ SW.tinyboard =
catalogPin: (threadRoot) -> catalogPin: (threadRoot) ->
threadRoot.dataset.sticky = 'true' threadRoot.dataset.sticky = 'true'
archiveListParse: (response) ->
$$(SW.tinyboard.selectors.archiveThreadID, response).map((x) -> +x.textContent)