Add redirection to project depending on rad-web cwd

This commit is contained in:
Sebastian Martinez
2024-02-07 11:47:08 +00:00
committed by Rūdolfs Ošiņš
parent 414c6cafda
commit 2b3b8bc0de
7 changed files with 28 additions and 11 deletions
Generated
+5 -5
View File
@@ -88,17 +88,17 @@
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
}, },
"locked": { "locked": {
"lastModified": 1706704813, "lastModified": 1707134016,
"narHash": "sha256-o0F1Bm1eUtDyz28hQdyktaW8dDnQl4bLeZhDUbP9dgM=", "narHash": "sha256-Cu8fHlircqH6qY9fN7Q5EWFgOZN1751BTKAKUI0AVQo=",
"ref": "master", "ref": "master",
"rev": "15d17098315469bb180157d1c20344faa10f4f73", "rev": "5abd7bf55a093341231c8b71953777068eade0e2",
"revCount": 1658, "revCount": 1667,
"type": "git", "type": "git",
"url": "https://seed.radicle.xyz/z3gqcJUoA1n9HaHKufZs5FCSGazv5.git" "url": "https://seed.radicle.xyz/z3gqcJUoA1n9HaHKufZs5FCSGazv5.git"
}, },
"original": { "original": {
"ref": "master", "ref": "master",
"rev": "15d17098315469bb180157d1c20344faa10f4f73", "rev": "5abd7bf55a093341231c8b71953777068eade0e2",
"type": "git", "type": "git",
"url": "https://seed.radicle.xyz/z3gqcJUoA1n9HaHKufZs5FCSGazv5.git" "url": "https://seed.radicle.xyz/z3gqcJUoA1n9HaHKufZs5FCSGazv5.git"
} }
+1 -1
View File
@@ -4,7 +4,7 @@
nixpkgs.follows = "heartwood/nixpkgs"; nixpkgs.follows = "heartwood/nixpkgs";
flake-utils.follows = "heartwood/flake-utils"; flake-utils.follows = "heartwood/flake-utils";
heartwood = { heartwood = {
url = "git+https://seed.radicle.xyz/z3gqcJUoA1n9HaHKufZs5FCSGazv5.git?ref=master&rev=15d17098315469bb180157d1c20344faa10f4f73"; url = "git+https://seed.radicle.xyz/z3gqcJUoA1n9HaHKufZs5FCSGazv5.git?ref=master&rev=5abd7bf55a093341231c8b71953777068eade0e2";
}; };
}; };
+5 -2
View File
@@ -1,6 +1,9 @@
<script> <script>
import { api, httpdStore } from "@app/lib/httpd"; import { api, httpdStore } from "@app/lib/httpd";
import Command from "./Command.svelte"; import Command from "./Command.svelte";
$: path = window.location.href.replace(window.location.origin, "");
$: pathParam = path === "/" ? "" : `--path "${path}"`;
</script> </script>
<style> <style>
@@ -31,14 +34,14 @@
<div class="label">Authenticate with your local node to make changes.</div> <div class="label">Authenticate with your local node to make changes.</div>
<Command <Command
fullWidth fullWidth
command={`rad web ${window.origin} --connect ${api.hostname}:${api.port}`} /> command={`rad web ${window.origin} --connect ${api.hostname}:${api.port} ${pathParam}`} />
{:else} {:else}
<div class="heading">Connect & Authenticate</div> <div class="heading">Connect & Authenticate</div>
<div class="label"> <div class="label">
Connect to your local node to browse projects on your local machine, Connect to your local node to browse projects on your local machine,
create issues, and participate in discussions. create issues, and participate in discussions.
</div> </div>
<Command fullWidth command={`rad web ${window.origin}`} /> <Command fullWidth command={`rad web ${window.origin} ${pathParam}`} />
<div class="divider" /> <div class="divider" />
<div class="heading">New to Radicle?</div> <div class="heading">New to Radicle?</div>
+1
View File
@@ -221,6 +221,7 @@ export function urlToRoute(url: URL): Route | null {
signature: url.searchParams.get("sig") ?? "", signature: url.searchParams.get("sig") ?? "",
publicKey: url.searchParams.get("pk") ?? "", publicKey: url.searchParams.get("pk") ?? "",
apiAddr: url.searchParams.get("addr") ?? "127.0.0.1:8080", apiAddr: url.searchParams.get("addr") ?? "127.0.0.1:8080",
path: url.searchParams.get("path") || undefined,
}, },
}; };
} }
+7 -1
View File
@@ -20,7 +20,13 @@ export interface NotFoundRoute {
interface SessionRoute { interface SessionRoute {
resource: "session"; resource: "session";
params: { id: string; signature: string; publicKey: string; apiAddr: string }; params: {
id: string;
signature: string;
publicKey: string;
apiAddr: string;
path?: string;
};
} }
export interface LoadErrorRoute { export interface LoadErrorRoute {
+8 -1
View File
@@ -35,7 +35,14 @@
}, },
}); });
} }
void router.push({ resource: "home" }); const route = router.urlToRoute(
new URL(activeRoute.params.path || "", window.location.origin),
);
if (route) {
void router.push(route);
} else {
void router.push({ resource: "home" });
}
}); });
</script> </script>
+1 -1
View File
@@ -1 +1 @@
15d17098315469bb180157d1c20344faa10f4f73 5abd7bf55a093341231c8b71953777068eade0e2