From ef0c047e994507790296c9b34112f8e9d541135e Mon Sep 17 00:00:00 2001 From: Artur Galyamov Date: Fri, 2 Sep 2022 19:15:10 +0500 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=20=D0=BF=D0=BE=D0=B8=D1=81=D0=BA=20=D0=BB?= =?UTF-8?q?=D0=B8=D1=86=20=D0=BF=D0=BE=20=D1=80=D0=B5=D1=81=D1=83=D1=80?= =?UTF-8?q?=D1=81=D0=B0=D0=BC=20=D0=B8=20=D0=B8=D0=BD=D1=82=D0=B5=D1=80?= =?UTF-8?q?=D0=B5=D1=81=D0=B0=D0=BC=20#106?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit пока выводятся форматированные компетенции --- models/user/search.go | 6 ++++++ options/locale/locale_ru-RU.ini | 2 ++ routers/web/explore/interest.go | 33 +++++++++++++++++++++++++++++++++ routers/web/explore/resource.go | 33 +++++++++++++++++++++++++++++++++ routers/web/web.go | 2 ++ templates/explore/interests.tmpl | 39 +++++++++++++++++++++++++++++++++++++++ templates/explore/navbar.tmpl | 6 ++++++ templates/explore/resources.tmpl | 39 +++++++++++++++++++++++++++++++++++++++ 8 files changed, 160 insertions(+) create mode 100644 routers/web/explore/interest.go create mode 100644 routers/web/explore/resource.go create mode 100644 templates/explore/interests.tmpl create mode 100644 templates/explore/resources.tmpl diff --git a/models/user/search.go b/models/user/search.go index f33039582f..4edb4c9f03 100644 --- a/models/user/search.go +++ b/models/user/search.go @@ -22,6 +22,8 @@ type SearchKind int64 const ( ByDescription SearchKind = iota ByCompetence + ByResource + ByInterest ) // SearchUserOptions contains the options for searching @@ -67,6 +69,10 @@ func (opts *SearchUserOptions) toSearchQueryBase() *xorm.Session { keywordCond = builder.Or(builder.Like{"LOWER(description)", lowerKeyword}) case ByCompetence: keywordCond = builder.Or(builder.Like{"LOWER(competences)", lowerKeyword}) + case ByResource: + keywordCond = builder.Or(builder.Like{"LOWER(resources)", lowerKeyword}) + case ByInterest: + keywordCond = builder.Or(builder.Like{"LOWER(interests)", lowerKeyword}) default: keywordCond = builder.Or(builder.Like{"LOWER(description)", lowerKeyword}) } diff --git a/options/locale/locale_ru-RU.ini b/options/locale/locale_ru-RU.ini index 27f9c4fa72..4bc3f3faf8 100644 --- a/options/locale/locale_ru-RU.ini +++ b/options/locale/locale_ru-RU.ini @@ -260,6 +260,8 @@ organizations=Сообщества search=Поиск code=Файлы competences=Компетенции +resources=Ресурсы +interests=Интересы search.fuzzy=Неточный search.match=Соответствие repo_no_results=Подходящие проекты не найдены. diff --git a/routers/web/explore/interest.go b/routers/web/explore/interest.go new file mode 100644 index 0000000000..071b989f36 --- /dev/null +++ b/routers/web/explore/interest.go @@ -0,0 +1,33 @@ +package explore + +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" + "code.gitea.io/gitea/modules/util" +) + +const ( + tplExploreInterests base.TplName = "explore/interests" +) + +func Interests(ctx *context.Context) { + ctx.Data["UsersIsDisabled"] = setting.Service.Explore.DisableUsersPage + ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled + ctx.Data["Title"] = ctx.Tr("explore") + ctx.Data["PageIsExplore"] = true + ctx.Data["PageIsExploreInterests"] = true + + RenderUserSearch(ctx, &user_model.SearchUserOptions{ + Actor: ctx.User, + Type: user_model.UserTypeIdentity, + ListOptions: db.ListOptions{PageSize: setting.UI.ExplorePagingNum}, + IsActive: util.OptionalBoolTrue, + Visible: []structs.VisibleType{structs.VisibleTypePublic, structs.VisibleTypeLimited, structs.VisibleTypePrivate}, + Kind: user_model.ByInterest, + }, tplExploreInterests) + +} diff --git a/routers/web/explore/resource.go b/routers/web/explore/resource.go new file mode 100644 index 0000000000..f13300bbf0 --- /dev/null +++ b/routers/web/explore/resource.go @@ -0,0 +1,33 @@ +package explore + +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" + "code.gitea.io/gitea/modules/util" +) + +const ( + tplExploreResources base.TplName = "explore/resources" +) + +func Resources(ctx *context.Context) { + ctx.Data["UsersIsDisabled"] = setting.Service.Explore.DisableUsersPage + ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled + ctx.Data["Title"] = ctx.Tr("explore") + ctx.Data["PageIsExplore"] = true + ctx.Data["PageIsExploreResources"] = true + + RenderUserSearch(ctx, &user_model.SearchUserOptions{ + Actor: ctx.User, + Type: user_model.UserTypeIdentity, + ListOptions: db.ListOptions{PageSize: setting.UI.ExplorePagingNum}, + IsActive: util.OptionalBoolTrue, + Visible: []structs.VisibleType{structs.VisibleTypePublic, structs.VisibleTypeLimited, structs.VisibleTypePrivate}, + Kind: user_model.ByResource, + }, tplExploreResources) + +} diff --git a/routers/web/web.go b/routers/web/web.go index 1851333e92..1fdd330df0 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -255,6 +255,8 @@ func RegisterRoutes(m *web.Route) { m.Get("/organizations", explore.Organizations) m.Get("/code", explore.Code) m.Get("/competences", explore.Competences) + m.Get("/resources", explore.Resources) + m.Get("/interests", explore.Interests) }, ignExploreSignIn) m.Group("/map", func() { m.Get("/umap", umap.UsersMap) diff --git a/templates/explore/interests.tmpl b/templates/explore/interests.tmpl new file mode 100644 index 0000000000..91fece10f9 --- /dev/null +++ b/templates/explore/interests.tmpl @@ -0,0 +1,39 @@ +{{template "base/head" .}} + +
+ {{template "explore/navbar" .}} +
+ {{template "explore/search" .}} + +
+ {{range .Users}} +
+ {{avatar .}} +
+ {{.Name}} {{.FullName}} +
+ {{if .Location}} + {{svg "octicon-location"}} {{.Location}} ({{.LocationCoordinate}}) + {{end}} + {{if and $.ShowUserEmail .Email $.IsSigned (not .KeepEmailPrivate)}} + {{svg "octicon-mail"}} + {{.Email}} + {{end}} + {{svg "octicon-clock"}} {{$.i18n.Tr "user.join_on"}} {{.CreatedUnix.FormatShort}} + {{if .Competences}} +

