DeokHong Kim (a.k.a insanehong) DeokHong Kim (a.k.a insanehong) 2013-10-28
codehistroy:fixed link on list button at code diff view
@190e24e3efee28444d4bfe32773e8c7068c82f3a
app/assets/stylesheets/less/_page.less
--- app/assets/stylesheets/less/_page.less
+++ app/assets/stylesheets/less/_page.less
@@ -4577,8 +4577,12 @@
         width: 40px;
     }
     .filename { float:left; line-height:30px; }
+    
+    .hide {
+        display:none;
+    }
 }
 
 div.diff-body[data-outdated="true"] tr:hover .icon-comment {
     visibility: hidden;
-}
+}
(No newline at end of file)
app/controllers/CodeHistoryApp.java
--- app/controllers/CodeHistoryApp.java
+++ app/controllers/CodeHistoryApp.java
@@ -12,6 +12,7 @@
 import models.enumeration.Operation;
 
 import models.enumeration.ResourceType;
+import org.apache.commons.lang.StringUtils;
 import org.eclipse.jgit.api.errors.GitAPIException;
 import org.eclipse.jgit.api.errors.NoHeadException;
 import org.tmatesoft.svn.core.SVNException;
@@ -156,6 +157,9 @@
         List<CommitComment> comments = CommitComment.find.where().eq("commitId",
                 commitId).eq("project.id", project.id).findList();
 
+        String selectedBranch = StringUtils.defaultIfBlank(request().getQueryString("branch"), "HEAD");
+        String path = StringUtils.defaultIfBlank(request().getQueryString("path"), "");
+
         if(project.vcs.equals(RepositoryService.VCS_SUBVERSION)) {
             String patch = repository.getPatch(commitId);
 
@@ -163,9 +167,7 @@
                 return notFound(ErrorViews.NotFound.render("error.notfound", project));
             }
 
-            String selectedBranch = request().getQueryString("branch");
-
-            return ok(svnDiff.render(project, commit, parentCommit, patch, comments, selectedBranch));
+            return ok(svnDiff.render(project, commit, parentCommit, patch, comments, selectedBranch, path));
         } else {
             List<FileDiff> fileDiffs = repository.getDiff(commitId);
 
@@ -173,9 +175,7 @@
                 return notFound(ErrorViews.NotFound.render("error.notfound", project));
             }
 
-            String selectedBranch = request().getQueryString("branch");
-
-            return ok(diff.render(project, commit, parentCommit, comments, selectedBranch, fileDiffs));
+            return ok(diff.render(project, commit, parentCommit, comments, selectedBranch, fileDiffs, path));
         }
     }
 
app/views/code/diff.scala.html
--- app/views/code/diff.scala.html
+++ app/views/code/diff.scala.html
@@ -1,4 +1,4 @@
-@(project: Project, commit:playRepository.Commit, parentCommit:playRepository.Commit, comments:List[CommitComment], selectedBranch:String, diff: List[playRepository.FileDiff])
+@(project: Project, commit:playRepository.Commit, parentCommit:playRepository.Commit, comments:List[CommitComment], selectedBranch:String, diff: List[playRepository.FileDiff],path:String)
 
 @import playRepository.RepositoryService
 @import java.net.URLEncoder
@@ -14,7 +14,7 @@
     <div class="code-browse-wrap">
         <div id="branches" class="btn-group branches pull-right" data-name="branch" data-activate="manual">
             <button class="btn dropdown-toggle large" data-toggle="dropdown">
-                <span class="d-label">@if(selectedBranch){ @selectedBranch } else { HEAD }</span>
+                <span class="d-label">@selectedBranch</span>
                 <span class="d-caret"><span class="caret"></span></span>
             </button>
             <ul class="dropdown-menu">
@@ -129,7 +129,7 @@
 
     <button id="watch-button" type="button" class="ybtn @if(commit.getWatchers(project).contains(UserApp.currentUser())) { active ybtn-watching }" data-toggle="button">@Messages("notification.watch")</button>
 
-    <a href="javascript: history.back();" class="ybtn pull-right">@Messages("button.list")</a>
+    <a href="@routes.CodeHistoryApp.history(project.owner, project.name, selectedBranch, path)" class="ybtn pull-right">@Messages("button.list")</a>
 
     <div id="minimap" class="minimap-outer">
         <div class="minimap-wrap">
app/views/code/history.scala.html
--- app/views/code/history.scala.html
+++ app/views/code/history.scala.html
@@ -22,9 +22,13 @@
         routes.CodeHistoryApp.historyUntilHead(project.owner, project.name)
     }
 }
