git-arr/views/blob.html
Eric Sunshine 84d628c690 views/blob: suppress double-slash in page title
For blobs in subdirectories, the page title always includes a double
slash between the final directory component and the filename (for
example, "git >> repo >> branch >> doc//readme.txt"). This is unsightly.

git-arr:blob() ensures that the directory passed to views/blob always
has a trailing slash, so we can drop the slash inserted by views/blob
between the directory and the filename.

As a side-effect, this also changes the page title for blobs in the root
directory. Instead of "git >> repo >> branch >> /readme.txt", the title
becomes "git >> repo >> branch >> readme.txt", which is slightly more
aesthetically pleasing.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
2015-01-24 19:23:18 +00:00

89 lines
2.3 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
% if not dirname.raw:
% reltree = './'
% else:
% reltree = '../' * (len(dirname.split('/')) - 1)
% end
% relroot = reltree + '../' * (len(branch.split('/')) - 1)
<title>git &raquo; {{repo.name}} &raquo;
{{branch}} &raquo; {{dirname.unicode}}{{fname.unicode}}</title>
<link rel="stylesheet" type="text/css"
href="{{relroot}}../../../../../static/git-arr.css"/>
<link rel="stylesheet" type="text/css"
href="{{relroot}}../../../../../static/syntax.css"/>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
</head>
<body class="tree">
<h1><a href="{{relroot}}../../../../../">git</a> &raquo;
<a href="{{relroot}}../../../">{{repo.name}}</a> &raquo;
<a href="{{reltree}}../">{{branch}}</a> &raquo;
<a href="{{reltree}}">tree</a>
</h1>
<h3>
<a href="{{reltree}}">[{{branch}}]</a> /
% base = smstr(reltree)
% for c in dirname.split('/'):
% if not c.raw:
% continue
% end
<a href="{{base.url}}{{c.url}}/">{{c.unicode}}</a> /
% base += c + '/'
% end
<a href="">{{!fname.html}}</a>
</h3>
% if len(blob.raw_content) == 0:
<table class="nice">
<tr>
<td>empty &mdash; 0 bytes</td>
</tr>
</table>
% elif can_embed_image(repo, fname.unicode):
{{!embed_image_blob(fname.raw, blob.raw_content)}}
% elif is_binary(blob.raw_content):
<table class="nice blob-binary">
<tr>
<td colspan="4">
binary &mdash; {{'{:,}'.format(len(blob.raw_content))}} bytes
</td>
</tr>
% lim = 256
% for offset, hex1, hex2, text in hexdump(blob.raw_content[:lim]):
<tr>
<td class="offset">{{offset}}</td>
<td><pre>{{hex1}}</pre></td>
<td><pre>{{hex2}}</pre></td>
<td><pre>{{text}}</pre></td>
</tr>
% end
% if lim < len(blob.raw_content):
<tr class="etc">
<td></td>
<td>&hellip;</td>
<td>&hellip;</td>
<td>&hellip;</td>
</tr>
% end
</table>
% elif can_markdown(repo, fname.unicode):
{{!markdown_blob(blob.utf8_content)}}
% elif can_colorize(blob.utf8_content):
{{!colorize_blob(fname.unicode, blob.utf8_content)}}
% else:
<pre class="blob-body">
{{blob.utf8_content}}
</pre>
% end
<hr/>
</body>
</html>