[Notice] Announcing the End of Demo Server [Read me]

config: Add application.siteName configuration
You can set your site's name by editing application.siteName in conf/application.conf. The name is used in the title bar of your web browser, the main page, the welcome page, the login page and many others.
@9a6fd581008fbf37c302a8ae0a88dbccf2447a44
--- app/actors/ValidationEmailSender.java
+++ app/actors/ValidationEmailSender.java
... | ... | @@ -46,9 +46,9 @@ |
46 | 46 |
final HtmlEmail htmlEmail = new HtmlEmail(); |
47 | 47 |
|
48 | 48 |
try { |
49 |
- htmlEmail.setFrom(Config.getEmailFromSmtp(), Messages.get("app.name")); |
|
49 |
+ htmlEmail.setFrom(Config.getEmailFromSmtp(), utils.Config.getSiteName()); |
|
50 | 50 |
htmlEmail.addTo(email.email, email.user.name); |
51 |
- htmlEmail.setSubject(Messages.get("emails.validation.email.title")); |
|
51 |
+ htmlEmail.setSubject(Messages.get("emails.validation.email.title", utils.Config.getSiteName())); |
|
52 | 52 |
htmlEmail.setHtmlMsg(getMessage(email.confirmUrl)); |
53 | 53 |
htmlEmail.setCharset("utf-8"); |
54 | 54 |
Mailer.send(htmlEmail); |
--- app/controllers/PasswordResetApp.java
+++ app/controllers/PasswordResetApp.java
... | ... | @@ -85,7 +85,7 @@ |
85 | 85 |
try { |
86 | 86 |
SimpleEmail email = new SimpleEmail(); |
87 | 87 |
email.setFrom(sender) |
88 |
- .setSubject("[" + Messages.get("app.name") + "] " + Messages.get("site.resetPasswordEmail.title")) |
|
88 |
+ .setSubject("[" + utils.Config.getSiteName() + "] " + Messages.get("site.resetPasswordEmail.title")) |
|
89 | 89 |
.addTo(user.email) |
90 | 90 |
.setMsg(Messages.get("site.resetPasswordEmail.mailContents") + "\n\n" + resetPasswordUrl) |
91 | 91 |
.setCharset("utf-8"); |
--- app/models/NotificationMail.java
+++ app/models/NotificationMail.java
... | ... | @@ -125,7 +125,7 @@ |
125 | 125 |
|
126 | 126 |
try { |
127 | 127 |
email.setFrom(Config.getEmailFromSmtp(), event.getSender().name); |
128 |
- email.addTo(Config.getEmailFromSmtp(), "Yobi"); |
|
128 |
+ email.addTo(Config.getEmailFromSmtp(), utils.Config.getSiteName()); |
|
129 | 129 |
|
130 | 130 |
for (User receiver : receivers) { |
131 | 131 |
email.addBcc(receiver.email, receiver.name); |
... | ... | @@ -171,7 +171,7 @@ |
171 | 171 |
|
172 | 172 |
if (urlToView != null) { |
173 | 173 |
doc.body().append(String.format("<hr><a href=\"%s\">%s</a>", urlToView, |
174 |
- "View it on Yobi")); |
|
174 |
+ "View it on " + utils.Config.getSiteName())); |
|
175 | 175 |
} |
176 | 176 |
|
177 | 177 |
return doc.html(); |
--- app/utils/Config.java
+++ app/utils/Config.java
... | ... | @@ -1,6 +1,7 @@ |
1 | 1 |
|
2 | 2 |
package utils; |
3 | 3 |
|
4 |
+import org.apache.commons.lang3.ObjectUtils; |
|
4 | 5 |
import play.Configuration; |
5 | 6 |
import play.mvc.Http; |
6 | 7 |
|
... | ... | @@ -10,6 +11,11 @@ |
10 | 11 |
public class Config { |
11 | 12 |
public static final String DEFAULT_SCHEME = "http"; |
12 | 13 |
|
14 |
+ public static String getSiteName() { |
|
15 |
+ return ObjectUtils.defaultIfNull( |
|
16 |
+ play.Configuration.root().getString("application.siteName"), "Yobi"); |
|
17 |
+ } |
|
18 |
+ |
|
13 | 19 |
public static String getHostport(String defaultValue) { |
14 | 20 |
play.Configuration config = play.Configuration.root(); |
15 | 21 |
|
--- app/views/code/nohead.scala.html
+++ app/views/code/nohead.scala.html
... | ... | @@ -24,23 +24,23 @@ |
24 | 24 |
<div class="span12"> |
25 | 25 |
@Html(Messages("code.nohead")) |
26 | 26 |
@if(isAllowed(UserApp.currentUser(), project.asResource(), Operation.UPDATE)) { |
27 |
- <h5>@Messages("code.nohead.clone", Messages("app.name"))</h5> |
|
27 |
+ <h5>@Messages("code.nohead.clone", utils.Config.getSiteName)</h5> |
|
28 | 28 |
<pre><code>git clone @getCodeURL(project) |
29 | 29 |
cd @project.name/ |
30 | 30 |
echo "# @project.name" > README.md |
31 | 31 |
git add README.md |
32 |
- git commit -m "Hello @Messages("app.name")" |
|
32 |
+ git commit -m "Hello @utils.Config.getSiteName" |
|
33 | 33 |
git push origin master</code></pre> |
34 |
- <h5>@Messages("code.nohead.init", Messages("app.name"))</h5> |
|
34 |
+ <h5>@Messages("code.nohead.init", utils.Config.getSiteName)</h5> |
|
35 | 35 |
<pre><code>mkdir @project.name |
36 | 36 |
cd @project.name/ |
37 | 37 |
echo "# @project.name" > README.md |
38 | 38 |
git init |
39 | 39 |
git add README.md |
40 |
- git commit -m "Hello @Messages("app.name")" |
|
40 |
+ git commit -m "Hello @utils.Config.getSiteName" |
|
41 | 41 |
git remote add origin @getCodeURL(project) |
42 | 42 |
git push origin master</code></pre> |
43 |
- <h5>@Messages("code.nohead.remote", Messages("app.name"))</h5> |
|
43 |
+ <h5>@Messages("code.nohead.remote", utils.Config.getSiteName)</h5> |
|
44 | 44 |
<pre><code>git remote add origin @getCodeURL(project) |
45 | 45 |
git push origin master</code></pre> |
46 | 46 |
<h5>@Messages("code.nohead.pull.push")</h5> |
--- app/views/code/nohead_svn.scala.html
+++ app/views/code/nohead_svn.scala.html
... | ... | @@ -31,7 +31,7 @@ |
31 | 31 |
<div class="span12"> |
32 | 32 |
@Html(Messages("code.nohead")) |
33 | 33 |
@if(isAllowed(UserApp.currentUser(), project.asResource(), Operation.UPDATE)) { |
34 |
- <h5>@Messages("code.nohead.svn.clone", Messages("app.name"))</h5> |
|
34 |
+ <h5>@Messages("code.nohead.svn.clone", utils.Config.getSiteName)</h5> |
|
35 | 35 |
<pre><code>svn co @CodeApp.getURL(project) --username @UserApp.currentUser().loginId |
36 | 36 |
cd @project.name/ |
37 | 37 |
echo "# @project.name" > README.md |
--- app/views/error/notfound_default.scala.html
+++ app/views/error/notfound_default.scala.html
... | ... | @@ -3,7 +3,7 @@ |
3 | 3 |
@layout(Messages(messageKey))(""){ |
4 | 4 |
<header class="gnb-outer"> |
5 | 5 |
<div class="gnb-inner"> |
6 |
- <a href="@routes.Application.index()" class="logo"><h1 class="blind">@Messages("app.name")</h1></a> |
|
6 |
+ <a href="@routes.Application.index()" class="logo"><h1 class="blind">@utils.Config.getSiteName</h1></a> |
|
7 | 7 |
<ul class="gnb-nav"> |
8 | 8 |
<li> |
9 | 9 |
<a href="@routes.ProjectApp.projects()">@Messages("title.projectList")</a> |
--- app/views/index/index.scala.html
+++ app/views/index/index.scala.html
... | ... | @@ -3,14 +3,14 @@ |
3 | 3 |
@import utils.TemplateHelper._ |
4 | 4 |
@import utils.JodaDateUtil |
5 | 5 |
|
6 |
-@siteLayout("app.name", utils.MenuType.SITE_HOME) { |
|
6 |
+@siteLayout(utils.Config.getSiteName, utils.MenuType.SITE_HOME) { |
|
7 | 7 |
@if(currentUser != User.anonymous){ |
8 | 8 |
<div class="page-wrap-outer"> |
9 | 9 |
<div class="page-wrap"> |
10 | 10 |
<div class="site-guide-outer hide"> |
11 | 11 |
<h3> |
12 | 12 |
<i class="yobicon-emo-wink"></i> |
13 |
- @Messages("app.welcome",Messages("app.name")) |
|
13 |
+ @Messages("app.welcome",utils.Config.getSiteName) |
|
14 | 14 |
<span>@Messages("app.description")</span> |
15 | 15 |
</h3> |
16 | 16 |
<div class="site-guide-inner"> |
--- app/views/index/partial_intro.scala.html
+++ app/views/index/partial_intro.scala.html
... | ... | @@ -11,7 +11,7 @@ |
11 | 11 |
</div> |
12 | 12 |
<div class="signup-btn"> |
13 | 13 |
<a href="@routes.UserApp.signupForm()" class="ybtn ybtn-success ybtn-padding"> |
14 |
- @Messages("button.signup",Messages("app.name")) |
|
14 |
+ @Messages("button.signup",utils.Config.getSiteName) |
|
15 | 15 |
</a> |
16 | 16 |
</div> |
17 | 17 |
</div> |
... | ... | @@ -69,7 +69,7 @@ |
69 | 69 |
<img src="/assets/images/sample-image.jpg" > |
70 | 70 |
</div> |
71 | 71 |
<div class="get-started"> |
72 |
- <h2>@Html(Messages("title.gettingStarted",Messages("app.name")))</h2> |
|
72 |
+ <h2>@Html(Messages("title.gettingStarted",utils.Config.getSiteName))</h2> |
|
73 | 73 |
|
74 | 74 |
<a href="@routes.ProjectApp.newProjectForm()" class="ybtn ybtn-success ybtn-padding"> |
75 | 75 |
<i class="yobicon-database-add"></i> @Messages("button.newProject") |
--- app/views/issue/my_list.scala.html
+++ app/views/issue/my_list.scala.html
... | ... | @@ -1,7 +1,7 @@ |
1 | 1 |
@(title: String, currentPage: com.avaje.ebean.Page[Issue], param: |
2 | 2 |
models.support.SearchCondition, project:Project) |
3 | 3 |
|
4 |
-@siteLayout("app.name", utils.MenuType.SITE_HOME) { |
|
4 |
+@siteLayout(utils.Config.getSiteName, utils.MenuType.SITE_HOME) { |
|
5 | 5 |
<div> |
6 | 6 |
<button class="btn-transparent" id="toggleIntro"></button> |
7 | 7 |
</div> |
--- app/views/site/lostPassword.scala.html
+++ app/views/site/lostPassword.scala.html
... | ... | @@ -4,7 +4,7 @@ |
4 | 4 |
<div class="lost-password"> |
5 | 5 |
<form id="mailForm" method="post" action="@routes.PasswordResetApp.requestResetPasswordEmail()" class="span7 form-horizontal"> |
6 | 6 |
<div class="control-group controls"> |
7 |
- <h3 class="title">[@Messages("app.name")] @Messages("site.resetPasswordEmail.title")</h3> |
|
7 |
+ <h3 class="title">[@utils.Config.getSiteName] @Messages("site.resetPasswordEmail.title")</h3> |
|
8 | 8 |
</div> |
9 | 9 |
|
10 | 10 |
@if(isSent) { |
--- app/views/siteLayout.scala.html
+++ app/views/siteLayout.scala.html
... | ... | @@ -17,7 +17,7 @@ |
17 | 17 |
</div> |
18 | 18 |
<header class="gnb-outer"> |
19 | 19 |
<div class="gnb-inner"> |
20 |
- <a href="@routes.Application.index()" class="logo"><h1 class="blind">@Messages("app.name")</h1></a> |
|
20 |
+ <a href="@routes.Application.index()" class="logo"><h1 class="blind">@utils.Config.getSiteName</h1></a> |
|
21 | 21 |
<ul class="gnb-nav"> |
22 | 22 |
<li class="@isActiveMenu(MenuType.PROJECTS)"> |
23 | 23 |
<a href="@routes.ProjectApp.projects()">@Messages("title.projectList")</a> |
--- app/views/user/edit.scala.html
+++ app/views/user/edit.scala.html
... | ... | @@ -13,7 +13,7 @@ |
13 | 13 |
<div class="page-wrap-outer"> |
14 | 14 |
<div class="page-wrap"> |
15 | 15 |
<h1 class="page-title"> |
16 |
- <span class="gray">@Messages("app.name") / </span> |
|
16 |
+ <span class="gray">@utils.Config.getSiteName / </span> |
|
17 | 17 |
<a href="@routes.UserApp.userInfo(session.get("loginId"))" style="vertical-align:top;">@user.loginId</a> |
18 | 18 |
</h1> |
19 | 19 |
|
--- app/views/user/login.scala.html
+++ app/views/user/login.scala.html
... | ... | @@ -4,7 +4,7 @@ |
4 | 4 |
<div class="page full"> |
5 | 5 |
<div class="center-wrap tag-line-wrap login"> |
6 | 6 |
<h1 class="title"> |
7 |
- Log In for <span class="high-light">@Messages("app.name")</span> |
|
7 |
+ Log In for <span class="high-light">@utils.Config.getSiteName</span> |
|
8 | 8 |
</h1> |
9 | 9 |
<p class="tag-line">Software development platform for Open Source project.</p> |
10 | 10 |
</div> |
--- app/views/user/signup.scala.html
+++ app/views/user/signup.scala.html
... | ... | @@ -6,7 +6,7 @@ |
6 | 6 |
<div class="page full"> |
7 | 7 |
<div class="center-wrap tag-line-wrap signup"> |
8 | 8 |
<h1 class="title"> |
9 |
- Sign Up for <span class="high-light">@Messages("app.name")</span> |
|
9 |
+ Sign Up for <span class="high-light">@utils.Config.getSiteName</span> |
|
10 | 10 |
</h1> |
11 | 11 |
<p class="tag-line">Software development platform for Open Source project.</p> |
12 | 12 |
</div> |
--- app/views/welcome/restart.scala.html
+++ app/views/welcome/restart.scala.html
... | ... | @@ -34,7 +34,7 @@ |
34 | 34 |
<div class="container page-wrap"> |
35 | 35 |
<div class="page"> |
36 | 36 |
<div class="secret-wrap"> |
37 |
- <a href="@routes.Application.index()" class="logo"><span>@Messages("app.name")</span></a> |
|
37 |
+ <a href="@routes.Application.index()" class="logo"><span>@utils.Config.getSiteName</span></a> |
|
38 | 38 |
|
39 | 39 |
<h3>@Messages("app.restart.welcome")</h3> |
40 | 40 |
<p class="secret-box txt-center"> |
... | ... | @@ -46,7 +46,7 @@ |
46 | 46 |
</div> |
47 | 47 |
<footer class="page-footer-outer"> |
48 | 48 |
<div class="page-footer"> |
49 |
- <span class="provider">Powered by <strong>@Messages("app.name")</strong></span> |
|
49 |
+ <span class="provider">Powered by <strong>@utils.Config.getSiteName</strong></span> |
|
50 | 50 |
</div> |
51 | 51 |
</footer> |
52 | 52 |
</body> |
--- app/views/welcome/secret.scala.html
+++ app/views/welcome/secret.scala.html
... | ... | @@ -4,7 +4,7 @@ |
4 | 4 |
<html> |
5 | 5 |
<head> |
6 | 6 |
<meta charset="utf-8"> |
7 |
-<title>@Messages("app.welcome", Messages("app.name"))</title> |
|
7 |
+<title>@Messages("app.welcome", utils.Config.getSiteName)</title> |
|
8 | 8 |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
9 | 9 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
10 | 10 |
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
... | ... | @@ -35,9 +35,9 @@ |
35 | 35 |
<div class="container page-wrap"> |
36 | 36 |
<div class="page"> |
37 | 37 |
<div class="secret-wrap"> |
38 |
- <a href="@routes.Application.index()" class="logo"><span>@Messages("app.name")</span></a> |
|
38 |
+ <a href="@routes.Application.index()" class="logo"><span>@utils.Config.getSiteName</span></a> |
|
39 | 39 |
|
40 |
- <h3>@Messages("app.welcome", Messages("app.name"))</h3> |
|
40 |
+ <h3>@Messages("app.welcome", utils.Config.getSiteName)</h3> |
|
41 | 41 |
|
42 | 42 |
<div class="alert alert-block secret-box"> |
43 | 43 |
<h4>@Messages("app.welcome.warning.title")</h4> |
... | ... | @@ -118,7 +118,7 @@ |
118 | 118 |
</div> |
119 | 119 |
<footer class="page-footer-outer"> |
120 | 120 |
<div class="page-footer"> |
121 |
- <span class="provider">Powered by <strong>@Messages("app.name")</strong></span> |
|
121 |
+ <span class="provider">Powered by <strong>@utils.Config.getSiteName</strong></span> |
|
122 | 122 |
</div> |
123 | 123 |
</footer> |
124 | 124 |
<script type="text/javascript"> |
--- conf/application.conf.default
+++ conf/application.conf.default
... | ... | @@ -1,6 +1,11 @@ |
1 | 1 |
# This is the main configuration file for the application. |
2 | 2 |
# ~~~~~ |
3 | 3 |
|
4 |
+# Site Name |
|
5 |
+# ~~~~~~~~~ |
|
6 |
+# The name of your website |
|
7 |
+application.siteName="Yobi" |
|
8 |
+ |
|
4 | 9 |
# Notification |
5 | 10 |
# ~~~~~ |
6 | 11 |
# Notfication email is delivered by default. |
--- test/utils/ConfigTest.java
+++ test/utils/ConfigTest.java
... | ... | @@ -62,4 +62,22 @@ |
62 | 62 |
Helpers.stop(app); |
63 | 63 |
} |
64 | 64 |
|
65 |
+ @Test |
|
66 |
+ public void getSiteName() { |
|
67 |
+ FakeApplication app; |
|
68 |
+ Map<String, String> additionalConfiguration = support.Helpers.makeTestConfig(); |
|
69 |
+ |
|
70 |
+ additionalConfiguration.put("application.siteName", "my site"); |
|
71 |
+ app = support.Helpers.makeTestApplication(additionalConfiguration); |
|
72 |
+ Helpers.start(app); |
|
73 |
+ assertThat(Config.getSiteName()).isEqualTo("my site"); |
|
74 |
+ Helpers.stop(app); |
|
75 |
+ |
|
76 |
+ // The default is "Yobi". |
|
77 |
+ additionalConfiguration.put("application.scheme", null); |
|
78 |
+ app = support.Helpers.makeTestApplication(additionalConfiguration); |
|
79 |
+ Helpers.start(app); |
|
80 |
+ assertThat(Config.getScheme("https")).isEqualTo("Yobi"); |
|
81 |
+ Helpers.stop(app); |
|
82 |
+ } |
|
65 | 83 |
} |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?