本文整理汇总了Golang中github.com/gpmgo/switch/modules/middleware.Context.HTML方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.HTML方法的具体用法?Golang Context.HTML怎么用?Golang Context.HTML使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/gpmgo/switch/modules/middleware.Context
的用法示例。
在下文中一共展示了Context.HTML方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Auth
func Auth(ctx *middleware.Context) {
if len(setting.AccessToken) == 0 ||
ctx.GetCookie("access_token") != setting.AccessToken {
ctx.Data["PageIsAuth"] = true
ctx.HTML(200, "auth")
}
}
示例2: LargeRevisions
func LargeRevisions(ctx *middleware.Context) {
ctx.Data["PageIsPackages"] = true
ctx.Data["PageIsPackagesLarges"] = true
models.GetLocalRevisions()
ctx.HTML(200, "packages/larges")
}
示例3: Search
func Search(ctx *middleware.Context) {
ctx.Data["Title"] = ctx.Locale.Tr("search")
ctx.Data["SearchKeyword"] = ctx.Query("q")
pkgs, err := models.SearchPackages(ctx.Query("q"))
if err != nil {
ctx.Handle(500, "SearchPackages", err)
return
}
ctx.Data["ResultPackages"] = pkgs
ctx.HTML(200, "search")
}
示例4: BlockRules
func BlockRules(ctx *middleware.Context) {
ctx.Data["PageIsBlocks"] = true
ctx.Data["PageIsBlocksRules"] = true
rules, err := models.ListBlockRules(0)
if err != nil {
ctx.Handle(500, "ListBlockRules", err)
return
}
ctx.Data["Rules"] = rules
ctx.HTML(200, "blocks/rules")
}
示例5: Blocks
func Blocks(ctx *middleware.Context) {
ctx.Data["PageIsBlocks"] = true
ctx.Data["PageIsBlocksList"] = true
blocks, err := models.ListBlockedPackages(0)
if err != nil {
ctx.Handle(500, "ListBlockedPackages", err)
return
}
ctx.Data["Blocks"] = blocks
ctx.HTML(200, "blocks/list")
}
示例6: Package
func Package(ctx *middleware.Context) {
importPath := ctx.Params("*")
_, err := models.GetPakcageByPath(importPath)
if err != nil {
if err == models.ErrPackageNotExist {
ctx.Handle(404, "Package", nil)
} else {
ctx.Handle(500, "Package", err)
}
return
}
ctx.Data["Title"] = importPath
ctx.Data["ImportPath"] = importPath
ctx.HTML(200, "package")
}
示例7: Download
func Download(ctx *middleware.Context) {
ctx.Data["Title"] = ctx.Tr("download")
ctx.Data["PageIsDownload"] = true
importPath := archive.GetRootPath(ctx.Query("pkgname"))
if ctx.Req.Method == "POST" {
rev := ctx.Query("revision")
r, err := models.CheckPkg(importPath, rev)
if err != nil {
ctx.Data["pkgname"] = importPath
ctx.Data["revision"] = rev
errMsg := err.Error()
if err == archive.ErrNotMatchAnyService {
ctx.Data["Err_PkgName"] = true
errMsg = ctx.Tr("download.err_not_match_service")
} else if _, ok := err.(*models.BlockError); ok {
errMsg = ctx.Tr("download.err_package_blocked", err.Error())
}
ctx.RenderWithErr(errMsg, "download", nil)
return
}
if err = models.IncreasePackageDownloadCount(importPath); err != nil {
ctx.Handle(500, "IncreasePackageDownloadCount", err)
return
} else if err = models.AddDownloader(ctx.RemoteAddr()); err != nil {
ctx.Handle(500, "AddDownloader", err)
return
}
ext := archive.GetExtension(importPath)
serveName := path.Base(importPath) + "-" + base.ShortSha(r.Revision) + ext
switch r.Storage {
case models.LOCAL:
ctx.ServeFile(path.Join(setting.ArchivePath, importPath, r.Revision+ext), serveName)
case models.QINIU:
ctx.Redirect("http://" + setting.BucketUrl + "/" + importPath + "-" + r.Revision + ext)
}
return
}
ctx.Data["pkgname"] = importPath
ctx.HTML(200, "download")
}
示例8: BlockPackage
func BlockPackage(ctx *middleware.Context) {
ctx.Data["PageIsBlocks"] = true
ctx.Data["PageIsBlocksList"] = true
ctx.HTML(200, "blocks/new")
}
示例9: NewBlockRule
func NewBlockRule(ctx *middleware.Context) {
ctx.Data["PageIsBlocks"] = true
ctx.Data["PageIsBlocksRules"] = true
ctx.HTML(200, "blocks/rules_new")
}
示例10: Dashboard
func Dashboard(ctx *middleware.Context) {
ctx.Data["PageIsDashboard"] = true
ctx.HTML(200, "dashboard")
}
示例11: About
func About(ctx *middleware.Context) {
ctx.Data["Title"] = ctx.Locale.Tr("about_lower")
ctx.Data["PageIsAbout"] = true
ctx.HTML(200, "about")
}
示例12: Home
func Home(ctx *middleware.Context) {
ctx.Data["Title"] = ctx.Tr("app_title")
ctx.Data["PageIsHome"] = true
ctx.Data["Stats"] = models.Statistic
ctx.HTML(200, "home")
}
示例13: Revisions
func Revisions(ctx *middleware.Context) {
ctx.Data["PageIsPackages"] = true
ctx.Data["PageIsPackagesList"] = true
ctx.HTML(200, "packages/list")
}