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

Commit d31373d1aa8533d495b83a91cdeae7a98d007d47
Parent: 96a6888759a485b3bfc588044a6db56270e442b4
Author: mcol <mcol@posteo.net>
Date: 2021-11-21 18:45:19 +0000
Committer: mcol <mcol@posteo.net>
Committed: 2021-11-21 18:45:19 +0000

Move template <head> into include file

templates/tree.html Modified

@@ -1,35 +1,27 @@
-<!doctype html>
-<html lang="en">
-  <head>
-    <meta charset="utf-8">
-    <meta http-equiv="x-ua-compatible" content="ie=edge">
-    <meta name="viewport" content="width=device-width, initial-scale=1">
-    <title>{{ name }} - Tree</title>
-    <link rel="stylesheet" type="text/css" href="{{ host }}/style.css" />
-    <link rel="icon" type="image/png" href="/favicon.png" />
-  </head>
+{% include "template.html.include" %}
 
-  <body>
-    {% include "repo-table-header.html.include" %}
+{% block title %}Tree{% endblock %}
 
-    <div id="content">
-      <table id="files">
-        <thead>
-          <tr>
-            <td><b>Mode</b></td>
-            <td><b>Name</b></td>
-          </tr>
-        </thead>
+{% block body %}
+{% include "repo-table-header.html.include" %}
 
-        <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>
-    </div>
-  </body>
-</html>
+<div id="content">
+	<table id="files">
+		<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>
+</div>
+{% endblock %}

templates/template.html.include Added

@@ -0,0 +1,15 @@
+<!doctype html>
+<html lang="en">
+  <head>
+    <meta charset="utf-8">
+    <meta http-equiv="x-ua-compatible" content="ie=edge">
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    <title>{{ name }} - {% block title %}{% endblock %}</title>
+    <link rel="stylesheet" type="text/css" href="{{ host }}/style.css"/>
+    <link rel="icon" type="image/png" href="/favicon.png"/>
+  </head>
+  <body>
+  {% block body %}
+  {% endblock %}
+  </body>
+</html>

templates/refs.html Modified

@@ -1,43 +1,35 @@
-<!doctype html>
-<html lang="en">
-  <head>
-    <meta charset="utf-8">
-    <meta http-equiv="x-ua-compatible" content="ie=edge">
-    <meta name="viewport" content="width=device-width, initial-scale=1">
-    <title>Refs - {{ name }} - {{ description }}</title>
-    <link rel="stylesheet" type="text/css" href="{{ host }}/style.css" />
-    <link rel="icon" type="image/png" href="/favicon.png" />
-  </head>
+{% include "template.html.include" %}
 
-  <body>
-    {% include  "repo-table-header.html.include" %}
+{% block title %}Refs{% endblock %}
 
-    <div id="content">
-      <h2>Branches</h2>
-      <table id="branches">
-        <thead>
-          <tr><td><b>Name</b></td><td><b>Last commit date</b></td><td><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 }}</td><td>{{ branch.title }}</td><td>{{ branch.author }}</td></tr>
-          {% endfor %}
-        </tbody>
-      </table>
+{% block body %}
+{% include  "repo-table-header.html.include" %}
 
-      <br>
+<div id="content">
+	<h2>Branches</h2>
+	<table id="branches">
+		<thead>
+			<tr><td><b>Name</b></td><td><b>Last commit date</b></td><td><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 }}</td><td>{{ branch.title }}</td><td>{{ branch.author }}</td></tr>
+			{% endfor %}
+		</tbody>
+	</table>
 
-      <h2>Tags</h2>
-      <table id="tags">
-        <thead>
-          <tr><td><b>Name</b></td><td><b>Last commit date</b></td><td><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 }}</td><td>{{ tag.title }}</td><td>{{ tag.author }}</td></tr>
-          {% endfor %}
-        </tbody>
-      </table>
-    </div>
-  </body>
-</html>
+	<br>
+
+	<h2>Tags</h2>
+	<table id="tags">
+		<thead>
+			<tr><td><b>Name</b></td><td><b>Last commit date</b></td><td><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 }}</td><td>{{ tag.title }}</td><td>{{ tag.author }}</td></tr>
+			{% endfor %}
+		</tbody>
+	</table>
+</div>
+{% endblock %}

templates/index.html Modified

@@ -1,33 +1,25 @@
-<!doctype html>
-<html lang="en">
-  <head>
-    <meta charset="utf-8">
-    <meta http-equiv="x-ua-compatible" content="ie=edge">
-    <meta name="viewport" content="width=device-width, initial-scale=1">
-    <title>{{ name }} - {{ description }}</title>
-    <link rel="stylesheet" type="text/css" href="{{ host }}/style.css" />
-    <link rel="icon" type="image/png" href="/favicon.png" />
-  </head>
+{% include "template.html.include" %}
 
-  <body>
-    {% include "repo-table-header.html.include" %}
+{% block title %}{{ description }}{% endblock %}
 
-    <div id="content">
-      <table id="log">
-        <thead>
-          <tr>
-            <td><b>Date</b></td>
-            <td><b>Commit message</b></td>
-            <td><b>Author</b></td>
-          </tr>
-        </thead>
+{% block body %}
+{% include "repo-table-header.html.include" %}
 
-        <tbody>
-          {% for commit in commits[:50] %}
-          <tr><td>{{ commit.authored[:16] }}</td><td><a href="commits/{{ commit.id }}.html">{{ commit.title }}</a></td><td>{{ commit.author }}</td></tr>
-          {% endfor %}
-        </tbody>
-      </table>
-    </div>
-  </body>
-</html>
+<div id="content">
+	<table id="log">
+		<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="commits/{{ commit.id }}.html">{{ commit.title }}</a></td><td>{{ commit.author }}</td></tr>
+			{% endfor %}
+		</tbody>
+	</table>
+</div>
+{% endblock %}

