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

Added '[repository] ENABLE_RAW_FILE_RENDER_MODE'.
pull/4312/head
Unknwon 2017-03-17 19:42:21 -04:00
parent cac7af2c78
commit b3c4a39208
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
4 changed files with 7 additions and 3 deletions

View File

@ -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.

File diff suppressed because one or more lines are too long

View File

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

View File

@ -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)