Skip to content

Commit

Permalink
Merge branch 'main' into fix-org-title
Browse files Browse the repository at this point in the history
  • Loading branch information
GiteaBot authored Nov 10, 2023
2 parents 60e1c4c + 6035733 commit eb4ae2c
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 16 deletions.
4 changes: 4 additions & 0 deletions custom/conf/app.example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,10 @@ LEVEL = Info
;; Whether to only show relevant repos on the explore page when no keyword is specified and default sorting is used.
;; A repo is considered irrelevant if it's a fork or if it has no metadata (no description, no icon, no topic).
;ONLY_SHOW_RELEVANT_REPOS = false
;;
;; Change the sort type of the explore pages.
;; Default is "recentupdate", but you also have "alphabetically", "reverselastlogin", "newest", "oldest".
;EXPLORE_PAGING_DEFAULT_SORT = recentupdate

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Expand Down
3 changes: 2 additions & 1 deletion docs/content/administration/config-cheat-sheet.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,9 @@ The following configuration set `Content-Type: application/vnd.android.package-a
add it to this config.
- `DEFAULT_SHOW_FULL_NAME`: **false**: Whether the full name of the users should be shown where possible. If the full name isn't set, the username will be used.
- `SEARCH_REPO_DESCRIPTION`: **true**: Whether to search within description at repository search on explore page.
- `ONLY_SHOW_RELEVANT_REPOS`: **false** Whether to only show relevant repos on the explore page when no keyword is specified and default sorting is used.
- `ONLY_SHOW_RELEVANT_REPOS`: **false**: Whether to only show relevant repos on the explore page when no keyword is specified and default sorting is used.
A repo is considered irrelevant if it's a fork or if it has no metadata (no description, no icon, no topic).
- `EXPLORE_PAGING_DEFAULT_SORT`: **recentupdate**: Change the sort type of the explore pages. Valid values are "recentupdate", "alphabetically", "reverselastlogin", "newest" and "oldest"

### UI - Admin (`ui.admin`)

Expand Down
3 changes: 2 additions & 1 deletion docs/content/usage/profile-readme.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ menu:

# Profile READMEs

To display a Markdown file in your Gitea profile page, simply create a repository named `.profile` and add a new file called `README.md`. Gitea will automatically display the contents of the file on your profile, above your repositories.
To display a Markdown file in your Gitea user or organization profile page, create a repository named `.profile` and add a new file named `README.md` to it.
Gitea will automatically display the contents of the file on your profile, in a new "Overview" above your repositories.

Making the `.profile` repository private will hide the Profile README.
1 change: 1 addition & 0 deletions modules/setting/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var UI = struct {
CustomEmojisMap map[string]string `ini:"-"`
SearchRepoDescription bool
OnlyShowRelevantRepos bool
ExploreDefaultSort string `ini:"EXPLORE_PAGING_DEFAULT_SORT"`

Notification struct {
MinTimeout time.Duration
Expand Down
2 changes: 1 addition & 1 deletion routers/web/admin/orgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func Organizations(ctx *context.Context) {
ctx.Data["PageIsAdminOrganizations"] = true

if ctx.FormString("sort") == "" {
ctx.SetFormString("sort", explore.UserSearchDefaultAdminSort)
ctx.SetFormString("sort", UserSearchDefaultAdminSort)
}

explore.RenderUserSearch(ctx, &user_model.SearchUserOptions{
Expand Down
5 changes: 4 additions & 1 deletion routers/web/admin/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ const (
tplUserEdit base.TplName = "admin/user/edit"
)

// UserSearchDefaultAdminSort is the default sort type for admin view
const UserSearchDefaultAdminSort = "alphabetically"

// Users show all the users
func Users(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("admin.users")
Expand All @@ -56,7 +59,7 @@ func Users(ctx *context.Context) {

sortType := ctx.FormString("sort")
if sortType == "" {
sortType = explore.UserSearchDefaultAdminSort
sortType = UserSearchDefaultAdminSort
ctx.SetFormString("sort", sortType)
}
ctx.PageData["adminUserListSearchForm"] = map[string]any{
Expand Down
2 changes: 1 addition & 1 deletion routers/web/explore/org.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func Organizations(ctx *context.Context) {
}

if ctx.FormString("sort") == "" {
ctx.SetFormString("sort", UserSearchDefaultSortType)
ctx.SetFormString("sort", setting.UI.ExploreDefaultSort)
}

RenderUserSearch(ctx, &user_model.SearchUserOptions{
Expand Down
9 changes: 7 additions & 2 deletions routers/web/explore/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,13 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
orderBy db.SearchOrderBy
)

ctx.Data["SortType"] = ctx.FormString("sort")
switch ctx.FormString("sort") {
sortOrder := ctx.FormString("sort")
if sortOrder == "" {
sortOrder = setting.UI.ExploreDefaultSort
}
ctx.Data["SortType"] = sortOrder

switch sortOrder {
case "newest":
orderBy = db.SearchOrderByNewest
case "oldest":
Expand Down
17 changes: 8 additions & 9 deletions routers/web/explore/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ const (
tplExploreUsers base.TplName = "explore/users"
)

// UserSearchDefaultSortType is the default sort type for user search
const (
UserSearchDefaultSortType = "recentupdate"
UserSearchDefaultAdminSort = "alphabetically"
)

var nullByte = []byte{0x00}

func isKeywordValid(keyword string) bool {
Expand Down Expand Up @@ -60,8 +54,13 @@ func RenderUserSearch(ctx *context.Context, opts *user_model.SearchUserOptions,

// we can not set orderBy to `models.SearchOrderByXxx`, because there may be a JOIN in the statement, different tables may have the same name columns

ctx.Data["SortType"] = ctx.FormString("sort")
switch ctx.FormString("sort") {
sortOrder := ctx.FormString("sort")
if sortOrder == "" {
sortOrder = setting.UI.ExploreDefaultSort
}
ctx.Data["SortType"] = sortOrder

switch sortOrder {
case "newest":
orderBy = "`user`.id DESC"
case "oldest":
Expand Down Expand Up @@ -134,7 +133,7 @@ func Users(ctx *context.Context) {
ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled

if ctx.FormString("sort") == "" {
ctx.SetFormString("sort", UserSearchDefaultSortType)
ctx.SetFormString("sort", setting.UI.ExploreDefaultSort)
}

RenderUserSearch(ctx, &user_model.SearchUserOptions{
Expand Down
26 changes: 26 additions & 0 deletions routers/web/org/home.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
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/git"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/markup"
"code.gitea.io/gitea/modules/markup/markdown"
"code.gitea.io/gitea/modules/setting"
Expand Down Expand Up @@ -155,5 +157,29 @@ func Home(ctx *context.Context) {

ctx.Data["ShowMemberAndTeamTab"] = ctx.Org.IsMember || len(members) > 0

profileGitRepo, profileReadmeBlob, profileClose := shared_user.FindUserProfileReadme(ctx)
defer profileClose()
prepareOrgProfileReadme(ctx, profileGitRepo, profileReadmeBlob)

ctx.HTML(http.StatusOK, tplOrgHome)
}

func prepareOrgProfileReadme(ctx *context.Context, profileGitRepo *git.Repository, profileReadme *git.Blob) {
if profileGitRepo == nil || profileReadme == nil {
return
}

if bytes, err := profileReadme.GetBlobContent(setting.UI.MaxDisplayFileSize); err != nil {
log.Error("failed to GetBlobContent: %v", err)
} else {
if profileContent, err := markdown.RenderString(&markup.RenderContext{
Ctx: ctx,
GitRepo: profileGitRepo,
Metas: map[string]string{"mode": "document"},
}, bytes); err != nil {
log.Error("failed to RenderString: %v", err)
} else {
ctx.Data["ProfileReadme"] = profileContent
}
}
}
3 changes: 3 additions & 0 deletions templates/org/home.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
<div class="ui container">
<div class="ui mobile reversed stackable grid">
<div class="ui {{if .ShowMemberAndTeamTab}}eleven wide{{end}} column">
{{if .ProfileReadme}}
<div id="readme_profile" class="markup">{{.ProfileReadme | Str2html}}</div>
{{end}}
{{template "explore/repo_search" .}}
{{template "explore/repo_list" .}}
{{template "base/paginate" .}}
Expand Down

0 comments on commit eb4ae2c

Please sign in to comment.