Skip to content

golint fixed for routers/repo/wiki.go #203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 21, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions routers/repo/wiki.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ import (
)

const (
WIKI_START base.TplName = "repo/wiki/start"
WIKI_VIEW base.TplName = "repo/wiki/view"
WIKI_NEW base.TplName = "repo/wiki/new"
WIKI_PAGES base.TplName = "repo/wiki/pages"
tplUncycloStart base.TplName = "repo/wiki/start"
tplUncycloView base.TplName = "repo/wiki/view"
tplUncycloNew base.TplName = "repo/wiki/new"
tplUncycloPages base.TplName = "repo/wiki/pages"
)

// MustEnableUncyclo check if wiki is enabled, if external then redirect
func MustEnableUncyclo(ctx *context.Context) {
if !ctx.Repo.Repository.EnableUncyclo {
ctx.Handle(404, "MustEnableUncyclo", nil)
Expand All @@ -37,6 +38,7 @@ func MustEnableUncyclo(ctx *context.Context) {
}
}

// PageMeta wiki page meat information
type PageMeta struct {
Name string
URL string
Expand Down Expand Up @@ -115,12 +117,13 @@ func renderUncycloPage(ctx *context.Context, isViewPage bool) (*git.Repository, str
return wikiRepo, pageName
}

// Uncyclo render wiki page
func Uncyclo(ctx *context.Context) {
ctx.Data["PageIsUncyclo"] = true

if !ctx.Repo.Repository.HasUncyclo() {
ctx.Data["Title"] = ctx.Tr("repo.wiki")
ctx.HTML(200, WIKI_START)
ctx.HTML(200, tplUncycloStart)
return
}

Expand All @@ -137,9 +140,10 @@ func Uncyclo(ctx *context.Context) {
}
ctx.Data["Author"] = lastCommit.Author

ctx.HTML(200, WIKI_VIEW)
ctx.HTML(200, tplUncycloView)
}

// UncycloPages render wiki pages list page
func UncycloPages(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repo.wiki.pages")
ctx.Data["PageIsUncyclo"] = true
Expand Down Expand Up @@ -183,9 +187,10 @@ func UncycloPages(ctx *context.Context) {
}
ctx.Data["Pages"] = pages

ctx.HTML(200, WIKI_PAGES)
ctx.HTML(200, tplUncycloPages)
}

// NewUncyclo render wiki create page
func NewUncyclo(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repo.wiki.new_page")
ctx.Data["PageIsUncyclo"] = true
Expand All @@ -195,23 +200,24 @@ func NewUncyclo(ctx *context.Context) {
ctx.Data["title"] = "Home"
}

ctx.HTML(200, WIKI_NEW)
ctx.HTML(200, tplUncycloNew)
}

// NewUncycloPost response fro wiki create request
func NewUncycloPost(ctx *context.Context, form auth.NewUncycloForm) {
ctx.Data["Title"] = ctx.Tr("repo.wiki.new_page")
ctx.Data["PageIsUncyclo"] = true
ctx.Data["RequireSimpleMDE"] = true

if ctx.HasError() {
ctx.HTML(200, WIKI_NEW)
ctx.HTML(200, tplUncycloNew)
return
}

if err := ctx.Repo.Repository.AddUncycloPage(ctx.User, form.Title, form.Content, form.Message); err != nil {
if models.IsErrUncycloAlreadyExist(err) {
ctx.Data["Err_Title"] = true
ctx.RenderWithErr(ctx.Tr("repo.wiki.page_already_exists"), WIKI_NEW, &form)
ctx.RenderWithErr(ctx.Tr("repo.wiki.page_already_exists"), tplUncycloNew, &form)
} else {
ctx.Handle(500, "AddUncycloPage", err)
}
Expand All @@ -221,6 +227,7 @@ func NewUncycloPost(ctx *context.Context, form auth.NewUncycloForm) {
ctx.Redirect(ctx.Repo.RepoLink + "/wiki/" + models.ToUncycloPageURL(form.Title))
}

// EditUncyclo render wiki modify page
func EditUncyclo(ctx *context.Context) {
ctx.Data["PageIsUncyclo"] = true
ctx.Data["PageIsUncycloEdit"] = true
Expand All @@ -236,16 +243,17 @@ func EditUncyclo(ctx *context.Context) {
return
}

ctx.HTML(200, WIKI_NEW)
ctx.HTML(200, tplUncycloNew)
}

// EditUncycloPost response fro wiki modify request
func EditUncycloPost(ctx *context.Context, form auth.NewUncycloForm) {
ctx.Data["Title"] = ctx.Tr("repo.wiki.new_page")
ctx.Data["PageIsUncyclo"] = true
ctx.Data["RequireSimpleMDE"] = true

if ctx.HasError() {
ctx.HTML(200, WIKI_NEW)
ctx.HTML(200, tplUncycloNew)
return
}

Expand All @@ -257,6 +265,7 @@ func EditUncycloPost(ctx *context.Context, form auth.NewUncycloForm) {
ctx.Redirect(ctx.Repo.RepoLink + "/wiki/" + models.ToUncycloPageURL(form.Title))
}

// DeleteUncycloPagePost delete wiki page
func DeleteUncycloPagePost(ctx *context.Context) {
pageURL := ctx.Params(":page")
if len(pageURL) == 0 {
Expand Down