diff options
author | Unknwon <u@gogs.io> | 2015-11-25 20:10:25 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-11-25 20:10:25 -0500 |
commit | 2b10fdc4dcb987b347b031f460cf4f02fd48a31a (patch) | |
tree | f3f723c75684c4213a58d57a2ce0b6afdc597d25 /routers | |
parent | 2f28a0310b0f391dd74bb3a2ab0ae06379a4fb1a (diff) | |
download | gitea-2b10fdc4dcb987b347b031f460cf4f02fd48a31a.tar.gz gitea-2b10fdc4dcb987b347b031f460cf4f02fd48a31a.zip |
Wiki: UI for page new
Diffstat (limited to 'routers')
-rw-r--r-- | routers/api/v1/miscellaneous.go | 6 | ||||
-rw-r--r-- | routers/repo/view.go | 3 | ||||
-rw-r--r-- | routers/repo/wiki.go | 49 |
3 files changed, 51 insertions, 7 deletions
diff --git a/routers/api/v1/miscellaneous.go b/routers/api/v1/miscellaneous.go index 7ffce85761..dd611b2e70 100644 --- a/routers/api/v1/miscellaneous.go +++ b/routers/api/v1/miscellaneous.go @@ -5,12 +5,9 @@ package v1 import ( - "strings" - "github.com/gogits/gogs/modules/auth/apiv1" "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/middleware" - "github.com/gogits/gogs/modules/setting" ) // Render an arbitrary Markdown document. @@ -27,8 +24,7 @@ func Markdown(ctx *middleware.Context, form apiv1.MarkdownForm) { switch form.Mode { case "gfm": - ctx.Write(base.RenderMarkdown([]byte(form.Text), - setting.AppUrl+strings.TrimPrefix(form.Context, "/"))) + ctx.Write(base.RenderMarkdown([]byte(form.Text), form.Context)) default: ctx.Write(base.RenderRawMarkdown([]byte(form.Text), "")) } diff --git a/routers/repo/view.go b/routers/repo/view.go index c057140c17..877ff4cba0 100644 --- a/routers/repo/view.go +++ b/routers/repo/view.go @@ -29,6 +29,7 @@ const ( func Home(ctx *middleware.Context) { ctx.Data["Title"] = ctx.Repo.Repository.Name + ctx.Data["PageIsViewCode"] = true ctx.Data["RequireHighlightJS"] = true branchName := ctx.Repo.BranchName @@ -52,8 +53,6 @@ func Home(ctx *middleware.Context) { treeLink += "/" + treename } - ctx.Data["IsRepoToolbarSource"] = true - isViewBranch := ctx.Repo.IsBranch ctx.Data["IsViewBranch"] = isViewBranch diff --git a/routers/repo/wiki.go b/routers/repo/wiki.go new file mode 100644 index 0000000000..c18e67de67 --- /dev/null +++ b/routers/repo/wiki.go @@ -0,0 +1,49 @@ +// Copyright 2015 The Gogs Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package repo + +import ( + "github.com/Unknwon/com" + + "github.com/gogits/gogs/models" + "github.com/gogits/gogs/modules/base" + "github.com/gogits/gogs/modules/middleware" +) + +const ( + WIKI_START base.TplName = "repo/wiki/start" + WIKI_VIEW base.TplName = "repo/wiki/view" + WIKI_NEW base.TplName = "repo/wiki/new" +) + +func Wiki(ctx *middleware.Context) { + ctx.Data["Title"] = ctx.Tr("repo.wiki") + ctx.Data["PageIsWiki"] = true + + wikiPath := models.WikiPath(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name) + if !com.IsDir(wikiPath) { + ctx.HTML(200, WIKI_START) + return + } + + ctx.HTML(200, WIKI_VIEW) +} + +func NewWiki(ctx *middleware.Context) { + ctx.Data["Title"] = ctx.Tr("repo.wiki.new_page") + ctx.Data["PageIsWiki"] = true + ctx.Data["RequireSimpleMDE"] = true + + wikiPath := models.WikiPath(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name) + if !com.IsDir(wikiPath) { + ctx.Data["title"] = "Home" + } + + ctx.HTML(200, WIKI_NEW) +} + +func EditWiki(ctx *middleware.Context) { + ctx.PlainText(200, []byte(ctx.Params(":page"))) +} |