예제 #1
0
파일: gogs.go 프로젝트: zzhua/gogsweb
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)
}
//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
0
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
0
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
0
파일: token.go 프로젝트: gobuild/gobuild
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:"******":github_token", tokens.Access(), 0)
	tokenKey := "user:"******":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
0
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
0
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
0
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
0
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
0
func DoComment(ctx *macaron.Context) {
	ctx.HTML(200, "comment")
}
예제 #11
0
func DoAbout(ctx *macaron.Context) {
	ctx.Data["Global"] = getGlobal()
	ctx.HTML(200, "about")
}
예제 #12
0
func DoDogs(ctx *macaron.Context) {
	ctx.Data["Title"] = "种犬展示"
	ctx.Data["Dogs"] = getDogs()
	ctx.HTML(200, "showList")
}
예제 #13
0
func DoPups(ctx *macaron.Context) {
	ctx.Data["Title"] = "待售幼犬"
	ctx.Data["Pups"] = getPups()
	ctx.HTML(200, "showList")
}
예제 #14
0
파일: web.go 프로젝트: pombredanne/wharf-1
func DashboardHandler(ctx *macaron.Context) {
	ctx.HTML(200, "dashboard")
}
예제 #15
0
func myHandler(ctx *macaron.Context) {
	ctx.Data["Name"] = "Person"
	ctx.HTML(200, "hello") // 200 is the response code.
}
예제 #16
0
파일: gogs.go 프로젝트: zzhua/gogsweb
func GogsHome(ctx *macaron.Context) {
	ctx.Data["IsPageHome"] = true
	ctx.HTML(200, "home_gogs", ctx.Data)
}
예제 #17
0
파일: gogs.go 프로젝트: zzhua/gogsweb
func Donate(ctx *macaron.Context, locale i18n.Locale) {
	ctx.Data["Link"] = "/donate"
	df := models.GetDoc("gogs", "donate", locale.Lang)
	ctx.Data["Data"] = string(df.Data)
	ctx.HTML(200, "page", ctx.Data)
}
예제 #18
0
func mySubmitHandler(ctx *macaron.Context, contact ContactForm) {
	submission := ContactEntry{0, contact.Name, contact.Email, contact.Message, contact.MailingAddress}
	// ctx.JSON(200, &submission)
	ctx.Data["Submission"] = &submission
	ctx.HTML(200, "success")
}
예제 #19
0
func myQueryStringHandler(ctx *macaron.Context) {
	ctx.Data["Name"] = ctx.QueryEscape("name")
	ctx.HTML(200, "hello")
}
예제 #20
0
func myOtherHandler(ctx *macaron.Context) {
	ctx.Data["Message"] = "the request path is: " + ctx.Req.RequestURI
	ctx.HTML(200, "welcome")
}
예제 #21
0
파일: web.go 프로젝트: pombredanne/wharf-1
func SettingHandler(ctx *macaron.Context) {
	ctx.HTML(200, "setting")
}
예제 #22
0
func DoSignin(ctx *macaron.Context) {
	ctx.HTML(200, "signin")
}
예제 #23
0
파일: web.go 프로젝트: pombredanne/wharf-1
func AdminAuthHandler(ctx *macaron.Context) {
	ctx.HTML(200, "admin/auth")
}
예제 #24
0
파일: home.go 프로젝트: liangchenye/oct-web
func NewsHandler(ctx *macaron.Context) {
	ctx.HTML(200, "news")
}
예제 #25
0
파일: homepage.go 프로젝트: gobuild/gobuild
func Homepage(ctx *macaron.Context) {
	ctx.Data["Host"] = ctx.Req.Host
	ctx.HTML(200, "homepage")
}
예제 #26
0
파일: home.go 프로젝트: pombredanne/wharf-1
func IndexHandler(ctx *macaron.Context) {
	ctx.HTML(200, "index")
}
예제 #27
0
파일: home.go 프로젝트: ralphowino/kanban
// Home returns main page
func Home(ctx *macaron.Context) {
	ctx.Data["Version"] = viper.GetString("version")
	ctx.Data["GitlabHost"] = viper.GetString("gitlab.url")
	ctx.HTML(200, "templates/index")
}