1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2025-01-07 10:20:26 +00:00

Get rid of " in some places

Violently
This commit is contained in:
Timur Ismagilov 2021-08-12 17:12:53 +05:00
parent ee8e01c0d8
commit 18179f1c7f
6 changed files with 22 additions and 15 deletions

View File

@ -45,13 +45,13 @@ func Register(username, password, group, source string, force bool) error {
switch {
case !util.IsPossibleUsername(username):
return fmt.Errorf("illegal username \"%s\"", username)
return fmt.Errorf("illegal username %s", username)
case !ValidGroup(group):
return fmt.Errorf("invalid group \"%s\"", group)
return fmt.Errorf("invalid group %s", group)
case !ValidSource(source):
return fmt.Errorf("invalid source \"%s\"", source)
return fmt.Errorf("invalid source %s", source)
case HasUsername(username):
return fmt.Errorf("username \"%s\" is already taken", username)
return fmt.Errorf("username %s is already taken", username)
case !force && cfg.RegistrationLimit > 0 && Count() >= cfg.RegistrationLimit:
return fmt.Errorf("reached the limit of registered users (%d)", cfg.RegistrationLimit)
}

View File

@ -2,11 +2,11 @@ package web
import (
"fmt"
"os"
"io"
"log"
"mime"
"net/http"
"os"
"sort"
"github.com/gorilla/mux"
@ -99,7 +99,7 @@ func handlerAdminUserEdit(w http.ResponseWriter, rq *http.Request) {
return
}
} else {
f = f.WithError(fmt.Errorf("invalid group \"%s\"", newGroup))
f = f.WithError(fmt.Errorf("invalid group %s", newGroup))
}
}

View File

@ -60,7 +60,7 @@ func handlerRegister(w http.ResponseWriter, rq *http.Request) {
err = user.Register(username, password, "editor", "local", false)
)
if err != nil {
log.Printf("Failed to register \"%s\": %s", username, err.Error())
log.Printf("Failed to register %s: %s", username, err.Error())
w.Header().Set("Content-Type", mime.TypeByExtension(".html"))
w.WriteHeader(http.StatusBadRequest)
fmt.Fprint(
@ -75,7 +75,7 @@ func handlerRegister(w http.ResponseWriter, rq *http.Request) {
),
)
} else {
log.Printf("Successfully registered \"%s\"", username)
log.Printf("Successfully registered %s", username)
user.LoginDataHTTP(w, rq, username, password)
http.Redirect(w, rq, "/"+rq.URL.RawQuery, http.StatusSeeOther)
}

View File

@ -40,7 +40,7 @@ func handlerHistory(w http.ResponseWriter, rq *http.Request) {
log.Println("Found", len(revs), "revisions for", hyphaName)
util.HTTP200Page(w, views.BaseHTML(
fmt.Sprintf("History of \"%s\"", util.BeautifulName(hyphaName)),
fmt.Sprintf("History of %s", util.BeautifulName(hyphaName)),
views.HistoryHTML(rq, hyphaName, list),
user.FromRequest(rq)))
}

View File

@ -57,7 +57,7 @@ func factoryHandlerAsker(
util.HTTP200Page(
w,
views.BaseHTML(
fmt.Sprintf(succTitleTemplate, hyphaName),
fmt.Sprintf(succTitleTemplate, util.BeautifulName(hyphaName)),
succPageTemplate(rq, hyphaName, h.Exists),
u))
}
@ -163,7 +163,7 @@ func handlerEdit(w http.ResponseWriter, rq *http.Request) {
util.HTTP200Page(
w,
views.BaseHTML(
fmt.Sprintf("Edit \"%s\"", util.BeautifulName(hyphaName)),
fmt.Sprintf("Edit %s", util.BeautifulName(hyphaName)),
views.EditHTML(rq, hyphaName, textAreaFill, warning),
u))
}
@ -198,7 +198,7 @@ func handlerUploadText(w http.ResponseWriter, rq *http.Request) {
util.HTTP200Page(
w,
views.BaseHTML(
fmt.Sprintf("Preview of \"%s\"", util.BeautifulName(hyphaName)),
fmt.Sprintf("Preview of %s", util.BeautifulName(hyphaName)),
views.PreviewHTML(
rq,
hyphaName,

View File

@ -41,7 +41,7 @@ func handlerAttachment(w http.ResponseWriter, rq *http.Request) {
)
util.HTTP200Page(w,
views.BaseHTML(
fmt.Sprintf("Attachment of \"%s\"", util.BeautifulName(hyphaName)),
fmt.Sprintf("Attachment of %s", util.BeautifulName(hyphaName)),
views.AttachmentMenuHTML(rq, h, u),
u))
}
@ -58,7 +58,7 @@ func handlerPrimitiveDiff(w http.ResponseWriter, rq *http.Request) {
)
util.HTTP200Page(w,
views.BaseHTML(
fmt.Sprintf("Diff of \"%s\" at %s", util.BeautifulName(hyphaName), revHash),
fmt.Sprintf("Diff of %s at %s", util.BeautifulName(hyphaName), revHash),
views.PrimitiveDiffHTML(rq, h, u, revHash),
u))
}
@ -88,7 +88,14 @@ func handlerRevision(w http.ResponseWriter, rq *http.Request) {
)
w.Header().Set("Content-Type", "text/html;charset=utf-8")
w.WriteHeader(http.StatusOK)
_, _ = fmt.Fprint(w, views.BaseHTML(util.BeautifulName(hyphaName), page, u))
_, _ = fmt.Fprint(
w,
views.BaseHTML(
fmt.Sprintf(`%s at %s`, util.BeautifulName(hyphaName), revHash),
page,
u,
),
)
}
// handlerText serves raw source text of the hypha.