index : gitrs
A lightweight web interface for browsing Git repositories, implemented in Rust
about summary refs log tree commit diff
author Yousef Al-Harbi <yo2w86@gmail.com> 2026-11-14 16:35:24 +0300
committer Yousef Al-Harbi <yo2w86@gmail.com> 2026-11-14 16:35:24 +0300
commit 3ba663a30f82405335bb0a3f52faf6cdc5cac31c [patch]
tree 85a299a684d16c4f411667eab9c6b9e5317a5899
parent 1c1f74a27b107df0aa031002980fdbf2749cb805
download 3ba663a30f82405335bb0a3f52faf6cdc5cac31c.tar.gz

UI Improvments

Diffstat

-rw-r--r-- src/time.rs 24
-rw-r--r-- static/style.css 298
-rw-r--r-- templates/base.html 5
-rw-r--r-- templates/repositorys.html 11
-rw-r--r-- src/routes/mod.rs 2
-rw-r--r-- templates/repository/commit.html 2
-rw-r--r-- templates/repository/refs.html 14
-rw-r--r-- templates/repository/summary.html 36
-rw-r--r-- src/routes/repository/diff.rs 1
 9 files changed, 258 insertions(+), 135 deletions(-)

diff --git a/src/time.rs b/src/time.rs
index 22f05d6..0eb01bc 100644
--- a/src/time.rs
+++ b/src/time.rs
@@ -68,18 +68,28 @@
    let days = diff.num_days();

    if secs < 120 {
        (format!("{} seconds", secs.max(0)), Recency::Fresh)
        (pluralize(secs.max(0), "second"), Recency::Fresh)
    } else if mins < 120 {
        (format!("{} minutes", mins), Recency::Fresh)
        (pluralize(mins, "minute"), Recency::Fresh)
    } else if hours < 48 {
        (format!("{} hours", hours), Recency::Fresh)
        (pluralize(hours, "hour"), Recency::Fresh)
    } else if days < 14 {
        (format!("{} days", days), Recency::Fresh)
        (pluralize(days, "day"), Recency::Fresh)
    } else if days < 30 {
        (pluralize(days / 7, "week"), Recency::Recent)
    } else if days < 60 {
        (format!("{} month", days / 30), Recency::Recent)
        (pluralize(days / 30, "month"), Recency::Recent)
    } else if days < 365 {
        (format!("{} months", days / 30), Recency::Stale)
        (pluralize(days / 30, "month"), Recency::Stale)
    } else {
        (format!("{} year", days / 365), Recency::Stale)
        (pluralize(days / 365, "year"), Recency::Stale)
    }
}

fn pluralize(count: i64, unit: &str) -> String {
    if count == 1 {
        format!("1 {unit}")
    } else {
        format!("{count} {unit}s")
    }
}
diff --git a/static/style.css b/static/style.css
index 1d4e71c..08cf526 100644
--- a/static/style.css
+++ b/static/style.css
@@ -45,38 +45,45 @@
}

/* ==========================================================================
   2. Base & Typography
   2. Base & Typography (Sharp Corners, Zero Border-Radius)
   ========================================================================== */
* {
*,
*::before,
*::after {
  box-sizing: border-box;
  border-radius: 0;
}

body {
  font-family: 'Maple Mono NF', monospace;
  font-size: 1rem;
  font-size: 0.95rem;
  line-height: 1.5;
  margin: 0;
  background: var(--base);
  color: var(--text);
}

div#body {
  padding: 2rem;
  padding: 1.5rem 2.5rem 3rem;
}

main {
  padding: 2rem;
  padding: 1.25rem 0 0;
  margin: 0 auto;
}

h1,
h2,
h3 {
h3,
h4 {
  color: var(--text);
  margin-top: 1.25rem;
  margin-bottom: 0.6rem;
}

a {
  color: var(--peach);
  padding: 5px;
  padding: 3px 6px;
  text-decoration: none;
}

@@ -85,25 +92,36 @@
a.active {
  color: var(--crust);
  background: var(--peach);
}

a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 1px solid var(--peach);
  outline-offset: 1px;
}

