From 70dbee839a05773eee75d8f3e658e1a83919f751 Mon Sep 17 00:00:00 2001
From: KOUNOIKE Yuusuke
Date: Sun, 29 Apr 2018 19:05:45 +0900
Subject: [PATCH 1/2] Show mail address in profile page, It can be controlled
by settings. closes #673.
---
.../core/controller/AccountController.scala | 6 +++++-
.../controller/SystemSettingsController.scala | 3 ++-
.../core/service/SystemSettingsService.scala | 8 ++++++--
.../gitbucket/core/account/activity.scala.html | 5 +++--
.../twirl/gitbucket/core/account/main.scala.html | 12 +++++++++++-
.../gitbucket/core/account/members.scala.html | 6 +++---
.../core/account/repositories.scala.html | 3 ++-
.../core/admin/settings_system.scala.html | 15 +++++++++++++++
.../core/view/AvatarImageProviderSpec.scala | 3 ++-
9 files changed, 49 insertions(+), 12 deletions(-)
diff --git a/src/main/scala/gitbucket/core/controller/AccountController.scala b/src/main/scala/gitbucket/core/controller/AccountController.scala
index e50b58337..99a0baccc 100644
--- a/src/main/scala/gitbucket/core/controller/AccountController.scala
+++ b/src/main/scala/gitbucket/core/controller/AccountController.scala
@@ -229,13 +229,15 @@ trait AccountControllerBase extends AccountManagementControllerBase {
get("/:userName") {
val userName = params("userName")
getAccountByUserName(userName).map { account =>
+ val extraMailAddresses = getAccountExtraMailAddresses(userName)
params.getOrElse("tab", "repositories") match {
// Public Activity
case "activity" =>
gitbucket.core.account.html.activity(
account,
if (account.isGroupAccount) Nil else getGroupsByUserName(userName),
- getActivitiesByUser(userName, true)
+ getActivitiesByUser(userName, true),
+ extraMailAddresses
)
// Members
@@ -244,6 +246,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
gitbucket.core.account.html.members(
account,
members,
+ extraMailAddresses,
context.loginAccount.exists(
x =>
members.exists { member =>
@@ -260,6 +263,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
account,
if (account.isGroupAccount) Nil else getGroupsByUserName(userName),
getVisibleRepositories(context.loginAccount, Some(userName)),
+ extraMailAddresses,
context.loginAccount.exists(
x =>
members.exists { member =>
diff --git a/src/main/scala/gitbucket/core/controller/SystemSettingsController.scala b/src/main/scala/gitbucket/core/controller/SystemSettingsController.scala
index 513affc81..b0a7453e9 100644
--- a/src/main/scala/gitbucket/core/controller/SystemSettingsController.scala
+++ b/src/main/scala/gitbucket/core/controller/SystemSettingsController.scala
@@ -89,7 +89,8 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
"jwsAlgorithm" -> trim(label("Signature algorithm", optional(text())))
)(OIDC.apply)
),
- "skinName" -> trim(label("AdminLTE skin name", text(required)))
+ "skinName" -> trim(label("AdminLTE skin name", text(required))),
+ "showMailAddress" -> trim(label("Show mail address", boolean()))
)(SystemSettings.apply).verifying { settings =>
Vector(
if (settings.ssh && settings.baseUrl.isEmpty) {
diff --git a/src/main/scala/gitbucket/core/service/SystemSettingsService.scala b/src/main/scala/gitbucket/core/service/SystemSettingsService.scala
index 41418228b..7ac861ec3 100644
--- a/src/main/scala/gitbucket/core/service/SystemSettingsService.scala
+++ b/src/main/scala/gitbucket/core/service/SystemSettingsService.scala
@@ -68,6 +68,7 @@ trait SystemSettingsService {
}
}
props.setProperty(SkinName, settings.skinName.toString)
+ props.setProperty(ShowMailAddress, settings.showMailAddress.toString)
using(new java.io.FileOutputStream(GitBucketConf)) { out =>
props.store(out, null)
}
@@ -144,7 +145,8 @@ trait SystemSettingsService {
} else {
None
},
- getValue(props, SkinName, "skin-blue")
+ getValue(props, SkinName, "skin-blue"),
+ getValue(props, ShowMailAddress, false)
)
}
}
@@ -174,7 +176,8 @@ object SystemSettingsService {
ldap: Option[Ldap],
oidcAuthentication: Boolean,
oidc: Option[OIDC],
- skinName: String
+ skinName: String,
+ showMailAddress: Boolean
) {
def baseUrl(request: HttpServletRequest): String =
@@ -283,6 +286,7 @@ object SystemSettingsService {
private val OidcClientSecret = "oidc.client_secret"
private val OidcJwsAlgorithm = "oidc.jws_algorithm"
private val SkinName = "skinName"
+ private val ShowMailAddress = "showMailAddress"
private def getValue[A: ClassTag](props: java.util.Properties, key: String, default: A): A = {
getSystemProperty(key).getOrElse(getEnvironmentVariable(key).getOrElse {
diff --git a/src/main/twirl/gitbucket/core/account/activity.scala.html b/src/main/twirl/gitbucket/core/account/activity.scala.html
index e3b13076c..f0d2cdce9 100644
--- a/src/main/twirl/gitbucket/core/account/activity.scala.html
+++ b/src/main/twirl/gitbucket/core/account/activity.scala.html
@@ -1,8 +1,9 @@
@(account: gitbucket.core.model.Account,
groupNames: List[String],
- activities: List[gitbucket.core.model.Activity])(implicit context: gitbucket.core.controller.Context)
+ activities: List[gitbucket.core.model.Activity],
+ extraMailAddresses: List[String])(implicit context: gitbucket.core.controller.Context)
@import gitbucket.core.view.helpers
-@gitbucket.core.account.html.main(account, groupNames, "activity"){
+@gitbucket.core.account.html.main(account, groupNames, "activity", extraMailAddresses){
diff --git a/src/main/twirl/gitbucket/core/account/main.scala.html b/src/main/twirl/gitbucket/core/account/main.scala.html
index 3a0c58891..4c2ebc02b 100644
--- a/src/main/twirl/gitbucket/core/account/main.scala.html
+++ b/src/main/twirl/gitbucket/core/account/main.scala.html
@@ -1,4 +1,4 @@
-@(account: gitbucket.core.model.Account, groupNames: List[String], active: String,
+@(account: gitbucket.core.model.Account, groupNames: List[String], active: String, extraMailAddresses: List[String],
isGroupManager: Boolean = false)(body: Html)(implicit context: gitbucket.core.controller.Context)
@import gitbucket.core.view.helpers
@gitbucket.core.html.main(account.userName){
@@ -20,6 +20,16 @@
@account.url
}
+ @if(context.settings.showMailAddress){
+
+ @account.mailAddress
+
+ @extraMailAddresses.map{ mail =>
+
+ @mail
+
+ }
+ }
Joined on @helpers.date(account.registeredDate)
diff --git a/src/main/twirl/gitbucket/core/account/members.scala.html b/src/main/twirl/gitbucket/core/account/members.scala.html
index 996dc1d7c..6edaf85b0 100644
--- a/src/main/twirl/gitbucket/core/account/members.scala.html
+++ b/src/main/twirl/gitbucket/core/account/members.scala.html
@@ -1,6 +1,6 @@
-@(account: gitbucket.core.model.Account, members: List[gitbucket.core.model.GroupMember], isGroupManager: Boolean)(implicit context: gitbucket.core.controller.Context)
+@(account: gitbucket.core.model.Account, members: List[gitbucket.core.model.GroupMember], extraMailAddresses: List[String], isGroupManager: Boolean)(implicit context: gitbucket.core.controller.Context)
@import gitbucket.core.view.helpers
-@gitbucket.core.account.html.main(account, Nil, "members", isGroupManager){
+@gitbucket.core.account.html.main(account, Nil, "members", extraMailAddresses, isGroupManager){
@if(members.isEmpty){
No members
} else {
@@ -13,4 +13,4 @@
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/twirl/gitbucket/core/account/repositories.scala.html b/src/main/twirl/gitbucket/core/account/repositories.scala.html
index b4c7acf3e..1d074f9da 100644
--- a/src/main/twirl/gitbucket/core/account/repositories.scala.html
+++ b/src/main/twirl/gitbucket/core/account/repositories.scala.html
@@ -1,8 +1,9 @@
@(account: gitbucket.core.model.Account, groupNames: List[String],
repositories: List[gitbucket.core.service.RepositoryService.RepositoryInfo],
+ extraMailAddresses: List[String],
isGroupManager: Boolean)(implicit context: gitbucket.core.controller.Context)
@import gitbucket.core.view.helpers
-@gitbucket.core.account.html.main(account, groupNames, "repositories", isGroupManager){
+@gitbucket.core.account.html.main(account, groupNames, "repositories", extraMailAddresses, isGroupManager){
@if(repositories.isEmpty){
No repositories
} else {
diff --git a/src/main/twirl/gitbucket/core/admin/settings_system.scala.html b/src/main/twirl/gitbucket/core/admin/settings_system.scala.html
index 7d787fac4..bad13d6d1 100644
--- a/src/main/twirl/gitbucket/core/admin/settings_system.scala.html
+++ b/src/main/twirl/gitbucket/core/admin/settings_system.scala.html
@@ -132,6 +132,21 @@
+
+
+
+
+
+
diff --git a/src/test/scala/gitbucket/core/view/AvatarImageProviderSpec.scala b/src/test/scala/gitbucket/core/view/AvatarImageProviderSpec.scala
index 6baf939a4..b856de082 100644
--- a/src/test/scala/gitbucket/core/view/AvatarImageProviderSpec.scala
+++ b/src/test/scala/gitbucket/core/view/AvatarImageProviderSpec.scala
@@ -134,7 +134,8 @@ class AvatarImageProviderSpec extends FunSpec with MockitoSugar {
ldap = None,
oidcAuthentication = false,
oidc = None,
- skinName = "skin-blue"
+ skinName = "skin-blue",
+ showMailAddress = false
)
/**
From f53497da561ca35c74f0a9be18dbf4c9be286f51 Mon Sep 17 00:00:00 2001
From: KOUNOIKE Yuusuke
Date: Sun, 29 Apr 2018 20:51:34 +0900
Subject: [PATCH 2/2] forgot radio group change.
---
src/main/twirl/gitbucket/core/admin/settings_system.scala.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/twirl/gitbucket/core/admin/settings_system.scala.html b/src/main/twirl/gitbucket/core/admin/settings_system.scala.html
index bad13d6d1..34b9033cf 100644
--- a/src/main/twirl/gitbucket/core/admin/settings_system.scala.html
+++ b/src/main/twirl/gitbucket/core/admin/settings_system.scala.html
@@ -142,7 +142,7 @@
Show - Anyone can view mail address by user's profile page.