Diff between 48072f205905566bd62b7787a25641cfa61cd851 and 98a3e7f0a0d78f875b3f7cc4fc7f29eedddeb107

Changed Files

File Additions Deletions Status
app.py +3 -0 modified
static/cat.png +0 -0 added
static/styles.css +7 -0 added
templates/base.html +22 -0 added
templates/blame.html +2 -0 modified
templates/blob.html +2 -0 modified
templates/commit.html +2 -0 modified
templates/commits.html +28 -7 modified
templates/diff.html +2 -0 modified
templates/index.html +11 -2 modified
templates/refs.html +2 -0 modified
templates/repo.html +4 -4 modified
templates/tree.html +2 -0 modified

Full Patch

diff --git a/app.py b/app.py
index 2d7420a..e7438a4 100644
--- a/app.py
+++ b/app.py
@@ -16,6 +16,9 @@ load_dotenv()
 
 app = Flask(__name__)
 
+# for base.html
+app.jinja_env.globals['request'] = request
+
 repo_path = os.getenv('GIT_REPO_PATH')
 
 def datetime_filter(value, format='%Y-%m-%d %H:%M:%S'):
diff --git a/static/cat.png b/static/cat.png
new file mode 100644
index 0000000..055bd8e
Binary files /dev/null and b/static/cat.png differ
diff --git a/static/styles.css b/static/styles.css
new file mode 100644
index 0000000..349a245
--- /dev/null
+++ b/static/styles.css
@@ -0,0 +1,7 @@
+body {
+    margin: 20px;
+}
+table {
+    border-collapse: collapse;
+    width: 100%;
+}
\ No newline at end of file
diff --git a/templates/base.html b/templates/base.html
new file mode 100644
index 0000000..f9a642d
--- /dev/null
+++ b/templates/base.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Py GitWeb</title>
+    <link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
+</head>
+<body>
+    <nav>
+        <a href="/">Home</a>
+        {% set repo_name = request.view_args.get('repo_name') %}
+        {% if repo_name %}
+        <a href="{{ url_for('repo_commits', repo_name=repo_name) }}">Commits</a>
+        <a href="{{ url_for('repo_refs', repo_name=repo_name) }}">Refs</a>
+        <a href="{{ url_for('repo_tree_path', repo_name=repo_name) }}">Tree</a>
+        <a href="{{ url_for('repo_diff', repo_name=repo_name) }}">Diff</a>
+        {% endif %}
+    </nav>
+    {% block content %}{% endblock %}
+</body>
+</html>
\ No newline at end of file
diff --git a/templates/blame.html b/templates/blame.html
index 663eafe..52d7b63 100644
--- a/templates/blame.html
+++ b/templates/blame.html
@@ -1,3 +1,5 @@
+{% extends "base.html" %}
+
 {% block content %}
 <h1>Blame: {{ path }}</h1>
 {% if blame %}
diff --git a/templates/blob.html b/templates/blob.html
index f8cd857..f75c70d 100644
--- a/templates/blob.html
+++ b/templates/blob.html
@@ -1,3 +1,5 @@
+{% extends "base.html" %}
+
 {% block content %}
 <h1>Blob: {{ blob.name }}</h1>
 <p>Blob id: {{ blob.id }}</p>
diff --git a/templates/commit.html b/templates/commit.html
index 29d753a..ff17ef8 100644
--- a/templates/commit.html
+++ b/templates/commit.html
@@ -1,3 +1,5 @@
+{% extends "base.html" %}
+
 {% block content %}
     <h1>Commit {{ commit.id }}</h1>
     <p>Message: {{ commit.message }}</p>
diff --git a/templates/commits.html b/templates/commits.html
index 98ec25f..7c35fe8 100644
--- a/templates/commits.html
+++ b/templates/commits.html
@@ -1,13 +1,34 @@
+{% extends "base.html" %}
+
 {% block content %}
     <h1>Commits for {{ repo_name }}</h1>
     <p><a href="{{ url_for('repo_tree_path', repo_name=repo_name, path='') }}?ref={{ ref }}">View Tree</a></p>
