🏡 index : ~doyle/rgit.git

author Jordan Doyle <jordan@doyle.la> 2022-07-31 17:34:02.0 +01:00:00
committer Jordan Doyle <jordan@doyle.la> 2022-07-31 17:34:02.0 +01:00:00
commit
acb7861cdadd24baa3d072b53f81344270b161f0 [patch]
tree
fe2fd32df8f6fdbb4923349e9d325eea1f7c0578
parent
3c0bec03d9b2f0dce6e8980bf224ff695995d3d4
download
acb7861cdadd24baa3d072b53f81344270b161f0.tar.gz

Clean-up rendered HTML



Diff

 templates/base.html             |  17 ++++++++++-------
 templates/index.html            |  76 +++++++++++++++++++++++++++++++++++++++++++++-------------------------------
 templates/repo/about.html       |  30 ++++++++++++++++--------------
 templates/repo/base.html        |   6 +++---
 templates/repo/commit.html      |  12 ++++++------
 templates/repo/diff.html        |  10 +++++-----
 templates/repo/file.html        |   8 ++++----
 templates/repo/log.html         |   2 +-
 templates/repo/refs.html        |  24 ++++++++++++------------
 templates/repo/summary.html     |  18 +++++++++---------
 templates/repo/tree.html        |  31 +++++++++++++++++--------------
 templates/repo/macros/refs.html | 166 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------
 12 files changed, 202 insertions(+), 198 deletions(-)

diff --git a/templates/base.html b/templates/base.html
index ff93441..3efe698 100644
--- a/templates/base.html
+++ a/templates/base.html
@@ -1,30 +1,33 @@
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width">
    <title>{% block title %}rgit{% endblock %}</title>
    {% block head %}{% endblock %}

    <link rel="stylesheet" type="text/css" href="/style.css" />
    {%- block head -%}{%- endblock %}
</head>

<body>
<header>
    <h1><a href="/" class="no-hover">🏡</a> {% block header %}Git repository browser{% endblock %}</h1>
    <h1>
        <a href="/" class="no-hover">🏡</a>
        {% block header -%}Git repository browser{%- endblock %}
    </h1>
</header>

{% block nav %}
{%- block nav -%}
<nav>
    <a href="/" class="active">index</a>
</nav>
{% endblock %}
{%- endblock -%}

<main>
    {% block content %}{% endblock %}
    {%- block content %}{% endblock -%}
</main>

<footer>
    generated by <a href="https://github.com/w4/rgit" target="_blank">rgit</a> v{{ crate::CRATE_VERSION }} at {{ time::OffsetDateTime::now_utc().to_string() }}
</footer>
</body>
</html>
</html>
diff --git a/templates/index.html b/templates/index.html
index a0f4c6f..2544395 100644
--- a/templates/index.html
+++ a/templates/index.html
@@ -12,44 +12,44 @@
        </thead>

        <tbody>
        {% for (path, repositories) in repositories.iter() %}
            {% if let Some(path) = path %}
                <tr><td class="repo-section" colspan="4">{{ path }}</td></tr>
            {% endif %}
        {%- for (path, repositories) in repositories.iter() %}
            {%- if let Some(path) = path %}
            <tr><td class="repo-section" colspan="4">{{ path }}</td></tr>
            {%- endif -%}

            {%for repository in repositories %}
                <tr class="{% if path.is_some() %}has-parent{% endif %}">
                    <td>
                        <a href="/{% if let Some(path) = path %}{{ path }}/{% endif %}{{ repository.name }}">
                            {{ repository.name }}
                        </a>
                    </td>
                    <td>
                        <a href="/{% if let Some(path) = path %}{{ path }}/{% endif %}{{ repository.name }}">
                            {% if let Some(description) = repository.description %}
                                {{ description }}
                            {% else %}
                                Unnamed repository; edit this file 'description' to name the repository.
                            {% endif %}
                        </a>
                    </td>
                    <td>
                        <a href="/{% if let Some(path) = path %}{{ path }}/{% endif %}{{ repository.name }}">
                            {% if let Some(owner) = repository.owner %}
                                {{ owner }}
                            {% endif %}
                        </a>
                    </td>
                    <td>
                        <a href="/{% if let Some(path) = path %}{{ path }}/{% endif %}{{ repository.name }}">
                            <time datetime="{{ repository.last_modified }}" title="{{ repository.last_modified }}">
                                {{ repository.last_modified.clone()|timeago }}
                            </time>
                        </a>
                    </td>
                </tr>
            {% endfor %}
        {% endfor %}
            {%- for repository in repositories %}
            <tr class="{% if path.is_some() %}has-parent{% endif %}">
                <td>
                    <a href="/{% if let Some(path) = path %}{{ path }}/{% endif %}{{ repository.name }}">
                        {{- repository.name -}}
                    </a>
                </td>
                <td>
                    <a href="/{% if let Some(path) = path %}{{ path }}/{% endif %}{{ repository.name }}">
                        {%- if let Some(description) = repository.description -%}
                            {{- description -}}
                        {%- else -%}
                            Unnamed repository; edit this file 'description' to name the repository.
                        {%- endif -%}
                    </a>
                </td>
                <td>
                    <a href="/{% if let Some(path) = path %}{{ path }}/{% endif %}{{ repository.name }}">
                        {%- if let Some(owner) = repository.owner -%}
                            {{- owner -}}
                        {%- endif -%}
                    </a>
                </td>
                <td>
                    <a href="/{% if let Some(path) = path %}{{ path }}/{% endif %}{{ repository.name }}">
                        <time datetime="{{ repository.last_modified }}" title="{{ repository.last_modified }}">
                            {{- repository.last_modified.clone()|timeago -}}
                        </time>
                    </a>
                </td>
            </tr>
            {%- endfor -%}
        {%- endfor %}
        </tbody>
    </table>
{% endblock %}
{% endblock %}
diff --git a/templates/repo/about.html b/templates/repo/about.html
index 29ae116..c0e8565 100644
--- a/templates/repo/about.html
+++ a/templates/repo/about.html
@@ -1,25 +1,25 @@
{% extends "repo/base.html" %}

