Skip to content

Commit

Permalink
code: Make issue number autolink in commit message body
Browse files Browse the repository at this point in the history
  • Loading branch information
doortts committed Mar 26, 2017
1 parent c420c99 commit daf24d6
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 56 deletions.
6 changes: 6 additions & 0 deletions app/assets/stylesheets/less/_page.less
Original file line number Diff line number Diff line change
Expand Up @@ -3084,6 +3084,9 @@ label.inline-list {
}

.commitMsg {
a {
color: @blue2;
}
&.short {
padding:5px;
font-size:14px;
Expand Down Expand Up @@ -4219,6 +4222,9 @@ label.issue-item-row {
.avatar-wrap { margin-right:5px; }
}
.commitMsg-wrap {
a {
color: @blue2;
}
.commitMsg.short { font-size:18px; white-space:normal; }
.commitMsg.desc { margin:5px; font-family: @fixed-font-family;}
}
Expand Down
28 changes: 10 additions & 18 deletions app/views/code/diff.scala.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
@**
* Yobi, Project Hosting SW
* Yona, 21st Century 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.
* Copyright Yona & Yobi Authors & NAVER Corp.
* https://yona.io
**@
@(project: Project, commit:playRepository.Commit,
parentCommit:playRepository.Commit, threads:List[CommentThread], selectedBranch:String, diff:
Expand All @@ -29,6 +15,12 @@
@import utils.JodaDateUtil
@import utils.AccessControl._
@import scala.collection.JavaConversions._
@import utils.AutoLinkRenderer

@autoLinkedMsg(msg:String) = @{
val autoLinkRenderer = new AutoLinkRenderer(msg, project)
autoLinkRenderer.render()
}

@projectLayout(Messages("code.commits") + " @" + commit.getId, project, utils.MenuType.CODE) {
@projectMenu(project, utils.MenuType.CODE, "main-menu-only")
Expand Down Expand Up @@ -84,7 +76,7 @@
</span>
</div>
<div class="commitMsg-wrap">
@common.commitMsg(commit.getShortMessage, commit.getMessage, "", true)
@common.commitMsg(autoLinkedMsg(commit.getShortMessage), autoLinkedMsg(commit.getMessage), "", true)
</div>
<div class="commitId-wrap">
<strong class="commitId">@{"@"}@commit.getId</strong>
Expand Down
28 changes: 10 additions & 18 deletions app/views/code/history.scala.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
@**
* Yobi, Project Hosting SW
* Yona, 21st Century 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.
* Copyright Yona & Yobi Authors & NAVER Corp.
* https://yona.io
**@
@(project: Project, history: List[playRepository.Commit], page: Integer, selectedBranch: String, path:String)

Expand All @@ -28,6 +14,12 @@
@import java.net.URLEncoder
@import org.joda.time.Duration
@import controllers.CodeApp
@import utils.AutoLinkRenderer

@autoLinkedMsg(msg:String) = @{
val autoLinkRenderer = new AutoLinkRenderer(msg, project)
autoLinkRenderer.render()
}

@getFilesURL = @{
if(selectedBranch){
Expand Down Expand Up @@ -160,7 +152,7 @@
<span class="number-of-comments"><i class="yobicon-comments"></i> @numOfComment</span>
}
}
@common.commitMsg(commit.getShortMessage(), commit.getMessage(), showCommitURL.toString())
@common.commitMsg(commit.getShortMessage(), autoLinkedMsg(commit.getMessage()), showCommitURL.toString())
</td>
@if(path != null){
<td class="browse">
Expand Down
26 changes: 6 additions & 20 deletions app/views/common/commitMsg.scala.html
Original file line number Diff line number Diff line change
@@ -1,36 +1,22 @@
@**
* Yobi, Project Hosting SW
* Yona, 21st Century Project Hosting SW
*
* Copyright 2013 NAVER Corp.
* http://yobi.io
*
* @author Jihan Kim
*
* 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.
* Copyright Yona & Yobi Authors & NAVER Corp.
* https://yona.io
**@
@(shortMessage:String, commitMsg:String, linkURL:String = "", forceExpand:Boolean = false)

@import org.apache.commons.lang3.StringUtils

@defining(StringUtils.defaultIfEmpty(shortMessage, Messages("code.commitMsg.empty"))) { msgText =>
@if(StringUtils.isEmpty(linkURL)){
<span class="commitMsg short">@msgText</span>
<span class="commitMsg short">@Html(msgText)</span>
} else {
<a href="@linkURL" class="commitMsg short">@msgText</a>
<a href="@linkURL" class="commitMsg short">@Html(msgText)</a>
}
}

@if(commitMsg.split("\n").length > 1){
@if(!forceExpand){<button type="button" class="commitMsg moreBtn"><span>&hellip;</span></button>}
<pre class="commitMsg desc @if(!forceExpand){hidden}">@commitMsg.replace(commitMsg.split("\n")(0)+"\n", "")</pre>
<pre class="commitMsg desc @if(!forceExpand){hidden}">@Html(commitMsg.replace(commitMsg.split("\n")(0)+"\n", ""))</pre>
}

0 comments on commit daf24d6

Please sign in to comment.