diff options
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/context/context.go | 13 | ||||
-rw-r--r-- | pkg/markup/markup.go | 4 |
2 files changed, 15 insertions, 2 deletions
diff --git a/pkg/context/context.go b/pkg/context/context.go index 1457deec..abf4aaec 100644 --- a/pkg/context/context.go +++ b/pkg/context/context.go @@ -51,6 +51,19 @@ func (c *Context) PageIs(name string) { c.Data["PageIs"+name] = true } +// Require sets "Requirexxx" field in template data. +func (c *Context) Require(name string) { + c.Data["Require"+name] = true +} + +func (c *Context) RequireHighlightJS() { + c.Require("HighlightJS") +} + +func (c *Context) RequireSimpleMDE() { + c.Require("SimpleMDE") +} + // FormErr sets "Err_xxx" field in template data. func (c *Context) FormErr(names ...string) { for i := range names { diff --git a/pkg/markup/markup.go b/pkg/markup/markup.go index 9f5734a3..2484a7f9 100644 --- a/pkg/markup/markup.go +++ b/pkg/markup/markup.go @@ -14,8 +14,8 @@ import ( "github.com/Unknwon/com" "golang.org/x/net/html" - "github.com/gogits/gogs/pkg/tool" "github.com/gogits/gogs/pkg/setting" + "github.com/gogits/gogs/pkg/tool" ) // IsReadmeFile reports whether name looks like a README file based on its extension. @@ -320,7 +320,7 @@ func Render(typ Type, input interface{}, urlPrefix string, metas map[string]stri panic(fmt.Sprintf("unrecognized input content type: %T", input)) } - urlPrefix = strings.Replace(urlPrefix, " ", "%20", -1) + urlPrefix = strings.TrimRight(strings.Replace(urlPrefix, " ", "%20", -1), "/") var rawHTML []byte switch typ { case MARKDOWN: |