Browse Source

setting: add config option for raw file render mode (#3608)

Added '[repository] ENABLE_RAW_FILE_RENDER_MODE'.
pull/4312/head
Unknwon 8 years ago
parent
commit
b3c4a39208
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
  1. 2
      conf/app.ini
  2. 4
      modules/bindata/bindata.go
  3. 1
      modules/setting/setting.go
  4. 3
      routers/repo/download.go

2
conf/app.ini

@ -93,6 +93,8 @@ ENABLE_LOCAL_PATH_MIGRATION = false
; value depend of how many CPUs (cores) you have. If the value is set to zero
; or under, GOGS will automatically detect the number of CPUs your system have
COMMITS_FETCH_CONCURRENCY = 0
; Enable render mode for raw file
ENABLE_RAW_FILE_RENDER_MODE = false
[repository.editor]
; List of file extensions that should have line wraps in the CodeMirror editor.

4
modules/bindata/bindata.go

File diff suppressed because one or more lines are too long

1
modules/setting/setting.go

@ -120,6 +120,7 @@ var (
DisableHTTPGit bool `ini:"DISABLE_HTTP_GIT"`
EnableLocalPathMigration bool
CommitsFetchConcurrency int
EnableRawFileRenderMode bool
// Repository editor settings
Editor struct {

3
routers/repo/download.go

@ -12,6 +12,7 @@ import (
"github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/context"
"github.com/gogits/gogs/modules/setting"
)
func ServeData(ctx *context.Context, name string, reader io.Reader) error {
@ -26,7 +27,7 @@ func ServeData(ctx *context.Context, name string, reader io.Reader) error {
ctx.Resp.Header().Set("Content-Disposition", "attachment; filename=\""+name+"\"")
ctx.Resp.Header().Set("Content-Transfer-Encoding", "binary")
}
} else if !ctx.QueryBool("render") {
} else if !setting.Repository.EnableRawFileRenderMode || !ctx.QueryBool("render") {
ctx.Resp.Header().Set("Content-Type", "text/plain; charset=utf-8")
}
ctx.Resp.Write(buf)

Loading…
Cancel
Save