diff --git a/captcha.go b/captcha.go index bc1d90e..12f381a 100644 --- a/captcha.go +++ b/captcha.go @@ -41,6 +41,7 @@ func (a *goBlog) captchaMiddleware(next http.Handler) http.Handler { b = []byte(r.PostForm.Encode()) } a.renderWithStatusCode(w, r, http.StatusUnauthorized, templateCaptcha, &renderData{ + BlogString: r.Context().Value(blogKey).(string), Data: map[string]string{ "captchamethod": r.Method, "captchaheaders": base64.StdEncoding.EncodeToString(h), diff --git a/captcha_test.go b/captcha_test.go index 99b0105..cbadc84 100644 --- a/captcha_test.go +++ b/captcha_test.go @@ -1,6 +1,7 @@ package main import ( + "context" "io" "net/http" "net/http/httptest" @@ -42,7 +43,7 @@ func Test_captchaMiddleware(t *testing.T) { rec := httptest.NewRecorder() - h.ServeHTTP(rec, req) + h.ServeHTTP(rec, req.WithContext(context.WithValue(req.Context(), blogKey, "en"))) res := rec.Result() resBody, _ := io.ReadAll(res.Body) diff --git a/editor.go b/editor.go index e6fb794..565b5ba 100644 --- a/editor.go +++ b/editor.go @@ -28,13 +28,6 @@ func (a *goBlog) serveEditorPost(w http.ResponseWriter, r *http.Request) { blog := r.Context().Value(blogKey).(string) if action := r.FormValue("editoraction"); action != "" { switch action { - case "loaddelete": - a.render(w, r, templateEditor, &renderData{ - BlogString: blog, - Data: map[string]interface{}{ - "DeleteURL": r.FormValue("url"), - }, - }) case "loadupdate": parsedURL, err := url.Parse(r.FormValue("url")) if err != nil { diff --git a/go.mod b/go.mod index 1365abd..fb0ab5d 100644 --- a/go.mod +++ b/go.mod @@ -74,7 +74,7 @@ require ( github.com/spf13/pflag v1.0.5 // indirect github.com/subosito/gotenv v1.2.0 // indirect github.com/tdewolff/parse/v2 v2.5.19 // indirect - golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e // indirect + golang.org/x/sys v0.0.0-20210902050250-f475640dd07b // indirect golang.org/x/text v0.3.7 // indirect gopkg.in/ini.v1 v1.62.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/go.sum b/go.sum index a61412b..bdd56a7 100644 --- a/go.sum +++ b/go.sum @@ -529,8 +529,8 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e h1:XMgFehsDnnLGtjvjOfqWSUzt0alpTR1RSEuznObga2c= -golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210902050250-f475640dd07b h1:S7hKs0Flbq0bbc9xgYt4stIEG1zNDFqyrPwAX2Wj/sE= +golang.org/x/sys v0.0.0-20210902050250-f475640dd07b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/templates/captcha.gohtml b/templates/captcha.gohtml index fc43d8a..feb0311 100644 --- a/templates/captcha.gohtml +++ b/templates/captcha.gohtml @@ -1,11 +1,10 @@ {{ define "title" }} - {{ string .Blog.Lang "captcha" }} - {{ mdtitle .Blog.Title }} + {{ mdtitle .Blog.Title }} {{ end }} {{ define "main" }}
-

{{ string .Blog.Lang "captcha" }}

- +

diff --git a/templates/editor.gohtml b/templates/editor.gohtml index f2b0050..12b00ad 100644 --- a/templates/editor.gohtml +++ b/templates/editor.gohtml @@ -12,30 +12,15 @@
+ {{ if .Data.UpdatePostURL }}

{{ string .Blog.Lang "update" }}

- {{ if .Data.UpdatePostURL }} - - - - {{ else }} - - - {{ end }} + + +
-

{{ string .Blog.Lang "delete" }}

-
- {{ if .Data.DeleteURL }} - - - - {{ else }} - - - - {{ end }} -
+ {{ end }}

{{ string .Blog.Lang "posts" }}

{{ string .Blog.Lang "drafts" }}

{{ string .Blog.Lang "privateposts" }}

diff --git a/templates/post.gohtml b/templates/post.gohtml index c581dab..e8de51e 100644 --- a/templates/post.gohtml +++ b/templates/post.gohtml @@ -28,11 +28,12 @@ -
- + + - +
+ {{ end }} {{ if .CommentsEnabled }} diff --git a/templates/strings/de.yaml b/templates/strings/de.yaml index 38ada37..96744ed 100644 --- a/templates/strings/de.yaml +++ b/templates/strings/de.yaml @@ -1,4 +1,5 @@ acommentby: "Ein Kommentar von" +captchainstructions: "Bitte gib die Ziffern aus dem oberen Bild ein" chars: "Buchstaben" comment: "Kommentar" comments: "Kommentare" @@ -44,6 +45,7 @@ share: "Online teilen" shorturl: "Kurz-Link:" speak: "Vorlesen" stopspeak: "Vorlesen stoppen" +submit: "Abschicken" total: "Gesamt" translate: "Übersetzen" translations: "Übersetzungen" diff --git a/templates/strings/default.yaml b/templates/strings/default.yaml index 416fb6a..aad5115 100644 --- a/templates/strings/default.yaml +++ b/templates/strings/default.yaml @@ -2,7 +2,6 @@ acommentby: "A comment by" approve: "Approve" approved: "Approved" authenticate: "Authenticate" -captcha: "Captcha" captchainstructions: "Please enter the digits from the image above" chars: "Characters" comment: "Comment"