code {
  background: var(--black2);
  color: var(--green);
  padding: 2px 6px;
  border: 1px solid var(--surface0);
}

pre {
  color: var(--text);
  background: var(--surface0);
  border: 1px var(--surface1) solid;
  font-size: 14px;
  padding: 6px 10px;
  background: var(--black2);
  border: 1px solid var(--surface1);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.6rem 0.9rem;
  overflow-x: auto;
}

pre code {
  color: var(--text);
  background: var(--surface0);
  background: transparent;
  border: none;
  padding: 0;
}

@@ -113,21 +131,26 @@
table {
  border-collapse: collapse;
  width: 100%;
  overflow: hidden;
}

table.section-table {
  margin-bottom: 1.75rem;
}

th {
  text-align: left;
  white-space: nowrap;
  color: var(--peach);
  font-weight: 600;
  letter-spacing: 0.05em;
  letter-spacing: 0.04em;
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--surface1);
}

td {
  text-align: left;
  white-space: nowrap;
  padding: 0.75rem 1rem;
  padding: 0.6rem 0.9rem;
}

td a {
@@ -136,11 +159,16 @@

td.mode,
th.mode {
  width: 10ch;
  font-family: monospace;
  width: 11ch;
  font-family: inherit;
  white-space: nowrap;
  color: var(--subtext0);
}

th.mode {
  color: var(--peach);
}

tbody tr:nth-child(even) {
  background: var(--one_bg);
}
@@ -163,58 +191,110 @@
  text-align: right;
}

td.form form {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

td.form input,
td.form select {
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--text);
  background: var(--surface0);
  border: 1px solid var(--surface1);
  border-radius: 0;
  padding: 5px;
  padding: 0.3rem 0.55rem;
}

td.form input[type="submit"] {
  cursor: pointer;
  color: var(--subtext1);
  background: var(--one_bg2);
}

td.form input[type="submit"]:hover {
  color: var(--crust);
  background: var(--peach);
  border-color: var(--peach);
}

/* ==========================================================================
   4. Header & Navigation Tabs
   ========================================================================== */
table.header {
  padding: 0.5rem 2.5rem 0;
}

table.header tr,
table.header tr:nth-child(odd),
table.header tr:nth-child(even),
table.header tr:hover {
  background: transparent;
}

td.logo {
  width: 96px;
  vertical-align: top;
  width: 72px;
  vertical-align: middle;
  padding: 0.75rem 0.75rem 0.75rem 2rem;
}

td.logo a:hover {
  background: transparent;
}

td.logo img {
  width: 96px;
  height: 96px;
  width: 64px;
  height: 64px;
  display: block;
}

td.main {
  font-size: 200%;
  padding-left: 10px;
  font-size: 1.65rem;
  font-weight: 600;
  padding: 0.6rem 0.75rem 0.25rem;
  white-space: nowrap;
}

td.sub {
  color: var(--subtext0);
  border-top: solid 2px var(--surface1);
  padding-left: 10px;
  border-top: 1px solid var(--surface1);
  padding: 0.45rem 0.75rem;
  font-size: 0.9rem;
}

.tabs {
  margin-top: 2rem;
  background: var(--black2);
  border: 1px solid var(--surface0);
}

.tabs td {
  padding: 0.5rem 0.75rem;
}

.tabs a {
  color: var(--text);
  padding: 0.25rem 0.6rem;
  margin-right: 0.15rem;
}

.tree-breadcrumb {
  background: var(--black2);
  padding: 5px;
  background: var(--mantle);
  border: 1px solid var(--surface0);
  border-top: none;
  padding: 0.45rem 0.75rem;
  font-size: 0.9rem;
}

.show_more td,
td.show_more {
  padding: 0.45rem 0.6rem;
}

.show_more a,
.pagination a {
  color: var(--peach);
  font-size: 18px;
  font-size: 0.95rem;
}

.show_more a:hover,
@@ -223,9 +303,8 @@
}

.pagination {
  margin-top: 1rem;
  padding-top: 0.85rem;
  text-align: center;
  font-size: 20px;
}

