当前位置: 首页>>代码示例>>Golang>>正文


Golang macaron.Render类代码示例

本文整理汇总了Golang中github.com/Unknwon/macaron.Render的典型用法代码示例。如果您正苦于以下问题:Golang Render类的具体用法?Golang Render怎么用?Golang Render使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Render类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: SendIssueMentionMail

// SendIssueMentionMail sends mail notification for who are mentioned in issue.
func SendIssueMentionMail(r macaron.Render, u, owner *models.User,
	repo *models.Repository, issue *models.Issue, tos []string) error {

	if len(tos) == 0 {
		return nil
	}

	subject := fmt.Sprintf("[%s] %s (#%d)", repo.Name, issue.Name, issue.Index)

	data := ComposeTplData(nil)
	data["IssueLink"] = fmt.Sprintf("%s/%s/issues/%d", owner.Name, repo.Name, issue.Index)
	data["Subject"] = subject
	data["ActUserName"] = u.DisplayName()
	data["Content"] = string(base.RenderSpecialLink([]byte(issue.Content), owner.Name+"/"+repo.Name))

	body, err := r.HTMLString(string(NOTIFY_MENTION), data)
	if err != nil {
		return fmt.Errorf("HTMLString: %v", err)
	}

	msg := NewMessage(tos, subject, body)
	msg.Info = fmt.Sprintf("Subject: %s, issue mention", subject)

	SendAsync(msg)
	return nil
}
开发者ID:nafrente,项目名称:gogs,代码行数:27,代码来源:mail.go

示例2: Host

func Host(r macaron.Render) {
	var ss = map[string]*sheep.SHEEP{}
	for i, s := range sheep.SHEEPS {
		ss[i] = s.Obj()
	}
	a := PARAHOST{Sheeps: ss, MapStatus: sheep.MAPSTATUS}
	r.HTML(200, "host", a)
}
开发者ID:luckykris,项目名称:shepherd,代码行数:8,代码来源:handler.go

示例3: Dashboard

func Dashboard(r macaron.Render) {
	var ss = map[string]*sheep.SHEEP{}
	for i, s := range sheep.SHEEPS {
		ss[i] = s.Obj()
	}
	a := PARADASHBOARD{Sheeps: ss, Requset: REQ / 3}
	r.HTML(200, "dashboard", a)
}
开发者ID:luckykris,项目名称:shepherd,代码行数:8,代码来源:handler.go

示例4: WI_FailEscape

//Escape the last failed job
func WI_FailEscape(r macaron.Render, req *http.Request) {
	req.ParseForm()
	var success bool = false
	var message string = ""
	shpid := req.Form.Get("sheepid")
	sheepobj, ok := sheep.SHEEPS[shpid]
	if !ok {
		message = "sheepid is unavaliable."
		r.JSON(200, map[string]interface{}{"success": success, "message": message})
		return
	} else {
		success = true
	}
	sheepobj.SetLastFail(nil)
	r.JSON(200, map[string]interface{}{"success": success, "message": message})
}
开发者ID:luckykris,项目名称:shepherd,代码行数:17,代码来源:handler.go

示例5: WI_JobQueueLen

//Monitor length of job queue stack
func WI_JobQueueLen(r macaron.Render, req *http.Request) {
	req.ParseForm()
	var success bool = false
	var message interface{}
	shpid := req.Form.Get("sheepid")
	sheepobj, ok := sheep.SHEEPS[shpid]
	if !ok {
		message = "sheepid is unavaliable."
		r.JSON(200, map[string]interface{}{"success": success, "message": message})
		return
	} else {
		success = true
	}
	message = sheepobj.JobLen()
	r.JSON(200, map[string]interface{}{"success": success, "message": message})
}
开发者ID:luckykris,项目名称:shepherd,代码行数:17,代码来源:handler.go

示例6: SendRegisterMail