-@getShowCommitURL(project:Project, commit:playRepository.Commit) = @{
+@getShowCommitURL(project:Project, commit:playRepository.Commit, path:String) = @{
     if(selectedBranch){
-        routes.CodeHistoryApp.show(project.owner, project.name, commit.getId()) + "?branch=" + URLEncoder.encode(selectedBranch, "UTF-8")
+        var queryString = "?branch=" + URLEncoder.encode(selectedBranch, "UTF-8");
+        if(path != null) {
+            queryString += "&path=" + path;
+        }
+        routes.CodeHistoryApp.show(project.owner, project.name, commit.getId()) + queryString;
     } else {
         routes.CodeHistoryApp.show(project.owner, project.name, commit.getId())
     }
@@ -105,15 +109,15 @@
                     </thead>
                     <tbody class="tbody">
                         @for(commit <- history.iterator()) {
-                        @defining(getShowCommitURL(project, commit)){ showCommitURL =>
+                        @defining(getShowCommitURL(project, commit, path)){ showCommitURL =>
                         <tr>
                             <td class="commit-id">
-                                <a href="@showCommitURL#@path" title="@Messages("code.showCommit")">
+                                <a href="@showCommitURL" title="@Messages("code.showCommit")">
                                     @commit.getShortId()
                                 </a>
                             </td>
                             <td class="messages">
-                                @defining(CommitComment.count(project, commit.getId, if(path != null){"/"+path}else{null})){ numOfComment =>
+                                @defining(CommitComment.count(project, commit.getId, path)){ numOfComment =>
                                 @if(numOfComment > 0) {
                                 <span class="number-of-comments"><i class="yobicon-comments"></i> @numOfComment</span>
                                 }
@@ -123,7 +127,7 @@
                                 @if(commitMsg.startsWith("Merge pull request")){
                                     @defining(commitMsg.split(" ")(3)) { pullRequestIdPart =>
                                         @defining(pullRequestIdPart.replace("#", "").toLong) { pullRequestId =>
-                                        <a href="@showCommitURL#@path">
+                                        <a href="@showCommitURL">
                                             @defining(commitMsg.indexOf(" #")) { indexOfPullRequestStart =>
                                                 @commitMsg.split("\n")(0).substring(0, indexOfPullRequestStart)
                                             }
@@ -131,7 +135,7 @@
                                         <a href="@routes.PullRequestApp.pullRequest(project.owner, project.name, pullRequestId)" class="secondary-txt">
                                             #@pullRequestId
                                         </a>
-                                        <a href="@showCommitURL#@path">
+                                        <a href="@showCommitURL">
                                             @defining(commitMsg.indexOf(commitMsg.split(" ")(3)) + commitMsg.split(" ")(3).length) { indexOfPullRequestIdEnd =>
                                             @commitMsg.split("\n")(0).substring(indexOfPullRequestIdEnd)
                                             }
@@ -139,7 +143,7 @@
                                         }
                                     }
                                 } else {
-                                    <a href="@showCommitURL#@path">@commitMsg.split("\n")(0)</a>
+                                    <a href="@showCommitURL">@commitMsg.split("\n")(0)</a>
                                 }
 
                                 @if(commitMsg.split("\n").length > 1){
app/views/code/svnDiff.scala.html
--- app/views/code/svnDiff.scala.html
+++ app/views/code/svnDiff.scala.html
@@ -1,4 +1,4 @@
-@(project: Project, commit:playRepository.Commit, parentCommit:playRepository.Commit, patch: String, comments:List[CommitComment], selectedBranch:String)
+@(project: Project, commit:playRepository.Commit, parentCommit:playRepository.Commit, patch: String, comments:List[CommitComment], selectedBranch:String, path:String)
 
 @import playRepository.RepositoryService
 @import java.net.URLEncoder
@@ -91,7 +91,7 @@
         </p>
         <pre class="commitMsg">@commit.getMessage</pre>
         <div class="diff-wrap">
-            <div id="commit" class="diff-body show-comments">@patch</div>
+            <div id="commit" data-commit-origin="true" class="diff-body show-comments hide">@patch</div>
         </div>
         <div id="compare" class="modal hide compare-wrap" tabindex="-1" role="dialog">
             <h4 class="path">
@@ -148,7 +148,7 @@
 
     <button id="watch-button" type="button" class="ybtn @if(commit.getWatchers(project).contains(UserApp.currentUser())) { active }" data-toggle="button">@Messages("notification.watch")</button>
 
-    <a href="javascript: history.back();" class="ybtn pull-right">@Messages("button.list")</a>
+    <a href="@routes.CodeHistoryApp.history(project.owner, project.name, selectedBranch, path)" class="ybtn pull-right">@Messages("button.list")</a>
 
     <div id="minimap" class="minimap-outer">
         <div class="minimap-wrap">
public/javascripts/service/yobi.code.SvnDiff.js
--- public/javascripts/service/yobi.code.SvnDiff.js
+++ public/javascripts/service/yobi.code.SvnDiff.js
@@ -50,7 +50,7 @@
             htVar.sTplMiniMapLink = '<a href="#${id}" style="top:${top}px; height:${height}px;"></a>';
             
             // yobi.Attachments
-            htVar.sTplFileItem = ('#tplAttachedFile').text();
+            htVar.sTplFileItem = $('#tplAttachedFile').text();
         }
 
         /**
@@ -134,6 +134,8 @@
                     window.scrollTo(0, welTarget.offset().top);
                 }
             }
+
+            $('[data-commit-origin="true"]').removeClass("hide");
         }
 
         /**
Add a comment
List