/* ==========================================================================
@@ -237,11 +316,11 @@
}

.recent {
  color: var(--overlay1);
  color: var(--subtext0);
}

.stale {
  color: var(--surface2);
  color: var(--overlay0);
}

.description {
@@ -249,8 +328,9 @@
  font-style: italic;
}

.folder {
a.folder {
  color: var(--peach);
  font-weight: 600;
}

.clone-url {
@@ -262,22 +342,27 @@

.badge_head {
  background: var(--crust);
  color: var(--text);
  color: var(--red);
  border: 1px solid var(--red);
  padding: 2px 8px;
  padding: 1px 6px;
  margin-left: 0.35rem;
  font-size: 0.8rem;
}

.badge_branch {
  background: var(--crust);
  color: var(--text);
  color: var(--green);
  border: 1px solid var(--green);
  padding: 2px 8px;
  padding: 1px 6px;
  margin-left: 0.35rem;
  font-size: 0.8rem;
}

.badge_branch:hover,
.badge_head:hover {
  color: var(--peach);
  background: var(--crust);
  color: var(--crust);
  background: var(--peach);
  border-color: var(--peach);
}

.green {
@@ -288,10 +373,17 @@
  color: var(--red);
}

span.avatar {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin-right: 0.25rem;
}

span.avatar img.inline {
  width: 20px;
  height: 20px;
  vertical-align: top;
  width: 18px;
  height: 18px;
  border: 1px solid var(--surface1);
}

span.avatar img.onhover {
@@ -307,6 +399,7 @@
  position: absolute;
  margin-left: 1.5em;
  background-color: var(--crust);
  z-index: 10;
}

/* ==========================================================================
@@ -331,9 +424,10 @@
}

.commit-info {
  margin-top: 2rem;
  max-width: fit-content;
  background: transparent;
  margin-top: 0.5rem;
  width: auto;
  background: var(--black2);
  border: 1px solid var(--surface0);
}

.commit-info tr:nth-child(odd),
@@ -343,7 +437,11 @@
}

.commit-info td {
  padding: 0.20rem 1rem 0.20rem 0;
  padding: 0.3rem 1rem;
}

.commit-info td:first-child {
  color: var(--subtext0);
}

.commit-info a {
@@ -351,17 +449,22 @@
}

.commit-subject {
  padding: 1rem 0;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--surface0);
  margin-bottom: 1rem;
}

.commit-subject h1 {
  font-weight: bold;
  font-size: 120%;
  font-weight: 600;
  font-size: 1.15rem;
  margin: 0.25rem 0;
}

.commit-subject h4 {
  font-weight: bold;
  color: var(--overlay1);
  font-weight: normal;
  color: var(--subtext0);
  white-space: pre-wrap;
  margin: 0.5rem 0 0;
}

/* ==========================================================================
@@ -372,10 +475,11 @@
  align-items: center;
  gap: 1em;
  padding: 0.5em 0.8em;
  margin-bottom: 0.5em;
  background-color: var(--black2);
  border: 1px solid var(--surface1);
  font-family: monospace;
  margin-bottom: 0;
  background-color: var(--mantle);
  border: 1px solid var(--surface0);
  border-bottom: none;
  font-family: inherit;
  font-size: 0.9em;
}

@@ -399,29 +503,34 @@
.blob-table {
  width: 100%;
  border-collapse: collapse;
  font-family: monospace;
  font-family: inherit;
  background: var(--black2);
  border: 1px solid var(--surface0);
}

.blob-table tr:nth-child(odd),
.blob-table tr:nth-child(even),
.blob-table tr:hover {
.blob-table tr:nth-child(even) {
  background-color: transparent;
}

.blob-table tr:hover {
  background-color: var(--one_bg);
}

.blob-table .line-no {
  width: 4em;
  width: 4.5em;
  text-align: right;
  padding: 0 0.8em;
  padding: 0.05rem 0.75rem;
  color: var(--overlay0);
  user-select: none;
  border-right: 1px solid var(--surface1);
  border-right: 1px solid var(--surface0);
  vertical-align: top;
  white-space: nowrap;
}

.blob-table .line-content {
  width: 100%;
  padding: 0 0.8em;
  padding: 0.05rem 0.85rem;
  color: var(--text);
}

@@ -438,14 +547,16 @@
   8. Diff & Diffstat
   ========================================================================== */
