From bb187d5f617f8efceb41810d6ff9adcaa60450bb Mon Sep 17 00:00:00 2001
From: "Panagiotis \"Ivory\" Vasilopoulos" <git@n0toose.net>
Date: Wed, 2 Aug 2023 17:18:34 +0200
Subject: [PATCH] [FEAT] Use OpenStreetMap in USER_LOCATION_MAP_URL by default

Follow-up to d58c5425799335ea57f27461f99ddd1078e9b2de for Forgejo.

By default, Gitea does not select any map service that can be used
to introduce a 'Show this place on a map' button in the location
field of a user profile. Before I tried upstreaming this change to
Gitea, this was the case in Forgejo. This patch essentially recovers
this functionality, which is nice for public-facing instances and
communities.

Links to original PRs:
- https://codeberg.org/forgejo/forgejo/pulls/1076
- https://github.com/go-gitea/gitea/pull/26214
---
 custom/conf/app.example.ini | 4 ++--
 modules/setting/service.go  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini
index b50c5b6738..852c59c92e 100644
--- a/custom/conf/app.example.ini
+++ b/custom/conf/app.example.ini
@@ -829,12 +829,12 @@ LEVEL = Info
 ;;
 ;; Default map service. No external API support has been included. A service has to allow
 ;; searching using URL parameters, the location will be appended to the URL as escaped query parameter.
-;; Disabled by default, some example values are:
+;; Some example values are:
 ;; - OpenStreetMap: https://www.openstreetmap.org/search?query=
 ;; - Google Maps: https://www.google.com/maps/place/
 ;; - MapQuest: https://www.mapquest.com/search/
 ;; - Bing Maps: https://www.bing.com/maps?where1=
-; USER_LOCATION_MAP_URL =
+; USER_LOCATION_MAP_URL = https://www.openstreetmap.org/search?query=
 ;;
 ;; Enable heatmap on users profiles.
 ;ENABLE_USER_HEATMAP = true
diff --git a/modules/setting/service.go b/modules/setting/service.go
index 595ea6528f..f1b415ef70 100644
--- a/modules/setting/service.go
+++ b/modules/setting/service.go
@@ -186,7 +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.UserLocationMapURL = sec.Key("USER_LOCATION_MAP_URL").String()
+	Service.UserLocationMapURL = sec.Key("USER_LOCATION_MAP_URL").MustString("https://www.openstreetmap.org/search?query=")
 	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)