summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/context/context.go2
-rw-r--r--modules/setting/setting.go8
-rw-r--r--modules/templates/dynamic.go16
-rw-r--r--modules/templates/static.go21
4 files changed, 37 insertions, 10 deletions
diff --git a/modules/context/context.go b/modules/context/context.go
index 7f9193f821..a831873653 100644
--- a/modules/context/context.go
+++ b/modules/context/context.go
@@ -264,7 +264,7 @@ func Contexter() macaron.Handler {
ctx.Data["ShowRegistrationButton"] = setting.Service.ShowRegistrationButton
ctx.Data["ShowFooterBranding"] = setting.ShowFooterBranding
ctx.Data["ShowFooterVersion"] = setting.ShowFooterVersion
- ctx.Data["EnableSwaggerEndpoint"] = setting.API.EnableSwaggerEndpoint
+ ctx.Data["EnableSwagger"] = setting.API.EnableSwagger
ctx.Data["EnableOpenIDSignIn"] = setting.Service.EnableOpenIDSignIn
c.Map(ctx)
diff --git a/modules/setting/setting.go b/modules/setting/setting.go
index 396dec2546..1b9919404c 100644
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -527,11 +527,11 @@ var (
// API settings
API = struct {
- EnableSwaggerEndpoint bool
- MaxResponseItems int
+ EnableSwagger bool
+ MaxResponseItems int
}{
- EnableSwaggerEndpoint: true,
- MaxResponseItems: 50,
+ EnableSwagger: true,
+ MaxResponseItems: 50,
}
U2F = struct {
diff --git a/modules/templates/dynamic.go b/modules/templates/dynamic.go
index c127b69470..d70a465c1c 100644
--- a/modules/templates/dynamic.go
+++ b/modules/templates/dynamic.go
@@ -22,8 +22,8 @@ var (
templates = template.New("")
)
-// Renderer implements the macaron handler for serving the templates.
-func Renderer() macaron.Handler {
+// HTMLRenderer implements the macaron handler for serving HTML templates.
+func HTMLRenderer() macaron.Handler {
return macaron.Renderer(macaron.RenderOptions{
Funcs: NewFuncMap(),
Directory: path.Join(setting.StaticRootPath, "templates"),
@@ -33,6 +33,18 @@ func Renderer() macaron.Handler {
})
}
+// JSONRenderer implements the macaron handler for serving JSON templates.
+func JSONRenderer() macaron.Handler {
+ return macaron.Renderer(macaron.RenderOptions{
+ Funcs: NewFuncMap(),
+ Directory: path.Join(setting.StaticRootPath, "templates"),
+ AppendDirectories: []string{
+ path.Join(setting.CustomPath, "templates"),
+ },
+ HTMLContentType: "application/json",
+ })
+}
+
// Mailer provides the templates required for sending notification mails.
func Mailer() *template.Template {
for _, funcs := range NewFuncMap() {
diff --git a/modules/templates/static.go b/modules/templates/static.go
index 65b82053fd..c16b18cc08 100644
--- a/modules/templates/static.go
+++ b/modules/templates/static.go
@@ -43,8 +43,7 @@ func (templates templateFileSystem) Get(name string) (io.Reader, error) {
return nil, fmt.Errorf("file '%s' not found", name)
}
-// Renderer implements the macaron handler for serving the templates.
-func Renderer() macaron.Handler {
+func NewTemplateFileSystem() templateFileSystem {
fs := templateFileSystem{}
fs.files = make([]macaron.TemplateFile, 0, 10)
@@ -110,9 +109,25 @@ func Renderer() macaron.Handler {
}
}
+ return fs
+}
+
+var tplFileSys = NewTemplateFileSystem()
+
+// HTMLRenderer implements the macaron handler for serving HTML templates.
+func HTMLRenderer() macaron.Handler {
+ return macaron.Renderer(macaron.RenderOptions{
+ Funcs: NewFuncMap(),
+ TemplateFileSystem: tplFileSys,
+ })
+}
+
+// JSONRenderer implements the macaron handler for serving JSON templates.
+func JSONRenderer() macaron.Handler {
return macaron.Renderer(macaron.RenderOptions{
Funcs: NewFuncMap(),
- TemplateFileSystem: fs,
+ TemplateFileSystem: tplFileSys,
+ HTMLContentType: "application/json",
})
}