mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-10-30 18:15:59 +01:00
133 lines
4.9 KiB
HTML
133 lines
4.9 KiB
HTML
@(branch: String,
|
|
repository: service.RepositoryService.RepositoryInfo,
|
|
pathList: List[String],
|
|
content: util.JGitUtil.ContentInfo,
|
|
latestCommit: util.JGitUtil.CommitInfo,
|
|
hasWritePermission: Boolean)(implicit context: app.Context)
|
|
@import context._
|
|
@import view.helpers._
|
|
@html.main(s"${repository.owner}/${repository.name}", Some(repository)) {
|
|
@html.menu("code", repository){
|
|
<div class="head">
|
|
@helper.html.dropdown(
|
|
value = if(branch.length == 40) branch.substring(0, 10) else branch,
|
|
prefix = if(branch.length == 40) "tree" else if(repository.branchList.contains(branch)) "branch" else "tree",
|
|
mini = true
|
|
){
|
|
@repository.branchList.map { x =>
|
|
<li><a href="@url(repository)/blob/@encodeRefName(x)/@pathList.mkString("/")">@helper.html.checkicon(x == branch) @x</a></li>
|
|
}
|
|
}
|
|
<a href="@url(repository)/tree/@encodeRefName(branch)">@repository.name</a> /
|
|
@pathList.zipWithIndex.map { case (section, i) =>
|
|
@if(i == pathList.length - 1){
|
|
@section
|
|
} else {
|
|
<a href="@url(repository)/tree/@encodeRefName(branch)/@pathList.take(i + 1).mkString("/")">@section</a> /
|
|
}
|
|
}
|
|
</div>
|
|
|
|
<table class="table table-bordered">
|
|
<tr>
|
|
<th style="font-weight: normal;">
|
|
<div class="pull-left">
|
|
@avatar(latestCommit, 20)
|
|
@user(latestCommit.committer, latestCommit.mailAddress, "username strong")
|
|
<span class="muted">@datetime(latestCommit.time)</span>
|
|
<a href="@url(repository)/commit/@latestCommit.id" class="commit-message">@link(latestCommit.summary, repository)</a>
|
|
</div>
|
|
<div class="btn-group pull-right">
|
|
@if(hasWritePermission && content.viewType == "text"){
|
|
<a class="btn btn-mini" href="@url(repository)/edit/@encodeRefName(branch)/@pathList.mkString("/")">Edit</a>
|
|
}
|
|
<a class="btn btn-mini" href="?raw=true">Raw</a>
|
|
<a class="btn btn-mini" href="@url(repository)/commits/@encodeRefName(branch)/@pathList.mkString("/")">History</a>
|
|
@if(hasWritePermission){
|
|
<a class="btn btn-mini btn-danger" href="@url(repository)/remove/@encodeRefName(branch)/@pathList.mkString("/")">Delete</a>
|
|
}
|
|
</div>
|
|
</th>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
@if(content.viewType == "text"){
|
|
@defining(pathList.reverse.head) { file =>
|
|
@if(renderableSuffixes.find(suffix => file.toLowerCase.endsWith(suffix))) {
|
|
<div class="box-content markdown-body" style="border: none; padding-left: 16px; padding-right: 16px;">
|
|
@renderMarkup(pathList, content.content.get, branch, repository, false, false)
|
|
</div>
|
|
} else {
|
|
<pre class="prettyprint linenums blob">@content.content.get</pre>
|
|
}
|
|
}
|
|
}
|
|
@if(content.viewType == "image"){
|
|
<img src="?raw=true"/>
|
|
}
|
|
@if(content.viewType == "large" || content.viewType == "binary"){
|
|
<div style="text-align: center">
|
|
<a href="?raw=true">View Raw</a><br>
|
|
(Sorry about that, but we can't show files that are this big right now)
|
|
</div>
|
|
}
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
}
|
|
}
|
|
<script src="@assets/common/js/jquery.ba-hashchange.js"></script>
|
|
<script>
|
|
$(window).load(function(){
|
|
$(window).hashchange(function(){
|
|
updateHighlighting();
|
|
}).hashchange();
|
|
|
|
$('pre.prettyprint ol.linenums li').each(function(i, e){
|
|
var pre = $('pre.prettyprint');
|
|
pre.append($('<div class="source-line-num">')
|
|
.data('line', (i + 1))
|
|
.css({
|
|
cursor : 'pointer',
|
|
position: 'absolute',
|
|
top : $(e).position().top + 'px',
|
|
left : pre.position().left + 'px',
|
|
width : ($(e).position().left - pre.position().left) + 'px',
|
|
height : '16px'
|
|
}));
|
|
});
|
|
|
|
$('div.source-line-num').click(function(e){
|
|
var line = $(e.target).data('line');
|
|
var hash = location.hash;
|
|
if(e.shiftKey == true && hash.match(/#L\d+(-L\d+)?/)){
|
|
var lines = hash.split('-');
|
|
location.hash = lines[0] + '-L' + line;
|
|
} else {
|
|
location.hash = '#L' + line;
|
|
}
|
|
});
|
|
});
|
|
|
|
/**
|
|
* Hightlight lines which are specified by URL hash.
|
|
*/
|
|
function updateHighlighting(){
|
|
var hash = location.hash;
|
|
if(hash.match(/#L\d+(-L\d+)?/)){
|
|
$('li.highlight').removeClass('highlight');
|
|
var lines = hash.substr(1).split('-');
|
|
if(lines.length == 1){
|
|
$('#' + lines[0]).addClass('highlight');
|
|
$(window).scrollTop($('#' + lines[0]).offset().top - 40);
|
|
} else if(lines.length > 1){
|
|
var start = parseInt(lines[0].substr(1));
|
|
var end = parseInt(lines[1].substr(1));
|
|
for(var i = start; i <= end; i++){
|
|
$('#L' + i).addClass('highlight');
|
|
}
|
|
$(window).scrollTop($('#L' + start).offset().top - 40);
|
|
}
|
|
}
|
|
}
|
|
</script> |