Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a67c8fd140 |
No files matched your search
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
# syntax=docker/dockerfile:1
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
# ---- build stage ----
|
# ---- build stage ----
|
||||||
FROM golang:1.27-alpine AS build
|
FROM golang:1.27.2-alpine AS build
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
|
|
||||||
# cache deps first
|
# cache deps first
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
module palette
|
module palette
|
||||||
|
|
||||||
go 1.27.1
|
go 1.27.2
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/go-chi/chi/v5 v5.3.2
|
github.com/go-chi/chi/v5 v5.3.2
|
||||||
github.com/go-enry/go-enry/v2 v2.9.6
|
github.com/go-enry/go-enry/v2 v2.9.6
|
||||||
golang.org/x/crypto v0.39.0
|
golang.org/x/crypto v0.58.0
|
||||||
modernc.org/sqlite v1.58.0
|
modernc.org/sqlite v1.58.0
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ require (
|
|||||||
github.com/mattn/go-isatty v0.0.24 // indirect
|
github.com/mattn/go-isatty v0.0.24 // indirect
|
||||||
github.com/ncruces/go-strftime v1.0.0 // indirect
|
github.com/ncruces/go-strftime v1.0.0 // indirect
|
||||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||||
golang.org/x/sys v0.47.0 // indirect
|
golang.org/x/sys v0.49.0 // indirect
|
||||||
modernc.org/libc v1.75.6 // indirect
|
modernc.org/libc v1.75.6 // indirect
|
||||||
modernc.org/mathutil v1.7.1 // indirect
|
modernc.org/mathutil v1.7.1 // indirect
|
||||||
modernc.org/memory v1.12.1 // indirect
|
modernc.org/memory v1.12.1 // indirect
|
||||||
|
|||||||
@@ -30,14 +30,14 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
|
|||||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||||
golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM=
|
golang.org/x/crypto v0.58.0 h1:COkYLr4k7nDI4r6QtMML2AfzeIswWHAJthLS6K/M/54=
|
||||||
golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U=
|
golang.org/x/crypto v0.58.0/go.mod h1:Xh+kl5A+M0gMiWDytH2Hhr5Z7WbNCpv/eB/EFgfSk+w=
|
||||||
golang.org/x/mod v0.38.0 h1:MECBjubtXD7yj4HrhIUcywNaGeNVUdfVnxmPajOk4yk=
|
golang.org/x/mod v0.38.0 h1:MECBjubtXD7yj4HrhIUcywNaGeNVUdfVnxmPajOk4yk=
|
||||||
golang.org/x/mod v0.38.0/go.mod h1:V6Xz0pq8TQ3dGqVQ1FVHuelZpAL0uNhSkk9ogYP3c40=
|
golang.org/x/mod v0.38.0/go.mod h1:V6Xz0pq8TQ3dGqVQ1FVHuelZpAL0uNhSkk9ogYP3c40=
|
||||||
golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek=
|
golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek=
|
||||||
golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
||||||
golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=
|
golang.org/x/sys v0.49.0 h1:XbzkgYJHdqh/8m2Uu0W/dQv8nktxx4BFHp1M0gROTXA=
|
||||||
golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
golang.org/x/sys v0.49.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||||
golang.org/x/tools v0.48.0 h1:3+hClM1aLL5mjMKm5ovokw9epgRXPuu2tILgismM6RE=
|
golang.org/x/tools v0.48.0 h1:3+hClM1aLL5mjMKm5ovokw9epgRXPuu2tILgismM6RE=
|
||||||
golang.org/x/tools v0.48.0/go.mod h1:08xX0orndb/F7jJxGDicx061tyd5pcMto75YMAXr6lk=
|
golang.org/x/tools v0.48.0/go.mod h1:08xX0orndb/F7jJxGDicx061tyd5pcMto75YMAXr6lk=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
|||||||
@@ -186,18 +186,9 @@ func (a *apiServer) handleCreatePasteMultipart(w http.ResponseWriter, r *http.Re
|
|||||||
case "burn_after_read":
|
case "burn_after_read":
|
||||||
p.BurnAfterRead = v == "true" || v == "1" || v == "on"
|
p.BurnAfterRead = v == "true" || v == "1" || v == "on"
|
||||||
case "burn_after_reads":
|
case "burn_after_reads":
|
||||||
if v == "" { // absent value: unset, like the JSON path's omitempty
|
if n, err := strconv.Atoi(v); err == nil {
|
||||||
continue
|
p.BurnAfterReads = &n
|
||||||
}
|
}
|
||||||
n, err := strconv.Atoi(v)
|
|
||||||
if err != nil {
|
|
||||||
// malformed burn_after_reads is a 400, not a silently-dropped
|
|
||||||
// budget: same 400-with-code shape the JSON path uses for
|
|
||||||
// invalid values (which fail unmarshal into the int field).
|
|
||||||
writeErrCode(w, 400, "burn_invalid", "burn_after_reads must be a positive number")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
p.BurnAfterReads = &n
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ body {
|
|||||||
|
|
||||||
/* new paste page */
|
/* new paste page */
|
||||||
.deck {
|
.deck {
|
||||||
display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px;
|
display: grid; grid-template-columns: 1fr 300px; gap: 16px;
|
||||||
padding: 16px 20px 20px; height: calc(100vh - 76px);
|
padding: 16px 20px 20px; height: calc(100vh - 76px);
|
||||||
max-width: 1400px; margin: 0 auto;
|
max-width: 1400px; margin: 0 auto;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
{{define "head"}}
|
{{define "head"}}
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>{{ pageTitle . }} · Palette</title>
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<link rel="stylesheet" href="/static/app.css">
|
<link rel="stylesheet" href="/static/app.css">
|
||||||
<link rel="icon" type="image/svg+xml" href="/static/favicon.svg">
|
<link rel="icon" type="image/svg+xml" href="/static/favicon.svg">
|
||||||
|
|||||||
@@ -74,7 +74,6 @@ func New() (*UI, error) {
|
|||||||
"humanSize": humanSize,
|
"humanSize": humanSize,
|
||||||
"version": func() string { return Version }, // #93: topbar version label
|
"version": func() string { return Version }, // #93: topbar version label
|
||||||
"defaultDark": func() bool { return DefaultDark }, // #127: server-configured default
|
"defaultDark": func() bool { return DefaultDark }, // #127: server-configured default
|
||||||
"pageTitle": pageTitle, // page <title> labels
|
|
||||||
}
|
}
|
||||||
t, err := template.New("").Funcs(funcs).ParseFS(tmplFS, "templates/*.html")
|
t, err := template.New("").Funcs(funcs).ParseFS(tmplFS, "templates/*.html")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -83,38 +82,6 @@ func New() (*UI, error) {
|
|||||||
return &UI{tmpl: t}, nil
|
return &UI{tmpl: t}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// pageTitle returns the <title> label for the rendered page. Page data is
|
|
||||||
// always a map with a "Page" key set by the handlers.
|
|
||||||
func pageTitle(data any) string {
|
|
||||||
m, _ := data.(map[string]any)
|
|
||||||
page, _ := m["Page"].(string)
|
|
||||||
id, _ := m["ID"].(string)
|
|
||||||
title, _ := m["Title"].(string)
|
|
||||||
switch page {
|
|
||||||
case "new":
|
|
||||||
return "New paste"
|
|
||||||
case "public":
|
|
||||||
return "Public pastes"
|
|
||||||
case "saved":
|
|
||||||
return "Saved"
|
|
||||||
case "settings":
|
|
||||||
return "Settings"
|
|
||||||
case "paste":
|
|
||||||
if title != "" {
|
|
||||||
return title
|
|
||||||
}
|
|
||||||
return "Paste " + id
|
|
||||||
case "unlock":
|
|
||||||
return "Unlock " + id
|
|
||||||
case "can":
|
|
||||||
return "Can " + id
|
|
||||||
case "notfound":
|
|
||||||
return "Not found"
|
|
||||||
default:
|
|
||||||
return "Palette"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func humanSize(n int) string {
|
func humanSize(n int) string {
|
||||||
if n < 1024 {
|
if n < 1024 {
|
||||||
return fmt.Sprintf("%d B", n)
|
return fmt.Sprintf("%d B", n)
|
||||||
|
|||||||
Reference in new issue
Block a user