Post is working now

This commit is contained in:
2023-11-20 21:58:11 +01:00
parent 201579ad87
commit 477db1afa0
2 changed files with 12 additions and 9 deletions

View File

@@ -71,7 +71,7 @@ const editorTemplate = `
<input type="text" name="title" placeholder="Naslov" value="{{.Title}}" />
<input name="ID" type="hidden" value="{{.ID}}" />
<div id="editorcontainer">
<textarea id="editor">{{.GemtextContent}}</textarea>
<textarea id="editor" name="editor">{{.GemtextContent.String}}</textarea>
</div>
<input type="submit" value="Sačuvaj" />
</form>
@@ -85,6 +85,16 @@ const editorTemplate = `
`
func editorHtml5Page(post *database.Post) string {
if post.GemtextContent.Valid {
if strings.HasPrefix(post.GemtextContent.String, "{") {
post.GemtextContent.String = strings.TrimPrefix(post.GemtextContent.String, "{")
}
if strings.HasSuffix(post.GemtextContent.String, "true}") {
post.GemtextContent.String = strings.TrimSuffix(post.GemtextContent.String, "true}")
}
} else {
post.GemtextContent.String = ""
}
t1 := template.New("editorHtml5Page")
t1, _ = t1.Parse(editorTemplate)
result := new(strings.Builder)