本文整理汇总了Golang中github.com/Unknwon/macaron.Context.HTML方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.HTML方法的具体用法?Golang Context.HTML怎么用?Golang Context.HTML使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/Unknwon/macaron.Context
的用法示例。
在下文中一共展示了Context.HTML方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: docs
func docs(ctx *macaron.Context, locale i18n.Locale, name string) {
docRoot := models.GetDocByLocale(name, locale.Lang)
if docRoot == nil {
docRoot = models.GetDocByLocale(name, "en-US")
}
link := strings.TrimPrefix(ctx.Params("*"), "/")
link = strings.TrimSuffix(link, ".html")
link = strings.TrimSuffix(link, ".md")
ctx.Data["Link"] = "/docs/" + link
var doc *models.DocNode
if len(link) == 0 {
ctx.Redirect("/docs/intro/")
return
}
doc, _ = docRoot.GetNodeByLink(link)
if doc == nil {
doc, _ = docRoot.GetNodeByLink(link + "/")
}
if doc == nil {
ctx.Error(404)
return
}
ctx.Data["DocRoot"] = docRoot
ctx.Data["Doc"] = doc
ctx.Data["Title"] = doc.Name
ctx.Data["Data"] = doc.GetContent()
ctx.HTML(200, "document_"+name, ctx.Data)
}
示例2: AlipayReturn
//process post alipay return
func AlipayReturn(ctx *macaron.Context, x *xorm.Engine) {
m, _ := url.ParseQuery(ctx.Req.URL.RawQuery)
params := map[string]string{}
for k, v := range m {
params[k] = v[0]
}
result := alipay.Return(params)
type OrderInfo struct {
Result bool
OrderId string
GoodId string
GoodCnt int64
Tel string
Name string
Addr string
Sum float32
}
var orderInfo OrderInfo
orderInfo.Result = false
if result.Status == -1 || result.Status == -5 || result.Status == -3 {
ctx.HTML(400, "orderresult", orderInfo)
return
}
o := &Order{Uuid: result.OrderNo}
has, err := x.Where("status=?", "等待支付").Get(o)
if err != nil || !has {
ctx.HTML(400, "orderresult", orderInfo)
return
}
if result.Status != 1 {
o.Status = "支付失败"
x.Id(o.Id).Cols("status").Update(o)
ctx.HTML(400, "orderresult", orderInfo)
return
}
o.Status = "支付成功"
_, err = x.Id(o.Id).Cols("status").Update(o)
if err != nil {
ctx.HTML(400, "orderresult", orderInfo)
return
}
orderInfo.Result = true
orderInfo.OrderId = o.CusTel + "_" + strconv.FormatInt(o.Id, 10)
orderInfo.GoodId = strconv.FormatInt(o.GoodId, 10)
orderInfo.GoodCnt = o.GoodCnt
orderInfo.Tel = o.CusTel
orderInfo.Name = o.CusName
orderInfo.Addr = o.CusAddr
orderInfo.Sum = o.Sum
ctx.HTML(200, "orderresult", orderInfo)
return
}
示例3: DoPupDetail
func DoPupDetail(ctx *macaron.Context) {
id := ctx.Query("Id")
pup := findPup(id)
if pup != nil {
ctx.Data["IsPup"] = true
ctx.Data["Pup"] = pup
ctx.HTML(200, "showDetail")
}
}
示例4: DoDogDetail
func DoDogDetail(ctx *macaron.Context) {
id := ctx.Query("Id")
dog := findDog(id)
if dog != nil {
ctx.Data["IsDog"] = true
ctx.Data["Dog"] = dog
ctx.HTML(200, "showDetail")
}
}
示例5: Build
func Build(tokens oauth2.Tokens, ctx *macaron.Context, req *http.Request) {
gh := github.New(tokens.Access())
user, err := gh.User()
if err != nil {
ctx.Error(500, err.Error())
return
}
muser := &models.User{
Name: user.Name,
Email: user.Email,
GithubToken: tokens.Access(),
Admin: false,
}
models.DB.Insert(muser)
// repos
var repos []*github.Repository
reposKey := "orgs:" + user.Login + ":repos"
if !rdx.Exists(reposKey).Val() || req.FormValue("refresh") != "" {
var err error
repos, err = gh.Repositories()
if err != nil {
ctx.Error(500, err.Error())
return
}
for _, repo := range repos {
rdx.HMSet(reposKey, repo.Fullname, "")
}
} else {
for _, repoName := range rdx.HKeys(reposKey).Val() {
repos = append(repos, &github.Repository{
Fullname: repoName,
})
}
}
// token
rdx.Set("user:"+user.Login+":github_token", tokens.Access(), 0)
tokenKey := "user:" + user.Login + ":token"
if !rdx.Exists(tokenKey).Val() {
rdx.Set(tokenKey, "gr"+goutils.RandNString(40), 0)
}
token := rdx.Get(tokenKey).Val()
rdx.Set("token:"+token+":user", user.Login, 0)
ctx.Data["User"] = user
ctx.Data["Token"] = token
ctx.Data["Repos"] = repos
ctx.HTML(200, "build")
}
示例6: OnSignin
func OnSignin(ctx *macaron.Context, f *session.Flash) {
userName := ctx.Query("username")
Password := ctx.Query("password")
c := db.C("Account")
account := Account{}
err := c.Find(bson.M{"UserName": userName, "Password": Password}).One(&account)
if err != nil {
ctx.Data["Title"] = "出错啦!"
ctx.Data["Info"] = "您的账户或密码错误,登录失败啦!"
ctx.HTML(200, "info")
}
ctx.Data["Admin"] = account.Role == 1
ctx.Data["Comments"] = getComments()
ctx.HTML(200, "profile")
}
示例7: Team
func Team(ctx *macaron.Context, locale i18n.Locale) {
ctx.Data["Link"] = "/team"
df := models.GetDoc(
"gitea",
"team",
locale.Lang)
if df == nil {
ctx.Error(404)
return
}
ctx.Data["Data"] = string(df.Data)
ctx.HTML(200, "page", ctx.Data)
}
示例8: Docs
func Docs(ctx *macaron.Context, locale i18n.Locale) {
docRoot := models.GetDocByLocale(
"gitea",
locale.Lang)
if docRoot == nil {
ctx.Error(404)
return
}
link := strings.TrimSuffix(
strings.TrimSuffix(
strings.TrimPrefix(
ctx.Params("*"),
"/"),
".html"),
".md")
ctx.Data["Link"] = "/docs/" + link
if len(link) == 0 {
ctx.Redirect("/docs/intro/")
return
}
doc, _ := docRoot.GetNodeByLink(link)
if doc == nil {
doc, _ = docRoot.GetNodeByLink(link + "/")
}
if doc == nil {
ctx.Error(404)
return
}
ctx.Data["DocRoot"] = docRoot
ctx.Data["Doc"] = doc
ctx.Data["Title"] = doc.Name
ctx.Data["Data"] = doc.GetContent()
ctx.HTML(200, "gitea", ctx.Data)
}
示例9: OnComment
func OnComment(ctx *macaron.Context) {
title := ctx.Query("title")
content := ctx.Query("content")
c := db.C("Comment")
comment := Comment{}
comment.Id = bson.NewObjectId()
comment.Title = title
comment.Content = content
comment.DateTime = time.Now()
err := c.Insert(comment)
if err != nil {
panic(err)
}
// resp := response.NewText("oMl6fs9C4x583NvZJfTcJxqvcomw", "", comment.DateTime, "["+comment.Title+"]"+comment.Content)
// mp.WriteRawResponse(ctx.Resp, nil, resp)
ctx.Data["Title"] = "成功啦!"
ctx.Data["Info"] = "您的留言已经第一时间发送出去啦!"
ctx.HTML(200, "info")
}
示例10: DoComment
func DoComment(ctx *macaron.Context) {
ctx.HTML(200, "comment")
}
示例11: DoAbout
func DoAbout(ctx *macaron.Context) {
ctx.Data["Global"] = getGlobal()
ctx.HTML(200, "about")
}
示例12: DoDogs
func DoDogs(ctx *macaron.Context) {
ctx.Data["Title"] = "种犬展示"
ctx.Data["Dogs"] = getDogs()
ctx.HTML(200, "showList")
}
示例13: DoPups
func DoPups(ctx *macaron.Context) {
ctx.Data["Title"] = "待售幼犬"
ctx.Data["Pups"] = getPups()
ctx.HTML(200, "showList")
}
示例14: DashboardHandler
func DashboardHandler(ctx *macaron.Context) {
ctx.HTML(200, "dashboard")
}
示例15: myHandler
func myHandler(ctx *macaron.Context) {
ctx.Data["Name"] = "Person"
ctx.HTML(200, "hello") // 200 is the response code.
}