Add baseurl
This commit is contained in:
parent
354c6ea294
commit
5be5548634
|
@ -8,10 +8,11 @@ import (
|
|||
type editorJsJson struct {
|
||||
Page string
|
||||
ContentType string
|
||||
BaseURL string
|
||||
Data template.JS
|
||||
}
|
||||
|
||||
func renderEditor(pageName, inputText, contentType string) (template.HTML, error) {
|
||||
func renderEditor(pageName, inputText, contentType string, baseurl string) (template.HTML, error) {
|
||||
if contentType == "json" {
|
||||
t, err := template.ParseFiles("templates/editorjs.html")
|
||||
if err != nil {
|
||||
|
@ -20,7 +21,7 @@ func renderEditor(pageName, inputText, contentType string) (template.HTML, error
|
|||
if inputText == "" {
|
||||
inputText = "null"
|
||||
}
|
||||
data := editorJsJson{Page: pageName, Data: template.JS(inputText), ContentType: contentType}
|
||||
data := editorJsJson{Page: pageName, Data: template.JS(inputText), ContentType: contentType, BaseURL: baseurl}
|
||||
var buf bytes.Buffer
|
||||
err = t.Execute(&buf, data)
|
||||
if err != nil {
|
||||
|
|
2
main.go
2
main.go
|
@ -384,7 +384,7 @@ func (h *editHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
var editor template.HTML
|
||||
if jsonEditor {
|
||||
editor, err = renderEditor(page, pageText, "json")
|
||||
editor, err = renderEditor(page, pageText, "json", *baseurl)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), 500)
|
||||
return
|
||||
|
|
|
@ -1 +1 @@
|
|||
<div id="editor" data-input="{{ .Data }}" data-saveurl="/save/" data-page="{{ .Page }}" save-type="{{ .ContentType }}"></div>
|
||||
<div id="editor" data-input="{{ .Data }}" data-saveurl="/save/" data-base-url="{{ .BaseURL }}" data-page="{{ .Page }}" save-type="{{ .ContentType }}"></div>
|
||||
|
|
Loading…
Reference in New Issue
Block a user