Trim each lines of command guidance

This commit is contained in:
Naoki Takezoe
2015-01-02 19:11:50 +09:00
parent da216c6960
commit 182acb2e02
2 changed files with 21 additions and 22 deletions

View File

@@ -38,10 +38,8 @@ object helpers extends AvatarImageProvider with LinkConverter with RequestCache
} }
/** /**
*
* Format java.util.Date to "x {seconds/minutes/hours/days} ago" * Format java.util.Date to "x {seconds/minutes/hours/days} ago"
* If duration over 1 month, format to "d MMM (yyyy)" * If duration over 1 month, format to "d MMM (yyyy)"
*
*/ */
def datetimeAgoRecentOnly(date: Date): String = { def datetimeAgoRecentOnly(date: Date): String = {
val duration = new Date().getTime - date.getTime val duration = new Date().getTime - date.getTime
@@ -79,7 +77,7 @@ object helpers extends AvatarImageProvider with LinkConverter with RequestCache
private[this] val renderersBySuffix: Seq[(String, (List[String], String, String, service.RepositoryService.RepositoryInfo, Boolean, Boolean, app.Context) => Html)] = private[this] val renderersBySuffix: Seq[(String, (List[String], String, String, service.RepositoryService.RepositoryInfo, Boolean, Boolean, app.Context) => Html)] =
Seq( Seq(
".md" -> ((filePath, fileContent, branch, repository, enableWikiLink, enableRefsLink, context) => markdown(fileContent, repository, enableWikiLink, enableRefsLink)(context)), ".md" -> ((filePath, fileContent, branch, repository, enableWikiLink, enableRefsLink, context) => markdown(fileContent, repository, enableWikiLink, enableRefsLink)(context)),
".markdown" -> ((filePath, fileContent, branch, repository, enableWikiLink, enableRefsLink, context) => markdown(fileContent, repository, enableWikiLink, enableRefsLink)(context)) ".markdown" -> ((filePath, fileContent, branch, repository, enableWikiLink, enableRefsLink, context) => markdown(fileContent, repository, enableWikiLink, enableRefsLink)(context))
) )
@@ -146,12 +144,12 @@ object helpers extends AvatarImageProvider with LinkConverter with RequestCache
*/ */
def activityMessage(message: String)(implicit context: app.Context): Html = def activityMessage(message: String)(implicit context: app.Context): Html =
Html(message Html(message
.replaceAll("\\[issue:([^\\s]+?)/([^\\s]+?)#((\\d+))\\]" , s"""<a href="${context.path}/$$1/$$2/issues/$$3">$$1/$$2#$$3</a>""") .replaceAll("\\[issue:([^\\s]+?)/([^\\s]+?)#((\\d+))\\]" , s"""<a href="${context.path}/$$1/$$2/issues/$$3">$$1/$$2#$$3</a>""")
.replaceAll("\\[pullreq:([^\\s]+?)/([^\\s]+?)#((\\d+))\\]" , s"""<a href="${context.path}/$$1/$$2/pull/$$3">$$1/$$2#$$3</a>""") .replaceAll("\\[pullreq:([^\\s]+?)/([^\\s]+?)#((\\d+))\\]" , s"""<a href="${context.path}/$$1/$$2/pull/$$3">$$1/$$2#$$3</a>""")
.replaceAll("\\[repo:([^\\s]+?)/([^\\s]+?)\\]" , s"""<a href="${context.path}/$$1/$$2\">$$1/$$2</a>""") .replaceAll("\\[repo:([^\\s]+?)/([^\\s]+?)\\]" , s"""<a href="${context.path}/$$1/$$2\">$$1/$$2</a>""")
.replaceAll("\\[branch:([^\\s]+?)/([^\\s]+?)#([^\\s]+?)\\]", (m: Match) => s"""<a href="${context.path}/${m.group(1)}/${m.group(2)}/tree/${encodeRefName(m.group(3))}">${m.group(3)}</a>""") .replaceAll("\\[branch:([^\\s]+?)/([^\\s]+?)#([^\\s]+?)\\]" , (m: Match) => s"""<a href="${context.path}/${m.group(1)}/${m.group(2)}/tree/${encodeRefName(m.group(3))}">${m.group(3)}</a>""")
.replaceAll("\\[tag:([^\\s]+?)/([^\\s]+?)#([^\\s]+?)\\]" , (m: Match) => s"""<a href="${context.path}/${m.group(1)}/${m.group(2)}/tree/${encodeRefName(m.group(3))}">${m.group(3)}</a>""") .replaceAll("\\[tag:([^\\s]+?)/([^\\s]+?)#([^\\s]+?)\\]" , (m: Match) => s"""<a href="${context.path}/${m.group(1)}/${m.group(2)}/tree/${encodeRefName(m.group(3))}">${m.group(3)}</a>""")
.replaceAll("\\[user:([^\\s]+?)\\]" , (m: Match) => user(m.group(1)).body) .replaceAll("\\[user:([^\\s]+?)\\]" , (m: Match) => user(m.group(1)).body)
.replaceAll("\\[commit:([^\\s]+?)/([^\\s]+?)\\@([^\\s]+?)\\]", (m: Match) => s"""<a href="${context.path}/${m.group(1)}/${m.group(2)}/commit/${m.group(3)}">${m.group(1)}/${m.group(2)}@${m.group(3).substring(0, 7)}</a>""") .replaceAll("\\[commit:([^\\s]+?)/([^\\s]+?)\\@([^\\s]+?)\\]", (m: Match) => s"""<a href="${context.path}/${m.group(1)}/${m.group(2)}/commit/${m.group(3)}">${m.group(1)}/${m.group(2)}@${m.group(3).substring(0, 7)}</a>""")
) )
@@ -247,6 +245,8 @@ object helpers extends AvatarImageProvider with LinkConverter with RequestCache
} }
} }
def pre(value: Html): Html = Html(s"<pre>${value.body.trim.split("\n").map(_.trim).mkString("\n")}</pre>")
/** /**
* Implicit conversion to add mkHtml() to Seq[Html]. * Implicit conversion to add mkHtml() to Seq[Html].
*/ */

View File

@@ -16,20 +16,19 @@
} }
</div> </div>
<h3 style="margin-top: 30px;">Create a new repository on the command line</h3> <h3 style="margin-top: 30px;">Create a new repository on the command line</h3>
<pre> @pre {
touch README.md touch README.md
git init git init
git add README.md git add README.md
git commit -m "first commit" git commit -m "first commit"
git remote add origin <span class="live-clone-url">@repository.httpUrl</span> git remote add origin <span class="live-clone-url">@repository.httpUrl</span>
git push -u origin master git push -u origin master
</pre> }
<h3 style="margin-top: 30px;">Push an existing repository from the command line</h3> <h3 style="margin-top: 30px;">Push an existing repository from the command line</h3>
<pre> @pre {
git remote add origin <span class="live-clone-url">@repository.httpUrl</span> git remote add origin <span class="live-clone-url">@repository.httpUrl</span>
git push -u origin master git push -u origin master
</pre> }
<script> <script>
$(function(){ $(function(){
$('.git-protocol-selector').click(function(e){ $('.git-protocol-selector').click(function(e){