git-arr/views/branch.html
Eric Sunshine 93b161c23e views: fix broken URLs involving hierarchical branch names
Git branch names can be hierarchical (for example, "wip/parser/fix"),
however, git-arr does not take this into account when formulating URLs
on branch, tree, and blobs pages. These URLs are dysfunctional because
it is assumed incorrectly that a single "../" is sufficient to climb
over the branch name when computing relative paths to resources higher
in the hierarchy. This problem manifests as failure to load static
resources (stylesheet, etc.), broken links to commits on branch pages,
and malfunctioning breadcrumb trails.

Fix this problem by computing the the proper number of "../" based upon
the branch name, rather than assuming that a single "../" will work
unconditionally. (This is analogous to the treatment already given to
hierarchical pathnames in tree and blob views.)

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

51 lines
1.4 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>
% relroot = '../' * (len(repo.branch.split('/')) - 1)
<title>git &raquo; {{repo.name}} &raquo; {{repo.branch}}</title>
<link rel="stylesheet" type="text/css" href="{{relroot}}../../../../static/git-arr.css"/>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
</head>
<body class="branch">
<h1><a href="{{relroot}}../../../../">git</a> &raquo;
<a href="{{relroot}}../../">{{repo.name}}</a> &raquo;
<a href="./">{{repo.branch}}</a>
</h1>
<p>
<a class="explicit" href="t/">Browse current source tree</a>
</p>
% commits = repo.commits("refs/heads/" + repo.branch,
% limit = repo.info.commits_per_page + 1,
% offset = repo.info.commits_per_page * offset)
% commits = list(commits)
% if len(commits) == 0:
% abort(404, "No more commits")
% end
% more = len(commits) > repo.info.commits_per_page
% if more:
% commits = commits[:-1]
% end
% more = more and offset + 1 < repo.info.max_pages
% include paginate more = more, offset = offset
% kwargs = dict(repo=repo, commits=commits,
% shorten=shorten, repo_root=relroot + "../..")
% include commit-list **kwargs
<p/>
% include paginate more = more, offset = offset
</body>
</html>