diff options
author | Drew DeVault <sir@cmpwn.com> | 2019-07-06 13:43:15 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-07-06 13:56:30 -0400 |
commit | 452ebe908c35f7550373c314fc84ed0cf591121b (patch) | |
tree | c42931819c7f9f3d49aaaa2a95344f5709ba7ddd /gitsrht/blueprints/repo.py | |
parent | 6e92c7c3dbd7ef01e6638664fb7a207141a2e9b4 (diff) |
Implement annotations
Diffstat (limited to 'gitsrht/blueprints/repo.py')
-rw-r--r-- | gitsrht/blueprints/repo.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/gitsrht/blueprints/repo.py b/gitsrht/blueprints/repo.py index fe9e068..a12bf8e 100644 --- a/gitsrht/blueprints/repo.py +++ b/gitsrht/blueprints/repo.py @@ -1,13 +1,15 @@ import binascii +import json import os import pygit2 import pygments -import sys import subprocess +import sys from datetime import timedelta from jinja2 import Markup from flask import Blueprint, render_template, abort, send_file, request from flask import Response, url_for +from gitsrht.annotations import AnnotatedFormatter from gitsrht.editorconfig import EditorConfig from gitsrht.git import Repository as GitRepository, commit_time, annotate_tree from gitsrht.git import diffstat @@ -45,8 +47,14 @@ def get_readme(repo, tip, link_prefix=None): return get_formatted_readme("git.sr.ht:git", file_finder, content_getter, link_prefix=link_prefix) -def _highlight_file(name, data, blob_id): - return get_highlighted_file("git.sr.ht:git", name, blob_id, data) +def _highlight_file(repo, ref, name, data, blob_id): + annotations = redis.get(f"git.sr.ht:git:annotations:{blob_id}") + if annotations: + annotations = json.loads(annotations.decode()) + link_prefix = url_for( + 'repo.tree', owner=repo.owner, repo=repo.name, ref=ref) + return get_highlighted_file("git.sr.ht:git", name, blob_id, data, + formatter=AnnotatedFormatter(annotations, link_prefix)) def render_empty_repo(owner, repo): origin = cfg("git.sr.ht", "origin") |