table.diffstat {
  background: var(--surface0);
  border: 1px var(--surface1) solid;
  max-width: 50%;
  background: var(--black2);
  border: 1px solid var(--surface0);
  width: auto;
  min-width: 50%;
  max-width: 100%;
  margin-bottom: 1rem;
}

table.diffstat td {
  padding: 0.2em 0.2em 0.1em 0.1em;
  padding: 0.3rem 0.65rem;
}

.diffstat tr,
@@ -461,6 +572,15 @@
  width: 1%;
}

.diffstat .right {
  text-align: right;
  color: var(--subtext0);
}

.diffstat .graph {
  min-width: 120px;
}

a.diffstat-added {
  color: var(--green);
}
@@ -481,28 +601,34 @@

.diffstat-addition {
  background: var(--green);
  height: 0.5rem;
  height: 0.45rem;
  padding: 0 !important;
}

.diffstat-deletion {
  background: var(--red);
  height: 0.5rem;
  height: 0.45rem;
  padding: 0 !important;
}

pre.diff {
  color: var(--text);
  background: none;
  border: none;
  font-size: 14px;
  padding: 0;
  background: var(--black2);
  border: 1px solid var(--surface0);
  font-size: 0.88rem;
  padding: 0.75rem 1rem;
  line-height: 1.45;
}

.diff-hunk {
  color: var(--blue);
  display: block;
  margin-top: 0.25rem;
}

.diff-file-header {
  font-weight: bold;
  font-weight: 600;
  color: var(--subtext1);
}

.diff-file-header > span > span {
@@ -510,7 +636,7 @@
}

.diff-addition {
  background: #2b3038;
  background: #243330;
  color: var(--green);
  display: block;
}
@@ -518,11 +644,11 @@
.diff-addition::before {
  content: '+ ';
  display: inline-block;
  color: #888;
  color: var(--overlay1);
}

.diff-deletion {
  background: #332839;
  background: #362432;
  color: var(--red);
  display: block;
}
@@ -530,25 +656,31 @@
.diff-deletion::before {
  content: '- ';
  display: inline-block;
  color: #888;
  color: var(--overlay1);
}

.diff-context::before {
  content: '  ';
  display: inline-block;
  color: #888;
  color: var(--overlay1);
}

/* ==========================================================================
   9. Markdown & Readme
   ========================================================================== */
.readme {
  background: var(--black2);
  border: 1px solid var(--surface0);
  padding: 1.25rem 1.75rem;
}

.readme h1,
.readme h2,
.readme h3,
.readme h4,
.readme h5,
.readme h6 {
  margin-bottom: 1rem;
  margin-bottom: 0.75rem;
}

.readme h1,
@@ -558,7 +690,7 @@
}

.readme p {
  font-size: 14px;
  font-size: 0.92rem;
  color: var(--subtext1);
}

diff --git a/templates/base.html b/templates/base.html
index f04c92b..3bff0a4 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -1,15 +1,16 @@
{%- import "macros.html" as macros -%}

<!DOCTYPE html>
<html>
<html lang="en">
  <head>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <title>{% block title %}rsgit{% endblock %}</title>
      <link rel="stylesheet" href="/static/style.css">
      <link rel="shortcut icon" href="/static/favicon.ico">
  </head>
  <body>
      <table class="header blob-table">
      <table class="header">
        <tbody>
          {% block header %}{% endblock %}
        </tbody>
diff --git a/templates/repositorys.html b/templates/repositorys.html
index 9909a26..0646bf8 100644
--- a/templates/repositorys.html
+++ b/templates/repositorys.html
@@ -42,16 +42,7 @@
              {% let gix_repo = repo.gix() %}
              {% if let Some(last_commit) = repo.last_commit(gix_repo)? %}
                {% let time = last_commit.time.format_relative() %}
                <span class="
                {% match time.1 %}
                  {% when Recency::Fresh %}fresh
                  {% when Recency::Recent %}recent
                  {% when Recency::Stale %}stale
                {% endmatch %}
                "
                title="{{ last_commit.time.format() }}">
                  {{ time.0 }}
                </span>
                <span class="{{ time.1 }}" title="{{ last_commit.time.format() }}">{{ time.0 }}</span>
              {% else %}
                <span class="stale">Unknown</span>
              {% endif %}
