~edwargix/git.sr.ht

0d3a9e2533658d84c77ce6f68f7968e11f1c09f0 — Drew DeVault 6 years ago 0c2a722
Polish
M gitsrht/app.py => gitsrht/app.py +5 -0
@@ 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

M gitsrht/templates/blob.html => gitsrht/templates/blob.html +33 -16
@@ 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>

M gitsrht/templates/commit.html => gitsrht/templates/commit.html +3 -4
@@ 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>

M gitsrht/templates/log.html => gitsrht/templates/log.html +5 -2
@@ 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>

M gitsrht/templates/refs.html => gitsrht/templates/refs.html +2 -3
@@ 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,

M gitsrht/templates/summary.html => gitsrht/templates/summary.html +5 -2
@@ 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>

M gitsrht/templates/tree.html => gitsrht/templates/tree.html +10 -1
@@ 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 }}

M gitsrht/templates/utils.html => gitsrht/templates/utils.html +10 -5
@@ 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}}"