From ad042f29e41a5b619fcd3edbdf336c24858fa3a4 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Wed, 16 Oct 2019 22:29:00 -0700 Subject: [PATCH 1/4] %URL in Sauce should use full image when extension is .jpeg. --- src/Images/Sauce.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Images/Sauce.coffee b/src/Images/Sauce.coffee index c8cd676e0..193e2c264 100644 --- a/src/Images/Sauce.coffee +++ b/src/Images/Sauce.coffee @@ -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('') From 334f7e2a521470b7050396d56b3bbd10f24f8ad3 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Mon, 21 Oct 2019 20:54:51 -0700 Subject: [PATCH 2/4] Recognize archived threads on kissu.moe as threads. --- src/classes/Post.coffee | 3 ++- src/main/Main.coffee | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/classes/Post.coffee b/src/classes/Post.coffee index 821130a0b..62065b65a 100644 --- a/src/classes/Post.coffee +++ b/src/classes/Post.coffee @@ -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() diff --git a/src/main/Main.coffee b/src/main/Main.coffee index 3e1de4492..53fad511a 100644 --- a/src/main/Main.coffee +++ b/src/main/Main.coffee @@ -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 From aca7ed0a550ecab4bcc38d13c09b2e5da115155c Mon Sep 17 00:00:00 2001 From: ccd0 Date: Thu, 12 Dec 2019 18:40:05 -0800 Subject: [PATCH 3/4] Don't prune data for threads on kissu.moe while they're in the archive. --- src/classes/DataBoard.coffee | 17 +++++++++++++---- src/platform/$.coffee | 4 ++-- src/site/SW.tinyboard.coffee | 5 +++++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/classes/DataBoard.coffee b/src/classes/DataBoard.coffee index 2e76d1413..9acb504bb 100644 --- a/src/classes/DataBoard.coffee +++ b/src/classes/DataBoard.coffee @@ -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 diff --git a/src/platform/$.coffee b/src/platform/$.coffee index e0df4ecb3..f7c7513dd 100644 --- a/src/platform/$.coffee +++ b/src/platform/$.coffee @@ -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) -> diff --git a/src/site/SW.tinyboard.coffee b/src/site/SW.tinyboard.coffee index 2d43c0654..2e1496631 100644 --- a/src/site/SW.tinyboard.coffee +++ b/src/site/SW.tinyboard.coffee @@ -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) From 7488ff9a6cfb26a6c8a351e4125fef6f878d07e6 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Thu, 12 Dec 2019 20:59:55 -0800 Subject: [PATCH 4/4] Add isArchived property to Thread Watcher data. --- src/Monitoring/ThreadWatcher.coffee | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/Monitoring/ThreadWatcher.coffee b/src/Monitoring/ThreadWatcher.coffee index a57b587dc..5a0271372 100644 --- a/src/Monitoring/ThreadWatcher.coffee +++ b/src/Monitoring/ThreadWatcher.coffee @@ -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