{% block head %}
{% if let Some(readme) = readme %}
    {% if readme.0 == crate::git::ReadmeFormat::Markdown %}
        <link rel="stylesheet" type="text/css" href="/highlight.css" />
        <link rel="stylesheet" type="text/css" href="/highlight-dark.css" />
    {% endif %}
{% endif %}
{% block head -%}
{%- if let Some(readme) = readme -%}
    {%- if readme.0 == crate::git::ReadmeFormat::Markdown %}
    <link rel="stylesheet" type="text/css" href="/highlight.css" />
    <link rel="stylesheet" type="text/css" href="/highlight-dark.css" />
    {%- endif -%}
{%- endif -%}
{% endblock %}

{% block about_nav_class %}active{% endblock %}

{% block content %}
{% if let Some(readme) = readme %}
    {% match readme.0 %}
        {% when crate::git::ReadmeFormat::Markdown %}
{% if let Some(readme) = readme -%}
    {%- match readme.0 -%}
        {%- when crate::git::ReadmeFormat::Markdown -%}
            {{ readme.1|safe }}
        {% when crate::git::ReadmeFormat::Plaintext %}
        {%- when crate::git::ReadmeFormat::Plaintext -%}
            <pre>{{ readme.1 }}</pre>
    {% endmatch %}
{% else %}
    {%- endmatch -%}
{%- else -%}
    No README in repository HEAD.
{% endif %}
{% endblock %}
{%- endif %}
{% endblock %}
diff --git a/templates/repo/base.html b/templates/repo/base.html
index 5a0a087..b4b58dc 100644
--- a/templates/repo/base.html
+++ a/templates/repo/base.html
@@ -1,10 +1,10 @@
{% extends "../base.html" %}

{% block title %}{{ repo.display() }}{% endblock %}

{% block header %}
<a href="/" class="no-style">index</a> : {{ repo.display() }}
{% endblock %}
{%- block header -%}
    <a href="/" class="no-style">index</a> : {{ repo.display() }}
{%- endblock -%}

{% block nav %}
<nav>
diff --git a/templates/repo/commit.html b/templates/repo/commit.html
index 113d8df..15097ea 100644
--- a/templates/repo/commit.html
+++ a/templates/repo/commit.html
@@ -1,9 +1,9 @@
{% extends "repo/base.html" %}

{% block head %}
<link rel="stylesheet" type="text/css" href="/highlight.css" />
<link rel="stylesheet" type="text/css" href="/highlight-dark.css" />
{% endblock %}
    <link rel="stylesheet" type="text/css" href="/highlight.css" />
    <link rel="stylesheet" type="text/css" href="/highlight-dark.css" />
{%- endblock %}

{% block commit_nav_class %}active{% endblock %}

