临时提交
This commit is contained in:
@@ -101,6 +101,50 @@ func AdminGetEmailTemplate(c *gin.Context) {
|
||||
Success(c, collectEmailTemplateNames())
|
||||
}
|
||||
|
||||
// AdminGetEmailTemplateContent returns the raw content of a specific email template.
|
||||
func AdminGetEmailTemplateContent(c *gin.Context) {
|
||||
name := c.Query("name")
|
||||
if name == "" {
|
||||
Fail(c, http.StatusBadRequest, "template name is required")
|
||||
return
|
||||
}
|
||||
|
||||
path := filepath.Join("resource", "views", "mail", name+".blade.php")
|
||||
if _, err := os.Stat(path); err != nil {
|
||||
path = filepath.Join("reference", "Xboard", "resources", "views", "mail", name+".blade.php")
|
||||
}
|
||||
|
||||
content, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
Success(c, "") // Return empty if not found
|
||||
return
|
||||
}
|
||||
|
||||
Success(c, string(content))
|
||||
}
|
||||
|
||||
// AdminSaveEmailTemplate saves the content of an email template.
|
||||
func AdminSaveEmailTemplate(c *gin.Context) {
|
||||
var payload struct {
|
||||
Name string `json:"name"`
|
||||
Content string `json:"content"`
|
||||
}
|
||||
if err := c.ShouldBindJSON(&payload); err != nil {
|
||||
Fail(c, http.StatusBadRequest, "invalid request")
|
||||
return
|
||||
}
|
||||
|
||||
path := filepath.Join("resource", "views", "mail", payload.Name+".blade.php")
|
||||
os.MkdirAll(filepath.Dir(path), 0755)
|
||||
|
||||
if err := os.WriteFile(path, []byte(payload.Content), 0644); err != nil {
|
||||
Fail(c, http.StatusInternalServerError, "failed to save template")
|
||||
return
|
||||
}
|
||||
|
||||
Success(c, true)
|
||||
}
|
||||
|
||||
// AdminGetThemeTemplate list available themes.
|
||||
func AdminGetThemeTemplate(c *gin.Context) {
|
||||
path := filepath.Join("public", "theme")
|
||||
|
||||
Reference in New Issue
Block a user