doortts doortts 2016-02-15
fix: Fix Incorrect link of user info page
When to use context root feature (eg. application.context at conf file),
user info page link guide to wrong path. Fix this problem.
@b4388e0dbab3343ac7d631a9ff1ec70aed87e67f
app/utils/Config.java
--- app/utils/Config.java
+++ app/utils/Config.java
@@ -61,6 +61,10 @@
                 play.Configuration.root().getString("application.siteName"), "Yona");
     }
 
+    public static String getContextRoot(){
+        return play.Configuration.root().getString("application.context", "/");
+    }
+
     public static String getHostport(String defaultValue) {
         String hostname = play.Configuration.root().getString("application.hostname");
 
app/utils/TemplateHelper.scala
--- app/utils/TemplateHelper.scala
+++ app/utils/TemplateHelper.scala
@@ -587,4 +587,8 @@
   private def extractHeaderWordsInBrackets(title: String): Array[String] = {
     return title.split("(=\\[)|(?<=\\])")
   }
+
+  def userInfo(loginId: String) = {
+    Config.getContextRoot() + loginId
+  }
 }
app/views/issue/partial_comments.scala.html
--- app/views/issue/partial_comments.scala.html
+++ app/views/issue/partial_comments.scala.html
@@ -28,7 +28,7 @@
 @import utils.Markdown
 
 @avatarByLoginId(loginId: String, loginName: String) = {
-    <a href="@routes.UserApp.userInfo(loginId)" class="usf-group" data-toggle="tooltip" data-placement="top" title="@loginName">
+    <a href="@userInfo(loginId)" class="usf-group" data-toggle="tooltip" data-placement="top" title="@loginName">
         <img src="@User.findByLoginId(loginId).avatarUrl" class="avatar-wrap small">
     </a>
 }
@@ -37,7 +37,7 @@
     @loginId match {
     case (loginId: String) => {
         @if(showAvatar){ @avatarByLoginId(loginId, loginName) }
-        <a href="@routes.UserApp.userInfo(loginId)" class="usf-group" data-toggle="tooltip" data-placement="top" title="@loginId">
+        <a href="@userInfo(loginId)" class="usf-group" data-toggle="tooltip" data-placement="top" title="@loginId">
             <strong>@loginName</strong>
         </a>
     }
@@ -77,14 +77,14 @@
     case (comment: Comment) => {
     <li class="comment @isAuthorComment(comment.authorLoginId)" id="comment-@comment.id">
         <div class="comment-avatar">
-            <a href="@routes.UserApp.userInfo(comment.authorLoginId)" class="avatar-wrap" data-toggle="tooltip" data-placement="top" title="@comment.authorName">
+            <a href="@userInfo(comment.authorLoginId)" class="avatar-wrap" data-toggle="tooltip" data-placement="top" title="@comment.authorName">
                 <img src="@User.findByLoginId(comment.authorLoginId).avatarUrl" width="32" height="32" alt="@comment.authorLoginId">
             </a>
         </div>
         <div class="media-body">
             <div class="meta-info">
                 <span class="comment_author pull-left">
-                    <a href="@routes.UserApp.userInfo(comment.authorLoginId)" data-toggle="tooltip" data-placement="top" title="@comment.authorName">
+                    <a href="@userInfo(comment.authorLoginId)" data-toggle="tooltip" data-placement="top" title="@comment.authorName">
                         <strong>@comment.authorLoginId </strong>
                     </a>
                 </span>
@@ -112,7 +112,7 @@
                                 @partial_voter_list("voters-" + issueComment.id, issueComment.voters)
                             } else {
                                 @for(voter <- issueComment.voters){
-                                    <a href="@routes.UserApp.userInfo(voter.loginId)" class="avatar-wrap smaller" data-toggle="tooltip" data-placement="top" title="@voter.name" style="margin-right:3px;">
+                                    <a href="@userInfo(voter.loginId)" class="avatar-wrap smaller" data-toggle="tooltip" data-placement="top" title="@voter.name" style="margin-right:3px;">
                                         <img src="@User.findByLoginId(voter.loginId).avatarUrl">
                                     </a>
                                 }
app/views/issue/partial_voter_list.scala.html
--- app/views/issue/partial_voter_list.scala.html
+++ app/views/issue/partial_voter_list.scala.html
@@ -20,6 +20,7 @@
 **@
 
 @(id:String, voters:Collection[User])
+@import utils.TemplateHelper._
 
 <div id="@id" class="modal hide voters-dialog">
     <div class="modal-header">
@@ -30,7 +31,7 @@
         <ul class="unstyled">
             @for(voter <- voters){
             <li>
-                <a href="@routes.UserApp.userInfo(voter.loginId)" class="usf-group" target="_blank">
+                <a href="@userInfo(voter.loginId)" class="usf-group" target="_blank">
                     <span class="avatar-wrap mlarge">
                         <img src="@voter.avatarUrl" width="40" height="40">
                     </span>
app/views/issue/view.scala.html
--- app/views/issue/view.scala.html
+++ app/views/issue/view.scala.html
@@ -84,7 +84,7 @@
         <div class="board-body row-fluid">
             <div class="span9">
                 <div class="author-info">
-                    <a href="@routes.UserApp.userInfo(issue.authorLoginId)" class="usf-group">
+                    <a href="@userInfo(issue.authorLoginId)" class="usf-group">
                         <span class="avatar-wrap smaller">
                             <img src="@User.findByLoginId(issue.authorLoginId).avatarUrl" width="20" height="20">
                         </span>
@@ -184,7 +184,7 @@
                                     @partial_assignee(project, issue)
                                 } else {
                                     @if(isAssigned){
-                                    <a href="@routes.UserApp.userInfo(issue.assignee.user.loginId)" class="usf-group">
+                                    <a href="@userInfo(issue.assignee.user.loginId)" class="usf-group">
                                         <span class="avatar-wrap smaller">
                                             <img src="@User.findByLoginId(issue.assignee.user.loginId).avatarUrl" width="20" height="20">
                                         </span>
Add a comment
List