Skip to content

Commit

Permalink
Split "modules/context.go" to separate files (#24569)
Browse files Browse the repository at this point in the history
The "modules/context.go" is too large to maintain.

This PR splits it to separate files, eg: context_request.go,
context_response.go, context_serve.go

This PR will help:

1. The future refactoring for Gitea's web context (eg: simplify the context)
2. Introduce proper "range request" support
3. Introduce context function

This PR only moves code, doesn't change any logic.
  • Loading branch information
wxiaoguang authored May 8, 2023
1 parent ff56292 commit cb700ae
Show file tree
Hide file tree
Showing 18 changed files with 747 additions and 676 deletions.
3 changes: 0 additions & 3 deletions models/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ import (
"xorm.io/builder"
)

// ItemsPerPage maximum items per page in forks, watchers and stars of a repo
var ItemsPerPage = 40

// Init initialize model
func Init(ctx context.Context) error {
if err := unit.LoadUnitConfig(); err != nil {
Expand Down
24 changes: 24 additions & 0 deletions models/repo/search.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT

package repo

import "code.gitea.io/gitea/models/db"

// SearchOrderByMap represents all possible search order
var SearchOrderByMap = map[string]map[string]db.SearchOrderBy{
"asc": {
"alpha": db.SearchOrderByAlphabetically,
"created": db.SearchOrderByOldest,
"updated": db.SearchOrderByLeastUpdated,
"size": db.SearchOrderBySize,
"id": db.SearchOrderByID,
},
"desc": {
"alpha": db.SearchOrderByAlphabeticallyReverse,
"created": db.SearchOrderByNewest,
"updated": db.SearchOrderByRecentUpdated,
"size": db.SearchOrderBySizeReverse,
"id": db.SearchOrderByIDReverse,
},
}
Loading

0 comments on commit cb700ae

Please sign in to comment.