aboutsummaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
Diffstat (limited to 'services')
-rw-r--r--services/auth/sspi.go4
-rw-r--r--services/context/captcha.go4
-rw-r--r--services/context/context.go2
-rw-r--r--services/context/context_response.go17
-rw-r--r--services/contexttest/context_tests.go2
-rw-r--r--services/mailer/mail.go16
-rw-r--r--services/mailer/mail_release.go4
-rw-r--r--services/mailer/mail_team_invite.go4
8 files changed, 26 insertions, 27 deletions
diff --git a/services/auth/sspi.go b/services/auth/sspi.go
index 7f8a03a4c6..8ac83dcb04 100644
--- a/services/auth/sspi.go
+++ b/services/auth/sspi.go
@@ -13,10 +13,10 @@ import (
"code.gitea.io/gitea/models/auth"
"code.gitea.io/gitea/models/db"
user_model "code.gitea.io/gitea/models/user"
- "code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/optional"
"code.gitea.io/gitea/modules/setting"
+ "code.gitea.io/gitea/modules/templates"
"code.gitea.io/gitea/modules/web/middleware"
"code.gitea.io/gitea/services/auth/source/sspi"
gitea_context "code.gitea.io/gitea/services/context"
@@ -25,7 +25,7 @@ import (
)
const (
- tplSignIn base.TplName = "user/auth/signin"
+ tplSignIn templates.TplName = "user/auth/signin"
)
type SSPIAuth interface {
diff --git a/services/context/captcha.go b/services/context/captcha.go
index 41afe0e7d2..9272e7a65a 100644
--- a/services/context/captcha.go
+++ b/services/context/captcha.go
@@ -7,13 +7,13 @@ import (
"fmt"
"sync"
- "code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/cache"
"code.gitea.io/gitea/modules/hcaptcha"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/mcaptcha"
"code.gitea.io/gitea/modules/recaptcha"
"code.gitea.io/gitea/modules/setting"
+ "code.gitea.io/gitea/modules/templates"
"code.gitea.io/gitea/modules/turnstile"
"gitea.com/go-chi/captcha"
@@ -60,7 +60,7 @@ const (
// VerifyCaptcha verifies Captcha data
// No-op if captchas are not enabled
-func VerifyCaptcha(ctx *Context, tpl base.TplName, form any) {
+func VerifyCaptcha(ctx *Context, tpl templates.TplName, form any) {
if !setting.Service.EnableCaptcha {
return
}
diff --git a/services/context/context.go b/services/context/context.go
index 812a8c27ee..0d5429e366 100644
--- a/services/context/context.go
+++ b/services/context/context.go
@@ -32,7 +32,7 @@ import (
// Render represents a template render
type Render interface {
TemplateLookup(tmpl string, templateCtx context.Context) (templates.TemplateExecutor, error)
- HTML(w io.Writer, status int, name string, data any, templateCtx context.Context) error
+ HTML(w io.Writer, status int, name templates.TplName, data any, templateCtx context.Context) error
}
// Context represents context of a request.
diff --git a/services/context/context_response.go b/services/context/context_response.go
index c43a649b49..4c086ea9f5 100644
--- a/services/context/context_response.go
+++ b/services/context/context_response.go
@@ -17,7 +17,6 @@ import (
"time"
user_model "code.gitea.io/gitea/models/user"
- "code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/httplib"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
@@ -63,10 +62,10 @@ func (ctx *Context) RedirectToCurrentSite(location ...string) {
ctx.Redirect(setting.AppSubURL + "/")
}
-const tplStatus500 base.TplName = "status/500"
+const tplStatus500 templates.TplName = "status/500"
// HTML calls Context.HTML and renders the template to HTTP response
-func (ctx *Context) HTML(status int, name base.TplName) {
+func (ctx *Context) HTML(status int, name templates.TplName) {
log.Debug("Template: %s", name)
tmplStartTime := time.Now()
@@ -77,7 +76,7 @@ func (ctx *Context) HTML(status int, name base.TplName) {
return strconv.FormatInt(time.Since(tmplStartTime).Nanoseconds()/1e6, 10) + "ms"
}
- err := ctx.Render.HTML(ctx.Resp, status, string(name), ctx.Data, ctx.TemplateContext)
+ err := ctx.Render.HTML(ctx.Resp, status, name, ctx.Data, ctx.TemplateContext)
if err == nil || errors.Is(err, syscall.EPIPE) {
return
}
@@ -94,7 +93,7 @@ func (ctx *Context) HTML(status int, name base.TplName) {
// JSONTemplate renders the template as JSON response
// keep in mind that the template is processed in HTML context, so JSON-things should be handled carefully, eg: by JSEscape
-func (ctx *Context) JSONTemplate(tmpl base.TplName) {
+func (ctx *Context) JSONTemplate(tmpl templates.TplName) {
t, err := ctx.Render.TemplateLookup(string(tmpl), nil)
if err != nil {
ctx.ServerError("unable to find template", err)
@@ -107,14 +106,14 @@ func (ctx *Context) JSONTemplate(tmpl base.TplName) {
}
// RenderToHTML renders the template content to a HTML string
-func (ctx *Context) RenderToHTML(name base.TplName, data map[string]any) (template.HTML, error) {
+func (ctx *Context) RenderToHTML(name templates.TplName, data map[string]any) (template.HTML, error) {
var buf strings.Builder
- err := ctx.Render.HTML(&buf, 0, string(name), data, ctx.TemplateContext)
+ err := ctx.Render.HTML(&buf, 0, name, data, ctx.TemplateContext)
return template.HTML(buf.String()), err
}
// RenderWithErr used for page has form validation but need to prompt error to users.
-func (ctx *Context) RenderWithErr(msg any, tpl base.TplName, form any) {
+func (ctx *Context) RenderWithErr(msg any, tpl templates.TplName, form any) {
if form != nil {
middleware.AssignForm(form, ctx.Data)
}
@@ -151,7 +150,7 @@ func (ctx *Context) notFoundInternal(logMsg string, logErr error) {
ctx.Data["IsRepo"] = ctx.Repo.Repository != nil
ctx.Data["Title"] = "Page Not Found"
- ctx.HTML(http.StatusNotFound, base.TplName("status/404"))
+ ctx.HTML(http.StatusNotFound, templates.TplName("status/404"))
}
// ServerError displays a 500 (Internal Server Error) page and prints the given error, if any.
diff --git a/services/contexttest/context_tests.go b/services/contexttest/context_tests.go
index 3c3fa76e3c..39ad5a362f 100644
--- a/services/contexttest/context_tests.go
+++ b/services/contexttest/context_tests.go
@@ -183,7 +183,7 @@ func (tr *MockRender) TemplateLookup(tmpl string, _ gocontext.Context) (template
return nil, nil
}
-func (tr *MockRender) HTML(w io.Writer, status int, _ string, _ any, _ gocontext.Context) error {
+func (tr *MockRender) HTML(w io.Writer, status int, _ templates.TplName, _ any, _ gocontext.Context) error {
if resp, ok := w.(http.ResponseWriter); ok {
resp.WriteHeader(status)
}
diff --git a/services/mailer/mail.go b/services/mailer/mail.go
index ee2c8c0963..a6763e4f03 100644
--- a/services/mailer/mail.go
+++ b/services/mailer/mail.go
@@ -21,11 +21,11 @@ import (
"code.gitea.io/gitea/models/renderhelper"
repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
- "code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/emoji"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/markup/markdown"
"code.gitea.io/gitea/modules/setting"
+ "code.gitea.io/gitea/modules/templates"
"code.gitea.io/gitea/modules/timeutil"
"code.gitea.io/gitea/modules/translation"
incoming_payload "code.gitea.io/gitea/services/mailer/incoming/payload"
@@ -34,14 +34,14 @@ import (
)
const (
- mailAuthActivate base.TplName = "auth/activate"
- mailAuthActivateEmail base.TplName = "auth/activate_email"
- mailAuthResetPassword base.TplName = "auth/reset_passwd"
- mailAuthRegisterNotify base.TplName = "auth/register_notify"
+ mailAuthActivate templates.TplName = "auth/activate"
+ mailAuthActivateEmail templates.TplName = "auth/activate_email"
+ mailAuthResetPassword templates.TplName = "auth/reset_passwd"
+ mailAuthRegisterNotify templates.TplName = "auth/register_notify"
- mailNotifyCollaborator base.TplName = "notify/collaborator"
+ mailNotifyCollaborator templates.TplName = "notify/collaborator"
- mailRepoTransferNotify base.TplName = "notify/repo_transfer"
+ mailRepoTransferNotify templates.TplName = "notify/repo_transfer"
// There's no actual limit for subject in RFC 5322
mailMaxSubjectRunes = 256
@@ -63,7 +63,7 @@ func SendTestMail(email string) error {
}
// sendUserMail sends a mail to the user
-func sendUserMail(language string, u *user_model.User, tpl base.TplName, code, subject, info string) {
+func sendUserMail(language string, u *user_model.User, tpl templates.TplName, code, subject, info string) {
locale := translation.NewLocale(language)
data := map[string]any{
"locale": locale,
diff --git a/services/mailer/mail_release.go b/services/mailer/mail_release.go
index 1d73d77612..796d63d27a 100644
--- a/services/mailer/mail_release.go
+++ b/services/mailer/mail_release.go
@@ -10,16 +10,16 @@ import (
"code.gitea.io/gitea/models/renderhelper"
repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
- "code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/markup/markdown"
"code.gitea.io/gitea/modules/setting"
+ "code.gitea.io/gitea/modules/templates"
"code.gitea.io/gitea/modules/translation"
sender_service "code.gitea.io/gitea/services/mailer/sender"
)
const (
- tplNewReleaseMail base.TplName = "release"
+ tplNewReleaseMail templates.TplName = "release"
)
// MailNewRelease send new release notify to all repo watchers.
diff --git a/services/mailer/mail_team_invite.go b/services/mailer/mail_team_invite.go
index 4f2d5e4ca7..5ca44442f3 100644
--- a/services/mailer/mail_team_invite.go
+++ b/services/mailer/mail_team_invite.go
@@ -11,15 +11,15 @@ import (
org_model "code.gitea.io/gitea/models/organization"
user_model "code.gitea.io/gitea/models/user"
- "code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
+ "code.gitea.io/gitea/modules/templates"
"code.gitea.io/gitea/modules/translation"
sender_service "code.gitea.io/gitea/services/mailer/sender"
)
const (
- tplTeamInviteMail base.TplName = "team_invite"
+ tplTeamInviteMail templates.TplName = "team_invite"
)
// MailTeamInvite sends team invites