Skip to content

Commit d696a32

Browse files
authored
Merge pull request #99 from drduh/12jun26
gosec action, theme selection with swatches, neutral names
2 parents 72825b2 + 363855d commit d696a32

67 files changed

Lines changed: 921 additions & 201 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/gosec.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: gosec
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
gosec:
14+
runs-on: ubuntu-latest
15+
timeout-minutes: 5
16+
steps:
17+
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
18+
19+
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
20+
with:
21+
go-version-file: 'go.mod'
22+
23+
- name: Install gosec
24+
run: go install github.com/securego/gosec/v2/cmd/gosec@latest
25+
26+
- name: Run gosec
27+
run: gosec ./...

.github/workflows/lint.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@ on:
88

99
permissions:
1010
contents: read
11-
pull-requests: read
1211

1312
jobs:
1413
lint:
1514
runs-on: ubuntu-latest
15+
timeout-minutes: 5
1616
steps:
1717
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
18+
1819
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
1920
with:
2021
go-version-file: 'go.mod'
22+
2123
- uses: golangci/golangci-lint-action@82606bf257cbaff209d206a39f5134f0cfbfd2ee # v9.2.1
2224
with:
2325
version: v2.12.2
24-
timeout-minutes: 5

.github/workflows/test.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@ on:
88

99
permissions:
1010
contents: read
11-
pull-requests: read
1211

1312
jobs:
1413
test:
1514
runs-on: ubuntu-latest
15+
timeout-minutes: 5
1616
steps:
1717
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
18+
1819
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
1920
with:
2021
go-version-file: 'go.mod'
22+
2123
- run: go test -short ./...
22-
timeout-minutes: 5

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ check-service:
163163
@$(SYSTEMCTL) status $(APPNAME) || \
164164
$(DEST_BIN) -conf $(DEST_CONF)
165165

166-
uninstall-service:
166+
uninstall:
167167
@sudo $(SYSTEMCTL) stop $(APPNAME)
168168
@sudo $(SYSTEMCTL) disable $(APPNAME)
169169
@sudo rm -f $(DEST_SERV)
@@ -207,7 +207,7 @@ static:
207207
$(call WARN,skipping '$@': '$(GOSTATIC)' not found); \
208208
fi
209209

210-
build-race: prep
210+
build-race: prep-build
211211
@$(GORACE)
212212