@@ -28,12 +28,12 @@
        <th>tree</th>
        <td colspan="2"><pre><a href="/{{ repo.display() }}/tree?id={{ commit.tree() }}" class="no-style">{{ commit.tree() }}</a></pre></td>
    </tr>
    {% for parent in commit.parents() %}
    {%- for parent in commit.parents() %}
    <tr>
        <th>parent</th>
        <td colspan="2"><pre><a href="/{{ repo.display() }}/commit?id={{ parent }}" class="no-style">{{ parent }}</a></pre></td>
    </tr>
    {% endfor %}
    {%- endfor %}
    </tbody>
</table>

@@ -43,4 +43,4 @@
<h3>Diff</h3>
<pre class="diff">{{ commit.diff_stats|safe }}
{{ commit.diff|safe }}</pre>
{% endblock %}
{% endblock %}
diff --git a/templates/repo/diff.html b/templates/repo/diff.html
index 958b234..42fd90d 100644
--- a/templates/repo/diff.html
+++ a/templates/repo/diff.html
@@ -1,9 +1,9 @@
{% extends "repo/base.html" %}

{% block head %}
<link rel="stylesheet" type="text/css" href="/highlight.css" />
<link rel="stylesheet" type="text/css" href="/highlight-dark.css" />
{% endblock %}
{%- block head %}
    <link rel="stylesheet" type="text/css" href="/highlight.css" />
    <link rel="stylesheet" type="text/css" href="/highlight-dark.css" />
{%- endblock -%}

{% block diff_nav_class %}active{% endblock %}

@@ -11,4 +11,4 @@
<h2>Diff</h2>
<pre class="diff">{{ commit.diff_stats|safe }}
{{ commit.diff|safe }}</pre>
{% endblock %}
{% endblock %}
diff --git a/templates/repo/file.html b/templates/repo/file.html
index 9684a69..b933f81 100644
--- a/templates/repo/file.html
+++ a/templates/repo/file.html
@@ -1,12 +1,12 @@
{% extends "repo/base.html" %}

{% block head %}
<link rel="stylesheet" type="text/css" href="/highlight.css" />
<link rel="stylesheet" type="text/css" href="/highlight-dark.css" />
{% endblock %}
    <link rel="stylesheet" type="text/css" href="/highlight.css" />
    <link rel="stylesheet" type="text/css" href="/highlight-dark.css" />
{%- endblock %}

{% block tree_nav_class %}active{% endblock %}

{% block content %}
<pre>{{ file.content|safe }}</pre>
{% endblock %}
{% endblock %}
diff --git a/templates/repo/log.html b/templates/repo/log.html
index e96eb5c..af7bf23 100644
--- a/templates/repo/log.html
+++ a/templates/repo/log.html
@@ -17,4 +17,4 @@
    {% endif %}
</div>
{% endif %}
{% endblock %}
{% endblock %}
diff --git a/templates/repo/refs.html b/templates/repo/refs.html
index dc887e9..af93432 100644
--- a/templates/repo/refs.html
+++ a/templates/repo/refs.html
@@ -7,17 +7,17 @@
<table class="repositories">
    {% call refs::branch_table(refs.heads) %}

    {% if !refs.tags.is_empty() %}
        <tbody>
        <tr class="separator">
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        </tbody>
    {%- if !refs.tags.is_empty() %}
    <tbody>
    <tr class="separator">
        <td></td>
        <td></td>
        <td></td>
        <td></td>
    </tr>
    </tbody>

        {% call refs::tag_table(refs.tags) %}
    {% endif %}
    {%- call refs::tag_table(refs.tags) -%}
    {%- endif %}
</table>
{% endblock %}
{% endblock %}
diff --git a/templates/repo/summary.html b/templates/repo/summary.html
index adbde6b..1d0b7d0 100644
--- a/templates/repo/summary.html
+++ a/templates/repo/summary.html
@@ -6,7 +6,7 @@
{% block content %}
<table class="repositories">
    {% call refs::branch_table(refs.heads.iter().take(10)) %}
    {% if refs.heads.len() > 10 %}
    {%- if refs.heads.len() > 10 -%}
    <tbody>
    <tr class="no-background">
        <td><a href="/{{ repo.display() }}/refs" class="no-style">[...]</a></td>
@@ -15,9 +15,9 @@
        <td></td>
    </tr>
    </tbody>
    {% endif %}
    {%- endif -%}

    {% if !refs.tags.is_empty() %}
    {%- if !refs.tags.is_empty() -%}
        <tbody>
        <tr class="separator">
            <td></td>