-    <ul>
-        {% for commit in commits %}
-            <li>
-            <a href="{{ url_for('commit_detail', repo_name=repo_name, commit_id=commit.id) }}">{{ commit.id }}</a> - {{ commit.message }} - {{ commit.author.name }} - {{ commit.date | datetime }} {{ commit.diff_stats.files_changed }} files changed, {{ commit.diff_stats.insertions }} insertions, {{ commit.diff_stats.deletions }} deletions
-            </li>
-        {% endfor %}
-    </ul>
+    <table border="1">
+        <thead>
+            <tr>
+                <th>Commit</th>
+                <th>Message</th>
+                <th>Author</th>
+                <th>Date</th>
+                <th>Files Changed</th>
+                <th>Insertions</th>
+                <th>Deletions</th>
+            </tr>
+        </thead>
+        <tbody>
+            {% for commit in commits %}
+                <tr>
+                    <td><a href="{{ url_for('commit_detail', repo_name=repo_name, commit_id=commit.id) }}">{{ commit.id[:8] }}</a></td>
+                    <td>{{ commit.message }}</td>
+                    <td>{{ commit.author.name }}</td>
+                    <td>{{ commit.date | datetime }}</td>
+                    <td>{{ commit.diff_stats.files_changed }}</td>
+                    <td>{{ commit.diff_stats.insertions }}</td>
+                    <td>{{ commit.diff_stats.deletions }}</td>
+                </tr>
+            {% endfor %}
+        </tbody>
+    </table>
     <div>
         {% if has_prev %}
             <a href="{{ url_for('repo_commits', repo_name=repo_name, page=page-1, ref=ref) }}">Previous</a>
diff --git a/templates/diff.html b/templates/diff.html
index 88388b5..c23bb9c 100644
--- a/templates/diff.html
+++ b/templates/diff.html
@@ -1,3 +1,5 @@
+{% extends "base.html" %}
+
 {% block content %}
 <h1>Diff between {{ diff.ref1 }} ({{ diff.ref1_id[:7] }}) and {{ diff.ref2 }} ({{ diff.ref2_id[:7] }})</h1>
 
diff --git a/templates/index.html b/templates/index.html
index de7f94c..ad357a2 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -1,4 +1,12 @@
-{% block content %}
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Py GitWeb</title>
+    <link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
+</head>
+<body>
     <h1>Repositories</h1>
     <ul>
         {% for repo in repos %}
@@ -8,4 +16,5 @@
     <small>
         Libgit2 - {{ version }}  git 
     </small>
-{% endblock %}
\ No newline at end of file
+</body>
+</html>
\ No newline at end of file
diff --git a/templates/refs.html b/templates/refs.html
index 0741998..941a1a1 100644
--- a/templates/refs.html
+++ b/templates/refs.html
@@ -1,3 +1,5 @@
+{% extends "base.html" %}
+
 {% block content %}
     <h1>Refs for {{ repo_name }}</h1>
     <ul>
diff --git a/templates/repo.html b/templates/repo.html
index 1b3bfce..0c7dc84 100644
--- a/templates/repo.html
+++ b/templates/repo.html
@@ -1,6 +1,6 @@
+{% extends "base.html" %}
+
 {% block content %}
-<a href="{{ url_for('repo_commits', repo_name=repo_name) }}">Commits</a>
-<a href="{{ url_for('repo_refs', repo_name=repo_name) }}">Refs</a>
-<a href="{{ url_for('repo_tree_path', repo_name=repo_name) }}">Tree</a>
-<a href="{{ url_for('repo_diff', repo_name=repo_name) }}">Diff</a>
+<h1>Repository: {{ repo_name }}</h1>
+<img src="{{ url_for('static', filename='cat.png') }}" alt="cat">
 {% endblock %}
\ No newline at end of file
diff --git a/templates/tree.html b/templates/tree.html
index 9bee483..a9e94db 100644
--- a/templates/tree.html
+++ b/templates/tree.html
@@ -1,3 +1,5 @@
+{% extends "base.html" %}
+
 {% block content %}
     <h1>Tree for {{ repo_name }} at {{ ref }}{% if path %} / {{ path }}{% endif %}</h1>
     <ul>