templates/index-main.html Modified

@@ -1,34 +1,26 @@
-<!doctype html>
-<html lang="en">
-  <head>
-    <meta charset="utf-8">
-    <meta http-equiv="x-ua-compatible" content="ie=edge">
-    <meta name="viewport" content="width=device-width, initial-scale=1">
-    <title>{{ host }} / code</title>
-    <link rel="stylesheet" type="text/css" href="{{ host }}/style.css" />
-    <link rel="icon" type="image/png" href="/favicon.png" />
-  </head>
+{% include "template.html.include" %}
 
-  <body>
-    <table id="head">
-			<tr><td width="32px" rowspan="2"><a href="{{ host }}"><img src="{{ host }}/avatar.png" id="avatar"/></a></td>
-				<td rowspan="2"><a href="{{ host }}">{{ host }}</a> / <a href="{{ host }}">code</a></td><td class="link"><a href="{{ host }}/posts.html">posts</a></td></tr><tr><td class="link"><a href="{{ host }}/about.html">about</a></td></tr>
-    </table>
+{% block title %}{% endblock %}
 
-    <hr>
+{% block body %}
+<table id="head">
+	<tr><td width="32px" rowspan="2"><a href="{{ host }}"><img src="{{ host }}/avatar.png" id="avatar"/></a></td>
+		<td rowspan="2"><a href="{{ host }}">{{ host }}</a> / <a href="{{ host }}">code</a></td><td class="link"><a href="{{ host }}/posts.html">posts</a></td></tr><tr><td class="link"><a href="{{ host }}/about.html">about</a></td></tr>
+</table>
 
-    <div id="content">
-      <table id="index">
-        <thead>
-					<tr><td><b>Name</b></td><td><b>Description</b></td><td><b>Last commit</b></td></tr>
-        </thead>
+<hr>
 
-        <tbody>
-          {% for repo in repositories %}
-          <tr><td><a href="{{ repo.name }}">{{ repo.name }}</a></td><td>{{ repo.description }}</td><td>{{ repo.updated }}</td></tr>
-          {% endfor %}
-        </tbody>
-      </table>
-    </div>
-  </body>
-</html>
+<div id="content">
+	<table id="index">
+		<thead>
+			<tr><td><b>Name</b></td><td><b>Description</b></td><td><b>Last commit</b></td></tr>
+		</thead>
+
+		<tbody>
+			{% for repo in repositories %}
+			<tr><td><a href="{{ repo.name }}">{{ repo.name }}</a></td><td>{{ repo.description }}</td><td>{{ repo.updated }}</td></tr>
+			{% endfor %}
+		</tbody>
+	</table>
+</div>
+{% endblock %}

templates/file.html Modified

@@ -1,47 +1,37 @@
-<!doctype html>
-<html lang="en">
-  <head>
-    <meta charset="utf-8">
-    <meta http-equiv="x-ua-compatible" content="ie=edge">
-    <meta name="viewport" content="width=device-width, initial-scale=1">
-    <title>{{ name }} - {{ file }}</title>
-    <link rel="stylesheet" type="text/css" href="{{ host }}/style.css"/>
-    <link rel="icon" type="image/png" href="/favicon.png"/>
-  </head>
+{% include "template.html.include" %}
 
-  <body>
-    {% include "repo-table-header.html.include" %}
+{% block title %}{{ file }}{% endblock %}
 
-    <div id="content">
-      <p>{{ file }} {{ file.mode_symbolic }}</p>
+{% block body %}
+{% include "repo-table-header.html.include" %}
 
-      <hr>
+<div id="content">
+	<p>{{ file }} {{ file.mode_symbolic }}</p><hr>
 
 {% if file.is_directory %}
-      <table id="files">
-        <thead>
-          <tr>
-            <td><b>Mode</b></td>
-            <td><b>Name</b></td>
-          </tr>
-        </thead>
+	<table id="files">
+		<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>
+		<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 id="blob">
+	<pre id="blob">
 {% for line in split(file.contents, '\n') %}
 <a href="#l{{ loop.index }}" class="line" id="l{{ loop.index }}">{{ printf("%7v", loop.index) }}</a> {{ line }}
 {% endfor %}
 {% endif %}
-      </pre>
-    </div>
-  </body>
-</html>
+	</pre>
+</div>
+{% endblock %}

templates/commit.html Modified

@@ -1,26 +1,18 @@
-<!doctype html>
-<html lang="en">
-  <head>
-    <meta charset="utf-8">
-    <meta http-equiv="x-ua-compatible" content="ie=edge">
-    <meta name="viewport" content="width=device-width, initial-scale=1">
-    <title>{{ name }} - {{ commit.title }}</title>
-    <link rel="stylesheet" type="text/css" href="{{ host }}/style.css" />
-    <link rel="icon" type="image/png" href="/favicon.png" />
-  </head>
+{% include "template.html.include" %}
 
-  <body>
-    {% include "repo-table-header.html.include" %}
+{% block title %}{{ commit.title }}{% endblock %}
 
-    <div id="content">
-      <pre><b>commit</b> <a href="{{ host }}/{{ name }}/commits/{{ commit.href }}">{{ commit.id }}</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 }}
+{% block body %}
+{% include "repo-table-header.html.include" %}
 
-      {{ commit.message }}
-      </pre>
-    </div>
-  </body>
-</html>
+<div id="content">
+	<pre><b>commit</b> <a href="{{ host }}/{{ name }}/commits/{{ commit.href }}">{{ commit.id }}</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>
+</div>
+{% endblock %}