@@ -27,8 +27,8 @@
        </tr>
        </tbody>

        {% call refs::tag_table(refs.tags.iter().take(10)) %}
        {% if refs.tags.len() > 10 %}
        {%- call refs::tag_table(refs.tags.iter().take(10)) -%}
        {%- if refs.tags.len() > 10 -%}
        <tbody>
        <tr class="no-background">
            <td><a href="/{{ repo.display() }}/refs" class="no-style">[...]</a></td>
@@ -37,8 +37,8 @@
            <td></td>
        </tr>
        </tbody>
        {% endif %}
    {% endif %}
        {%- endif -%}
    {%- endif %}

    <tbody>
    <tr class="separator">
@@ -59,6 +59,6 @@
        <td></td>
    </tr>
    </tbody>
    {% endif %}
    {%- endif %}
</table>
{% endblock %}
{% endblock %}
diff --git a/templates/repo/tree.html b/templates/repo/tree.html
index 3c8ff7a..7ca5e15 100644
--- a/templates/repo/tree.html
+++ a/templates/repo/tree.html
@@ -13,22 +13,23 @@
    </thead>

    <tbody>
    {% for item in items %}
    {% for item in items -%}
    <tr>
        {% match item %}
            {% when crate::git::TreeItem::Tree with (tree) %}
                <td><pre>{{ tree.mode|file_perms }}</pre></td>
                <td><pre><a class="nested-tree" href="/{{ repo.display() }}/tree/{{ tree.path.display() }}{{ query }}">{{ tree.name }}</a></pre></td>
                <td></td>
                <td></td>
            {% when crate::git::TreeItem::File with (file) %}
                <td><pre>{{ file.mode|file_perms }}</pre></td>
                <td><pre><a href="/{{ repo.display() }}/tree/{{ file.path.display() }}{{ query }}">{{ file.name }}</a></pre></td>
                <td><pre>{{ file.size }}</pre></td>
                <td></td>
        {% endmatch %}
        {% match item -%}
        {%- when crate::git::TreeItem::Tree with (tree) -%}
        <td><pre>{{ tree.mode|file_perms }}</pre></td>
        <td><pre><a class="nested-tree" href="/{{ repo.display() }}/tree/{{ tree.path.display() }}{{ query }}">{{ tree.name }}</a></pre></td>
        <td></td>
        <td></td>

        {%- when crate::git::TreeItem::File with (file) -%}
        <td><pre>{{ file.mode|file_perms }}</pre></td>
        <td><pre><a href="/{{ repo.display() }}/tree/{{ file.path.display() }}{{ query }}">{{ file.name }}</a></pre></td>
        <td><pre>{{ file.size }}</pre></td>
        <td></td>
        {%- endmatch %}
    </tr>
    {% endfor %}
    {% endfor -%}
    </tbody>
</table>
{% endblock %}
{% endblock %}
diff --git a/templates/repo/macros/refs.html b/templates/repo/macros/refs.html
index 5ae7403..926eabf 100644
--- a/templates/repo/macros/refs.html
+++ a/templates/repo/macros/refs.html
@@ -1,88 +1,88 @@
{% macro branch_table(branches) %}
<thead>
<tr>
    <th>Branch</th>
    <th>Commit message</th>
    <th>Author</th>
    <th>Age</th>
</tr>
</thead>
{%- macro branch_table(branches) -%}
    <thead>
    <tr>
        <th>Branch</th>
        <th>Commit message</th>
        <th>Author</th>
        <th>Age</th>
    </tr>
    </thead>

<tbody>
{% for (name, commit) in branches %}
<tr>
    <td><a href="/{{ repo.display() }}/log/?h={{ name }}">{{ name }}</a></td>
    <td><a href="/{{ repo.display() }}/commit/?id={{ commit.get().hash|hex }}">{{ commit.get().summary }}</a></td>
    <td>
        <img src="https://www.gravatar.com/avatar/{{ commit.get().author.email|md5 }}?s=13&d=retro" width="13" height="13">
        {{ commit.get().author.name }}
    </td>
    <td>
        <time datetime="{{ commit.get().author.time }}" title="{{ commit.get().author.time }}">
            {{ commit.get().author.time|timeago }}
        </time>
    </td>
