diff --git a/src/templates/src/editor.html b/src/templates/src/editor.html
index dbabc5fb..1532be83 100644
--- a/src/templates/src/editor.html
+++ b/src/templates/src/editor.html
@@ -1,7 +1,7 @@
{{ template "base.html" . }}
{{ define "extrahead" }}
- {{ template "markdown_previews.html" . }}
+ {{ template "markdown_previews.html" .TextEditor }}
@@ -116,8 +116,8 @@
@@ -407,8 +407,8 @@
document.querySelector('.upload_bar'),
description,
doMarkdown,
- {{ .MaxFileSize }},
- {{ .UploadUrl }}
+ {{ .TextEditor.MaxFileSize }},
+ {{ .TextEditor.UploadUrl }}
);
diff --git a/src/templates/types.go b/src/templates/types.go
index e1e70220..74b508fd 100644
--- a/src/templates/types.go
+++ b/src/templates/types.go
@@ -389,6 +389,12 @@ type Tag struct {
Url string
}
+type TextEditor struct {
+ ParserName string
+ MaxFileSize int
+ UploadUrl string
+}
+
type EduArticle struct {
Title string
Slug string
diff --git a/src/website/education.go b/src/website/education.go
index c27d22fc..b16b2681 100644
--- a/src/website/education.go
+++ b/src/website/education.go
@@ -317,12 +317,14 @@ func getEditorDataForEduArticle(
SubmitLabel: "Submit",
CanEditPostTitle: true,
- MaxFileSize: AssetMaxSize(currentUser),
- UploadUrl: urlContext.BuildAssetUpload(),
ShowEduOptions: true,
PreviewClass: "edu-article",
- ParserName: "parseMarkdownEdu",
+ TextEditor: templates.TextEditor{
+ ParserName: "parseMarkdownEdu",
+ MaxFileSize: AssetMaxSize(currentUser),
+ UploadUrl: urlContext.BuildAssetUpload(),
+ },
}
if article != nil {
diff --git a/src/website/forums.go b/src/website/forums.go
index dbf44abb..14904a15 100644
--- a/src/website/forums.go
+++ b/src/website/forums.go
@@ -51,9 +51,7 @@ type editorData struct {
ShowEduOptions bool
PreviewClass string
- ParserName string
- MaxFileSize int
- UploadUrl string
+ TextEditor templates.TextEditor
}
func getEditorDataForNew(urlContext *hmnurl.UrlContext, currentUser *models.User, baseData templates.BaseData, replyPost *templates.Post) editorData {
@@ -61,8 +59,10 @@ func getEditorDataForNew(urlContext *hmnurl.UrlContext, currentUser *models.User
BaseData: baseData,
CanEditPostTitle: replyPost == nil,
PostReplyingTo: replyPost,
- MaxFileSize: AssetMaxSize(currentUser),
- UploadUrl: urlContext.BuildAssetUpload(),
+ TextEditor: templates.TextEditor{
+ MaxFileSize: AssetMaxSize(currentUser),
+ UploadUrl: urlContext.BuildAssetUpload(),
+ },
}
if replyPost != nil {
@@ -79,8 +79,10 @@ func getEditorDataForEdit(urlContext *hmnurl.UrlContext, currentUser *models.Use
CanEditPostTitle: p.Thread.FirstID == p.Post.ID,
IsEditing: true,
EditInitialContents: p.CurrentVersion.TextRaw,
- MaxFileSize: AssetMaxSize(currentUser),
- UploadUrl: urlContext.BuildAssetUpload(),
+ TextEditor: templates.TextEditor{
+ MaxFileSize: AssetMaxSize(currentUser),
+ UploadUrl: urlContext.BuildAssetUpload(),
+ },
}
}
diff --git a/src/website/projects.go b/src/website/projects.go
index 3b530bab..ecfc1dd5 100644
--- a/src/website/projects.go
+++ b/src/website/projects.go
@@ -419,8 +419,7 @@ type ProjectEditData struct {
APICheckUsernameUrl string
LogoMaxFileSize int
- MaxFileSize int
- UploadUrl string
+ TextEditor templates.TextEditor
}
func ProjectNew(c *RequestContext) ResponseData {
@@ -463,8 +462,10 @@ func ProjectNew(c *RequestContext) ResponseData {
APICheckUsernameUrl: hmnurl.BuildAPICheckUsername(),
LogoMaxFileSize: ProjectLogoMaxFileSize,
- MaxFileSize: AssetMaxSize(c.CurrentUser),
- UploadUrl: c.UrlContext.BuildAssetUpload(),
+ TextEditor: templates.TextEditor{
+ MaxFileSize: AssetMaxSize(c.CurrentUser),
+ UploadUrl: c.UrlContext.BuildAssetUpload(),
+ },
}, c.Perf)
return res
}
@@ -606,8 +607,10 @@ func ProjectEdit(c *RequestContext) ResponseData {
APICheckUsernameUrl: hmnurl.BuildAPICheckUsername(),
LogoMaxFileSize: ProjectLogoMaxFileSize,
- MaxFileSize: AssetMaxSize(c.CurrentUser),
- UploadUrl: c.UrlContext.BuildAssetUpload(),
+ TextEditor: templates.TextEditor{
+ MaxFileSize: AssetMaxSize(c.CurrentUser),
+ UploadUrl: c.UrlContext.BuildAssetUpload(),
+ },
}, c.Perf)
return res
}