Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Add project stats
Alexis Sellier committed 4 years ago
commit 77c1d0abefd7919647d14ac51737cdb76a387010
parent 15545fdee8c849eb8c8584fbac25fb7ec81974be
2 files changed +38 -16
modified src/base/projects/Browser.svelte
@@ -30,33 +30,37 @@

<style>
  main > header {
+
    font-size: 0.75rem;
    padding: 0 8rem;
    margin-bottom: 2rem;
    display: flex;
+
    align-items: center;
+
    justify-content: left;
+

+
  }
+
  main > header > * {
+
    margin-right: 0.75rem;
+
    border-radius: 0.25rem;
+
    min-width: max-content;
  }
+

  .commit {
    display: inline-block;
-
    font-size: 0.75rem;
    font-family: var(--font-family-monospace);
    color: var(--color-secondary);
    background-color: var(--color-secondary-background);
    padding: 0.75rem;
-
    border-radius: 0.25rem;
-
    min-width: max-content;
  }

  .anchor {
    display: flex;
-
    margin-left: 0.75rem;
-
    min-width: max-content;
  }
  .anchor-widget {
    display: flex;
    padding: 0.75rem;
+
    border-radius: 0.25rem;
    color: var(--color-tertiary);
    background-color: var(--color-tertiary-background);
-
    font-size: 0.75rem;
-
    border-radius: 0.25rem;
  }
  .anchor-widget.not-anchored {
    color: var(--color-foreground-faded);
@@ -70,6 +74,12 @@
    margin-right: 0;
  }

+
  .stat {
+
    font-family: var(--font-family-monospace);
+
    padding: 0.75rem;
+
    background: var(--color-foreground-background);
+
  }
+

  .center-content {
    margin: 0 auto;
    max-width: var(--content-max-width);
@@ -124,6 +134,12 @@
      <div class="commit">
        commit {commit}
      </div>
+
      <div class="stat">
+
        <strong>{tree.stats.commits}</strong> commits
+
      </div>
+
      <div class="stat">
+
        <strong>{tree.stats.contributors}</strong> contributors
+
      </div>
      <div class="anchor">
        {#if org}
          {#await getAnchor}
modified src/project.ts
@@ -21,6 +21,18 @@ export interface Meta {
  maintainers: Urn[];
}

+
export interface Tree {
+
  path: string;
+
  info: EntryInfo;
+
  entries: Array<Entry>;
+
  stats: Stats;
+
}
+

+
export interface Stats {
+
  commits: number;
+
  contributors: number;
+
}
+

export interface Author {
  avatar: string;
  email: string;
@@ -41,7 +53,7 @@ export interface CommitHeader {
  summary: string;
}

-
export interface Info {
+
export interface EntryInfo {
  name: string;
  objectType: ObjectType;
  lastCommit: CommitHeader;
@@ -49,7 +61,7 @@ export interface Info {

export interface Entry {
  path: string;
-
  info: Info;
+
  info: EntryInfo;
}

export interface Blob {
@@ -60,12 +72,6 @@ export interface Blob {
  info: Info;
}

-
export interface Tree {
-
  entries: Entry[];
-
  info: Info;
-
  path: string;
-
}
-

export async function getInfo(urn: string, config: Config): Promise<Info> {
  return api.get(`projects/${urn}`, {}, config);
}
@@ -75,7 +81,7 @@ export async function getTree(
  commit: string,
  path: string,
  config: Config
-
): Promise<any> {
+
): Promise<Tree> {
  if (path === "/") {
    path = "";
  }