// Send user register mail with active code
func SendRegisterMail(r macaron.Render, u *models.User) {
	code := CreateUserActiveCode(u, nil)
	subject := "Register success, Welcome"

	data := GetMailTmplData(u)
	data["Code"] = code
	body, err := r.HTMLString(string(AUTH_REGISTER_SUCCESS), data)
	if err != nil {
		log.Error(4, "mail.SendRegisterMail(fail to render): %v", err)
		return
	}

	msg := NewMailMessage([]string{u.Email}, subject, body)
	msg.Info = fmt.Sprintf("UID: %d, send register mail", u.Id)

	SendAsync(&msg)
}
开发者ID:pecastro,项目名称:gogs,代码行数:18,代码来源:mail.go

示例7: WI_SheepStatus

//sheeps` status
func WI_SheepStatus(r macaron.Render, req *http.Request) {
	var success bool = true
	var message interface{}
	var data []SHEEPSTATUS
	var tmp SHEEPSTATUS
	for shpid, sheepobj := range sheep.SHEEPS {
		rs := sheepobj.RuningStatus()
		tmp.ID = shpid
		tmp.ENABLE = rs["ENABLE"].(bool)
		tmp.STATUS = rs["STATUS"].(int)
		tmp.JOBQLEN = rs["JOBQLEN"].(int)
		tmp.FOQLEN = rs["FOQLEN"].(int)
		tmp.CAPACITY = rs["CAPACITY"].(int)
		data = append(data, tmp)
	}
	r.JSON(200, map[string]interface{}{"success": success, "message": message, "data": data})
}
开发者ID:luckykris,项目名称:shepherd,代码行数:18,代码来源:handler.go

示例8: SendActiveMail

// Send email verify active email.
func SendActiveMail(r macaron.Render, u *models.User) {
	code := CreateUserActiveCode(u, nil)

	subject := "Verify your e-mail address"

	data := GetMailTmplData(u)
	data["Code"] = code
	body, err := r.HTMLString(string(AUTH_ACTIVE), data)
	if err != nil {
		log.Error(4, "mail.SendActiveMail(fail to render): %v", err)
		return
	}

	msg := NewMailMessage([]string{u.Email}, subject, body)
	msg.Info = fmt.Sprintf("UID: %d, send active mail", u.Id)

	SendAsync(&msg)
}
开发者ID:pecastro,项目名称:gogs,代码行数:19,代码来源:mail.go

示例9: SendResetPasswdMail

// Send reset password email.
func SendResetPasswdMail(r macaron.Render, u *models.User) {
	code := CreateUserActiveCode(u, nil)

	subject := "Reset your password"

	data := GetMailTmplData(u)
	data["Code"] = code
	body, err := r.HTMLString(string(AUTH_RESET_PASSWORD), data)
	if err != nil {
		log.Error(4, "mail.SendResetPasswdMail(fail to render): %v", err)
		return
	}

	msg := NewMailMessage([]string{u.Email}, subject, body)
	msg.Info = fmt.Sprintf("UID: %d, send reset password email", u.Id)

	SendAsync(&msg)
}
开发者ID:pecastro,项目名称:gogs,代码行数:19,代码来源:mail.go

示例10: SendCollaboratorMail

// SendCollaboratorMail sends mail notification to new collaborator.
func SendCollaboratorMail(r macaron.Render, u, doer *models.User, repo *models.Repository) error {
	subject := fmt.Sprintf("%s added you to %s/%s", doer.Name, repo.Owner.Name, repo.Name)

	data := ComposeTplData(nil)
	data["RepoLink"] = path.Join(repo.Owner.Name, repo.Name)
	data["Subject"] = subject

	body, err := r.HTMLString(string(NOTIFY_COLLABORATOR), data)
	if err != nil {
		return fmt.Errorf("HTMLString: %v", err)
	}

	msg := NewMessage([]string{u.Email}, subject, body)
	msg.Info = fmt.Sprintf("UID: %d, add collaborator", u.Id)

	SendAsync(msg)
	return nil
}
开发者ID:nafrente,项目名称:gogs,代码行数:19,代码来源:mail.go

示例11: SendActivateEmail

