From 0c2a72230bdbaf7e0d8b527ebe49ae6505c9815d Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Mon, 1 Oct 2018 17:14:14 -0400 Subject: [PATCH] Add annotated ref page --- gitsrht/blueprints/repo.py | 14 ++++++++++++ gitsrht/templates/commit.html | 30 ++++++++++++++------------ gitsrht/templates/ref.html | 40 +++++++++++++++++++++++++++++++++++ gitsrht/templates/refs.html | 5 ++++- gitsrht/templates/utils.html | 28 +++++++++++++----------- 5 files changed, 90 insertions(+), 27 deletions(-) create mode 100644 gitsrht/templates/ref.html diff --git a/gitsrht/blueprints/repo.py b/gitsrht/blueprints/repo.py index fa6ca54..3d8a712 100644 --- a/gitsrht/blueprints/repo.py +++ b/gitsrht/blueprints/repo.py @@ -372,3 +372,17 @@ def refs(owner, repo): owner=owner, repo=repo, tags=tags, branches=branches, git_repo=git_repo, isinstance=isinstance, pygit2=pygit2, page=page + 1, total_pages=total_pages) + +@repo.route("///refs/") +def ref(owner, repo, ref): + owner, repo = get_repo(owner, repo) + if not repo: + abort(404) + if not has_access(repo, UserAccess.read): + abort(401) + git_repo = CachedRepository(repo.path) + tag = git_repo.revparse_single(ref) + if not isinstance(tag, pygit2.Tag): + abort(404) + return render_template("ref.html", view="refs", + owner=owner, repo=repo, git_repo=git_repo, tag=tag) diff --git a/gitsrht/templates/commit.html b/gitsrht/templates/commit.html index 2e601e6..ebf4531 100644 --- a/gitsrht/templates/commit.html +++ b/gitsrht/templates/commit.html @@ -16,20 +16,22 @@
diff --git a/gitsrht/templates/ref.html b/gitsrht/templates/ref.html new file mode 100644 index 0000000..adf61d2 --- /dev/null +++ b/gitsrht/templates/ref.html @@ -0,0 +1,40 @@ +{% extends "repo.html" %} +{% import "utils.html" as utils %} +{% block title %} +{{repo.owner.canonical_name}}/{{repo.name}} {{tag.name}} - {{cfg("sr.ht", "site-name")}} git +{% endblock %} +{% block content %} +
+
+
+
+
+

+ {{tag.name}} + + {{commit_time(tag) | date}} + +

+ {% if tag.message %} +
{{tag.message}}
+ {% endif %} +
+
+
+ +
+
+{% endblock %} diff --git a/gitsrht/templates/refs.html b/gitsrht/templates/refs.html index 4a7c985..2d9c1dc 100644 --- a/gitsrht/templates/refs.html +++ b/gitsrht/templates/refs.html @@ -21,7 +21,10 @@ {% if isinstance(tag, pygit2.Commit) %} {{ref[len("refs/tags/"):]}} {% else %} - + {{tag.name}} {% endif %} diff --git a/gitsrht/templates/utils.html b/gitsrht/templates/utils.html index 1db0f80..fd25dd3 100644 --- a/gitsrht/templates/utils.html +++ b/gitsrht/templates/utils.html @@ -56,18 +56,22 @@ endif %}{% endfor %} {% endif %} {% if c.id.hex in refs %} - {% for ref in refs[c.id.hex] %} - {{ref.name}} + + {% for ref in refs[c.id.hex] %} + {{ref.name}} + {% endfor %} {% endif %}
-- 2.38.4