1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2025-01-08 10:51:09 +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 { switch {
case !util.IsPossibleUsername(username): case !util.IsPossibleUsername(username):
return fmt.Errorf("illegal username \"%s\"", username) return fmt.Errorf("illegal username %s", username)
case !ValidGroup(group): case !ValidGroup(group):
return fmt.Errorf("invalid group \"%s\"", group) return fmt.Errorf("invalid group %s", group)
case !ValidSource(source): case !ValidSource(source):
return fmt.Errorf("invalid source \"%s\"", source) return fmt.Errorf("invalid source %s", source)
case HasUsername(username): 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: case !force && cfg.RegistrationLimit > 0 && Count() >= cfg.RegistrationLimit:
return fmt.Errorf("reached the limit of registered users (%d)", cfg.RegistrationLimit) return fmt.Errorf("reached the limit of registered users (%d)", cfg.RegistrationLimit)
} }

View File

@ -2,11 +2,11 @@ package web
import ( import (
"fmt" "fmt"
"os"
"io" "io"
"log" "log"
"mime" "mime"
"net/http" "net/http"
"os"
"sort" "sort"
"github.com/gorilla/mux" "github.com/gorilla/mux"
@ -99,7 +99,7 @@ func handlerAdminUserEdit(w http.ResponseWriter, rq *http.Request) {
return return
} }
} else { } 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) err = user.Register(username, password, "editor", "local", false)
) )
if err != nil { 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.Header().Set("Content-Type", mime.TypeByExtension(".html"))
w.WriteHeader(http.StatusBadRequest) w.WriteHeader(http.StatusBadRequest)
fmt.Fprint( fmt.Fprint(
@ -75,7 +75,7 @@ func handlerRegister(w http.ResponseWriter, rq *http.Request) {
), ),
) )
} else { } else {
log.Printf("Successfully registered \"%s\"", username) log.Printf("Successfully registered %s", username)
user.LoginDataHTTP(w, rq, username, password) user.LoginDataHTTP(w, rq, username, password)
http.Redirect(w, rq, "/"+rq.URL.RawQuery, http.StatusSeeOther) 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) log.Println("Found", len(revs), "revisions for", hyphaName)
util.HTTP200Page(w, views.BaseHTML( 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), views.HistoryHTML(rq, hyphaName, list),
user.FromRequest(rq))) user.FromRequest(rq)))
} }

View File

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

View File

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