213213
race: build-race
@@ -248,6 +248,7 @@ d: debug
248248
devug: debug
249249
f: fmt
250250
litn: lint
251+
prep: prep-build
251252
prod: release
252253
t: test
253254
tset: test

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ gone is an ephemeral content server written in [Go](https://go.dev/).
22

33
The primary goal is to share files and text using an HTML interface and API.
44

5-
[![test](https://github.com/drduh/gone/actions/workflows/test.yml/badge.svg)](https://github.com/drduh/gone/actions/workflows/test.yml) [![lint](https://github.com/drduh/gone/actions/workflows/lint.yml/badge.svg)](https://github.com/drduh/gone/actions/workflows/lint.yml)
5+
[![test](https://github.com/drduh/gone/actions/workflows/test.yml/badge.svg)](https://github.com/drduh/gone/actions/workflows/test.yml)
6+
[![lint](https://github.com/drduh/gone/actions/workflows/lint.yml/badge.svg)](https://github.com/drduh/gone/actions/workflows/lint.yml)
7+
[![gosec](https://github.com/drduh/gone/actions/workflows/gosec.yml/badge.svg)](https://github.com/drduh/gone/actions/workflows/gosec.yml)
68

79
## Features
810

assets/style.css

Lines changed: 119 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* style.css */
1+
/* https://github.com/drduh/gone/blob/main/assets/style.css */
22

33
* {
44
box-sizing: border-box;
@@ -8,7 +8,6 @@ html {
88
animation: var(--bg-animation);
99
background: var(--bg-gradient);
1010
background-size: var(--bg-size);
11-
background-attachment: fixed;
1211
min-height: 100%;
1312
}
1413

@@ -19,14 +18,14 @@ body {
1918
display: flex;
2019
flex-direction: column;
2120
font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
22-
font-size: 1em;
21+
font-size: var(--font-size);
2322
margin: 1em auto;
2423
}
2524

2625
.box {
2726
background-color: var(--bg-norm-half);
2827
border: 1px solid var(--fg-dark);
29-
border-radius: var(--box-radius);
28+
border-radius: var(--radius-box);
3029
flex: 1;
3130
margin: 1em auto;
3231
padding: 1em;
@@ -62,7 +61,6 @@ select {
6261

6362
button[disabled] {
6463
opacity: 0.5;
65-
pointer-events: none;
6664
}
6765

6866
button:focus,
@@ -85,7 +83,7 @@ select {
8583
appearance: none;
8684
background-color: var(--bg-dark);
8785
border: none;
88-
border-radius: var(--box-radius);
86+
border-radius: var(--radius-box);
8987
color: var(--fg-light);
9088
cursor: pointer;
9189
margin: 10px;
@@ -106,7 +104,7 @@ input[type="number"] {
106104

107105
.message .owner {
108106
background-color: var(--bg-light);
109-
border-radius: var(--box-radius);
107+
border-radius: var(--radius-box);
110108
bottom: 2em;
111109
color: var(--fg-light);
112110
padding: 6px 0;
@@ -121,7 +119,7 @@ input[type="number"] {
121119
.message .owner::after {
122120
border-color: var(--fg-light) transparent transparent transparent;
123121
border-style: solid;
124-
border-width: var(--box-radius);
122+
border-width: var(--radius-box);
125123
content: "";
126124
left: 50%;
127125
margin-left: -5px;
@@ -183,12 +181,17 @@ input[type="file"]::file-selector-button:hover {
183181
}
184182

185183
input[type="radio"] {
186-
display: none;
184+
height: 1px;
185+
margin: 0;
186+
opacity: 0;
187+
pointer-events: none;
188+
position: absolute;
189+
width: 1px;
187190
}
188191

189192
table {
190193
border-collapse: collapse;
191-
border-radius: var(--box-radius);
194+
border-radius: var(--radius-box);
192195
margin: 1em auto;
193196
overflow: hidden;
194197
width: 80%;
@@ -248,3 +251,109 @@ summary::marker {
248251
content: "";
249252
display: none;
250253
}
254+
255+
.themes {
256+
display: grid;
257+
gap: 1em;
258+
grid-template-columns: repeat(5, 1fr);
259+
}
260+
261+
.themes label {
262+
display: block;
263+
width: var(--width-theme);
264+
height: var(--width-theme);
265+
border-radius: var(--radius-theme);
266+
cursor: pointer;
267+
outline: 2px solid transparent;
268+
outline-offset: 2px;
269+
}
270+
271+
.themes label:hover,
272+
.themes label:has(input:checked) {
273+
outline-color: var(--fg-dark);
274+
}
275+
276+
.themes label:has(input:focus-visible) {
277+
outline-color: var(--fg-light);
278+
}
279+
280+
.theme {
281+
clip: rect(0,0,0,0);
282+
position: absolute;
283+
}
284+
285+
.theme-light {
286+
background: linear-gradient(var(--rotation),
287+
rgba(238,232,213,1) 0%,
288+
rgba(253,246,227,1) 100%);
289+
}
290+
.theme-dark {
291+
background: linear-gradient(var(--rotation),
292+
rgba(101,123,131,1) 0%,
293+
rgba( 0, 43, 54,1) 100%);
294+
}
295+
.theme-navy {
296+
background: linear-gradient(var(--rotation),
297+
rgba( 0, 91,150,1) 0%,
298+
rgba( 1, 31, 75,1) 100%);
299+
}
300+
.theme-rose {
301+
background: linear-gradient(var(--rotation),
302+
rgba(220,130,130,1) 0%,
303+
rgba(145, 55, 55,1) 100%);
304+
}
305+
.theme-green {
306+
background: linear-gradient(var(--rotation),
307+
rgba(119,171, 89,1) 0%,
308+
rgba( 35, 77, 32,1) 100%);
309+
}
310+
.theme-lime {
311+
background: linear-gradient(var(--rotation),
312+
rgba(170,220,130,1) 0%,
313+
rgba( 80,130, 50,1) 100%);
314+
}
315+
.theme-pink {
316+
background: linear-gradient(var(--rotation),
317+
rgba(255,185,210,1) 0%,
318+
rgba(210, 90,140,1) 100%);
319+
}
320+
.theme-gold {
321+
background: linear-gradient(var(--rotation),
322+
rgba(255,212, 71,1) 0%,
323+
rgba(166,124, 0,1) 100%);
324+
}
325+
.theme-purple {
326+
background: linear-gradient(var(--rotation),
327+
rgba(170,145,230,1) 0%,
328+
rgba( 80, 60,160,1) 100%);
329+
}
330+
.theme-lush {
331+
background: linear-gradient(var(--rotation),
332+
rgba(169,132,248,1) 0%,
333+
rgba( 26,184,126,1) 100%);
334+
}
335+
.theme-beach {
336+
background: linear-gradient(var(--rotation),
337+
rgba(246, 97, 81,1) 0%,
338+
rgba( 66,142,186,1) 100%);
339+
}
340+
.theme-dusk {
341+
background: linear-gradient(var(--rotation),
342+
rgba(255,190,111,1) 0%,
343+
rgba( 38, 36, 48,1) 100%);
344+
}
345+
.theme-neon {
346+
background: linear-gradient(var(--rotation),
347+
rgba(146, 21,245,1) 0%,
348+
rgba( 0, 0, 0,1) 100%);
349+
}
350+
.theme-night {
351+
background: linear-gradient(var(--rotation),
352+
rgba(128, 0, 0,1) 0%,
353+
rgba( 0, 0, 0,1) 100%);
354+
}
355+
.theme-ember {
356+
background: linear-gradient(var(--rotation),
357+
rgba(240,130, 30,1) 0%,
358+
rgba(120, 40, 0,1) 100%);
359+
}

audit/handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const errMarshal = `{"time":%q,` +
1515

1616
// Handle formats and prints audit events in JSON format.
1717
func (a *Auditor) Handle(
18-
ctx context.Context,
18+
_ context.Context,
1919
r slog.Record,
2020
) error {
2121
data := make(map[string]any, r.NumAttrs())

audit/handler_test.go

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,9 @@ package audit
33
import (
44
"bytes"
55
"encoding/json"
6-
"io"
7-
"log"
8-
"log/slog"
96
"testing"
107
)
118

12-
// newTestAuditor creates a new Auditor writing to buf.
13-
func newTestAuditor(buf *bytes.Buffer) *Auditor {
14-
a := &Auditor{
15-
Config: Config{
16-
TimeFormat: "2006-01-02 15:04:05",
17-
},
18-
Handler: slog.NewJSONHandler(io.Discard, nil),
19-
Logger: log.New(buf, "", 0),
20-
}
21-
a.Log = slog.New(a)
22-
return a
23-
}
24-
259
// TestHandleMarshalable tests a log entry is written
2610
// as valid JSON with expected fields.
2711
func TestHandleMarshalable(t *testing.T) {
@@ -30,8 +14,9 @@ func TestHandleMarshalable(t *testing.T) {
3014
a.Log.Info("test event", "key", "value")
3115

3216
var entry map[string]any
33-
if err := json.Unmarshal(buf.Bytes(), &entry); err != nil {
34-
t.Fatalf("expected valid json, got error: %v\noutput: %s",
17+
if err := json.Unmarshal(
18+
buf.Bytes(), &entry); err != nil {
19+
t.Fatalf("expected json, got error: %v\noutput: %s",
3520
err, buf.String())
3621
}
3722

audit/testutil_test.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package audit
2+
3+
import (
4+
"bytes"
5+
"context"
6+
"log"
7+
"log/slog"
8+
)
9+
10+
type testHandler struct{}
11+
12+
func (testHandler) Enabled(context.Context, slog.Level) bool {
13+
return true
14+
}
15+
16+
func (h testHandler) Handle(context.Context, slog.Record) error {
17+
return nil
18+
}
19+
20+
func (h testHandler) WithAttrs([]slog.Attr) slog.Handler {
21+
return h
22+
}
23+
24+
func (h testHandler) WithGroup(string) slog.Handler {
25+
return h
26+
}
27+
28+
// newTestAuditor creates a new Auditor writing to buf.
29+
func newTestAuditor(buf *bytes.Buffer) *Auditor {
30+
a := &Auditor{
31+
Config: Config{
32+
TimeFormat: "2006-01-02 15:04:05",
33+
},
34+
Handler: testHandler{},
35+
Logger: log.New(buf, "", 0),
36+
}
37+
a.Log = slog.New(a)
38+
return a
39+
}

auth/cookie.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ func GetCookie(w http.ResponseWriter, r *http.Request,
1414
http.SetCookie(w, NewCookie(defaultValue, id, t))
1515
return defaultValue
1616
}
17+
1718
return cookie.Value
1819
}
1920

0 commit comments

Comments
 (0)