Remove bbConvert usage. Minor fixes
This commit is contained in:
@@ -38,8 +38,7 @@ const (
|
|||||||
{{end}}
|
{{end}}
|
||||||
</select>
|
</select>
|
||||||
</p>
|
</p>
|
||||||
<div id="editor" hx-on::after-settle="blogEditorResize()">{{.Editor}}</div>
|
<div id="editor" hx-on::after-settle="blogEditorResize()">{{.Editor}}</div>`
|
||||||
`
|
|
||||||
editorForm = `
|
editorForm = `
|
||||||
<form id="editorForm" hx-post="/editor/post" hx-target="#formResult" hx-confirm="Save changes, overwritting previous values??">
|
<form id="editorForm" hx-post="/editor/post" hx-target="#formResult" hx-confirm="Save changes, overwritting previous values??">
|
||||||
<input name="id" type="hidden" value="{{.Blog.ID}}"></input>
|
<input name="id" type="hidden" value="{{.Blog.ID}}"></input>
|
||||||
@@ -81,11 +80,12 @@ func trueLoginRequest(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
u, err := back.TryLogin(r.Context(), r.FormValue("username"), r.FormValue("password"))
|
u, err := back.TryLogin(r.Context(), r.FormValue("username"), r.FormValue("password"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == backend.ErrLoginTimeout {
|
switch err {
|
||||||
sendContent(w, r, fmt.Sprint("<p>Timed out for", time.Unix(u.Timeout, 0).Sub(time.Now()), "</p>"), "", "")
|
case backend.ErrLoginTimeout:
|
||||||
} else if err == backend.ErrLoginIncorrect {
|
sendContent(w, r, fmt.Sprint("<p>Timed out for", time.Until(time.Unix(u.Timeout, 0)), "</p>"), "", "")
|
||||||
|
case backend.ErrLoginIncorrect:
|
||||||
sendContent(w, r, "<p>Username or password invalid</p>", "", "")
|
sendContent(w, r, "<p>Username or password invalid</p>", "", "")
|
||||||
} else {
|
default:
|
||||||
log.Println("error trying to login:", err)
|
log.Println("error trying to login:", err)
|
||||||
sendContent(w, r, "<p>Server error</p>", "", "")
|
sendContent(w, r, "<p>Server error</p>", "", "")
|
||||||
}
|
}
|
||||||
@@ -211,7 +211,7 @@ func editorPost(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if newBlog.ID == "" {
|
if newBlog.ID == "" {
|
||||||
newBlog.ID = strings.TrimSpace(strings.ToLower(strings.ReplaceAll(newBlog.ID, " ", "-")))
|
newBlog.ID = strings.TrimSpace(strings.ToLower(strings.ReplaceAll(newBlog.Title, " ", "-")))
|
||||||
if blogApp.Contains(r.Context(), newBlog.ID) {
|
if blogApp.Contains(r.Context(), newBlog.ID) {
|
||||||
sendContent(w, r, "<p>Title is not unique!</p>", "", "")
|
sendContent(w, r, "<p>Title is not unique!</p>", "", "")
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -61,9 +61,10 @@ func (b *Blog) HTMX(blogApp *BlogApp, ctx context.Context) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *BlogApp) ConvertBlog(blog *Blog) {
|
func (b *BlogApp) ConvertBlog(blog *Blog) {
|
||||||
if !blog.StaticPage {
|
//TODO: fix bbConvert
|
||||||
blog.HTMLBlog = b.conv.HTMLConvert(blog.RawBlog)
|
// if !blog.StaticPage {
|
||||||
}
|
// blog.HTMLBlog = b.conv.HTMLConvert(blog.RawBlog)
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *BlogApp) GetAuthor(ctx context.Context, blog *Blog) (*Author, error) {
|
func (b *BlogApp) GetAuthor(ctx context.Context, blog *Blog) (*Author, error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user