Consolidated shared editor-related params
This commit is contained in:
parent
c9ee420dbb
commit
c489d0ffa9
|
@ -1,7 +1,7 @@
|
|||
{{ template "base.html" . }}
|
||||
|
||||
{{ define "extrahead" }}
|
||||
{{ template "markdown_previews.html" . }}
|
||||
{{ template "markdown_previews.html" .TextEditor }}
|
||||
|
||||
<script src="{{ static "js/base64.js" }}"></script>
|
||||
<script src="{{ static "js/markdown_upload.js" }}"></script>
|
||||
|
@ -116,8 +116,8 @@
|
|||
</div>
|
||||
|
||||
<script>
|
||||
const maxFileSize = {{ .MaxFileSize }};
|
||||
const uploadUrl = {{ .UploadUrl }};
|
||||
const maxFileSize = {{ .TextEditor.MaxFileSize }};
|
||||
const uploadUrl = {{ .TextEditor.UploadUrl }};
|
||||
|
||||
const form = document.querySelector('#form');
|
||||
const titleField = document.querySelector('#title'); // may be undefined, be careful!
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{{ template "base.html" . }}
|
||||
|
||||
{{ define "extrahead" }}
|
||||
{{ template "markdown_previews.html" . }}
|
||||
{{ template "markdown_previews.html" .TextEditor }}
|
||||
<script src="{{ static "js/tabs.js" }}"></script>
|
||||
<script src="{{ static "js/image_selector.js" }}"></script>
|
||||
<script src="{{ static "js/templates.js" }}"></script>
|
||||
|
@ -407,8 +407,8 @@
|
|||
document.querySelector('.upload_bar'),
|
||||
description,
|
||||
doMarkdown,
|
||||
{{ .MaxFileSize }},
|
||||
{{ .UploadUrl }}
|
||||
{{ .TextEditor.MaxFileSize }},
|
||||
{{ .TextEditor.UploadUrl }}
|
||||
);
|
||||
|
||||
</script>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue