git.sr.ht/gitsrht/templates/blob.html

117 lines
3.3 KiB
HTML

{% extends "repo-full.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 repohead %}
<style>
pre {
tab-size: {{editorconfig.tab_width()}}
}
</style>
{% endblock %}
{% block content %}
<div class="header-extension" style="margin-bottom: 0;">
<div class="blob container-fluid">
<span>
{{ utils.breadcrumb(ref, repo, path, entry, view, path_join, stat, pygit2, humanize) }}
</span>
{% if commit %}
<div class="commit">
<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 }}
</span>
</div>
<div class="clearfix"></div>
{% endif %}
</div>
</div>
{% if markdown %}
<div class="container-fluid markdown-nav">
<ul class="nav nav-tabs">
<li class="nav-item">
<a
class="nav-link {{"active" if not force_source else ""}}"
href="?view-rendered"
>View Rendered</a>
</li>
<li class="nav-item">
<a
class="nav-link {{"active" if force_source else ""}}"
href="?view-source"
>View Source</a>
</li>
</ul>
</div>
{% endif %}
{% if markdown and not force_source %}
<div class="container">
{% else %}
<div class="container-fluid code-viewport">
{% endif %}
{#
This row has some weird styles going on. This prevents the page from
scrolling horizontally
#}
<div class="row" style="margin-right: 0;">
{% if markdown and not force_source %}
<div class="col-md-10 offset-md-1" style="margin-top: 1rem">
{{ markdown }}
</div>
{% else %}
{% if not blob.is_binary %}
<div class="col-md-12 code-view">
<pre class="ruler"><span>{% for i in range(
editorconfig.max_line_length()) %} {% endfor %}</span></pre>
<pre class="lines">{% for line in data.splitlines() %}<a
href="#L{{loop.index}}"
id="L{{loop.index}}"
>{{loop.index}}</a>{% if not loop.last %}
{% endif %}{% endfor %}</pre>
{{ highlight_file(repo, ref, entry,
data, blob.id.hex, commit.id.hex) }}
</div>
{% else %}
<div class="col-md-12">
<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"
rel="nofollow"
>Download {{icon("caret-right")}}</a>
</p>
</div>
</div>
{% endif %}
{% endif %}
</div>
{% endblock %}
{% block scripts %}
<script src="/static/linelight.js"></script>
{% endblock %}