Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Rename for clarity
Alexis Sellier committed 4 years ago
commit 8f467a3dbc1808a7d1ab854d8af7f9f664998073
parent c58db9d278982ddf7405c2a8a3f2c65f22431ad0
3 files changed +48 -48
modified src/base/projects/ProjectContentRoutes.svelte
@@ -3,7 +3,7 @@
  import type * as proj from "@app/project";
  import type { Config } from "@app/config";
  import { ProjectContent } from "@app/project";
-
  import RouteContext from "./RouteContext.svelte";
+
  import ProjectRoute from "./ProjectRoute.svelte";

  export let config: Config;
  export let source: proj.Source;
@@ -13,26 +13,26 @@
<Router>
  <!-- The default action is to render Browser with the default branch head -->
  <Route path="/">
-
    <RouteContext content={ProjectContent.Tree} {peer} {source} {config} />
+
    <ProjectRoute content={ProjectContent.Tree} {peer} {source} {config} />
  </Route>
  <Route path="/tree">
-
    <RouteContext content={ProjectContent.Tree} {peer} {source} {config} />
+
    <ProjectRoute content={ProjectContent.Tree} {peer} {source} {config} />
  </Route>
  <Route path="/tree/*" let:params>
-
    <RouteContext route={params["*"]} content={ProjectContent.Tree} {peer} {source} {config} />
+
    <ProjectRoute route={params["*"]} content={ProjectContent.Tree} {peer} {source} {config} />
  </Route>

  <Route path="/history">
-
    <RouteContext content={ProjectContent.History} {peer} {source} {config} />
+
    <ProjectRoute content={ProjectContent.History} {peer} {source} {config} />
  </Route>
  <Route path="/history/*" let:params>
-
    <RouteContext route={params["*"]} content={ProjectContent.History} {peer} {source} {config} />
+
    <ProjectRoute route={params["*"]} content={ProjectContent.History} {peer} {source} {config} />
  </Route>

  <Route path="/commits/:commit" let:params>
-
    <RouteContext revision={params.commit} content={ProjectContent.Commit} {peer} {source} {config} />
+
    <ProjectRoute revision={params.commit} content={ProjectContent.Commit} {peer} {source} {config} />
  </Route>
  <Route path="/commits/*" let:params>
-
    <RouteContext route={params["*"]} content={ProjectContent.Commit} {peer} {source} {config} />
+
    <ProjectRoute route={params["*"]} content={ProjectContent.Commit} {peer} {source} {config} />
  </Route>
</Router>
added src/base/projects/ProjectRoute.svelte
@@ -0,0 +1,40 @@
+
<script lang="ts">
+
  import type { Writable } from 'svelte/store';
+
  import type { Config } from "@app/config";
+
  import * as proj from '@app/project';
+

+
  import Project from './Project.svelte';
+

+
  export let browserStore: Writable<proj.Browser> = proj.browserStore;
+
  export let route: string | null = null;
+
  export let revision: string | null = null;
+
  export let peer: string | null;
+
  export let content: proj.ProjectContent = proj.ProjectContent.Tree;
+
  export let source: proj.Source;
+
  export let config: Config;
+

+
  const browse: any = { content, peer, path: "/" };
+
  const head = source.branches[source.project.defaultBranch];
+

+
  $: if (route) {
+
    const { path, revision } = proj.parseRoute(route, source.branches);
+

+
    if (path) browse.path = path;
+
    if (revision) browse.revision = revision;
+
  } else if (revision) {
+
    browse.revision = revision;
+
  } else {
+
    browse.revision = head;
+
  }
+

+
  $: proj.browse(browse);
+
  $: browser = $browserStore;
+
</script>
+

+
<Project
+
  peer={browser.peer}
+
  revision={browser.revision || head}
+
  content={browser.content}
+
  {source}
+
  {config}
+
/>
deleted src/base/projects/RouteContext.svelte
@@ -1,40 +0,0 @@
-
<script lang="ts">
-
  import type { Writable } from 'svelte/store';
-
  import type { Config } from "@app/config";
-
  import * as proj from '@app/project';
-

-
  import Project from './Project.svelte';
-

-
  export let browserStore: Writable<proj.Browser> = proj.browserStore;
-
  export let route: string | null = null;
-
  export let revision: string | null = null;
-
  export let peer: string | null;
-
  export let content: proj.ProjectContent = proj.ProjectContent.Tree;
-
  export let source: proj.Source;
-
  export let config: Config;
-

-
  const browse: any = { content, peer, path: "/" };
-
  const head = source.branches[source.project.defaultBranch];
-

-
  $: if (route) {
-
    const { path, revision } = proj.parseRoute(route, source.branches);
-

-
    if (path) browse.path = path;
-
    if (revision) browse.revision = revision;
-
  } else if (revision) {
-
    browse.revision = revision;
-
  } else {
-
    browse.revision = head;
-
  }
-

-
  $: proj.browse(browse);
-
  $: browser = $browserStore;
-
</script>
-

-
<Project
-
  peer={browser.peer}
-
  revision={browser.revision || head}
-
  content={browser.content}
-
  {source}
-
  {config}
-
/>