aboutsummaryrefslogtreecommitdiffstats
path: root/internal/web/filetype_test.go
diff options
context:
space:
mode:
authorgrm <grm@eyesin.space>2026-09-17 21:29:44 +0300
committergrm <grm@eyesin.space>2026-09-17 21:29:44 +0300
commite96bbec551c0388e972894b349413fa6ef607352 (patch)
treec63b50d515fc0a0f754f970b8d316dd37f73ac80 /internal/web/filetype_test.go
parent69912c4ac04ada3286c09400ce523d5d3ab4cfb4 (diff)
downloadblogspace-e96bbec551c0388e972894b349413fa6ef607352.tar.gz
blogspace-e96bbec551c0388e972894b349413fa6ef607352.tar.bz2
blogspace-e96bbec551c0388e972894b349413fa6ef607352.zip
Add custom fonts: upload WOFF2/WOFF/TTF/OTF files and pick them on the Design tab
Fonts become a file kind of their own (sniffed from the bytes like images, served inline from /media), and the theme gets custom_font and custom_heading_font: a chosen file is declared as @font-face and put first in the stack, the built-in Font / Heading font choice behind it as the fallback, so there is no "custom" enum value and no invalid state. The pickers are plain selects with an upload input, no script. Fonts uploaded before this are reclassified by the migration. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Sd8UPWrvyYCLj97JexNw3A
Diffstat (limited to 'internal/web/filetype_test.go')
-rw-r--r--internal/web/filetype_test.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/internal/web/filetype_test.go b/internal/web/filetype_test.go
index 1f1d89e..45c4166 100644
--- a/internal/web/filetype_test.go
+++ b/internal/web/filetype_test.go
@@ -35,8 +35,14 @@ func TestFileType(t *testing.T) {
{"hello world", "notes.txt", "text/plain", "document"},
{"hello world", "server.log", "text/plain", "document"}, // text/* names only confirm the sniff
{"hello world", "notes.md", "text/plain", "document"},
- {"hello world", "README", "text/plain", "document"}, // no extension: the bytes are all we have
- {"\x00\x01\x02\x03\xff\xfe", "font.ttf", "application/octet-stream", "other"},
+ {"hello world", "README", "text/plain", "document"}, // no extension: the bytes are all we have
+ {"\x00\x01\x02\x03\xff\xfe", "font.ttf", "application/octet-stream", "other"}, // a font is known by its bytes
+ {"wOF2\x00\x01\x00\x00", "body.woff2", "font/woff2", "font"},
+ {"wOFF\x00\x01\x00\x00", "body.woff", "font/woff", "font"},
+ {"\x00\x01\x00\x00\x00\x10", "body.ttf", "font/ttf", "font"},
+ {"OTTO\x00\x10\x00\x80", "body.otf", "font/otf", "font"},
+ {"OTTO\x00\x10\x00\x80", "evil.html", "font/otf", "font"},
+ {"ttcf\x00\x01\x00\x00", "family.ttc", "application/octet-stream", "other"},
{"hello world", "data.csv", "text/csv", "document"},
{"hello world", "evil.html", "application/octet-stream", "other"},
{"<svg xmlns='http://www.w3.org/2000/svg'><script>1</script></svg>", "evil.svg", "application/octet-stream", "other"},
@@ -69,6 +75,7 @@ func TestServedAs(t *testing.T) {
{"text/plain", false, "text/plain; charset=utf-8", "inline"},
{"audio/mpeg", false, "audio/mpeg", "inline"},
{"video/mp4", false, "video/mp4", "inline"},
+ {"font/woff2", false, "font/woff2", "inline"},
{"application/zip", false, "application/octet-stream", "attachment"},
{"text/html", false, "application/octet-stream", "attachment"},
{"image/svg+xml", false, "application/octet-stream", "attachment"},