diff --git a/src/routes/mod.rs b/src/routes/mod.rs
index bba66f6..0c6a5f9 100644
--- a/src/routes/mod.rs
+++ b/src/routes/mod.rs
@@ -1,6 +1,6 @@
use serde::Deserialize;

use crate::{prelude::*, time::Recency};
use crate::prelude::*;

pub mod about;
pub mod git;
diff --git a/templates/repository/commit.html b/templates/repository/commit.html
index 403db25..a199fc9 100644
--- a/templates/repository/commit.html
+++ b/templates/repository/commit.html
@@ -32,7 +32,7 @@
      </tr>
      <tr>
        <td>tree</td>
        <td colspan="2"><a href="/{{ repo.name }}/commit/?id={{ commit.id }}">{{ commit.id }}</a></td>
        <td colspan="2"><a href="/{{ repo.name }}/tree/?id={{ commit.id }}">{{ commit.tree_id }}</a></td>
      </tr>
      {% for parent in commit.parents %}
        <tr>
diff --git a/templates/repository/refs.html b/templates/repository/refs.html
index a57e361..8b43cd8 100644
--- a/templates/repository/refs.html
+++ b/templates/repository/refs.html
@@ -11,13 +11,15 @@
{% endblock %}

{% block content %}
  <table>
    {% if !branches.is_empty() %}
  {% if !branches.is_empty() %}
    <table class="section-table">
      {{ macros::branches(branches, branches_has_more, has_prev, page, mode) }}
    {% endif %}
    </table>
  {% endif %}

    {% if !tags.is_empty() %}
  {% if !tags.is_empty() %}
    <table class="section-table">
      {{ macros::tags(tags, tags_has_more, has_prev, page, mode) }}
    {% endif %}
  </table>
    </table>
  {% endif %}
{% endblock %}
diff --git a/templates/repository/summary.html b/templates/repository/summary.html
index 23203a7..96b013c 100644
--- a/templates/repository/summary.html
+++ b/templates/repository/summary.html
@@ -11,38 +11,24 @@
{% endblock %}

{% block content %}
<table>
  {% if !branches.is_empty() %}
    {{ macros::branches(branches, branches_has_more, false, page, "") }}
    <table class="section-table">
      {{ macros::branches(branches, branches_has_more, false, page, "") }}
    </table>
  {% endif %}

  <tbody>
    <tr class="no-background">
        <td></td>
        <td></td>
        <td></td>
        <td></td>
    </tr>
  </tbody>

  {% if !tags.is_empty() %}
    {{ macros::tags(tags, tags_has_more, false, page, "") }}
    <table class="section-table">
      {{ macros::tags(tags, tags_has_more, false, page, "") }}
    </table>
  {% endif %}

  <tbody>
    <tr class="no-background">
        <td></td>
        <td></td>
        <td></td>
        <td></td>
    </tr>
  </tbody>

  {% if !commits.is_empty() %}
    {{ macros::commits(commits, commits_has_more, false, page, "") }}
    <table class="section-table">
      {{ macros::commits(commits, commits_has_more, false, page, "") }}
    </table>
  {% endif %}
</table>

<h3>Clone</h3>
<pre>https://git.y2w8.online/{{ repo.name }}</pre>
  <h3>Clone</h3>
  <pre>https://git.y2w8.online/{{ repo.name }}</pre>
{% endblock %}
diff --git a/src/routes/repository/diff.rs b/src/routes/repository/diff.rs
index 41e1a59..b8da47f 100644
--- a/src/routes/repository/diff.rs
+++ b/src/routes/repository/diff.rs
@@ -26,6 +26,7 @@
    data: web::Data<App>,
) -> Result<HttpResponse, Error> {
    let (name, file_path) = path.into_inner();
    let file_path = file_path.filter(|p| !p.is_empty());
    let repo = data.get_repo(&name)?;
    let gix_repo = repo.gix();