Browse Source

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

Added '[repository] ENABLE_RAW_FILE_RENDER_MODE'.
Unknwon 8 years ago
parent
commit
b3c4a39208
4 changed files with 5 additions and 1 deletions
  1. 2 0
      conf/app.ini
  2. 0 0
      modules/bindata/bindata.go
  3. 1 0
      modules/setting/setting.go
  4. 2 1
      routers/repo/download.go

+ 2 - 0
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.

File diff suppressed because it is too large
+ 0 - 0
modules/bindata/bindata.go


+ 1 - 0
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 {

+ 2 - 1
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)

Some files were not shown because too many files changed in this diff