本文整理匯總了Golang中github.com/peachdocs/peach/modules/middleware.Context.HTML方法的典型用法代碼示例。如果您正苦於以下問題:Golang Context.HTML方法的具體用法?Golang Context.HTML怎麽用?Golang Context.HTML使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/peachdocs/peach/modules/middleware.Context
的用法示例。
在下文中一共展示了Context.HTML方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Docs
func Docs(ctx *middleware.Context) {
toc := models.Tocs[ctx.Locale.Language()]
if toc == nil {
toc = models.Tocs[setting.Docs.Langs[0]]
}
ctx.Data["Toc"] = toc
nodeName := strings.TrimPrefix(strings.ToLower(strings.TrimSuffix(ctx.Req.URL.Path, ".html")), setting.Page.DocsBaseURL)
node, isDefault := toc.GetDoc(nodeName)
if node == nil {
NotFound(ctx)
return
}
if !setting.ProdMode {
node.ReloadContent()
}
langVer := toc.Lang
if isDefault {
ctx.Data["IsShowingDefault"] = isDefault
langVer = setting.Docs.Langs[0]
}
ctx.Data["Title"] = node.Title
ctx.Data["Content"] = fmt.Sprintf(`<script type="text/javascript" src="/%s/%s?=%d"></script>`, langVer, node.DocumentPath+".js", node.LastBuildTime)
renderEditPage(ctx, node.DocumentPath)
ctx.HTML(200, "docs")
}
示例2: Pages
func Pages(ctx *middleware.Context) {
toc := models.Tocs[ctx.Locale.Language()]
if toc == nil {
toc = models.Tocs[setting.Docs.Langs[0]]
}
pageName := strings.ToLower(strings.TrimSuffix(ctx.Req.URL.Path[1:], ".html"))
for i := range toc.Pages {
if toc.Pages[i].Name == pageName {
page := toc.Pages[i]
if !com.IsFile(page.FileName) {
ctx.Data["IsShowingDefault"] = true
page = models.Tocs[setting.Docs.Langs[0]].Pages[i]
}
if !setting.ProdMode {
page.ReloadContent()
}
ctx.Data["Title"] = page.Title
ctx.Data["Content"] = fmt.Sprintf(`<script type="text/javascript" src="/%s/%s?=%d"></script>`, toc.Lang, page.DocumentPath+".js", page.LastBuildTime)
ctx.Data["Pages"] = toc.Pages
renderEditPage(ctx, page.DocumentPath)
ctx.HTML(200, "docs")
return
}
}
NotFound(ctx)
}
示例3: Home
func Home(ctx *middleware.Context) {
if !setting.Page.HasLandingPage {
ctx.Redirect(setting.Page.DocsBaseURL)
return
}
ctx.HTML(200, "home")
}
示例4: Docs
func Docs(ctx *middleware.Context) {
toc := models.Tocs[ctx.Locale.Language()]
if toc == nil {
toc = models.Tocs[setting.Docs.Langs[0]]
}
ctx.Data["Toc"] = toc
nodeName := strings.TrimPrefix(strings.ToLower(strings.TrimSuffix(ctx.Req.URL.Path, ".html")), setting.Page.DocsBaseURL)
title, content, isDefault := toc.GetDoc(nodeName)
if content == nil {
NotFound(ctx)
return
}
ctx.Data["Title"] = title
ctx.Data["Content"] = string(content)
ctx.Data["IsShowingDefault"] = isDefault
ctx.HTML(200, "docs")
}
示例5: Pages
func Pages(ctx *middleware.Context) {
toc := models.Tocs[ctx.Locale.Language()]
if toc == nil {
toc = models.Tocs[setting.Docs.Langs[0]]
}
pageName := strings.ToLower(strings.TrimSuffix(ctx.Req.URL.Path[1:], ".html"))
for i := range toc.Pages {
if toc.Pages[i].Name == pageName {
page := toc.Pages[i]
if !com.IsFile(page.FileName) {
ctx.Data["IsShowingDefault"] = true
page = models.Tocs[setting.Docs.Langs[0]].Pages[i]
}
ctx.Data["Title"] = page.Title
ctx.Data["Content"] = string(page.Content())
ctx.Data["Pages"] = toc.Pages
ctx.HTML(200, "docs")
return
}
}
NotFound(ctx)
}
示例6: NotFound
func NotFound(ctx *middleware.Context) {
ctx.Data["Title"] = "404"
ctx.HTML(404, "404")
}