parent
528682a294
commit
4b25bdfbc4
|
@ -3,7 +3,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra
|
||||||
|
|
||||||
![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true)
|
![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true)
|
||||||
|
|
||||||
##### Current tip version: 0.9.35 (see [Releases](https://github.com/gogits/gogs/releases) for binary versions)
|
##### Current tip version: 0.9.36 (see [Releases](https://github.com/gogits/gogs/releases) for binary versions)
|
||||||
|
|
||||||
| Web | UI | Preview |
|
| Web | UI | Preview |
|
||||||
|:-------------:|:-------:|:-------:|
|
|:-------------:|:-------:|:-------:|
|
||||||
|
|
|
@ -345,6 +345,10 @@ MIRROR = 300
|
||||||
CLONE = 300
|
CLONE = 300
|
||||||
PULL = 300
|
PULL = 300
|
||||||
|
|
||||||
|
[api]
|
||||||
|
; Max number of items will response in a page
|
||||||
|
MAX_RESPONSE_ITEMS = 50
|
||||||
|
|
||||||
[i18n]
|
[i18n]
|
||||||
LANGS = en-US,zh-CN,zh-HK,zh-TW,de-DE,fr-FR,nl-NL,lv-LV,ru-RU,ja-JP,es-ES,pt-BR,pl-PL,bg-BG,it-IT,fi-FI,tr-TR,cs-CZ
|
LANGS = en-US,zh-CN,zh-HK,zh-TW,de-DE,fr-FR,nl-NL,lv-LV,ru-RU,ja-JP,es-ES,pt-BR,pl-PL,bg-BG,it-IT,fi-FI,tr-TR,cs-CZ
|
||||||
NAMES = English,简体中文,繁體中文(香港),繁體中文(台湾),Deutsch,Français,Nederlands,Latviešu,Русский,日本語,Español,Português do Brasil,Polski,български,Italiano,Suomalainen,Türk,čeština
|
NAMES = English,简体中文,繁體中文(香港),繁體中文(台湾),Deutsch,Français,Nederlands,Latviešu,Русский,日本語,Español,Português do Brasil,Polski,български,Italiano,Suomalainen,Türk,čeština
|
||||||
|
|
2
gogs.go
2
gogs.go
|
@ -17,7 +17,7 @@ import (
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
const APP_VER = "0.9.35.0702"
|
const APP_VER = "0.9.36.0704"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||||
|
|
|
@ -1521,9 +1521,6 @@ func SearchRepositoryByName(opts *SearchRepoOptions) (repos []*Repository, _ int
|
||||||
}
|
}
|
||||||
opts.Keyword = strings.ToLower(opts.Keyword)
|
opts.Keyword = strings.ToLower(opts.Keyword)
|
||||||
|
|
||||||
if opts.PageSize <= 0 || opts.PageSize > setting.ExplorePagingNum {
|
|
||||||
opts.PageSize = setting.ExplorePagingNum
|
|
||||||
}
|
|
||||||
if opts.Page <= 0 {
|
if opts.Page <= 0 {
|
||||||
opts.Page = 1
|
opts.Page = 1
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -159,20 +159,6 @@ var (
|
||||||
SessionConfig session.Options
|
SessionConfig session.Options
|
||||||
CSRFCookieName = "_csrf"
|
CSRFCookieName = "_csrf"
|
||||||
|
|
||||||
// Git settings
|
|
||||||
Git struct {
|
|
||||||
MaxGitDiffLines int
|
|
||||||
MaxGitDiffLineCharacters int
|
|
||||||
MaxGitDiffFiles int
|
|
||||||
GcArgs []string `delim:" "`
|
|
||||||
Timeout struct {
|
|
||||||
Migrate int
|
|
||||||
Mirror int
|
|
||||||
Clone int
|
|
||||||
Pull int
|
|
||||||
} `ini:"git.timeout"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cron tasks
|
// Cron tasks
|
||||||
Cron struct {
|
Cron struct {
|
||||||
UpdateMirror struct {
|
UpdateMirror struct {
|
||||||
|
@ -194,6 +180,25 @@ var (
|
||||||
} `ini:"cron.check_repo_stats"`
|
} `ini:"cron.check_repo_stats"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Git settings
|
||||||
|
Git struct {
|
||||||
|
MaxGitDiffLines int
|
||||||
|
MaxGitDiffLineCharacters int
|
||||||
|
MaxGitDiffFiles int
|
||||||
|
GcArgs []string `delim:" "`
|
||||||
|
Timeout struct {
|
||||||
|
Migrate int
|
||||||
|
Mirror int
|
||||||
|
Clone int
|
||||||
|
Pull int
|
||||||
|
} `ini:"git.timeout"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// API settings
|
||||||
|
API struct {
|
||||||
|
MaxResponseItems int
|
||||||
|
}
|
||||||
|
|
||||||
// I18n settings
|
// I18n settings
|
||||||
Langs, Names []string
|
Langs, Names []string
|
||||||
dateLangs map[string]string
|
dateLangs map[string]string
|
||||||
|
@ -465,10 +470,12 @@ func NewContext() {
|
||||||
|
|
||||||
if err = Cfg.Section("markdown").MapTo(&Markdown); err != nil {
|
if err = Cfg.Section("markdown").MapTo(&Markdown); err != nil {
|
||||||
log.Fatal(4, "Fail to map Markdown settings: %v", err)
|
log.Fatal(4, "Fail to map Markdown settings: %v", err)
|
||||||
} else if err = Cfg.Section("git").MapTo(&Git); err != nil {
|
|
||||||
log.Fatal(4, "Fail to map Git settings: %v", err)
|
|
||||||
} else if err = Cfg.Section("cron").MapTo(&Cron); err != nil {
|
} else if err = Cfg.Section("cron").MapTo(&Cron); err != nil {
|
||||||
log.Fatal(4, "Fail to map Cron settings: %v", err)
|
log.Fatal(4, "Fail to map Cron settings: %v", err)
|
||||||
|
} else if err = Cfg.Section("git").MapTo(&Git); err != nil {
|
||||||
|
log.Fatal(4, "Fail to map Git settings: %v", err)
|
||||||
|
} else if err = Cfg.Section("api").MapTo(&API); err != nil {
|
||||||
|
log.Fatal(4, "Fail to map API settings: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
Langs = Cfg.Section("i18n").Key("LANGS").Strings(",")
|
Langs = Cfg.Section("i18n").Key("LANGS").Strings(",")
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
// Copyright 2016 The Gogs 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 convert
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gogits/gogs/modules/setting"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ToCorrectPageSize makes sure page size is in allowed range.
|
||||||
|
func ToCorrectPageSize(size int) int {
|
||||||
|
if size <= 0 {
|
||||||
|
size = 10
|
||||||
|
} else if size > setting.API.MaxResponseItems {
|
||||||
|
size = setting.API.MaxResponseItems
|
||||||
|
}
|
||||||
|
return size
|
||||||
|
}
|
|
@ -7,8 +7,6 @@ package repo
|
||||||
import (
|
import (
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
"github.com/Unknwon/com"
|
|
||||||
|
|
||||||
api "github.com/gogits/go-gogs-client"
|
api "github.com/gogits/go-gogs-client"
|
||||||
|
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
|
@ -23,11 +21,8 @@ import (
|
||||||
func Search(ctx *context.APIContext) {
|
func Search(ctx *context.APIContext) {
|
||||||
opts := &models.SearchRepoOptions{
|
opts := &models.SearchRepoOptions{
|
||||||
Keyword: path.Base(ctx.Query("q")),
|
Keyword: path.Base(ctx.Query("q")),
|
||||||
OwnerID: com.StrTo(ctx.Query("uid")).MustInt64(),
|
OwnerID: ctx.QueryInt64("uid"),
|
||||||
PageSize: com.StrTo(ctx.Query("limit")).MustInt(),
|
PageSize: convert.ToCorrectPageSize(ctx.QueryInt("limit")),
|
||||||
}
|
|
||||||
if opts.PageSize == 0 {
|
|
||||||
opts.PageSize = 10
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check visibility.
|
// Check visibility.
|
||||||
|
@ -50,7 +45,7 @@ func Search(ctx *context.APIContext) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
repos, _, err := models.SearchRepositoryByName(opts)
|
repos, count, err := models.SearchRepositoryByName(opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.JSON(500, map[string]interface{}{
|
ctx.JSON(500, map[string]interface{}{
|
||||||
"ok": false,
|
"ok": false,
|
||||||
|
@ -74,6 +69,7 @@ func Search(ctx *context.APIContext) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx.SetLinkHeader(int(count), setting.API.MaxResponseItems)
|
||||||
ctx.JSON(200, map[string]interface{}{
|
ctx.JSON(200, map[string]interface{}{
|
||||||
"ok": true,
|
"ok": true,
|
||||||
"data": results,
|
"data": results,
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
0.9.35.0702
|
0.9.36.0704
|
Loading…
Reference in New Issue