Fix /api/v1/new and Makefile.

This commit is contained in:
Leonid Maslakov 2022-10-16 21:53:55 +07:00
parent cde971bb95
commit 77034fc591
4 changed files with 7 additions and 3 deletions

View File

@ -17,7 +17,7 @@ all:
chmod +x ./dist/bin/$(NAME)
fmt:
@$(GO) -w $(shell find ./ -type f -name '*.go')
@$(GOFMT) -w $(shell find ./ -type f -name '*.go')
clean:
rm -rf ./dist/

View File

@ -74,6 +74,10 @@ func PasteAddFromForm(form url.Values, db storage.DB, titleMaxLen int, bodyMaxLe
}
// Check syntax
if paste.Syntax == "" {
paste.Syntax = "plaintext"
}
syntaxOk := false
for _, name := range lexerNames {
if name == paste.Syntax {

View File

@ -19,12 +19,12 @@
package web
import (
"embed"
"git.lcomrade.su/root/lenpaste/internal/config"
"git.lcomrade.su/root/lenpaste/internal/logger"
"git.lcomrade.su/root/lenpaste/internal/storage"
chromaLexers "github.com/alecthomas/chroma/lexers"
"html/template"
"embed"
textTemplate "text/template"
)

View File

@ -20,6 +20,7 @@ package web
import (
"bytes"
"embed"
"errors"
"fmt"
"html/template"
@ -27,7 +28,6 @@ import (
"path/filepath"
"strconv"
"strings"
"embed"
)
type Locale map[string]string