From 9ee9f2c2c61d32475f98627320b308a77adaf9a2 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Tue, 6 Aug 2019 23:38:17 -0700 Subject: [PATCH] Fix custom board links for boards without native catalog/archive being changed to nonexistent native catalog/archive links on catalog/archive pages. #2390 --- src/General/Get.coffee | 5 ++++- src/General/Header.coffee | 3 ++- src/site/SW.yotsuba.coffee | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/General/Get.coffee b/src/General/Get.coffee index 159d350e1..4a2795120 100644 --- a/src/General/Get.coffee +++ b/src/General/Get.coffee @@ -1,6 +1,9 @@ Get = url: (type, IDs, args...) -> - g.sites[IDs.siteID]?.urls[type] IDs, args... + if (site = g.sites[IDs.siteID]) and (f = $.getOwn(site.urls, type)) + f IDs, args... + else + undefined threadExcerpt: (thread) -> {OP} = thread excerpt = ("/#{decodeURIComponent thread.board.ID}/ - ") + ( diff --git a/src/General/Header.coffee b/src/General/Header.coffee index 6654b2fe1..e334041ea 100644 --- a/src/General/Header.coffee +++ b/src/General/Header.coffee @@ -256,7 +256,8 @@ Header = href: "//#{BoardConfig.domain(boardID)}/#{boardID}/" textContent: boardID title: BoardConfig.title(boardID) - a.href += g.VIEW if g.VIEW in ['catalog', 'archive'] + if g.VIEW in ['catalog', 'archive'] and (urlV = Get.url g.VIEW, {siteID: '4chan.org', boardID}) + a.href = urlV a.className = 'current' if a.hostname is location.hostname and boardID is g.BOARD.ID a diff --git a/src/site/SW.yotsuba.coffee b/src/site/SW.yotsuba.coffee index c29f51cfe..1d8e828cd 100644 --- a/src/site/SW.yotsuba.coffee +++ b/src/site/SW.yotsuba.coffee @@ -7,6 +7,7 @@ SW.yotsuba = post: ({postID}) -> "#p#{postID}" index: ({boardID}) -> "#{location.protocol}//#{BoardConfig.domain(boardID)}/#{boardID}/" catalog: ({boardID}) -> if boardID is 'f' then undefined else "#{location.protocol}//#{BoardConfig.domain(boardID)}/#{boardID}/catalog" + archive: ({boardID}) -> if BoardConfig.isArchived(boardID) then "#{location.protocol}//#{BoardConfig.domain(boardID)}/#{boardID}/archive" else undefined threadJSON: ({boardID, threadID}) -> "#{location.protocol}//a.4cdn.org/#{boardID}/thread/#{threadID}.json" threadsListJSON: ({boardID}) -> "#{location.protocol}//a.4cdn.org/#{boardID}/threads.json" archiveListJSON: ({boardID}) -> if BoardConfig.isArchived(boardID) then "#{location.protocol}//a.4cdn.org/#{boardID}/archive.json" else ''