// Send email to verify secondary email.
func SendActivateEmail(r macaron.Render, user *models.User, email *models.EmailAddress) {
	code := CreateUserEmailActivateCode(user, email, nil)

	subject := "Verify your e-mail address"

	data := GetMailTmplData(user)
	data["Code"] = code
	data["Email"] = email.Email
	body, err := r.HTMLString(string(AUTH_ACTIVATE_EMAIL), data)
	if err != nil {
		log.Error(4, "mail.SendActiveMail(fail to render): %v", err)
		return
	}

	msg := NewMailMessage([]string{email.Email}, subject, body)
	msg.Info = fmt.Sprintf("UID: %d, send activate email to %s", user.Id, email.Email)

	SendAsync(&msg)
}
开发者ID:pecastro,项目名称:gogs,代码行数:20,代码来源:mail.go

示例12: WI_JobAssign

//Assign jobs
func WI_JobAssign(r macaron.Render, req *http.Request) {
	REQ += 1
	req.ParseForm()
	var success bool = false
	var message interface{}
	var isbypass bool = false
	bypass := req.Form.Get("bypass")
	key := req.Form.Get("key")
	if bypass == "1" { // check if bypass mode is
		isbypass = true
	}
	isOk, message := sheep.Assign(req.Form.Get("info"), key, isbypass)
	success = isOk
	message_e, isError := message.(error)
	if isError {
		message = message_e.Error()
	}
	r.JSON(200, map[string]interface{}{"success": success, "message": message})
}
开发者ID:luckykris,项目名称:shepherd,代码行数:20,代码来源:handler.go

示例13: SendCollaboratorMail

// SendCollaboratorMail sends mail notification to new collaborator.
func SendCollaboratorMail(r macaron.Render, u, owner *models.User,
	repo *models.Repository) error {

	subject := fmt.Sprintf("%s added you to %s", owner.Name, repo.Name)

	data := GetMailTmplData(nil)
	data["RepoLink"] = path.Join(owner.Name, repo.Name)
	data["Subject"] = subject

	body, err := r.HTMLString(string(NOTIFY_COLLABORATOR), data)
	if err != nil {
		return fmt.Errorf("mail.SendCollaboratorMail(fail to render): %v", err)
	}

	msg := NewMailMessage([]string{u.Email}, subject, body)
	msg.Info = fmt.Sprintf("UID: %d, send register mail", u.Id)

	SendAsync(&msg)
	return nil
}
开发者ID:pecastro,项目名称:gogs,代码行数:21,代码来源:mail.go

示例14: SendIssueMentionMail

// SendIssueMentionMail sends mail notification for who are mentioned in issue.
func SendIssueMentionMail(r macaron.Render, u, owner *models.User,
	repo *models.Repository, issue *models.Issue, tos []string) error {

	if len(tos) == 0 {
		return nil
	}

	subject := fmt.Sprintf("[%s] %s (#%d)", repo.Name, issue.Name, issue.Index)

	data := GetMailTmplData(nil)
	data["IssueLink"] = fmt.Sprintf("%s/%s/issues/%d", owner.Name, repo.Name, issue.Index)
	data["Subject"] = subject

	body, err := r.HTMLString(string(NOTIFY_MENTION), data)
	if err != nil {
		return fmt.Errorf("mail.SendIssueMentionMail(fail to render): %v", err)
	}

	msg := NewMailMessageFrom(tos, u.Email, subject, body)
	msg.Info = fmt.Sprintf("Subject: %s, send issue mention emails", subject)
	SendAsync(&msg)
	return nil
}
开发者ID:pecastro,项目名称:gogs,代码行数:24,代码来源:mail.go

示例15: WI_HostEnable

func WI_HostEnable(r macaron.Render, req *http.Request) {
	req.ParseForm()
	var success bool = false
	var message string = ""
	shpid := req.Form.Get("sheepid")
	sheepobj, ok := sheep.SHEEPS[shpid]
	if !ok {
		message = "sheepid is unavaliable."
		r.JSON(200, map[string]interface{}{"success": success, "message": message})
		return
	}
	enable := req.Form.Get("enable")
	switch enable {
	case "0":
		sheepobj.Disable()
		success = true
	case "1":
		sheepobj.Enable()
		success = true
	default:
		message = fmt.Sprintf("enable type '%s'is undefined.", enable)
	}
	r.JSON(200, map[string]interface{}{"success": success, "message": message})
}
开发者ID:luckykris,项目名称:shepherd,代码行数:24,代码来源:handler.go


注:本文中的github.com/Unknwon/macaron.Render类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。