Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-28 20:56:11 +01:00

Make OSM button configurable

This commit is contained in:
Panagiotis "Ivory" Vasilopoulos 2023-07-20 17:28:29 +02:00
parent 1254f2aa9d
commit ba3d76f5ba
5 changed files with 14 additions and 5 deletions

View file

@ -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. ;; 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 ;ALLOW_CROSS_REPOSITORY_DEPENDENCIES = true
;; ;;
;; Enable OpenStreetMap button in Location field on user profiles
;ENABLE_OSM_BUTTON = true
;;
;; Enable heatmap on users profiles. ;; Enable heatmap on users profiles.
;ENABLE_USER_HEATMAP = true ;ENABLE_USER_HEATMAP = true
;; ;;

View file

@ -73,6 +73,7 @@ var Service = struct {
AllowCrossRepositoryDependencies bool AllowCrossRepositoryDependencies bool
DefaultAllowOnlyContributorsToTrackTime bool DefaultAllowOnlyContributorsToTrackTime bool
NoReplyAddress string NoReplyAddress string
EnableOSMButton bool
EnableUserHeatmap bool EnableUserHeatmap bool
AutoWatchNewRepos bool AutoWatchNewRepos bool
AutoWatchOnChanges bool AutoWatchOnChanges bool
@ -185,6 +186,7 @@ func loadServiceFrom(rootCfg ConfigProvider) {
Service.AllowCrossRepositoryDependencies = sec.Key("ALLOW_CROSS_REPOSITORY_DEPENDENCIES").MustBool(true) Service.AllowCrossRepositoryDependencies = sec.Key("ALLOW_CROSS_REPOSITORY_DEPENDENCIES").MustBool(true)
Service.DefaultAllowOnlyContributorsToTrackTime = sec.Key("DEFAULT_ALLOW_ONLY_CONTRIBUTORS_TO_TRACK_TIME").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.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.EnableUserHeatmap = sec.Key("ENABLE_USER_HEATMAP").MustBool(true)
Service.AutoWatchNewRepos = sec.Key("AUTO_WATCH_NEW_REPOS").MustBool(true) Service.AutoWatchNewRepos = sec.Key("AUTO_WATCH_NEW_REPOS").MustBool(true)
Service.AutoWatchOnChanges = sec.Key("AUTO_WATCH_ON_CHANGES").MustBool(false) Service.AutoWatchOnChanges = sec.Key("AUTO_WATCH_ON_CHANGES").MustBool(false)

View file

@ -52,6 +52,7 @@ func userProfile(ctx *context.Context) {
ctx.Data["Title"] = ctx.ContextUser.DisplayName() ctx.Data["Title"] = ctx.ContextUser.DisplayName()
ctx.Data["PageIsUserProfile"] = true ctx.Data["PageIsUserProfile"] = true
ctx.Data["EnableOSMButton"] = setting.Service.EnableOSMButton
// prepare heatmap data // prepare heatmap data
if setting.Service.EnableUserHeatmap { if setting.Service.EnableUserHeatmap {

View file

@ -27,11 +27,13 @@
<li> <li>
{{svg "octicon-location" 18 "gt-mr-2"}} {{svg "octicon-location" 18 "gt-mr-2"}}
{{.ContextUser.Location}} {{.ContextUser.Location}}
{{if .EnableOSMButton}}
<a href="https://www.openstreetmap.org/search?query={{.ContextUser.Location}}" rel="nofollow noreferrer"> <a href="https://www.openstreetmap.org/search?query={{.ContextUser.Location}}" rel="nofollow noreferrer">
<i class="ui right"> <i class="ui right">
{{svg "octicon-link-external" 18 "gt-mr-2"}} {{svg "octicon-link-external" 18 "gt-mr-2"}}
</i> </i>
</a> </a>
{{end}}
</li> </li>
{{end}} {{end}}
{{if (eq .SignedUserID .ContextUser.ID)}} {{if (eq .SignedUserID .ContextUser.ID)}}

View file

@ -279,6 +279,7 @@ func TestListStopWatches(t *testing.T) {
} }
func TestGetOpenStreetMapLink(t *testing.T) { func TestGetOpenStreetMapLink(t *testing.T) {
setting.Service.EnableOSMButton = true
defer tests.PrepareTestEnv(t)() defer tests.PrepareTestEnv(t)()
testLocations := map[string]string{ testLocations := map[string]string{