From ba3d76f5ba1621356390412a3767fc2daa6bfae7 Mon Sep 17 00:00:00 2001 From: "Panagiotis \"Ivory\" Vasilopoulos" Date: Thu, 20 Jul 2023 17:28:29 +0200 Subject: [PATCH] Make OSM button configurable --- custom/conf/app.example.ini | 3 +++ modules/setting/service.go | 2 ++ routers/web/user/profile.go | 1 + templates/shared/user/profile_big_avatar.tmpl | 12 +++++++----- tests/integration/user_test.go | 1 + 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index 307404d022..aaa7e35a41 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -827,6 +827,9 @@ LEVEL = Info ;; Dependencies can be added from any repository where the user is granted access or only from the current repository depending on this setting. ;ALLOW_CROSS_REPOSITORY_DEPENDENCIES = true ;; +;; Enable OpenStreetMap button in Location field on user profiles +;ENABLE_OSM_BUTTON = true +;; ;; Enable heatmap on users profiles. ;ENABLE_USER_HEATMAP = true ;; diff --git a/modules/setting/service.go b/modules/setting/service.go index 03225f566b..bc816c0933 100644 --- a/modules/setting/service.go +++ b/modules/setting/service.go @@ -73,6 +73,7 @@ var Service = struct { AllowCrossRepositoryDependencies bool DefaultAllowOnlyContributorsToTrackTime bool NoReplyAddress string + EnableOSMButton bool EnableUserHeatmap bool AutoWatchNewRepos bool AutoWatchOnChanges bool @@ -185,6 +186,7 @@ func loadServiceFrom(rootCfg ConfigProvider) { Service.AllowCrossRepositoryDependencies = sec.Key("ALLOW_CROSS_REPOSITORY_DEPENDENCIES").MustBool(true) Service.DefaultAllowOnlyContributorsToTrackTime = sec.Key("DEFAULT_ALLOW_ONLY_CONTRIBUTORS_TO_TRACK_TIME").MustBool(true) Service.NoReplyAddress = sec.Key("NO_REPLY_ADDRESS").MustString("noreply." + Domain) + Service.EnableOSMButton = sec.Key("ENABLE_OSM_BUTTON").MustBool(true) Service.EnableUserHeatmap = sec.Key("ENABLE_USER_HEATMAP").MustBool(true) Service.AutoWatchNewRepos = sec.Key("AUTO_WATCH_NEW_REPOS").MustBool(true) Service.AutoWatchOnChanges = sec.Key("AUTO_WATCH_ON_CHANGES").MustBool(false) diff --git a/routers/web/user/profile.go b/routers/web/user/profile.go index 07a2261c96..7e44288b43 100644 --- a/routers/web/user/profile.go +++ b/routers/web/user/profile.go @@ -52,6 +52,7 @@ func userProfile(ctx *context.Context) { ctx.Data["Title"] = ctx.ContextUser.DisplayName() ctx.Data["PageIsUserProfile"] = true + ctx.Data["EnableOSMButton"] = setting.Service.EnableOSMButton // prepare heatmap data if setting.Service.EnableUserHeatmap { diff --git a/templates/shared/user/profile_big_avatar.tmpl b/templates/shared/user/profile_big_avatar.tmpl index e17d48456c..c4b31d9f10 100644 --- a/templates/shared/user/profile_big_avatar.tmpl +++ b/templates/shared/user/profile_big_avatar.tmpl @@ -27,11 +27,13 @@
  • {{svg "octicon-location" 18 "gt-mr-2"}} {{.ContextUser.Location}} - - - {{svg "octicon-link-external" 18 "gt-mr-2"}} - - + {{if .EnableOSMButton}} + + + {{svg "octicon-link-external" 18 "gt-mr-2"}} + + + {{end}}
  • {{end}} {{if (eq .SignedUserID .ContextUser.ID)}} diff --git a/tests/integration/user_test.go b/tests/integration/user_test.go index 2bec409023..434b9fb4d0 100644 --- a/tests/integration/user_test.go +++ b/tests/integration/user_test.go @@ -279,6 +279,7 @@ func TestListStopWatches(t *testing.T) { } func TestGetOpenStreetMapLink(t *testing.T) { + setting.Service.EnableOSMButton = true defer tests.PrepareTestEnv(t)() testLocations := map[string]string{