mirror of
https://github.com/alexandernicholson/s3panoramic.git
synced 2026-03-31 09:07:11 +09:00
fix: navigation loop
This commit is contained in:
parent
a99386865d
commit
3c42336da3
@@ -59,4 +59,4 @@ docker run -p 3000:3000 \
|
|||||||
|
|
||||||
## Authorization
|
## Authorization
|
||||||
|
|
||||||
This application does not perform authorisation of users. I recommend using a proxy such as [oauth2-proxy](https://github.com/oauth2-proxy/oauth2-proxy) to protect your application.
|
This application does not perform authorisation of users. I recommend using a proxy such as [oauth2-proxy](https://github.com/oauth2-proxy/oauth2-proxy) to protect your files from unauthorised access.
|
||||||
|
|||||||
@@ -27,12 +27,27 @@ viewRoutes.get("/", async (c) => {
|
|||||||
continuationToken,
|
continuationToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
// If it's an HTMX request, return just the browser content
|
// If it's an HTMX request, return both navigation and content
|
||||||
if (c.req.header("HX-Request")) {
|
if (c.req.header("HX-Request")) {
|
||||||
const content = browser(result, prefix, query);
|
return c.html(`
|
||||||
const doc = new DOMParser().parseFromString(content, "text/html");
|
<div class="breadcrumbs">
|
||||||
const browserContent = doc?.querySelector("#browser-content")?.innerHTML || "";
|
<a href="/"
|
||||||
return c.html(browserContent);
|
hx-get="/"
|
||||||
|
hx-target="#browser-content"
|
||||||
|
hx-push-url="true">Home</a>
|
||||||
|
${prefix.split("/").filter(Boolean).map((part, i, parts) => {
|
||||||
|
const path = parts.slice(0, i + 1).join("/");
|
||||||
|
return `
|
||||||
|
<a href="/?prefix=${path}"
|
||||||
|
hx-get="/?prefix=${path}"
|
||||||
|
hx-target="#browser-content"
|
||||||
|
hx-push-url="true">${part}</a>
|
||||||
|
`;
|
||||||
|
}).join(" / ")}
|
||||||
|
</div>
|
||||||
|
${objectList(result)}
|
||||||
|
${pagination(result)}
|
||||||
|
`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise return the full layout
|
// Otherwise return the full layout
|
||||||
|
|||||||
@@ -14,21 +14,13 @@ export function browser(
|
|||||||
|
|
||||||
${search(query)}
|
${search(query)}
|
||||||
|
|
||||||
<div class="browser-navigation">
|
|
||||||
${renderBreadcrumbs(prefix)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="browser-content">
|
<div id="browser-content">
|
||||||
${objectList(result)}
|
<div class="breadcrumbs">
|
||||||
${pagination(result)}
|
<a href="/"
|
||||||
</div>
|
hx-get="/"
|
||||||
</div>
|
hx-target="#browser-content"
|
||||||
`;
|
hx-push-url="true">Home</a>
|
||||||
}
|
${prefix.split("/").filter(Boolean).map((part, i, parts) => {
|
||||||
|
|
||||||
export function renderBreadcrumbs(prefix: string) {
|
|
||||||
const parts = prefix.split("/").filter(Boolean);
|
|
||||||
const links = parts.map((part, i) => {
|
|
||||||
const path = parts.slice(0, i + 1).join("/");
|
const path = parts.slice(0, i + 1).join("/");
|
||||||
return `
|
return `
|
||||||
<a href="/?prefix=${path}"
|
<a href="/?prefix=${path}"
|
||||||
@@ -36,15 +28,11 @@ export function renderBreadcrumbs(prefix: string) {
|
|||||||
hx-target="#browser-content"
|
hx-target="#browser-content"
|
||||||
hx-push-url="true">${part}</a>
|
hx-push-url="true">${part}</a>
|
||||||
`;
|
`;
|
||||||
});
|
}).join(" / ")}
|
||||||
|
</div>
|
||||||
return `
|
${objectList(result)}
|
||||||
<div class="breadcrumbs">
|
${pagination(result)}
|
||||||
<a href="/"
|
</div>
|
||||||
hx-get="/"
|
|
||||||
hx-target="#browser-content"
|
|
||||||
hx-push-url="true">Home</a>
|
|
||||||
${links.length ? " / " + links.join(" / ") : ""}
|
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ export function objectList(result: ListObjectsResult) {
|
|||||||
<div class="folder">
|
<div class="folder">
|
||||||
<a href="/?prefix=${prefix}"
|
<a href="/?prefix=${prefix}"
|
||||||
hx-get="/?prefix=${prefix}"
|
hx-get="/?prefix=${prefix}"
|
||||||
hx-target="#browser-content"
|
hx-target="#browser-navigation, #browser-content"
|
||||||
hx-push-url="true">
|
hx-push-url="true">
|
||||||
📁 ${prefix}
|
📁 ${prefix}
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
Reference in New Issue
Block a user