Reconcile the authenticated Hop homepage link with the concurrent prompt UI cache-busting update.
Hop-State: A_06FN8H69P46VDF0HK6YF5QR Hop-Proposal: R_06FN8H5RRQKVJVY2JNSFBM0 Hop-Task: T_06FN8GMDFCS0GKTW2RRDQ70 Hop-Attempt: AT_06FN8H33JB50J4M5WD37BCR
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"id": "P_06FN8GMDFDHV1G2BH5CC6X0",
|
||||
"task_id": "T_06FN8GMDFCS0GKTW2RRDQ70",
|
||||
"attempt_id": "AT_06FN8GMDFF85Q3R6MQ1PSW0",
|
||||
"state_id": "P_06FN8GMDFDHV1G2BH5CC6X0",
|
||||
"prompt": "Can we add a Hop link to the nav bar only for authenticated users, that when clicked loads the Homepage that unathenticated users see",
|
||||
"agent_name": "codex",
|
||||
"status": "proposed",
|
||||
"response_summary": "Add an authenticated-only Hop navbar link that displays the public landing homepage while preserving the signed-in navigation.",
|
||||
"created_at": "2026-07-12T02:57:55.579767Z",
|
||||
"metadata": {
|
||||
"source_tree": "8de4a24376935a4fb3f5791b017591bd2fbc2848",
|
||||
"git_commit": "67321dd93a25d30bddb0083706db2695bdabe622",
|
||||
"attempt_head": "C_06FN8H1TPEWCZT16VNZPF0R",
|
||||
"attempt_head_kind": "checkpoint"
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,9 @@ docker compose --env-file "$env_file" cp \
|
||||
docker compose --env-file "$env_file" cp \
|
||||
deploy/gitea/templates/custom/footer.tmpl \
|
||||
gitea:/data/gitea/templates/custom/footer.tmpl
|
||||
docker compose --env-file "$env_file" cp \
|
||||
deploy/gitea/templates/custom/extra_links.tmpl \
|
||||
gitea:/data/gitea/templates/custom/extra_links.tmpl
|
||||
docker compose --env-file "$env_file" cp \
|
||||
deploy/gitea/public/assets/js/hop-native.js \
|
||||
gitea:/data/gitea/public/assets/js/hop-native.js
|
||||
|
||||
@@ -372,6 +372,42 @@
|
||||
}
|
||||
}
|
||||
|
||||
function publicHomepageRequested() {
|
||||
return new URLSearchParams(window.location.search).get('hop') === 'home';
|
||||
}
|
||||
|
||||
async function loadPublicHomepage() {
|
||||
const link = document.querySelector('[data-hop-public-home-link]');
|
||||
if (link) link.classList.toggle('active', publicHomepageRequested());
|
||||
if (!link || !publicHomepageRequested() || document.documentElement.dataset.hopPublicHome) return;
|
||||
|
||||
document.documentElement.dataset.hopPublicHome = 'loading';
|
||||
try {
|
||||
const publicURL = new URL(link.href, window.location.origin);
|
||||
publicURL.search = '';
|
||||
const response = await fetch(publicURL, {credentials: 'omit'});
|
||||
if (!response.ok) throw new Error(`Could not load the Hop homepage (${response.status})`);
|
||||
|
||||
const publicDocument = new DOMParser().parseFromString(await response.text(), 'text/html');
|
||||
const publicMain = publicDocument.querySelector('#hop-main');
|
||||
const currentMain = document.querySelector('[role="main"]');
|
||||
if (!publicMain || !currentMain) throw new Error('The Hop homepage was not present in the response');
|
||||
|
||||
for (const style of publicMain.parentElement?.querySelectorAll(':scope > style') || []) {
|
||||
style.dataset.hopPublicHomeStyle = 'true';
|
||||
document.head.append(style);
|
||||
}
|
||||
currentMain.replaceWith(publicMain);
|
||||
document.title = publicDocument.title;
|
||||
document.documentElement.dataset.hopPublicHome = 'rendered';
|
||||
bindInstallationSwitchers();
|
||||
bindInstallationCopyButtons();
|
||||
} catch (error) {
|
||||
delete document.documentElement.dataset.hopPublicHome;
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
function applyHopSemantics() {
|
||||
const brandLogo = document.querySelector('#navbar-logo img');
|
||||
if (brandLogo) brandLogo.src = brandLogo.src.replace(/\/img\/(?:logo|hop)\.svg(?:\?.*)?$/, '/img/hop.svg?v=4');
|
||||
@@ -383,6 +419,7 @@
|
||||
renderPromptPage();
|
||||
bindInstallationSwitchers();
|
||||
bindInstallationCopyButtons();
|
||||
void loadPublicHomepage();
|
||||
document.documentElement.dataset.hopNative = 'true';
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{{if .IsSigned}}
|
||||
<a class="item" data-hop-public-home-link href="{{AppSubUrl}}/?hop=home">Hop</a>
|
||||
{{end}}
|
||||
Reference in New Issue
Block a user