Fix custom board links for boards without native catalog/archive being changed to nonexistent native catalog/archive links on catalog/archive pages. #2390

This commit is contained in:
ccd0 2019-08-06 23:38:17 -07:00
parent d09ef5396e
commit 9ee9f2c2c6
3 changed files with 7 additions and 2 deletions

View File

@ -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}/ - ") + (

View File

@ -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

View File

@ -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 ''