Show possible states for post status

This commit is contained in:
Jan-Lukas Else 2021-08-01 19:27:21 +02:00
parent 408f7aef6b
commit 55fa3421f9
5 changed files with 39 additions and 33 deletions

View File

@ -3,6 +3,7 @@ package main
import ( import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"fmt"
"io" "io"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
@ -126,12 +127,10 @@ func (a *goBlog) editorPostTemplate(blog string) string {
return builder.String() return builder.String()
} }
func (a *goBlog) editorMoreParams(blog string) string { func (a *goBlog) editorPostDesc(blog string) string {
var builder strings.Builder
bc := a.cfg.Blogs[blog] bc := a.cfg.Blogs[blog]
builder.WriteString(a.ts.GetTemplateStringVariant(bc.Lang, "emptyparams")) t := a.ts.GetTemplateStringVariant(bc.Lang, "editorpostdesc")
builder.WriteByte(' ') var paramBuilder, statusBuilder strings.Builder
builder.WriteString(a.ts.GetTemplateStringVariant(bc.Lang, "moreparams"))
for i, param := range []string{ for i, param := range []string{
"summary", "summary",
"translationkey", "translationkey",
@ -150,12 +149,21 @@ func (a *goBlog) editorMoreParams(blog string) string {
continue continue
} }
if i > 0 { if i > 0 {
builder.WriteString(", ") paramBuilder.WriteString(", ")
} }
builder.WriteByte('`') paramBuilder.WriteByte('`')
builder.WriteString(param) paramBuilder.WriteString(param)
builder.WriteByte('`') paramBuilder.WriteByte('`')
} }
builder.WriteByte('.') for i, status := range []postStatus{
return builder.String() statusDraft, statusPublished, statusUnlisted, statusPrivate,
} {
if i > 0 {
statusBuilder.WriteString(", ")
}
statusBuilder.WriteByte('`')
statusBuilder.WriteString(string(status))
statusBuilder.WriteByte('`')
}
return fmt.Sprintf(t, paramBuilder.String(), "status", statusBuilder.String())
} }

View File

@ -61,23 +61,23 @@ func (a *goBlog) initRendering() error {
"liketitle": a.likeTitle, "liketitle": a.likeTitle,
"photolinks": a.photoLinks, "photolinks": a.photoLinks,
// Others // Others
"dateformat": dateFormat, "dateformat": dateFormat,
"isodate": isoDateFormat, "isodate": isoDateFormat,
"unixtodate": unixToLocalDateString, "unixtodate": unixToLocalDateString,
"now": localNowString, "now": localNowString,
"asset": a.assetFileName, "asset": a.assetFileName,
"string": a.ts.GetTemplateStringVariantFunc(), "string": a.ts.GetTemplateStringVariantFunc(),
"include": a.includeRenderedTemplate, "include": a.includeRenderedTemplate,
"urlize": urlize, "urlize": urlize,
"sort": sortedStrings, "sort": sortedStrings,
"absolute": a.getFullAddress, "absolute": a.getFullAddress,
"mentions": a.db.getWebmentionsByAddress, "mentions": a.db.getWebmentionsByAddress,
"geotitle": a.geoTitle, "geotitle": a.geoTitle,
"geolink": geoOSMLink, "geolink": geoOSMLink,
"opensearch": openSearchUrl, "opensearch": openSearchUrl,
"mbytes": mBytesString, "mbytes": mBytesString,
"editortemplate": a.editorPostTemplate, "editortemplate": a.editorPostTemplate,
"editormoreparams": a.editorMoreParams, "editorpostdesc": a.editorPostDesc,
} }
baseTemplate, err := template.New("base").Funcs(templateFunctions).ParseFiles(path.Join(templatesDir, templateBase+templatesExt)) baseTemplate, err := template.New("base").Funcs(templateFunctions).ParseFiles(path.Join(templatesDir, templateBase+templatesExt))
if err != nil { if err != nil {

View File

@ -6,7 +6,7 @@
<main> <main>
<h1>{{ string .Blog.Lang "editor" }}</h1> <h1>{{ string .Blog.Lang "editor" }}</h1>
<h2>{{ string .Blog.Lang "create" }}</h2> <h2>{{ string .Blog.Lang "create" }}</h2>
{{ md (editormoreparams .BlogString) }} {{ md (editorpostdesc .BlogString) }}
<form class="fw p" method="post"> <form class="fw p" method="post">
<input type="hidden" name="h" value="entry"> <input type="hidden" name="h" value="entry">
<textarea name="content" class="monospace h400p formcache" id="create-input">{{ editortemplate .BlogString }}</textarea> <textarea name="content" class="monospace h400p formcache" id="create-input">{{ editortemplate .BlogString }}</textarea>

View File

@ -13,8 +13,8 @@ docomment: "Kommentieren"
download: "Herunterladen" download: "Herunterladen"
drafts: "Entwürfe" drafts: "Entwürfe"
editor: "Editor" editor: "Editor"
editorpostdesc: "Leere Parameter werden automatisch entfernt. Mehr mögliche Parameter: %s. Mögliche Zustände für `%s`: %s."
emailopt: "E-Mail (optional)" emailopt: "E-Mail (optional)"
emptyparams: "Leere Parameter werden automatisch entfernt."
fileuses: "Datei-Verwendungen" fileuses: "Datei-Verwendungen"
interactions: "Interaktionen & Kommentare" interactions: "Interaktionen & Kommentare"
interactionslabel: "Hast du eine Antwort hierzu veröffentlicht? Füge hier die URL ein." interactionslabel: "Hast du eine Antwort hierzu veröffentlicht? Füge hier die URL ein."
@ -27,7 +27,6 @@ locationnotsupported: "Die Standort-API wird von diesem Browser nicht unterstüt
mediafiles: "Medien-Dateien" mediafiles: "Medien-Dateien"
message: "Nachricht" message: "Nachricht"
messagesent: "Nachricht gesendet" messagesent: "Nachricht gesendet"
moreparams: "Mehr Parameter: "
next: "Weiter" next: "Weiter"
nofiles: "Keine Dateien" nofiles: "Keine Dateien"
nolocations: "Keine Posts mit Standorten" nolocations: "Keine Posts mit Standorten"

View File

@ -18,8 +18,8 @@ docomment: "Comment"
download: "Download" download: "Download"
drafts: "Drafts" drafts: "Drafts"
editor: "Editor" editor: "Editor"
editorpostdesc: "Empty parameters are removed automatically. More possible parameters: %s. Possible states for `%s`: %s."
emailopt: "Email (optional)" emailopt: "Email (optional)"
emptyparams: "Empty parameters will be removed automatically."
feed: "Feed" feed: "Feed"
fileuses: "file uses" fileuses: "file uses"
indieauth: "IndieAuth" indieauth: "IndieAuth"
@ -36,7 +36,6 @@ logout: "Logout"
mediafiles: "Media files" mediafiles: "Media files"
message: "Message" message: "Message"
messagesent: "Message sent" messagesent: "Message sent"
moreparams: "More parameters: "
nameopt: "Name (optional)" nameopt: "Name (optional)"
next: "Next" next: "Next"
nofiles: "No files" nofiles: "No files"