Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Browse files using repo HEAD
Alexis Sellier committed 4 years ago
commit b9999209dee389e36836f2e283c30926dc78c489
parent c76e42d49331b55aae6947b962bbd072ed026754
3 files changed +20 -7
modified src/base/projects/Browser.svelte
@@ -12,6 +12,7 @@
  export let commit: string;
  export let config: Config;
  export let path: string;
+
  export let onSelect: (event: { detail: string }) => void;

  let info: "loading" | proj.Info | null = null;
  let blob: Promise<proj.Blob | null> | null = null;
@@ -20,10 +21,6 @@
    return proj.getTree(urn, commit, path, config);
  };

-
  const onSelect = async ({ detail: path }: { detail: string }) => {
-
    navigate(`/projects/${urn}/${commit}/${path}`);
-
  };
-

  $: if (path === "/") {
    blob = proj.getReadme(urn, commit, config);
  } else {
modified src/base/projects/Routes.svelte
@@ -10,6 +10,10 @@
  };
</script>

+
<Route path="/projects/:urn/head/:path/*" let:params>
+
  <View {config} urn={params.urn} path={joinPaths(params.path, params['*'])} />
+
</Route>
+

<Route path="/projects/:urn/:commit/:path/*" let:params>
  <View {config} urn={params.urn} commit={params.commit} path={joinPaths(params.path, params['*'])} />
</Route>
@@ -18,6 +22,10 @@
  <View {config} urn={params.urn} commit={params.commit} path="/" />
</Route>

+
<Route path="/projects/:urn/head" let:params>
+
  <View {config} urn={params.urn} path="/" />
+
</Route>
+

<Route path="/projects/:urn" let:params>
-
  <View {config} urn={params.urn} commit={null} path="/" />
+
  <View {config} urn={params.urn} path="/" />
</Route>
modified src/base/projects/View.svelte
@@ -12,12 +12,20 @@
  };

  export let urn: string;
-
  export let commit: string | null;
+
  export let commit: string | null = null;
  export let config: Config;
  export let path: string;

  let project: State.Loading | proj.Info | null = null;

+
  const onSelect = ({ detail: path }: { detail: string }) => {
+
    if (commit) {
+
      navigate(`/projects/${urn}/${commit}/${path}`);
+
    } else {
+
      navigate(`/projects/${urn}/head/${path}`);
+
    }
+
  };
+

  onMount(async () => {
    project = State.Loading;
    project = await proj.getInfo(urn, config);
@@ -72,7 +80,7 @@
        commit {commit || project.head}
      </div>
    </header>
-
    <Browser {urn} commit={commit || project.head} {path} {config} />
+
    <Browser {urn} commit={commit || project.head} {path} {onSelect} {config} />
  {:else}
    <!-- Not found -->
  {/if}