🐙 Templated web page generator for your git repositories
git clone https://github.com/m-col/gitja
Files | Refs | Readme | License

Commit 5a9057420818b8f976b25f7c87c6e63843ef5ff4
Parent: ea59d71188bc5b580c8262045a1297f21247b0cf
Author: mcol <mcol@posteo.net>
Date: 2021-11-30 23:22:01 +0000
Committer: mcol <mcol@posteo.net>
Committed: 2021-11-30 23:22:01 +0000

Complete base template

templates/base/template.html.include Modified

@@ -1,8 +1,4 @@
-{#-
-This file is being used as a base template by all other files.
-
-They just need to define a 'title' block and a 'body' block.
--#}
+{# This file is being used as a base template by all other files. #}
 
 <!doctype html>
 <html>
@@ -14,7 +10,28 @@
   </head>
 
   <body>
-  {% block body %}
-  {% endblock %}
+    {# This head only really applies to a specify repository, so the index page overrides it. #}
+    {% block head %}
+    <span id="back"><a href="{{ host }}">Back to index</a></span>
+    <h1>{{ name }}</h1>
+    <p><b>{{ description }}</b></p>
+    <p>
+    <span id="clone"><b>git clone <a href="{{ host }}/{{ name }}">{{ host }}/{{ name }}</a></b></span>
+    <div class="links">
+      <a href="{{ host }}/{{ name }}/index.html">Log</a> |
+      <a href="{{ host }}/{{ name }}/tree.html">Files</a> |
+      <a href="{{ host }}/{{ name }}/refs.html">Refs</a>
+      {% if readme %}
+      | <a href="{{ host }}/{{ name }}/file/{{ readme.href }}">{{ readme.path }}</a>
+      {% endif %}
+      {% if license %}
+      | <a href="{{ host }}/{{ name }}/file/{{ license.href }}">{{ license.path }}</a>
+      {% endif %}
+    </div>
+    </p>
+    {% endblock %}
+
+    {% block content %}
+    {% endblock %}
   </body>
 </html>

templates/base/style.css Modified

@@ -15,4 +15,9 @@
 
 html {
     font-size: 1em;
+    margin: 25px;
+}
+
+#clone {
+    float: right;
 }

templates/base/repo/tree.html Added

@@ -0,0 +1,23 @@
+{% extends "../template.html.include" %}
+
+{%- block title %}{{ name }} - Tree{% endblock -%}
+
+{% block content %}
+<table>
+  <thead>
+    <tr>
+      <td><b>Mode</b></td>
+      <td><b>Name</b></td>
+    </tr>
+  </thead>
+
+  <tbody>
+    {% for file in tree %}
+    <tr>
+      <td>{{ file.mode_symbolic }}</td>
+      <td><a href="{{ host }}/{{ name }}/file/{{ file.href }}">{{ file.path }}</a></td>
+    </tr>
+    {% endfor %}
+  </tbody>
+</table>
+{% endblock %}

templates/base/repo/refs.html Added

@@ -0,0 +1,49 @@
+{% extends "../template.html.include" %}
+
+{%- block title %}{{ name }} - Refs{% endblock -%}
+
+{% block content %}
+<h2>Branches</h2>
+<table>
+  <thead>
+    <tr>
+      <td><b>Name</b></td>
+      <td colspan="2"><b>Last commit</b></td>
+      <td><b>Author</b></td>
+    </tr>
+  </thead>
+  <tbody>
+    {% for branch in branches %}
+    <tr>
+      <td>{{ branch.name }}</td>
+      <td>{{ branch.authored[:16] }}</td>
+      <td>{{ branch.title }}</td>
+      <td>{{ branch.author }}</td>
+    </tr>
+    {% endfor %}
+  </tbody>
+</table>
+
+<br>
+
+<h2>Tags</h2>
+<table id="tags">
+  <thead>
+    <tr>
+      <td><b>Name</b></td>
+      <td colspan="2"><b>Last commit</b></td>
+      <td><b>Author</b></td>
+    </tr>
+  </thead>
+  <tbody>
+    {% for tag in tags %}
+    <tr>
+      <td>{{ tag.name }}</td>
+      <td>{{ tag.authored[:16] }}</td>
+      <td>{{ tag.title }}</td>
+      <td>{{ tag.author }}</td>
+    </tr>
+    {% endfor %}
+  </tbody>
+</table>
+{% endblock %}

templates/base/repo/index.html Added

@@ -0,0 +1,31 @@
+{% extends "../template.html.include" %}
+
+{%- block title %}{{ name }} - Log{% endblock -%}
+
+{% block content %}
+<table>
+  <thead>
+    <tr>
+      <td><b>Date</b></td>
+      <td><b>Commit message</b></td>
+      <td><b>Author</b></td>
+    </tr>
+  </thead>
+
+  <tbody>
+    {% for commit in commits[:50] %}
+    <tr>
+      <td>{{ commit.authored[:16] }}</td>
+      <td><a href="{{ host }}/{{ name }}/commit/{{ commit.id }}.html">{{ commit.title }}</a></td>
+      <td>{{ commit.author }}</td>
+    </tr>
+    {% endfor %}
+
+    {% if length(commits) > 50 %}
+    <tr>
+      <td colspan="3">More commits not shown.</td>
+    </tr>
+    {% endif %}
+  </tbody>
+</table>
+{% endblock %}

templates/base/repo/file.html Added

@@ -0,0 +1,33 @@
+{% extends "../template.html.include" %}
+
+{%- block title %}{{ name }} - {{ file }}{% endblock %}
+
+{%- block content %}
+<p>{{ file.mode_symbolic }} {{ file }}</p><hr>
+
+{% if file.is_directory %}
+<table>
+  <thead>
+    <tr>
+      <td><b>Mode</b></td>
+      <td><b>Name</b></td>
+    </tr>
+  </thead>
+
+  <tbody>
+    {% for child in file.contents %}
+    <tr>
+      <td>{{ child.mode_symbolic }}</td>
+      <td><a href="{{ host }}/{{ name }}/file/{{ child.href }}">{{ child.path }}</a></td>
+    </tr>
+    {% endfor %}
+  </tbody>
+</table>
+{% else %}
+  <pre>
+{% for line in split(file.contents, '\n') %}
+<a href="#l{{ loop.index }}" class="line" id="l{{ loop.index }}">{{ printf("%5v", loop.index) }}</a>  {{ line }}
+{% endfor %}
+{% endif %}
+</pre>
+{% endblock %}

templates/base/repo/commit.html Added

@@ -0,0 +1,15 @@
+{% extends "../template.html.include" %}
+
+{%- block title %}{{ name }} - {{ commit.title }}{% endblock %}
+
+{%- block content %}
+<pre><b>Commit</b> <a href="{{ host }}/{{ name }}/commit/{{ commit.id }}.html">{{ commit.id }}</a>
+<b>Parent:</b> <a href="{{ host }}/{{ name }}/commit/{{ commit.parent }}.html">{{ commit.parent }}</a>
+<b>Author:</b> {{ commit.author }} &lt;<a href="mailto:{{ commit.author_email }}">{{ commit.author_email }}</a>&gt;
+<b>Date:</b> {{ commit.authored }}
+<b>Committer:</b> {{ commit.committer }} &lt;<a href="mailto:{{ commit.committer_email }}">{{ commit.committer_email }}</a>&gt;
+<b>Committed:</b> {{ commit.committed }}
+
+{{ commit.message }}
+</pre>
+{% endblock %}

templates/base/index.html Modified

@@ -1 +1,40 @@
-TODO
+{% extends "template.html.include" %}
+
+{%- block title %}My git repositories{% endblock %}
+
+{%- block head %}
+<h1>My git repositories</h1>
+
+<p>
+This is the base template for <code>gitserve</code>.
+</p>
+
+<p>
+The full documentation for <code>gitserve</code>, including how templates need
+to be organised and what variables are available within them, see <a
+href="https://gitserve.mcol.xyz">https://gitserve.mcol.xyz</a>.
+</p>
+{% endblock %}
+
+{%- block content %}
+<table>
+  <thead>
+    <tr>
+      <td><b>Name</b></td>
+      <td><b>Description</b></td>
+      <td colspan="2"><b>Last commit</b></td>
+    </tr>
+  </thead>
+
+  <tbody>
+    {% for repo in repositories %}
+    <tr>
+      <td><a href="{{ host }}/{{ repo.name }}">{{ repo.name }}</a></td>
+      <td>{{ repo.description }}</td>
+      <td>{{ repo.updated[:16] }}</td>
+      <td>{{ repo.head.title }}</td>
+    </tr>
+    {% endfor %}
+  </tbody>
+</table>
+{% endblock %}