Компетенции:

+
{{(index $.RenderedCompetences .ID)|Str2html}}
+ {{end}} +
+
+
+ {{else}} +
{{$.i18n.Tr "explore.user_no_results"}}
+ {{end}} +
+ + {{template "base/paginate" .}} +
+
+ +{{template "base/footer" .}} diff --git a/templates/explore/navbar.tmpl b/templates/explore/navbar.tmpl index 8ab195895b..4e3d74a921 100644 --- a/templates/explore/navbar.tmpl +++ b/templates/explore/navbar.tmpl @@ -18,4 +18,10 @@ {{svg "octicon-book"}} {{.i18n.Tr "explore.competences"}} + + {{svg "octicon-briefcase"}} {{.i18n.Tr "explore.resources"}} + + + {{svg "octicon-code-of-conduct"}} {{.i18n.Tr "explore.interests"}} + diff --git a/templates/explore/resources.tmpl b/templates/explore/resources.tmpl new file mode 100644 index 0000000000..91fece10f9 --- /dev/null +++ b/templates/explore/resources.tmpl @@ -0,0 +1,39 @@ +{{template "base/head" .}} + +
+ {{template "explore/navbar" .}} +
+ {{template "explore/search" .}} + +
+ {{range .Users}} +
+ {{avatar .}} +
+ {{.Name}} {{.FullName}} +
+ {{if .Location}} + {{svg "octicon-location"}} {{.Location}} ({{.LocationCoordinate}}) + {{end}} + {{if and $.ShowUserEmail .Email $.IsSigned (not .KeepEmailPrivate)}} + {{svg "octicon-mail"}} + {{.Email}} + {{end}} + {{svg "octicon-clock"}} {{$.i18n.Tr "user.join_on"}} {{.CreatedUnix.FormatShort}} + {{if .Competences}} +

Компетенции:

+
{{(index $.RenderedCompetences .ID)|Str2html}}
+ {{end}} +
+
+
+ {{else}} +
{{$.i18n.Tr "explore.user_no_results"}}
+ {{end}} +
+ + {{template "base/paginate" .}} +
+
+ +{{template "base/footer" .}}