Browse Source

Карта сообществ #20

Заодно добавлена ссылка на карте, чтобы можно было легко перейти либо на пользователя, либо на сообщество.
pull/114/head
parent
commit
7bb71a8f74
  1. 40
      routers/web/map/orgmap.go
  2. 1
      routers/web/web.go
  3. 4
      templates/map/navbar.tmpl
  4. 4
      templates/map/umap.tmpl

40
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)
}

1
routers/web/web.go

@ -257,6 +257,7 @@ func RegisterRoutes(m *web.Route) {
}, ignExploreSignIn) }, ignExploreSignIn)
m.Group("/map", func() { m.Group("/map", func() {
m.Get("/umap", umap.UsersMap) m.Get("/umap", umap.UsersMap)
m.Get("/orgmap", umap.Organizations)
}, ignExploreSignIn) }, ignExploreSignIn)
m.Get("/issues", reqSignIn, user.Issues) m.Get("/issues", reqSignIn, user.Issues)
m.Get("/pulls", reqSignIn, user.Pulls) m.Get("/pulls", reqSignIn, user.Pulls)

4
templates/map/navbar.tmpl

@ -1,7 +1,9 @@
<div class="ui secondary pointing tabular top attached borderless stackable menu new-menu navbar"> <div class="ui secondary pointing tabular top attached borderless stackable menu new-menu navbar">
<!--
<a class="{{if .PageIsMapRepositories}}active{{end}} item" href="{{AppSubUrl}}/map/rmap"> <a class="{{if .PageIsMapRepositories}}active{{end}} item" href="{{AppSubUrl}}/map/rmap">
{{svg "octicon-repo"}} {{.i18n.Tr "explore.repos"}} {{svg "octicon-repo"}} {{.i18n.Tr "explore.repos"}}
</a> </a>
-->
{{if not .UsersIsDisabled}} {{if not .UsersIsDisabled}}
<a class="{{if .PageIsMapUsers}}active{{end}} item" href="{{AppSubUrl}}/map/umap"> <a class="{{if .PageIsMapUsers}}active{{end}} item" href="{{AppSubUrl}}/map/umap">
{{svg "octicon-person"}} {{.i18n.Tr "explore.users"}} {{svg "octicon-person"}} {{.i18n.Tr "explore.users"}}
@ -10,9 +12,11 @@
<a class="{{if .PageIsMapOrganizations}}active{{end}} item" href="{{AppSubUrl}}/map/orgmap"> <a class="{{if .PageIsMapOrganizations}}active{{end}} item" href="{{AppSubUrl}}/map/orgmap">
{{svg "octicon-organization"}} {{.i18n.Tr "explore.organizations"}} {{svg "octicon-organization"}} {{.i18n.Tr "explore.organizations"}}
</a> </a>
<!--
{{if .IsRepoIndexerEnabled}} {{if .IsRepoIndexerEnabled}}
<a class="{{if .PageIsMapCode}}active{{end}} item" href="{{AppSubUrl}}/map/codemap"> <a class="{{if .PageIsMapCode}}active{{end}} item" href="{{AppSubUrl}}/map/codemap">
{{svg "octicon-code"}} {{.i18n.Tr "explore.code"}} {{svg "octicon-code"}} {{.i18n.Tr "explore.code"}}
</a> </a>
{{end}} {{end}}
-->
</div> </div>

4
templates/map/umap.tmpl

@ -1,8 +1,6 @@
{{template "base/head" .}} {{template "base/head" .}}
<div class="page-content explore repositories"> <div class="page-content explore repositories">
<!--
{{template "map/navbar" .}} {{template "map/navbar" .}}
-->
<link rel="stylesheet" href="/assets/lib/leaflet/dist/leaflet.css" crossorigin="" /> <link rel="stylesheet" href="/assets/lib/leaflet/dist/leaflet.css" crossorigin="" />
<script src="/assets/lib/leaflet/dist/leaflet.js"></script> <script src="/assets/lib/leaflet/dist/leaflet.js"></script>
<script src="/assets/lib/leaflet.markercluster/dist/leaflet.markercluster.js"></script> <script src="/assets/lib/leaflet.markercluster/dist/leaflet.markercluster.js"></script>
@ -23,7 +21,7 @@
{{range .Users}} {{range .Users}}
{{if .LocationCoordinate}} {{if .LocationCoordinate}}
[parseFloat({{.LocationCoordinate}}.split(',')[0]) , parseFloat({{.LocationCoordinate}}.split(',')[1]), "{{avatar .}} {{.HomeLink}} {{.FullName}} <li> <div class=\"render-content markup\"> {{.Description | Str2html}} </div> </li>"], [parseFloat({{.LocationCoordinate}}.split(',')[0]) , parseFloat({{.LocationCoordinate}}.split(',')[1]), "<a href='{{.HomeLink}}'>{{avatar .}} {{.FullName}}</a> <li> <div class=\"render-content markup\"> {{.Description | Str2html}} </div> </li>"],
{{end}} {{end}}
{{else}} {{else}}

Loading…
Cancel
Save