Consolidated shared editor-related params
This commit is contained in:
parent
c9ee420dbb
commit
c489d0ffa9
|
@ -1,7 +1,7 @@
|
||||||
{{ template "base.html" . }}
|
{{ template "base.html" . }}
|
||||||
|
|
||||||
{{ define "extrahead" }}
|
{{ define "extrahead" }}
|
||||||
{{ template "markdown_previews.html" . }}
|
{{ template "markdown_previews.html" .TextEditor }}
|
||||||
|
|
||||||
<script src="{{ static "js/base64.js" }}"></script>
|
<script src="{{ static "js/base64.js" }}"></script>
|
||||||
<script src="{{ static "js/markdown_upload.js" }}"></script>
|
<script src="{{ static "js/markdown_upload.js" }}"></script>
|
||||||
|
@ -116,8 +116,8 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const maxFileSize = {{ .MaxFileSize }};
|
const maxFileSize = {{ .TextEditor.MaxFileSize }};
|
||||||
const uploadUrl = {{ .UploadUrl }};
|
const uploadUrl = {{ .TextEditor.UploadUrl }};
|
||||||
|
|
||||||
const form = document.querySelector('#form');
|
const form = document.querySelector('#form');
|
||||||
const titleField = document.querySelector('#title'); // may be undefined, be careful!
|
const titleField = document.querySelector('#title'); // may be undefined, be careful!
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{{ template "base.html" . }}
|
{{ template "base.html" . }}
|
||||||
|
|
||||||
{{ define "extrahead" }}
|
{{ define "extrahead" }}
|
||||||
{{ template "markdown_previews.html" . }}
|
{{ template "markdown_previews.html" .TextEditor }}
|
||||||
<script src="{{ static "js/tabs.js" }}"></script>
|
<script src="{{ static "js/tabs.js" }}"></script>
|
||||||
<script src="{{ static "js/image_selector.js" }}"></script>
|
<script src="{{ static "js/image_selector.js" }}"></script>
|
||||||
<script src="{{ static "js/templates.js" }}"></script>
|
<script src="{{ static "js/templates.js" }}"></script>
|
||||||
|
@ -407,8 +407,8 @@
|
||||||
document.querySelector('.upload_bar'),
|
document.querySelector('.upload_bar'),
|
||||||
description,
|
description,
|
||||||
doMarkdown,
|
doMarkdown,
|
||||||
{{ .MaxFileSize }},
|
{{ .TextEditor.MaxFileSize }},
|
||||||
{{ .UploadUrl }}
|
{{ .TextEditor.UploadUrl }}
|
||||||
);
|
);
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -389,6 +389,12 @@ type Tag struct {
|
||||||
Url string
|
Url string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type TextEditor struct {
|
||||||
|
ParserName string
|
||||||
|
MaxFileSize int
|
||||||
|
UploadUrl string
|
||||||
|
}
|
||||||
|
|
||||||
type EduArticle struct {
|
type EduArticle struct {
|
||||||
Title string
|
Title string
|
||||||
Slug string
|
Slug string
|
||||||
|
|
|
@ -317,12 +317,14 @@ func getEditorDataForEduArticle(
|
||||||
SubmitLabel: "Submit",
|
SubmitLabel: "Submit",
|
||||||
|
|
||||||
CanEditPostTitle: true,
|
CanEditPostTitle: true,
|
||||||
MaxFileSize: AssetMaxSize(currentUser),
|
|
||||||
UploadUrl: urlContext.BuildAssetUpload(),
|
|
||||||
ShowEduOptions: true,
|
ShowEduOptions: true,
|
||||||
PreviewClass: "edu-article",
|
PreviewClass: "edu-article",
|
||||||
|
|
||||||
|
TextEditor: templates.TextEditor{
|
||||||
ParserName: "parseMarkdownEdu",
|
ParserName: "parseMarkdownEdu",
|
||||||
|
MaxFileSize: AssetMaxSize(currentUser),
|
||||||
|
UploadUrl: urlContext.BuildAssetUpload(),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if article != nil {
|
if article != nil {
|
||||||
|
|
|
@ -51,9 +51,7 @@ type editorData struct {
|
||||||
ShowEduOptions bool
|
ShowEduOptions bool
|
||||||
PreviewClass string
|
PreviewClass string
|
||||||
|
|
||||||
ParserName string
|
TextEditor templates.TextEditor
|
||||||
MaxFileSize int
|
|
||||||
UploadUrl string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func getEditorDataForNew(urlContext *hmnurl.UrlContext, currentUser *models.User, baseData templates.BaseData, replyPost *templates.Post) editorData {
|
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,
|
BaseData: baseData,
|
||||||
CanEditPostTitle: replyPost == nil,
|
CanEditPostTitle: replyPost == nil,
|
||||||
PostReplyingTo: replyPost,
|
PostReplyingTo: replyPost,
|
||||||
|
TextEditor: templates.TextEditor{
|
||||||
MaxFileSize: AssetMaxSize(currentUser),
|
MaxFileSize: AssetMaxSize(currentUser),
|
||||||
UploadUrl: urlContext.BuildAssetUpload(),
|
UploadUrl: urlContext.BuildAssetUpload(),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if replyPost != nil {
|
if replyPost != nil {
|
||||||
|
@ -79,8 +79,10 @@ func getEditorDataForEdit(urlContext *hmnurl.UrlContext, currentUser *models.Use
|
||||||
CanEditPostTitle: p.Thread.FirstID == p.Post.ID,
|
CanEditPostTitle: p.Thread.FirstID == p.Post.ID,
|
||||||
IsEditing: true,
|
IsEditing: true,
|
||||||
EditInitialContents: p.CurrentVersion.TextRaw,
|
EditInitialContents: p.CurrentVersion.TextRaw,
|
||||||
|
TextEditor: templates.TextEditor{
|
||||||
MaxFileSize: AssetMaxSize(currentUser),
|
MaxFileSize: AssetMaxSize(currentUser),
|
||||||
UploadUrl: urlContext.BuildAssetUpload(),
|
UploadUrl: urlContext.BuildAssetUpload(),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -419,8 +419,7 @@ type ProjectEditData struct {
|
||||||
APICheckUsernameUrl string
|
APICheckUsernameUrl string
|
||||||
LogoMaxFileSize int
|
LogoMaxFileSize int
|
||||||
|
|
||||||
MaxFileSize int
|
TextEditor templates.TextEditor
|
||||||
UploadUrl string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func ProjectNew(c *RequestContext) ResponseData {
|
func ProjectNew(c *RequestContext) ResponseData {
|
||||||
|
@ -463,8 +462,10 @@ func ProjectNew(c *RequestContext) ResponseData {
|
||||||
APICheckUsernameUrl: hmnurl.BuildAPICheckUsername(),
|
APICheckUsernameUrl: hmnurl.BuildAPICheckUsername(),
|
||||||
LogoMaxFileSize: ProjectLogoMaxFileSize,
|
LogoMaxFileSize: ProjectLogoMaxFileSize,
|
||||||
|
|
||||||
|
TextEditor: templates.TextEditor{
|
||||||
MaxFileSize: AssetMaxSize(c.CurrentUser),
|
MaxFileSize: AssetMaxSize(c.CurrentUser),
|
||||||
UploadUrl: c.UrlContext.BuildAssetUpload(),
|
UploadUrl: c.UrlContext.BuildAssetUpload(),
|
||||||
|
},
|
||||||
}, c.Perf)
|
}, c.Perf)
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
@ -606,8 +607,10 @@ func ProjectEdit(c *RequestContext) ResponseData {
|
||||||
APICheckUsernameUrl: hmnurl.BuildAPICheckUsername(),
|
APICheckUsernameUrl: hmnurl.BuildAPICheckUsername(),
|
||||||
LogoMaxFileSize: ProjectLogoMaxFileSize,
|
LogoMaxFileSize: ProjectLogoMaxFileSize,
|
||||||
|
|
||||||
|
TextEditor: templates.TextEditor{
|
||||||
MaxFileSize: AssetMaxSize(c.CurrentUser),
|
MaxFileSize: AssetMaxSize(c.CurrentUser),
|
||||||
UploadUrl: c.UrlContext.BuildAssetUpload(),
|
UploadUrl: c.UrlContext.BuildAssetUpload(),
|
||||||
|
},
|
||||||
}, c.Perf)
|
}, c.Perf)
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue