mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-02 19:45:57 +01:00
123 lines
4.4 KiB
HTML
123 lines
4.4 KiB
HTML
@(diffs: Seq[util.JGitUtil.DiffInfo],
|
|
repository: service.RepositoryService.RepositoryInfo,
|
|
newCommitId: Option[String],
|
|
oldCommitId: Option[String],
|
|
showIndex: Boolean)(implicit context: app.Context)
|
|
@import context._
|
|
@import view.helpers._
|
|
@import org.eclipse.jgit.diff.DiffEntry.ChangeType
|
|
@if(showIndex){
|
|
<div>
|
|
<div class="pull-right" style="margin-bottom: 10px;">
|
|
<div class="btn-group" data-toggle="buttons-radio">
|
|
<input type="button" id="btn-unified" class="btn btn-default btn-small active" value="Unified">
|
|
<input type="button" id="btn-split" class="btn btn-default btn-small" value="Split">
|
|
</div>
|
|
</div>
|
|
Showing <a href="javascript:void(0);" id="toggle-file-list">@diffs.size changed @plural(diffs.size, "file")</a>
|
|
</div>
|
|
<ul id="commit-file-list" style="display: none;">
|
|
@diffs.zipWithIndex.map { case (diff, i) =>
|
|
<li@if(i > 0){ class="border"}>
|
|
<a href="#diff-@i">
|
|
@if(diff.changeType == ChangeType.COPY || diff.changeType == ChangeType.RENAME){
|
|
<img src="@assets/common/images/diff_move.png"/> @diff.oldPath -> @diff.newPath
|
|
}
|
|
@if(diff.changeType == ChangeType.ADD){
|
|
<img src="@assets/common/images/diff_add.png"/> @diff.newPath
|
|
}
|
|
@if(diff.changeType == ChangeType.MODIFY){
|
|
<img src="@assets/common/images/diff_edit.png"/> @diff.newPath
|
|
}
|
|
@if(diff.changeType == ChangeType.DELETE){
|
|
<img src="@assets/common/images/diff_delete.png"/> @diff.oldPath
|
|
}
|
|
</a>
|
|
</li>
|
|
}
|
|
</ul>
|
|
}
|
|
@diffs.zipWithIndex.map { case (diff, i) =>
|
|
<a name="diff-@i"></a>
|
|
<table class="table table-bordered">
|
|
<tr>
|
|
<th style="font-weight: normal; line-height: 27px;" class="box-header">
|
|
@if(diff.changeType == ChangeType.COPY || diff.changeType == ChangeType.RENAME){
|
|
@diff.oldPath -> @diff.newPath
|
|
@if(newCommitId.isDefined){
|
|
<div class="pull-right align-right">
|
|
<a href="@url(repository)/blob/@newCommitId.get/@diff.newPath" class="btn btn-small">View file @@ @newCommitId.get.substring(0, 10)</a>
|
|
</div>
|
|
}
|
|
}
|
|
@if(diff.changeType == ChangeType.ADD || diff.changeType == ChangeType.MODIFY){
|
|
@diff.newPath
|
|
@if(newCommitId.isDefined){
|
|
<div class="pull-right align-right">
|
|
<a href="@url(repository)/blob/@newCommitId.get/@diff.newPath" class="btn btn-small">View file @@ @newCommitId.get.substring(0, 10)</a>
|
|
</div>
|
|
}
|
|
}
|
|
@if(diff.changeType == ChangeType.DELETE){
|
|
@diff.oldPath
|
|
@if(oldCommitId.isDefined){
|
|
<div class="pull-right align-right">
|
|
<a href="@url(repository)/blob/@oldCommitId.get/@diff.oldPath" class="btn btn-small">View file @@ @oldCommitId.get.substring(0, 10)</a>
|
|
</div>
|
|
}
|
|
}
|
|
</th>
|
|
</tr>
|
|
<tr>
|
|
<td style="padding: 0;">
|
|
@if(diff.newContent != None || diff.oldContent != None){
|
|
<div id="diffText-@i"></div>
|
|
<textarea id="newText-@i" style="display: none;">@diff.newContent.getOrElse("")</textarea>
|
|
<textarea id="oldText-@i" style="display: none;">@diff.oldContent.getOrElse("")</textarea>
|
|
} else {
|
|
Not supported
|
|
}
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
}
|
|
<script type="text/javascript" src="@assets/vendors/jsdifflib/difflib.js"></script>
|
|
<script type="text/javascript" src="@assets/vendors/jsdifflib/diffview.js"></script>
|
|
<link href="@assets/vendors/jsdifflib/diffview.css" type="text/css" rel="stylesheet" />
|
|
<script>
|
|
$(function(){
|
|
@if(showIndex){
|
|
$('#toggle-file-list').click(function(){
|
|
$('#commit-file-list').toggle();
|
|
if($(this).val() == 'Show file list'){
|
|
$(this).val('Hide file list');
|
|
} else {
|
|
$(this).val('Show file list');
|
|
}
|
|
});
|
|
}
|
|
|
|
// Render diffs as unified mode initially
|
|
renderDiffs(1);
|
|
|
|
$('#btn-unified').click(function(){
|
|
$('.container-wide').removeClass('container-wide').addClass('container');
|
|
renderDiffs(1);
|
|
});
|
|
|
|
$('#btn-split').click(function(){
|
|
$('.container').removeClass('container').addClass('container-wide');
|
|
renderDiffs(0);
|
|
});
|
|
|
|
function renderDiffs(viewType){
|
|
@diffs.zipWithIndex.map { case (diff, i) =>
|
|
@if(diff.newContent != None || diff.oldContent != None){
|
|
if($('#oldText-@i').length > 0){
|
|
diffUsingJS('oldText-@i', 'newText-@i', 'diffText-@i', viewType);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
</script> |