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" .}} + +