mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-07 05:55:51 +01:00
97 lines
3.4 KiB
HTML
97 lines
3.4 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.header("code", repository)
|
|
@tab(branch, repository, "files")
|
|
<div class="head">
|
|
<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){
|
|
<a class="btn" href="@url(repository)/edit/@encodeRefName(branch)/@pathList.mkString("/")">Edit</a>
|
|
}
|
|
<a class="btn" href="?raw=true">Raw</a>
|
|
<a class="btn" href="@url(repository)/commits/@encodeRefName(branch)/@pathList.mkString("/")">History</a>
|
|
@if(hasWritePermission){
|
|
<a class="btn 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))) {
|
|
@renderMarkup(pathList, content.content.get, branch, repository, false, false)
|
|
} 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();
|
|
});
|
|
|
|
/**
|
|
* 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> |