From 7bb71a8f744fc7ef1f1ca191304c2e681f5a456e Mon Sep 17 00:00:00 2001 From: Alexei Bezborodov Date: Wed, 31 Aug 2022 20:52:06 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9A=D0=B0=D1=80=D1=82=D0=B0=20=D1=81=D0=BE?= =?UTF-8?q?=D0=BE=D0=B1=D1=89=D0=B5=D1=81=D1=82=D0=B2=20#20=20=D0=97=D0=B0?= =?UTF-8?q?=D0=BE=D0=B4=D0=BD=D0=BE=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D1=81=D1=81=D1=8B=D0=BB=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BA=D0=B0=D1=80=D1=82=D0=B5,=20=D1=87=D1=82?= =?UTF-8?q?=D0=BE=D0=B1=D1=8B=20=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE=20=D0=B1?= =?UTF-8?q?=D1=8B=D0=BB=D0=BE=20=D0=BB=D0=B5=D0=B3=D0=BA=D0=BE=20=D0=BF?= =?UTF-8?q?=D0=B5=D1=80=D0=B5=D0=B9=D1=82=D0=B8=20=D0=BB=D0=B8=D0=B1=D0=BE?= =?UTF-8?q?=20=D0=BD=D0=B0=20=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D1=82=D0=B5=D0=BB=D1=8F,=20=D0=BB=D0=B8=D0=B1=D0=BE=20?= =?UTF-8?q?=D0=BD=D0=B0=20=D1=81=D0=BE=D0=BE=D0=B1=D1=89=D0=B5=D1=81=D1=82?= =?UTF-8?q?=D0=B2=D0=BE.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/web/map/orgmap.go | 40 ++++++++++++++++++++++++++++++++++++++++ routers/web/web.go | 1 + templates/map/navbar.tmpl | 4 ++++ templates/map/umap.tmpl | 4 +--- 4 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 routers/web/map/orgmap.go diff --git a/routers/web/map/orgmap.go b/routers/web/map/orgmap.go new file mode 100644 index 0000000000..96b84bb1ef --- /dev/null +++ b/routers/web/map/orgmap.go @@ -0,0 +1,40 @@ +// Copyright 2021 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package umap + +import ( + "code.gitea.io/gitea/models/db" + user_model "code.gitea.io/gitea/models/user" + "code.gitea.io/gitea/modules/base" + "code.gitea.io/gitea/modules/context" + "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/structs" +) + +const ( + // tpluMapOrganizations umap organizations page template + tpluMapOrganizations base.TplName = "map/umap" +) + +// Organizations render explore organizations page +func Organizations(ctx *context.Context) { + ctx.Data["UsersIsDisabled"] = setting.Service.Explore.DisableUsersPage + ctx.Data["Title"] = ctx.Tr("map") + ctx.Data["PageIsMap"] = true + ctx.Data["PageIsMapOrganizations"] = true + ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled + + visibleTypes := []structs.VisibleType{structs.VisibleTypePublic} + if ctx.User != nil { + visibleTypes = append(visibleTypes, structs.VisibleTypeLimited, structs.VisibleTypePrivate) + } + + RenderUserSearch(ctx, &user_model.SearchUserOptions{ + Actor: ctx.User, + Type: user_model.UserTypeOrganization, + ListOptions: db.ListOptions{PageSize: 8 * 1024}, // Get all users + Visible: visibleTypes, + }, tpluMapOrganizations) +} diff --git a/routers/web/web.go b/routers/web/web.go index aa946dd343..1810185425 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -257,6 +257,7 @@ func RegisterRoutes(m *web.Route) { }, ignExploreSignIn) m.Group("/map", func() { m.Get("/umap", umap.UsersMap) + m.Get("/orgmap", umap.Organizations) }, ignExploreSignIn) m.Get("/issues", reqSignIn, user.Issues) m.Get("/pulls", reqSignIn, user.Pulls) diff --git a/templates/map/navbar.tmpl b/templates/map/navbar.tmpl index 137f077657..dc674a4b47 100644 --- a/templates/map/navbar.tmpl +++ b/templates/map/navbar.tmpl @@ -1,7 +1,9 @@ diff --git a/templates/map/umap.tmpl b/templates/map/umap.tmpl index 8d40d7ea12..51c9f5c68f 100644 --- a/templates/map/umap.tmpl +++ b/templates/map/umap.tmpl @@ -1,8 +1,6 @@ {{template "base/head" .}}
- @@ -23,7 +21,7 @@ {{range .Users}} {{if .LocationCoordinate}} - [parseFloat({{.LocationCoordinate}}.split(',')[0]) , parseFloat({{.LocationCoordinate}}.split(',')[1]), "{{avatar .}} {{.HomeLink}} {{.FullName}}
  • {{.Description | Str2html}}
  • "], + [parseFloat({{.LocationCoordinate}}.split(',')[0]) , parseFloat({{.LocationCoordinate}}.split(',')[1]), "{{avatar .}} {{.FullName}}
  • {{.Description | Str2html}}
  • "], {{end}} {{else}}