Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'Show on a map' button to Location in profile, fix layout #26214

Merged
merged 22 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
8fdd3ac
Add OpenStreetMap URL to Location field in profile
n0toose Jul 29, 2023
560cc47
Fix small indentation error in CSS
n0toose Jul 29, 2023
3833501
Address comments by wxiaoguang
n0toose Jul 29, 2023
8d77d74
Oops, I actually forgot to push the changes.
n0toose Jul 30, 2023
4554222
Improve tips in app.example.ini
n0toose Jul 30, 2023
5b79191
Okay, I mixed up the spaces and the tabs, oops
n0toose Jul 30, 2023
e35e391
Address comments, use <span> for 'Joined on'
n0toose Jul 30, 2023
7ff0695
Generalize string
n0toose Jul 30, 2023
6452720
Address some further comments, replace 'Show' with 'View'
n0toose Jul 30, 2023
62ce4ca
Remove class="ui right" entirely, as flex-grow: 1 does the job
n0toose Jul 30, 2023
c667c6c
Oops, missed one.
n0toose Jul 30, 2023
19183f3
Merge branch 'main' into osm-urls-in-profiles
n0toose Jul 30, 2023
b6e4991
Disable feature by default
n0toose Jul 30, 2023
f19f308
sync config name, add config doc, add QueryEscape
wxiaoguang Jul 30, 2023
d00a49e
fix layout
wxiaoguang Jul 30, 2023
635c6e4
add test for manually escaping
wxiaoguang Jul 30, 2023
682bd4b
Merge branch 'main' into osm-urls-in-profiles
GiteaBot Jul 31, 2023
2b3e152
Merge branch 'main' into osm-urls-in-profiles
GiteaBot Jul 31, 2023
650babd
Merge branch 'main' into osm-urls-in-profiles
GiteaBot Jul 31, 2023
6506687
Merge branch 'main' into osm-urls-in-profiles
GiteaBot Jul 31, 2023
fed5bc1
Merge branch 'main' into osm-urls-in-profiles
GiteaBot Jul 31, 2023
f48ff4f
Merge branch 'main' into osm-urls-in-profiles
GiteaBot Jul 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions custom/conf/app.example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,17 @@ 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 button that redirects users to a map service in Location fields on profiles
;ENABLE_LOCATION_BUTTON = true
;;
;; Default map service. No external API support has been included. A service has to allow
;; searching using URL parameters. Only relevant if ENABLE_LOCATION_BUTTON is enabled.
;; Some examples are:
;; - https://www.google.com/maps/place/
;; - https://www.mapquest.com/search/
;; - https://www.bing.com/maps?where1=
; LOCATION_QUERY_URL = https://www.openstreetmap.org/search?query=
;;
wxiaoguang marked this conversation as resolved.
Show resolved Hide resolved
;; Enable heatmap on users profiles.
;ENABLE_USER_HEATMAP = true
;;
Expand Down
4 changes: 4 additions & 0 deletions modules/setting/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ var Service = struct {
AllowCrossRepositoryDependencies bool
DefaultAllowOnlyContributorsToTrackTime bool
NoReplyAddress string
EnableLocationButton bool
LocationQueryURL string
EnableUserHeatmap bool
AutoWatchNewRepos bool
AutoWatchOnChanges bool
Expand Down Expand Up @@ -185,6 +187,8 @@ 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.EnableLocationButton = sec.Key("ENABLE_OSM_BUTTON").MustBool(true)
Service.LocationQueryURL = sec.Key("LOCATION_QUERY_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)
Expand Down
2 changes: 2 additions & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,7 @@ user_bio = Biography
disabled_public_activity = This user has disabled the public visibility of the activity.
email_visibility.limited = Your email address is visible to all authenticated users
email_visibility.private = Your email address is only visible to you and administrators
redirect_to_osm = View on OpenStreetMap
n0toose marked this conversation as resolved.
Show resolved Hide resolved

form.name_reserved = The username "%s" is reserved.
form.name_pattern_not_allowed = The pattern "%s" is not allowed in a username.
Expand All @@ -627,6 +628,7 @@ webauthn = Security Keys

public_profile = Public Profile
biography_placeholder = Tell us a little bit about yourself
location_placeholder = Share your approximate location with others
profile_desc = Your email address will be used for notifications and other operations.
password_username_disabled = Non-local users are not allowed to change their username. Please contact your site administrator for more details.
full_name = Full Name
Expand Down
2 changes: 2 additions & 0 deletions routers/web/user/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ func userProfile(ctx *context.Context) {

ctx.Data["Title"] = ctx.ContextUser.DisplayName()
ctx.Data["PageIsUserProfile"] = true
ctx.Data["EnableLocationButton"] = setting.Service.EnableLocationButton
ctx.Data["LocationQueryURL"] = setting.Service.LocationQueryURL

// prepare heatmap data
if setting.Service.EnableUserHeatmap {
Expand Down
14 changes: 13 additions & 1 deletion templates/shared/user/profile_big_avatar.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,19 @@
<div class="extra content gt-word-break">
<ul>
{{if .ContextUser.Location}}
<li>{{svg "octicon-location"}} {{.ContextUser.Location}}</li>
<li>
{{svg "octicon-location"}}
<span>{{.ContextUser.Location}}</span>
{{/* Checking whether .LocationQueryURL is empty is arguably excessive, but makes this functionality foolproof */}}
{{if and .EnableLocationButton .LocationQueryURL}}
{{/* We presume that the LocationQueryURL is safe, as it is provided by the site administrator. */}}
<a href="{{.LocationQueryURL | Safe}}{{.ContextUser.Location}}" rel="nofollow noreferrer">
n0toose marked this conversation as resolved.
Show resolved Hide resolved
<i class="ui right" data-tooltip-content="{{.locale.Tr "user.redirect_to_osm"}}">
n0toose marked this conversation as resolved.
Show resolved Hide resolved
{{svg "octicon-link-external"}}
</i>
</a>
{{end}}
</li>
{{end}}
{{if (eq .SignedUserID .ContextUser.ID)}}
<li>
Expand Down
2 changes: 1 addition & 1 deletion templates/user/settings/profile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</div>
<div class="field">
<label for="location">{{.locale.Tr "settings.location"}}</label>
<input id="location" name="location" value="{{.SignedUser.Location}}" maxlength="50">
<input id="location" name="location" placeholder="{{.locale.Tr "settings.location_placeholder"}}" value="{{.SignedUser.Location}}" maxlength="50">
</div>

<div class="divider"></div>
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package integration

import (
"fmt"

Check failure on line 7 in tests/integration/user_test.go

View workflow job for this annotation

GitHub Actions / lint-backend

"fmt" imported and not used

Check failure on line 7 in tests/integration/user_test.go

View workflow job for this annotation

GitHub Actions / lint-go-gogit

"fmt" imported and not used

Check failure on line 7 in tests/integration/user_test.go

View workflow job for this annotation

GitHub Actions / lint-go-windows

"fmt" imported and not used

Check failure on line 7 in tests/integration/user_test.go

View workflow job for this annotation

GitHub Actions / test-pgsql

"fmt" imported and not used

Check failure on line 7 in tests/integration/user_test.go

View workflow job for this annotation

GitHub Actions / test-mysql5

"fmt" imported and not used

Check failure on line 7 in tests/integration/user_test.go

View workflow job for this annotation

GitHub Actions / test-mysql8

"fmt" imported and not used

Check failure on line 7 in tests/integration/user_test.go

View workflow job for this annotation

GitHub Actions / test-mssql

"fmt" imported and not used

Check failure on line 7 in tests/integration/user_test.go

View workflow job for this annotation

GitHub Actions / test-sqlite

"fmt" imported and not used
"net/http"
"testing"

Expand All @@ -12,6 +13,7 @@
repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/unittest"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/setting"

Check failure on line 16 in tests/integration/user_test.go

View workflow job for this annotation

GitHub Actions / lint-backend

"code.gitea.io/gitea/modules/setting" imported and not used (typecheck)

Check failure on line 16 in tests/integration/user_test.go

View workflow job for this annotation

GitHub Actions / lint-go-gogit

"code.gitea.io/gitea/modules/setting" imported and not used (typecheck)

Check failure on line 16 in tests/integration/user_test.go

View workflow job for this annotation

GitHub Actions / lint-go-windows

"code.gitea.io/gitea/modules/setting" imported and not used (typecheck)

Check failure on line 16 in tests/integration/user_test.go

View workflow job for this annotation

GitHub Actions / test-pgsql

"code.gitea.io/gitea/modules/setting" imported and not used

Check failure on line 16 in tests/integration/user_test.go

View workflow job for this annotation

GitHub Actions / test-mysql5

"code.gitea.io/gitea/modules/setting" imported and not used

Check failure on line 16 in tests/integration/user_test.go

View workflow job for this annotation

GitHub Actions / test-mysql8

"code.gitea.io/gitea/modules/setting" imported and not used

Check failure on line 16 in tests/integration/user_test.go

View workflow job for this annotation

GitHub Actions / test-mssql

"code.gitea.io/gitea/modules/setting" imported and not used

Check failure on line 16 in tests/integration/user_test.go

View workflow job for this annotation

GitHub Actions / test-sqlite

"code.gitea.io/gitea/modules/setting" imported and not used
api "code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/test"
"code.gitea.io/gitea/modules/translation"
Expand Down
5 changes: 5 additions & 0 deletions web_src/css/user.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,14 @@
}

.user.profile .ui.card .extra.content > ul > li:not(:last-child) {
display: flex;
border-bottom: 1px solid var(--color-secondary);
}

.user.profile .ui.card .extra.content > ul > li:not(:last-child) > :nth-child(2) {
wxiaoguang marked this conversation as resolved.
Show resolved Hide resolved
flex-grow: 1;
n0toose marked this conversation as resolved.
Show resolved Hide resolved
}

.user.profile .ui.card .extra.content > ul > li .svg {
margin-left: 1px;
margin-right: 5px;
Expand Down
Loading