summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-10-01 17:26:18 -0400
committerDrew DeVault <sir@cmpwn.com>2018-10-01 17:26:18 -0400
commit0d3a9e2533658d84c77ce6f68f7968e11f1c09f0 (patch)
tree3be573d5e4c0c3e685db500ad239de0c153b04b6
parent0c2a72230bdbaf7e0d8b527ebe49ae6505c9815d (diff)
Polish
-rw-r--r--gitsrht/app.py5
-rw-r--r--gitsrht/templates/blob.html49
-rw-r--r--gitsrht/templates/commit.html7
-rw-r--r--gitsrht/templates/log.html7
-rw-r--r--gitsrht/templates/refs.html5
-rw-r--r--gitsrht/templates/summary.html7
-rw-r--r--gitsrht/templates/tree.html11
-rw-r--r--gitsrht/templates/utils.html15
8 files changed, 73 insertions, 33 deletions
diff --git a/gitsrht/app.py b/gitsrht/app.py
index 3f9fc90..f4c41bb 100644
--- a/gitsrht/app.py
+++ b/gitsrht/app.py
@@ -2,6 +2,7 @@ import humanize
import stat
import os
from flask import session
+from functools import lru_cache
from srht.flask import SrhtFlask
from srht.config import cfg
from srht.database import DbSession
@@ -15,6 +16,9 @@ db.init()
import gitsrht.oauth
from gitsrht.git import commit_time, trim_commit
+def lookup_user(email):
+ return User.query.filter(User.email == email).one_or_none()
+
class GitApp(SrhtFlask):
def __init__(self):
super().__init__("git.sr.ht", __name__)
@@ -46,6 +50,7 @@ class GitApp(SrhtFlask):
"commit_time": commit_time,
"trim_commit": trim_commit,
"humanize": humanize,
+ "lookup_user": lookup_user,
"stat": stat,
"notice": notice,
"path_join": os.path.join
diff --git a/gitsrht/templates/blob.html b/gitsrht/templates/blob.html
index a530ead..fd03801 100644
--- a/gitsrht/templates/blob.html
+++ b/gitsrht/templates/blob.html
@@ -1,5 +1,8 @@
{% extends "repo.html" %}
{% import "utils.html" as utils %}
+{% block title %}
+<title>{{repo.owner.canonical_name}}/{{repo.name}}: {{path_join(*path)}} - {{cfg("sr.ht", "site-name")}} git</title>
+{% endblock %}
{% block content %}
<style>
pre {
@@ -34,8 +37,19 @@ pre, body {
</span>
{% if commit %}
<div class="pull-right">
- <a href="#">{{commit.id.hex[:8]}}</a> &mdash;
- <a href="#">{{commit.author.name}}</a>:
+ <a
+ href="{{url_for("repo.commit",
+ owner=repo.owner.canonical_name,
+ repo=repo.name,
+ ref=ref)}}"
+ >{{commit.id.hex[:8]}}</a> &mdash;
+ {% set author_user = lookup_user(commit.author.email) %}
+ {% if author_user %}
+ <a href="{{url_for("public.user_index",
+ username=author_user.username)}}">{{commit.author.name}}</a>
+ {% else %}
+ {{commit.author.name}}
+ {% endif %}
{{trim_commit(commit.message)}}
<span class="text-muted">
{{ commit_time(commit) | date }}
@@ -59,20 +73,23 @@ pre, body {
</div>
{% else %}
<div class="col-md-12">
- <p>
- <span title="{{ blob.size }} bytes">
- {{humanize.naturalsize(blob.size,
- binary=True).replace("Byte", "byte")}}
- </span>
- binary file not shown.
- </p>
- <p>
- <a href="{{url_for("repo.raw_blob", owner=repo.owner.canonical_name,
- repo=repo.name, branch=branch_name,
- path=path_join(*path))}}" class="btn btn-primary">
- Download {{icon("caret-right")}}
- </a>
- </p>
+ <div style="padding: 1rem">
+ <p>
+ <span title="{{ blob.size }} bytes">
+ {{humanize.naturalsize(blob.size,
+ binary=True).replace("Byte", "byte")}}
+ </span>
+ binary file not shown.
+ </p>
+ <p>
+ <a href="{{url_for("repo.raw_blob",
+ owner=repo.owner.canonical_name,
+ repo=repo.name, ref=ref,
+ path=path_join(*path))}}" class="btn btn-primary">
+ Download {{icon("caret-right")}}
+ </a>
+ </p>
+ </div>
</div>
{% endif %}
</div>
diff --git a/gitsrht/templates/commit.html b/gitsrht/templates/commit.html
index ebf4531..0e81410 100644
--- a/gitsrht/templates/commit.html
+++ b/gitsrht/templates/commit.html
@@ -1,5 +1,5 @@
{% extends "repo.html" %}
-{% import "utils.html" as utils %}
+{% import "utils.html" as utils with context %}
{% block title %}
<title>{{repo.owner.canonical_name}}/{{repo.name}}: {{trim_commit(commit.message)}} - {{cfg("sr.ht", "site-name")}} git</title>
{% endblock %}
@@ -9,9 +9,8 @@
<div class="col-md-10">
<div class="event-list">
<div class="event">
- {{ utils.commit_event(repo, commit, commit_time, trim_commit,
- full_body=True, full_id=True, refs=refs, parents=True,
- any=any) }}
+ {{ utils.commit_event(repo, commit, full_body=True,
+ full_id=True, refs=refs, parents=True) }}
</div>
</div>
</div>
diff --git a/gitsrht/templates/log.html b/gitsrht/templates/log.html
index ae99229..f874a26 100644
--- a/gitsrht/templates/log.html
+++ b/gitsrht/templates/log.html
@@ -1,5 +1,8 @@
{% extends "repo.html" %}
-{% import "utils.html" as utils %}
+{% import "utils.html" as utils with context %}
+{% block title %}
+<title>{{repo.owner.canonical_name}}/{{repo.name}}: {{ref}} - {{cfg("sr.ht", "site-name")}} git</title>
+{% endblock %}
{% block content %}
<div class="container">
<div class="row">
@@ -7,7 +10,7 @@
<div class="event-list">
{% for c in commits[:-1] %}
<div class="event">
- {{ utils.commit_event(repo, c, commit_time, None, True, refs) }}
+ {{ utils.commit_event(repo, c, True, refs) }}
</div>
{% endfor %}
</div>
diff --git a/gitsrht/templates/refs.html b/gitsrht/templates/refs.html
index 2d9c1dc..a9f32a7 100644
--- a/gitsrht/templates/refs.html
+++ b/gitsrht/templates/refs.html
@@ -1,5 +1,5 @@
{% extends "repo.html" %}
-{% import "utils.html" as utils %}
+{% import "utils.html" as utils with context %}
{% block title %}
<title>{{repo.owner.canonical_name}}/{{repo.name}} refs - {{cfg("sr.ht", "site-name")}} git</title>
{% endblock %}
@@ -61,8 +61,7 @@
{% set branch = branch[1] %}
<div class="event">
{{name}}
- {{ utils.commit_event(repo, commit, commit_time,
- trim_commit, skip_body=True) }}
+ {{ utils.commit_event(repo, commit, skip_body=True) }}
<a
href="{{url_for("repo.tree",
owner=repo.owner.canonical_name,
diff --git a/gitsrht/templates/summary.html b/gitsrht/templates/summary.html
index 19a565d..aec08cc 100644
--- a/gitsrht/templates/summary.html
+++ b/gitsrht/templates/summary.html
@@ -1,5 +1,8 @@
{% extends "repo.html" %}
-{% import "utils.html" as utils %}
+{% import "utils.html" as utils with context %}
+{% block title %}
+<title>{{repo.owner.canonical_name}}/{{repo.name}} - {{cfg("sr.ht", "site-name")}} git</title>
+{% endblock %}
{% block content %}
{% if repo.description %}
<div class="header-extension">
@@ -14,7 +17,7 @@
<div class="event-list" style="margin-bottom: 0.5rem">
{% for c in commits %}
<div class="event">
- {{ utils.commit_event(repo, c, commit_time, trim_commit) }}
+ {{ utils.commit_event(repo, c) }}
</div>
{% endfor %}
</div>
diff --git a/gitsrht/templates/tree.html b/gitsrht/templates/tree.html
index dd36016..9d5d44e 100644
--- a/gitsrht/templates/tree.html
+++ b/gitsrht/templates/tree.html
@@ -1,5 +1,8 @@
{% extends "repo.html" %}
{% import "utils.html" as utils %}
+{% block title %}
+<title>{{repo.owner.canonical_name}}/{{repo.name}}: {{path_join(*path)}}/ - {{cfg("sr.ht", "site-name")}} git</title>
+{% endblock %}
{% block content %}
<div class="header-extension">
<div class="container-fluid">
@@ -13,7 +16,13 @@
repo=repo.name,
ref=ref)}}"
>{{commit.id.hex[:8]}}</a> &mdash;
- <a href="#">{{commit.author.name}}</a>:
+ {% set author_user = lookup_user(commit.author.email) %}
+ {% if author_user %}
+ <a href="{{url_for("public.user_index",
+ username=author_user.username)}}">{{commit.author.name}}</a>
+ {% else %}
+ {{commit.author.name}}
+ {% endif %}
{{trim_commit(commit.message)}}
<span class="text-muted">
{{ commit_time(commit) | date }}
diff --git a/gitsrht/templates/utils.html b/gitsrht/templates/utils.html
index fd25dd3..0e820db 100644
--- a/gitsrht/templates/utils.html
+++ b/gitsrht/templates/utils.html
@@ -17,10 +17,9 @@
endif %}{% endfor %}
{% endmacro %}
-{% macro commit_event(
- repo, c, commit_time, trim_commit,
- full_body=False, refs={}, full_id=False, parents=False,
- any=None, skip_body=False) %}
+{% macro commit_event(repo, c,
+ full_body=False, refs={}, full_id=False,
+ parents=False, skip_body=False) %}
<div>
{% if full_id %}
{{c.id.hex}}
@@ -32,7 +31,13 @@ endif %}{% endfor %}
>{{c.id.hex[:8]}}</a>
{% endif %}
&mdash;
- <a href="#">{{c.author.name}}</a>
+ {% set author_user = lookup_user(c.author.email) %}
+ {% if author_user %}
+ <a href="{{url_for("public.user_index",
+ username=author_user.username)}}">{{c.author.name}}</a>
+ {% else %}
+ {{c.author.name}}
+ {% endif %}
<a
id="log-{{c.id}}"
href="#log-{{c.id}}"