</tr>
{% endfor %}
</tbody>
{% endmacro %}
    <tbody>
    {% for (name, commit) in branches -%}
    <tr>
        <td><a href="/{{ repo.display() }}/log/?h={{ name }}">{{ name }}</a></td>
        <td><a href="/{{ repo.display() }}/commit/?id={{ commit.get().hash|hex }}">{{ commit.get().summary }}</a></td>
        <td>
            <img src="https://www.gravatar.com/avatar/{{ commit.get().author.email|md5 }}?s=13&d=retro" width="13" height="13">
            {{ commit.get().author.name }}
        </td>
        <td>
            <time datetime="{{ commit.get().author.time }}" title="{{ commit.get().author.time }}">
                {{- commit.get().author.time|timeago -}}
            </time>
        </td>
    </tr>
    {% endfor -%}
    </tbody>
{%- endmacro -%}

{% macro tag_table(tags) %}
<thead>
<tr class="no-background">
    <th>Tag</th>
    <th>Download</th>
    <th>Author</th>
    <th>Age</th>
</tr>
</thead>
{%- macro tag_table(tags) -%}
    <thead>
    <tr class="no-background">
        <th>Tag</th>
        <th>Download</th>
        <th>Author</th>
        <th>Age</th>
    </tr>
    </thead>

<tbody>
{% for (name, tag) in tags %}
<tr>
    <td><a href="/{{ repo.display() }}/tag/?h={{ name }}">{{ name }}</a></td>
    <td></td>
    <td>
        {% if let Some(tagger) = tag.get().tagger %}
        <img src="https://www.gravatar.com/avatar/{{ tagger.email|md5 }}?s=13&d=retro" width="13" height="13">
        {{ tagger.name }}
        {% endif %}
    </td>
    <td>
        {% if let Some(tagger) = tag.get().tagger %}
        <time datetime="{{ tagger.time }}" title="{{ tagger.time }}">
            {{ tagger.time|timeago }}
        </time>
        {% endif %}
    </td>
</tr>
{% endfor %}
</thead>
{% endmacro %}
    <tbody>
    {% for (name, tag) in tags -%}
    <tr>
        <td><a href="/{{ repo.display() }}/tag/?h={{ name }}">{{- name -}}</a></td>
        <td></td>
        <td>
            {% if let Some(tagger) = tag.get().tagger -%}
            <img src="https://www.gravatar.com/avatar/{{ tagger.email|md5 }}?s=13&d=retro" width="13" height="13">
            {{ tagger.name }}
            {%- endif %}
        </td>
        <td>
            {% if let Some(tagger) = tag.get().tagger -%}
            <time datetime="{{ tagger.time }}" title="{{ tagger.time }}">
                {{- tagger.time|timeago -}}
            </time>
            {%- endif %}
        </td>
    </tr>
    {% endfor -%}
    </tbody>
{%- endmacro -%}

{% macro commit_table(commits) %}
<thead>
<tr>
    <th>Age</th>
    <th>Commit message</th>
    <th>Author</th>
</tr>
</thead>
{%- macro commit_table(commits) -%}
    <thead>
    <tr>
        <th>Age</th>
        <th>Commit message</th>
        <th>Author</th>
    </tr>
    </thead>

<tbody>
{% for commit in commits %}
<tr>
    <td>
        <time datetime="{{ commit.committer.time }}" title="{{ commit.committer.time }}">
            {{ commit.committer.time.clone()|timeago }}
        </time>
    </td>
    <td><a href="/{{ repo.display() }}/commit/?id={{ commit.hash|hex }}">{{ commit.summary }}</a></td>
    <td>
        <img src="https://www.gravatar.com/avatar/{{ commit.author.email|md5 }}?s=13&d=retro" width="13" height="13">
        {{ commit.author.name }}
    </td>
</tr>
{% endfor %}
</tbody>
{% endmacro %}
    <tbody>
    {% for commit in commits -%}
    <tr>
        <td>
            <time datetime="{{ commit.committer.time }}" title="{{ commit.committer.time }}">
                {{- commit.committer.time.clone()|timeago -}}
            </time>
        </td>
        <td><a href="/{{ repo.display() }}/commit/?id={{ commit.hash|hex }}">{{ commit.summary }}</a></td>
        <td>
            <img src="https://www.gravatar.com/avatar/{{ commit.author.email|md5 }}?s=13&d=retro" width="13" height="13">
            {{ commit.author.name }}
        </td>
    </tr>
    {% endfor -%}
    </tbody>
{%- endmacro -%}