THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

test
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

268 lines
12 KiB

@**
* Yobi, Project Hosting SW
*
* Copyright 2012 NAVER Corp.
* http://yobi.io
*
* @Author Yi EungJun
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**@
@(project: Project, history: List[playRepository.Commit], page: Integer, selectedBranch: String, path:String)
@import utils.JodaDateUtil._
@import utils.TemplateHelper._
@import utils.TemplateHelper.Branches._
@import utils.Url
@import playRepository.RepositoryService
@import java.net.URLEncoder
@import org.joda.time.Duration
@import controllers.CodeApp
@getFilesURL = @{
if(selectedBranch){
routes.CodeApp.codeBrowserWithBranch(project.owner, project.name, URLEncoder.encode(selectedBranch, "UTF-8"), "")
} else {
routes.CodeApp.codeBrowserWithBranch(project.owner, project.name, "HEAD", "")
}
}
@getHistoryURL(path:String) = @{
if(selectedBranch){
routes.CodeHistoryApp.history(project.owner, project.name, URLEncoder.encode(selectedBranch, "UTF-8"), path)
} else {
routes.CodeHistoryApp.historyUntilHead(project.owner, project.name)
}
}
@getShowCommitURL(project:Project, commit:playRepository.Commit, path:String) = @{
if(selectedBranch){
var queryString = "?branch=" + URLEncoder.encode(selectedBranch, "UTF-8")
if(path != null) {
queryString += "&path=" + path + "#" + path.replace("/", "-").replace(".", "-")
}
routes.CodeHistoryApp.show(project.owner, project.name, commit.getId()) + queryString
} else {
routes.CodeHistoryApp.show(project.owner, project.name, commit.getId())
}
}
@getCorrectedPath(filePath:String, fileName:String) = @{
if((filePath != "") && (filePath.substring(filePath.length() - 1) == "/")){
filePath + fileName
} else {
filePath + "/" + fileName
}
}
@makeBreadCrumbs(pagePath:String) = @{
if(pagePath != null){
var basePath = routes.CodeHistoryApp.history(project.owner, project.name, URLEncoder.encode(selectedBranch, "UTF-8"), null).toString()
var partialPath = ""
pagePath.split("/").toList.map { p =>
if(partialPath == ""){
partialPath = p
} else {
partialPath = partialPath + "/" + p
}
Html("<a href=\"" + getCorrectedPath(basePath, partialPath) + "\">" + p + "</a>")
}
}
}
@isHistoryExistAndHasParent(history: List[playRepository.Commit]) = @{
(history.size > 0 && history.get(history.size - 1).getParentCount() > 0)
}
@projectLayout(Messages("title.commitHistory"), project, utils.MenuType.CODE) {
@projectMenu(project, utils.MenuType.CODE, "main-menu-only")
<div class="page-wrap-outer">
<div class="project-page-wrap">
<div class="bubble-wrap dark-gray repo-wrap">
<div class="code-browse-wrap">
@if(path != null){
<div id="breadcrumbs" class="code-breadcrumb-wrap">
<a href="@routes.CodeHistoryApp.history(project.owner, project.name, URLEncoder.encode(selectedBranch, "UTF-8"), "")">@project.name</a>
@makeBreadCrumbs(path)
</div>
}
@if(path == null){
<select id="branches" data-toggle="select2" data-format="branch" data-dropdown-css-class="branches" class="pull-right">
@defining(RepositoryService.getRepository(project).getBranchNames()) { branches =>
@for(branchName <- branches){
<option value="@routes.CodeHistoryApp.history(project.owner, project.name, URLEncoder.encode(branchName, "UTF-8"), null)"
@if(selectedBranch){ @if(branchItemName(branchName) == branchItemName(selectedBranch)){ selected } }>
@branchName
</option>
}
}
</select>
<ul class="nav nav-tabs" style="margin-bottom:20px;">
<li>
<a href="@getFilesURL">@Messages("code.files")</a>
</li>
<li class="active">
<a href="@getHistoryURL(path)">@Messages("code.commits")</a>
</li>
@if(project.isGit()) {
<li>
<a href="@routes.BranchApp.branches(project.owner, project.name)">@Messages("title.branches")</a>
</li>
}
</ul>
}
<div id="history" class="commit-wrap">
<table class="code-table commits@if(path != null){ mt10}">
<thead class="thead">
<tr>
<td class="commit-id"><strong>@{"@"}</strong></td>
<td class="messages"><strong>@Messages("code.commitMsg")</strong></td>
@if(path != null){
<td class="browse"></td>
}
<td class="date"><strong>@if(project.isGit) { @Messages("code.authorDate") } else { @Messages("code.commitDate") }</strong></td>
<td class="author"><strong>@Messages("code.author")</strong></td>
</tr>
</thead>
<tbody class="tbody">
@if(history.isEmpty()){
<tr><td colspan="5" class="warning-none">@Messages("code.nocommits")</td></tr>
}
@for(commit <- history.iterator) {
@defining(getShowCommitURL(project, commit, path)){ showCommitURL =>
<tr>
<td class="commit-id">
<button type="button" class="ybtn ybtn-mini btn-copy-commitId"
title="@Messages("code.copyCommitId")" data-commitId="@commit.getId()">
<i class="yobicon-copy"></i>
</button>
<a href="@showCommitURL" title="@Messages("code.showCommit")">
@commit.getShortId()
</a>
</td>
<td class="messages">
@defining(
if(project.isGit()) {
CommentThread.count(null, commit.getId, path)
} else {
CommitComment.count(project, commit.getId, path)
}){ numOfComment =>
@if(numOfComment > 0) {
<span class="number-of-comments"><i class="yobicon-comments"></i> @numOfComment</span>
}
}
@common.commitMsg(commit.getShortMessage(), commit.getMessage(), showCommitURL.toString())
</td>
@if(path != null){
<td class="browse">
<a href="@routes.CodeApp.codeBrowserWithBranch(project.owner, project.name, commit.getShortId(), path)" title="@Messages("code.showCodeAtThisCommit")" class="ybtn">
@Messages("code.showCode")
</a>
</td>
}
<td class="date">@agoOrDateString(commit.getAuthorDate)</td>
<td class="author">
@(commit.getAuthor, commit.getAuthorEmail, commit.getAuthorName) match {
case (user: User, _, _) if !user.isAnonymous => {
<a href="@routes.UserApp.userInfo(commit.getAuthor.loginId)" class="avatar-wrap" data-toggle="tooltip" data-placement="top" title="@user.loginId">
@if(user.avatarUrl == UserApp.DEFAULT_AVATAR_URL){
@if(commit.getAuthorEmail != null) {
<img src="@urlToPicture(commit.getAuthorEmail, 32)">
} else {
<img src="@urlToPicture(commit.getAuthor.email, 32)">
}
} else {
<img src="@commit.getAuthor.avatarUrl" alt="@commit.getAuthor.name" width="32" height="32"/>
} </a>
}
case (_, email, _) if email != null => {
<span class="avatar-wrap" class="avatar-wrap" data-toggle="tooltip" data-placement="top" title="@commit.getAuthorEmail">
<img src="@urlToPicture(commit.getAuthorEmail, 32)">
</span>
}
case (_, _, name) if name != null => {
<span>@commit.getAuthorName</span>
}
case (_, _, _) => {
<span>@User.anonymous.name</span>
}
}
</td>
</tr>
}
}
</tbody>
</table>
</div>
</div>
<div class="actrow margin-top-20">
@if(page > 0) {
<a href="@getHistoryURL(path)?page=@(page - 1)" class="ybtn pull-left">@Messages("code.newer")</a>
}
@if(isHistoryExistAndHasParent(history)) {
<a href="@getHistoryURL(path)?page=@(page + 1)" class="ybtn pull-left">@Messages("code.older")</a>
}
</div>
</div>
</div>
</div>
@common.select2()
<script type="text/javascript">
$(document).ready(function(){
$("button.moreBtn").on("click", function(){
$(this).next("pre.commitMsg.desc").toggleClass("hidden");
});
$("#branches").on("change", function(evt){
location.href = evt.val;
});
// Copy CommitId
$("#history").find(".btn-copy-commitId").each(function(i, el){
var welBtnCopy = $(el);
// zclip() works only in visible element
welBtnCopy.on("mouseenter", function(){
if(!welBtnCopy.data("zclipped")){
welBtnCopy.data("zclipped", true);
$(this).zclip({
"path": "@routes.Assets.at("javascripts/lib/jquery/ZeroClipboard.swf")",
"copy": function(){
return $(this).data("commitid");
},
"afterCopy": function(){
$yobi.notify("@Messages("code.copyCommitId.copied")", 1000);
}
});
}
});
});
var htKeyMap = {};
@if(page > 0){
htKeyMap.A = "@getHistoryURL(path)?page=@(page - 1)";
}
@if(isHistoryExistAndHasParent(history)) {
htKeyMap.S = "@getHistoryURL(path)?page=@(page + 1)";
}
if(htKeyMap.A || htKeyMap.S){
yobi.ShortcutKey.setKeymapLink(htKeyMap);
}
});
</script>
}