From 0c0900cdea12364a25ebf9bb8205a795416e8d6d Mon Sep 17 00:00:00 2001 From: SayaAndy Date: Fri, 1 Aug 2025 16:52:52 +0700 Subject: feat: support of multi-page blog via b2 feat: use markdown + frontmatter for page content feat: add main page with dynamic page lookup feat: add night theme feat: extract timestamp of photo taken from picture name --- .gitignore | 3 + config/config.go | 67 +++++++ config/config.yaml | 17 ++ go.mod | 13 +- go.sum | 25 +++ internal/b2/client.go | 121 +++++++++++++ internal/frontmatter/parser.go | 37 ++++ internal/lightgallery/block.go | 26 +++ internal/lightgallery/extension.go | 28 +++ internal/lightgallery/html_renderer.go | 137 ++++++++++++++ internal/lightgallery/parser.go | 77 ++++++++ internal/tailwind/extension.go | 21 +++ internal/tailwind/transformer.go | 72 ++++++++ main.go | 112 +++++++++++- static/input.css | 95 +++++++++- static/output.css | 237 +++++++++++++++++++++++- views/index.html | 317 ++++++++------------------------- views/layouts/blog-page.html | 128 +++++++++++++ 18 files changed, 1273 insertions(+), 260 deletions(-) create mode 100644 config/config.go create mode 100644 config/config.yaml create mode 100644 internal/b2/client.go create mode 100644 internal/frontmatter/parser.go create mode 100644 internal/lightgallery/block.go create mode 100644 internal/lightgallery/extension.go create mode 100644 internal/lightgallery/html_renderer.go create mode 100644 internal/lightgallery/parser.go create mode 100644 internal/tailwind/extension.go create mode 100644 internal/tailwind/transformer.go create mode 100644 views/layouts/blog-page.html diff --git a/.gitignore b/.gitignore index e8f4633..9fb93e9 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,6 @@ config*.json /main /sayana-demo + +/.vscode +.envrc diff --git a/config/config.go b/config/config.go new file mode 100644 index 0000000..67c0c4d --- /dev/null +++ b/config/config.go @@ -0,0 +1,67 @@ +package config + +import ( + "log/slog" + "os" + + "github.com/go-playground/validator/v10" + "gopkg.in/yaml.v3" +) + +type Config struct { + LogLevel slog.Level `json:"LogLevel" yaml:"logLevel" validate:"required"` + BlogPages BlogPagesConfig `json:"BlogPages" yaml:"blogPages" validate:"required"` +} + +type BlogPagesConfig struct { + Storage StorageConfig `json:"Storage" yaml:"storage" validate:"required"` + AvailableLanguages []AvailableLanguageConfig `json:"AvailableLanguages" yaml:"availableLanguages" validate:"required"` +} + +type StorageConfig struct { + Type string `json:"type" yaml:"type"` + Config B2Config `json:"Config" yaml:"config" validate:"required"` +} + +type B2Config struct { + BucketName string `json:"BucketName" yaml:"bucketName" validate:"required,min=1"` + Region string `json:"Region" yaml:"region" validate:"required,min=1"` + Prefix string `json:"Prefix" yaml:"prefix"` + KeyID string `json:"KeyID" yaml:"keyID"` + ApplicationKey string `json:"ApplicationKey" yaml:"applicationKey"` +} + +type AvailableLanguageConfig struct { + Name string `json:"Name" yaml:"name" validate:"required"` + Alt string `json:"Alt" yaml:"alt"` + Flag string `json:"Flag" yaml:"flag" validate:"url"` +} + +func LoadConfig(path string, config *Config) error { + fileBytes, err := os.ReadFile(path) + if err != nil { + return err + } + + expandedFileBytes := []byte(os.ExpandEnv(string(fileBytes))) + + if err = yaml.Unmarshal(expandedFileBytes, config); err != nil { + return err + } + + return nil +} + +func InitConfig(path string) (*Config, error) { + config := &Config{} + if err := LoadConfig(path, config); err != nil { + return nil, err + } + + validate := validator.New(validator.WithRequiredStructEnabled()) + if err := validate.Struct(config); err != nil { + return nil, err + } + + return config, nil +} diff --git a/config/config.yaml b/config/config.yaml new file mode 100644 index 0000000..908bfe2 --- /dev/null +++ b/config/config.yaml @@ -0,0 +1,17 @@ +logLevel: debug +blogPages: + storage: + type: b2 + config: + bucketName: sayana-pages + region: eu-central-003 + prefix: '' + keyID: '${B2_KEY_ID}' + applicationKey: '${B2_APPLICATION_KEY}' + availableLanguages: + - name: ru + alt: Русский + flag: https://f003.backblazeb2.com/file/sayana-static/flags/ru.svg + - name: en + alt: English + flag: https://f003.backblazeb2.com/file/sayana-static/flags/gb.svg diff --git a/go.mod b/go.mod index 578b61b..c6f267d 100644 --- a/go.mod +++ b/go.mod @@ -5,12 +5,18 @@ go 1.24.5 require github.com/gofiber/fiber/v2 v2.52.9 require ( + github.com/Backblaze/blazer v0.7.2 // indirect github.com/andybalholm/brotli v1.1.0 // indirect + github.com/gabriel-vasile/mimetype v1.4.8 // indirect + github.com/go-playground/locales v0.14.1 // indirect + github.com/go-playground/universal-translator v0.18.1 // indirect + github.com/go-playground/validator/v10 v10.27.0 // indirect github.com/gofiber/template v1.8.3 // indirect github.com/gofiber/template/html/v2 v2.1.3 // indirect github.com/gofiber/utils v1.1.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/klauspost/compress v1.17.9 // indirect + github.com/leodido/go-urn v1.4.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.16 // indirect @@ -18,5 +24,10 @@ require ( github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasthttp v1.51.0 // indirect github.com/valyala/tcplisten v1.0.0 // indirect - golang.org/x/sys v0.28.0 // indirect + github.com/yuin/goldmark v1.7.13 // indirect + golang.org/x/crypto v0.33.0 // indirect + golang.org/x/net v0.34.0 // indirect + golang.org/x/sys v0.30.0 // indirect + golang.org/x/text v0.22.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index cfc34da..e418881 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,15 @@ +github.com/Backblaze/blazer v0.7.2 h1:UWNHMLB+Nf+UmbO2qkVvgriODLEMz4kIyr2Hm+DVXQM= +github.com/Backblaze/blazer v0.7.2/go.mod h1:T4y3EYa9IQ5J0PKc/C/J8/CEnSd3qa/lgNw938wZg10= github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY= +github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM= +github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8= +github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= +github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= +github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= +github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= +github.com/go-playground/validator/v10 v10.27.0 h1:w8+XrWVMhGkxOaaowyKH35gFydVHOvC0/uWoy2Fzwn4= +github.com/go-playground/validator/v10 v10.27.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo= github.com/gofiber/fiber/v2 v2.52.9 h1:YjKl5DOiyP3j0mO61u3NTmK7or8GzzWzCFzkboyP5cw= github.com/gofiber/fiber/v2 v2.52.9/go.mod h1:YEcBbO/FB+5M1IZNBP9FO3J9281zgPAreiI1oqg8nDw= github.com/gofiber/template v1.8.3 h1:hzHdvMwMo/T2kouz2pPCA0zGiLCeMnoGsQZBTSYgZxc= @@ -12,6 +22,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= +github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= @@ -27,7 +39,20 @@ github.com/valyala/fasthttp v1.51.0 h1:8b30A5JlZ6C7AS81RsWjYMQmrZG6feChmgAolCl1S github.com/valyala/fasthttp v1.51.0/go.mod h1:oI2XroL+lI7vdXyYoQk03bXBThfFl2cVdIA3Xl7cH8g= github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8= github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= +github.com/yuin/goldmark v1.7.13 h1:GPddIs617DnBLFFVJFgpo1aBfe/4xcvMc3SB5t/D0pA= +github.com/yuin/goldmark v1.7.13/go.mod h1:ip/1k0VRfGynBgxOz0yCqHrbZXhcjxyuS66Brc7iBKg= +golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus= +golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M= +golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0= +golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= +golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= +golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/b2/client.go b/internal/b2/client.go new file mode 100644 index 0000000..f2b6cad --- /dev/null +++ b/internal/b2/client.go @@ -0,0 +1,121 @@ +package b2 + +import ( + "context" + "fmt" + "strings" + "time" + + "github.com/Backblaze/blazer/b2" + "github.com/SayaAndy/saya-today-web/config" + "github.com/SayaAndy/saya-today-web/internal/frontmatter" +) + +type B2Client struct { + prefix string + bucket *b2.Bucket + b2cl *b2.Client +} + +func NewB2Client(cfg *config.B2Config) (*B2Client, error) { + b2cl, err := b2.NewClient(context.Background(), cfg.KeyID, cfg.ApplicationKey) + if err != nil { + return nil, err + } + + bucket, err := b2cl.Bucket(context.Background(), cfg.BucketName) + if err != nil { + return nil, err + } + + return &B2Client{b2cl: b2cl, bucket: bucket, prefix: cfg.Prefix}, nil +} + +type BlogPage struct { + Link string + Metadata *frontmatter.Metadata +} + +func (c *B2Client) Scan() ([]*BlogPage, error) { + filePaths := []*BlogPage{} + + iter := c.bucket.List(context.Background(), b2.ListPrefix(c.prefix)) + + for iter.Next() { + obj := iter.Object() + if obj == nil { + return nil, fmt.Errorf("failed to reference object in B2 bucket") + } + + attrs, err := obj.Attrs(context.Background()) + if err != nil { + return nil, fmt.Errorf("get attributes for object: %w", err) + } + + if attrs.Status != b2.Uploaded { + continue + } + + if !strings.Contains(attrs.ContentType, "text/markdown") { + continue + } + + if _, ok := attrs.Info["title"]; !ok { + continue + } + + publishedTime, err := time.Parse(time.RFC3339, attrs.Info["published-time"]) + if err != nil { + return nil, fmt.Errorf("failed to parse published time metadata field: %w", err) + } + + linkParts := strings.Split(obj.Name(), ".") + + filePaths = append(filePaths, &BlogPage{ + Link: strings.Join(linkParts[:len(linkParts)-1], "."), + Metadata: &frontmatter.Metadata{ + Title: attrs.Info["title"], + ShortDescription: attrs.Info["short-description"], + ActionDate: attrs.Info["action-date"], + PublishedTime: publishedTime, + Thumbnail: attrs.Info["thumbnail"], + Tags: strings.Split(attrs.Info["tags"], ","), + }, + }) + } + + if err := iter.Err(); err != nil { + return nil, fmt.Errorf("iterate over B2 objects: %w", err) + } + + return filePaths, nil +} + +func (c *B2Client) ReadAll(path string) ([]byte, error) { + obj := c.bucket.Object(c.prefix + path) + if obj == nil { + return nil, fmt.Errorf("failed to reference object in B2 bucket") + } + attrs, err := obj.Attrs(context.Background()) + if err != nil { + return nil, fmt.Errorf("error getting attributes of an object: %w", err) + } + + content := make([]byte, attrs.Size) + reader := obj.NewReader(context.Background()) + + if _, err = reader.Read(content); err != nil { + return nil, fmt.Errorf("failed to read file content: %w", err) + } + + return content, nil +} + +func (c *B2Client) ReadFrontmatter(path string) (metadata *frontmatter.Metadata, markdown []byte, err error) { + contentBytes, err := c.ReadAll(path) + if err != nil { + return nil, nil, fmt.Errorf("failed to read file for frontmatter parsing: %w", err) + } + + return frontmatter.ParseFrontmatter(contentBytes) +} diff --git a/internal/frontmatter/parser.go b/internal/frontmatter/parser.go new file mode 100644 index 0000000..6cc3ee8 --- /dev/null +++ b/internal/frontmatter/parser.go @@ -0,0 +1,37 @@ +package frontmatter + +import ( + "fmt" + "regexp" + "time" + + "gopkg.in/yaml.v3" +) + +type Metadata struct { + Title string `yaml:"title"` + ShortDescription string `yaml:"shortDescription"` + ActionDate string `yaml:"actionDate"` + PublishedTime time.Time `yaml:"publishedTime"` + Thumbnail string `yaml:"thumbnail"` + Tags []string `yaml:"tags"` +} + +func ParseFrontmatter(content []byte) (metadata *Metadata, markdown []byte, err error) { + frontmatterRegex := regexp.MustCompile(`^---\s*\r?\n([\s\S]*?)\r?\n---\s*\r?\n([\s\S]*)$`) + matches := frontmatterRegex.FindSubmatch(content) + + if len(matches) != 3 { + return nil, content, nil + } + + yamlContent := matches[1] + markdownContent := matches[2] + + metadata = &Metadata{} + if err := yaml.Unmarshal([]byte(yamlContent), &metadata); err != nil { + return nil, nil, fmt.Errorf("failed to parse YAML frontmatter: %w", err) + } + + return metadata, markdownContent, nil +} diff --git a/internal/lightgallery/block.go b/internal/lightgallery/block.go new file mode 100644 index 0000000..dade2ea --- /dev/null +++ b/internal/lightgallery/block.go @@ -0,0 +1,26 @@ +package lightgallery + +import "github.com/yuin/goldmark/ast" + +// LightGalleryBlock represents a light gallery block in the AST +type LightGalleryBlock struct { + ast.BaseBlock + Images []LightGalleryImage +} + +type LightGalleryImage struct { + URL string + Caption string +} + +var KindLightGalleryBlock = ast.NewNodeKind("LightGalleryBlock") + +// Dump implements ast.Node.Dump +func (n *LightGalleryBlock) Dump(source []byte, level int) { + ast.DumpHelper(n, source, level, nil, nil) +} + +// Kind implements ast.Node.Kind +func (n *LightGalleryBlock) Kind() ast.NodeKind { + return KindLightGalleryBlock +} diff --git a/internal/lightgallery/extension.go b/internal/lightgallery/extension.go new file mode 100644 index 0000000..761dc05 --- /dev/null +++ b/internal/lightgallery/extension.go @@ -0,0 +1,28 @@ +package lightgallery + +import ( + "github.com/yuin/goldmark" + "github.com/yuin/goldmark/parser" + "github.com/yuin/goldmark/renderer" + "github.com/yuin/goldmark/util" +) + +// Extension that combines parser and renderer +type LightGalleryExtension struct{} + +func NewLightGalleryExtension() goldmark.Extender { + return &LightGalleryExtension{} +} + +func (e *LightGalleryExtension) Extend(m goldmark.Markdown) { + m.Parser().AddOptions( + parser.WithBlockParsers( + util.Prioritized(NewLightGalleryParser(), 500), + ), + ) + m.Renderer().AddOptions( + renderer.WithNodeRenderers( + util.Prioritized(NewLightGalleryHTMLRenderer(), 500), + ), + ) +} diff --git a/internal/lightgallery/html_renderer.go b/internal/lightgallery/html_renderer.go new file mode 100644 index 0000000..fb65b06 --- /dev/null +++ b/internal/lightgallery/html_renderer.go @@ -0,0 +1,137 @@ +package lightgallery + +import ( + "fmt" + "math/rand" + "strings" + "time" + + "github.com/yuin/goldmark/ast" + "github.com/yuin/goldmark/renderer" + "github.com/yuin/goldmark/renderer/html" + "github.com/yuin/goldmark/util" +) + +type LightGalleryHTMLRenderer struct { + html.Config +} + +func NewLightGalleryHTMLRenderer(opts ...html.Option) renderer.NodeRenderer { + r := &LightGalleryHTMLRenderer{ + Config: html.NewConfig(), + } + for _, opt := range opts { + opt.SetHTMLOption(&r.Config) + } + return r +} + +func (r *LightGalleryHTMLRenderer) RegisterFuncs(reg renderer.NodeRendererFuncRegisterer) { + reg.Register(KindLightGalleryBlock, r.renderLightGallery) +} + +func (r *LightGalleryHTMLRenderer) renderLightGallery(w util.BufWriter, source []byte, n ast.Node, entering bool) (ast.WalkStatus, error) { + if entering { + gallery := n.(*LightGalleryBlock) + + if len(gallery.Images) == 0 { + return ast.WalkContinue, nil + } + + galleryID := generateDivId(4) + + w.WriteString(fmt.Sprintf(` +
+
+ +
+
`, galleryID)) + + var dynamicElements []string + for _, img := range gallery.Images { + imageUrlSegments := strings.Split(img.URL, ".") + imageUrlWithoutExt := strings.Join(imageUrlSegments[:len(imageUrlSegments)-1], ".") + imageNameParts := strings.Split(imageUrlWithoutExt, "-") + + dayDate, _ := time.Parse("20060102 150405", imageNameParts[len(imageNameParts)-2]+" "+imageNameParts[len(imageNameParts)-1]) + dynamicElements = append(dynamicElements, fmt.Sprintf(`{ + src: + "https://f003.backblazeb2.com/file/sayana-photos/full/%s", + downloadUrl: + "https://f003.backblazeb2.com/file/sayana-photos/full/%s", + alt: "%s", + sources: [{ + srcset: "https://f003.backblazeb2.com/file/sayana-photos/thumbnails/%s.webp", + media: "(max-width: 800px)" + }], + thumb: + "https://f003.backblazeb2.com/file/sayana-photos/thumbnails/%s.webp", + subHtml: `+"`"+``+"`"+` + }`, img.URL, img.URL, img.Caption, imageUrlWithoutExt, imageUrlWithoutExt, img.Caption, dayDate.Format("2006-01-02 15:04:05 -07:00"))) + } + + w.WriteString(fmt.Sprintf(` +`, galleryID, galleryID, strings.Join(dynamicElements, ","), galleryID, galleryID, galleryID, galleryID, galleryID, galleryID)) + } + + return ast.WalkContinue, nil +} + +func escapeHTML(s string) string { + s = strings.ReplaceAll(s, "&", "&") + s = strings.ReplaceAll(s, "<", "<") + s = strings.ReplaceAll(s, ">", ">") + s = strings.ReplaceAll(s, "\"", """) + s = strings.ReplaceAll(s, "'", "'") + return s +} + +func generateDivId(length int) string { + const charset = "abcdefghijklmnopqrstuvwxyz" + seededRand := rand.New(rand.NewSource(time.Now().UnixNano())) // Seed with current time + b := make([]byte, length) + for i := range b { + b[i] = charset[seededRand.Intn(len(charset))] + } + return string(b) +} diff --git a/internal/lightgallery/parser.go b/internal/lightgallery/parser.go new file mode 100644 index 0000000..0ce209c --- /dev/null +++ b/internal/lightgallery/parser.go @@ -0,0 +1,77 @@ +package lightgallery + +import ( + "bytes" + "strings" + + "github.com/yuin/goldmark/ast" + "github.com/yuin/goldmark/parser" + "github.com/yuin/goldmark/text" +) + +type LightGalleryParser struct{} + +func NewLightGalleryParser() parser.BlockParser { + return &LightGalleryParser{} +} + +func (p *LightGalleryParser) Trigger() []byte { + return []byte{'{'} +} + +func (p *LightGalleryParser) Open(parent ast.Node, reader text.Reader, pc parser.Context) (ast.Node, parser.State) { + line, _ := reader.PeekLine() + + if !bytes.HasPrefix(line, []byte("{Gallery}")) { + return nil, parser.NoChildren + } + + trimmed := bytes.TrimSpace(line) + if !bytes.Equal(trimmed, []byte("{Gallery}")) { + return nil, parser.NoChildren + } + + return &LightGalleryBlock{}, parser.NoChildren +} + +func (p *LightGalleryParser) Continue(node ast.Node, reader text.Reader, pc parser.Context) parser.State { + line, segment := reader.PeekLine() + if len(line) == 0 || segment.Len() == 0 { + return parser.Close + } + + trimmed := bytes.TrimSpace(line) + if bytes.Equal(trimmed, []byte("{Gallery}")) { + reader.AdvanceLine() + return parser.Close + } + + gallery := node.(*LightGalleryBlock) + lineStr := string(trimmed) + + parts := strings.SplitN(lineStr, "|", 2) + url := strings.TrimSpace(parts[0]) + caption := "" + + if len(parts) > 1 { + caption = strings.TrimSpace(parts[1]) + } + + gallery.Images = append(gallery.Images, LightGalleryImage{ + URL: url, + Caption: caption, + }) + + return parser.Continue | parser.NoChildren +} + +func (p *LightGalleryParser) Close(node ast.Node, reader text.Reader, pc parser.Context) { +} + +func (p *LightGalleryParser) CanInterruptParagraph() bool { + return true +} + +func (p *LightGalleryParser) CanAcceptIndentedLine() bool { + return false +} diff --git a/internal/tailwind/extension.go b/internal/tailwind/extension.go new file mode 100644 index 0000000..c3254cc --- /dev/null +++ b/internal/tailwind/extension.go @@ -0,0 +1,21 @@ +package tailwind + +import ( + "github.com/yuin/goldmark" + "github.com/yuin/goldmark/parser" + "github.com/yuin/goldmark/util" +) + +type TailwindExtension struct{} + +func NewTailwindExtension() goldmark.Extender { + return &TailwindExtension{} +} + +func (e *TailwindExtension) Extend(m goldmark.Markdown) { + m.Parser().AddOptions( + parser.WithASTTransformers( + util.Prioritized(&TailwindTransformer{}, 500), + ), + ) +} diff --git a/internal/tailwind/transformer.go b/internal/tailwind/transformer.go new file mode 100644 index 0000000..51a33bc --- /dev/null +++ b/internal/tailwind/transformer.go @@ -0,0 +1,72 @@ +package tailwind + +import ( + "github.com/yuin/goldmark/ast" + "github.com/yuin/goldmark/parser" + "github.com/yuin/goldmark/text" +) + +type TailwindTransformer struct{} + +func (t *TailwindTransformer) Transform(node *ast.Document, reader text.Reader, pc parser.Context) { + ast.Walk(node, func(n ast.Node, entering bool) (ast.WalkStatus, error) { + if !entering { + return ast.WalkContinue, nil + } + + switch node := n.(type) { + case *ast.Heading: + classes := map[int]string{ + 1: "font-patua text-vmax2-5 font-bold text-main-dark mb-vmin1-2 ls-vmin0-04", + 2: "font-spectral text-vmax2 font-bold text-main-dark mb-vmin0-8 ls-vmin0-04", + 3: "font-spectral text-vmax1-5 font-medium text-main-dark mb-vmin0-6 ls-vmin0-04", + 4: "font-spectral text-vmax1-2 font-medium text-main-medium mb-vmin0-4 ls-vmin0-04", + 5: "font-spectral text-vmax1 font-medium text-main-medium mb-vmin0-4 italic ls-vmin0-04", + 6: "font-spectral text-vmax1 font-medium text-secondary mb-vmin0-4", + } + if class, ok := classes[node.Level]; ok { + node.SetAttribute([]byte("class"), []byte(class)) + } + + case *ast.Paragraph: + node.SetAttribute([]byte("class"), []byte("text-vmax1 font-spectral lh-2 ls-vmin0-04 timl-vmax2 mb-vmin1-6")) + + case *ast.List: + if node.IsOrdered() { + node.SetAttribute([]byte("class"), []byte("list-decimal list-inside space-y-vmin0-8 mb-vmin1-6 pl-vmax2")) + } else { + node.SetAttribute([]byte("class"), []byte("list-disc list-inside space-y-vmin0-8 mb-vmin1-6 pl-vmax2")) + } + + case *ast.ListItem: + node.SetAttribute([]byte("class"), []byte("text-vmax1 font-spectral lh-2 ls-vmin0-04")) + + case *ast.Blockquote: + node.SetAttribute([]byte("class"), []byte("border-l-vmin0-4 border-main-medium bg-background-dark p-vmin0-8 mb-vmin0-8 italic")) + + case *ast.CodeSpan: + node.SetAttribute([]byte("class"), []byte("bg-background-dark")) + + case *ast.CodeBlock, *ast.FencedCodeBlock: + node.SetAttribute([]byte("class"), []byte("bg-background-dark p-vmin0-8 rounded-lg overflow-x-auto mb-vmin1-6")) + + case *ast.Link: + node.SetAttribute([]byte("class"), []byte("text-secondary hover:text-main-dark underline")) + + case *ast.Image: + node.SetAttribute([]byte("class"), []byte("max-w-full h-auto rounded-lg shadow-lg mb-vmin1-6")) + + case *ast.Emphasis: + switch node.Level { + case 1: + node.SetAttribute([]byte("class"), []byte("italic")) + case 2: + node.SetAttribute([]byte("class"), []byte("font-bold")) + case 3: + node.SetAttribute([]byte("class"), []byte("italic font-bold")) + } + } + + return ast.WalkContinue, nil + }) +} diff --git a/main.go b/main.go index b559a48..37d6e8d 100644 --- a/main.go +++ b/main.go @@ -1,13 +1,65 @@ package main import ( + "bytes" + "flag" + "fmt" + "html/template" "log" + "log/slog" + "os" + "strconv" + "strings" + "github.com/SayaAndy/saya-today-web/config" + "github.com/SayaAndy/saya-today-web/internal/b2" + "github.com/SayaAndy/saya-today-web/internal/frontmatter" + "github.com/SayaAndy/saya-today-web/internal/lightgallery" + "github.com/SayaAndy/saya-today-web/internal/tailwind" "github.com/gofiber/fiber/v2" "github.com/gofiber/template/html/v2" + "github.com/yuin/goldmark" + "github.com/yuin/goldmark/parser" + gmhtml "github.com/yuin/goldmark/renderer/html" +) + +var ( + md = goldmark.New( + goldmark.WithExtensions( + lightgallery.NewLightGalleryExtension(), + tailwind.NewTailwindExtension(), + ), + goldmark.WithParserOptions( + parser.WithAutoHeadingID(), + ), + goldmark.WithRendererOptions( + gmhtml.WithXHTML(), + ), + ) + b2Client *b2.B2Client + configPath = flag.String("c", "config.yaml", "Path to the configuration file (in YAML format)") ) func main() { + var err error + + flag.Parse() + + cfg := &config.Config{} + if err := config.LoadConfig(*configPath, cfg); err != nil { + slog.Error("fail to load configuration", slog.String("error", err.Error())) + os.Exit(1) + } + + slog.SetLogLoggerLevel(cfg.LogLevel) + slog.Info("starting sayana-web server...") + + b2Client, err = b2.NewB2Client(&cfg.BlogPages.Storage.Config) + if err != nil { + slog.Error("fail to initialize b2 client", slog.String("error", err.Error())) + os.Exit(1) + } + engine := html.New("./views", ".html") app := fiber.New(fiber.Config{ @@ -15,8 +67,46 @@ func main() { }) app.Get("/", func(c *fiber.Ctx) error { - return c.Render("index", fiber.Map{ - "Title": "Демо-материал после демон-аэропорта", + pages, err := b2Client.Scan() + status := fiber.StatusOK + if err != nil { + status = fiber.StatusPartialContent + pages = []*b2.BlogPage{} + } + + pageMeta := make([]map[string]string, 0, len(pages)) + for _, page := range pages { + slog.Debug("enlist page for catalogue", slog.Any("page", page), slog.String("endpoint", "/")) + pageMeta = append(pageMeta, map[string]string{ + "Link": page.Link, + "Title": page.Metadata.Title, + "PublishedTime": page.Metadata.PublishedTime.Format("2006-01-02 15:04:05 -0700"), + "ActionDate": page.Metadata.ActionDate, + "ShortDescription": page.Metadata.ShortDescription, + "Thumbnail": page.Metadata.Thumbnail, + "Tags": strings.Join(page.Metadata.Tags, ", "), + }) + } + + return c.Status(status).Render("index", fiber.Map{ + "PublishedYear": "2025", + "BlogPages": pageMeta, + }) + }) + + app.Get("/blog/:lang/:title", func(c *fiber.Ctx) error { + metadata, parsedMarkdownDesktop, parsedMarkdownMobile, err := readBlogPost(c.Params("lang") + "/" + c.Params("title")) + if err != nil { + c.Set(fiber.HeaderContentType, fiber.MIMETextPlainCharsetUTF8) + return c.Status(fiber.ErrNotFound.Code).SendString(fmt.Sprintf("failed to find '%s' post", c.Params("title"))) + } + + return c.Render("layouts/blog-page", fiber.Map{ + "Title": metadata.Title, + "PublishedDate": metadata.PublishedTime.Format("2006-01-02 15:04:05 -07:00"), + "PublishedYear": strconv.Itoa(metadata.PublishedTime.Year()), + "ParsedMarkdownDesktop": template.HTML(parsedMarkdownDesktop), + "ParsedMarkdownMobile": template.HTML(parsedMarkdownMobile), }) }) @@ -24,3 +114,21 @@ func main() { log.Fatal(app.Listen(":3000")) } + +func readBlogPost(sourceName string) (metadata *frontmatter.Metadata, desktopBody string, mobileBody string, err error) { + metadata, markdown, err := b2Client.ReadFrontmatter(sourceName + ".md") + if err != nil { + return nil, "", "", fmt.Errorf("failed to read a frontmatter file: %w", err) + } + + var bufDesktop bytes.Buffer + if err := md.Convert(markdown, &bufDesktop); err != nil { + return nil, "", "", fmt.Errorf("convert source context from md to html (desktop version): %w", err) + } + var bufMobile bytes.Buffer + if err := md.Convert(markdown, &bufMobile); err != nil { + return nil, "", "", fmt.Errorf("convert source context from md to html (mobile version): %w", err) + } + + return metadata, bufDesktop.String(), bufMobile.String(), nil +} diff --git a/static/input.css b/static/input.css index 3b90f50..dfa9219 100644 --- a/static/input.css +++ b/static/input.css @@ -26,8 +26,10 @@ --sidebar-stroke-color: var(--main-dark-color); --secondary-color: var(--main-light-color); --interlocked-hexagons-background: url('https://f003.backblazeb2.com/file/sayana-static/themes/olive/interlocked-hexagons.svg'); + --interlocked-hexagons-background-repeat: repeat; + --interlocked-hexagons-background-size: 10vw; --squares-and-triangles-background: url('https://f003.backblazeb2.com/file/sayana-static/themes/olive/squares-and-triangles.svg'); - --invert-colors-in-sidebar: false; + --squares-and-triangles-background-repeat: repeat; } [data-theme="lettuce"] { @@ -40,16 +42,37 @@ --sidebar-stroke-color: var(--background-dark-color); --secondary-color: var(--main-medium-color); --interlocked-hexagons-background: url('https://f003.backblazeb2.com/file/sayana-static/themes/lettuce/interlocked-hexagons.svg'); + --interlocked-hexagons-background-repeat: repeat; + --interlocked-hexagons-background-size: 10vw; --squares-and-triangles-background: url('https://f003.backblazeb2.com/file/sayana-static/themes/lettuce/squares-and-triangles.svg'); - --invert-colors-in-sidebar: true; + --squares-and-triangles-background-repeat: repeat; +} + +[data-theme="night"] { + --main-dark-color: var(--color-sky-100); + --main-medium-color: var(--color-sky-200); + --main-light-color: var(--color-sky-300); + --background-dark-color: #13131b; + --background-light-color: #222230; + --sidebar-text-color: var(--main-dark-color); + --sidebar-stroke-color: var(--background-light-color); + --secondary-color: var(--main-light-color); + --interlocked-hexagons-background: radial-gradient(33.5% 25% at 100% 82%, rgba(190, 227, 248, 0.2) 0%, rgba(197, 179, 246, 0.13) 33.33%, rgba(255, 0, 0, 0) 100%), radial-gradient(54% 25% at 55% 100%, rgba(190, 227, 248, 0.2) 0%, rgba(197, 179, 246, 0.13) 33.33%, rgba(255, 0, 0, 0) 100%), radial-gradient(37% 19.5% at 20% 100%, rgba(176, 220, 248, 0.3) 0%, rgba(197, 172, 247, 0.2) 33.33%, rgba(255, 0, 0, 0) 100%), radial-gradient(63% 34.5% at 66% 77%, rgba(190, 227, 248, 0.15) 0%, rgba(197, 179, 246, 0.1) 33.33%, rgba(255, 0, 0, 0) 100%), linear-gradient(0deg, #2f5883 0%, #2f4e7a 4.75%, #2e4472 9.5%, #2a3065 19%, #272e57 26.5%, #242b4b 34%, #1f2437 49%, #1c2030 57.75%, #1a1b29 66.5%, #13131b 84%); + --interlocked-hexagons-background-repeat: no-repeat; + --interlocked-hexagons-background-size: 100vw 100vh; + --squares-and-triangles-background: url("data:image/svg+xml,"); + --squares-and-triangles-background-repeat: repeat; } .bg-interlocked-hexagons { background-image: var(--interlocked-hexagons-background); + background-repeat: var(--interlocked-hexagons-background-repeat); + background-size: var(--interlocked-hexagons-background-size); } .bg-squares-and-triangles { background-image: var(--squares-and-triangles-background); + background-repeat: var(--squares-and-triangles-background-repeat); } .text-sidebar { @@ -64,6 +87,10 @@ color: var(--main-dark-color); } +.text-main-medium { + color: var(--main-medium-color); +} + .text-background-dark { color: var(--background-dark-color); } @@ -88,6 +115,10 @@ border-color: var(--main-dark-color); } +.border-main-medium { + border-color: var(--main-medium-color); +} + .desktop-sidebar-custom { width: 5vw; background-size: 10vw; @@ -102,7 +133,7 @@ .logo-custom { width: 3.5vw; - height: 25vw; + height: 20vw; font-size: 2.5vw; -webkit-text-stroke: 0.1vw var(--sidebar-stroke-color); writing-mode: sideways-lr; @@ -137,10 +168,6 @@ border-left: 0.5vh dotted var(--main-dark-color); } -.bg-pattern-body { - background-size: 10vw; -} - .inset-shadow { box-shadow: inset 0vh 1vh 1vh -1vh rgba(75, 81, 58, 0.5), inset 1vh 0vh 1vh -1vh rgba(75, 81, 58, 0.5), @@ -180,6 +207,10 @@ font-size: 1vmax !important; } +.text-vmax1-2 { + font-size: 1.2vmax; +} + .text-vmax1-5 { font-size: 1.5vmax !important; } @@ -188,6 +219,10 @@ font-size: 2vmax; } +.text-vmax2-5 { + font-size: 2.5vmax; +} + .w-vw90 { width: 90vw; } @@ -217,14 +252,30 @@ margin-bottom: 0.4vmin; } +.mb-vmin0-6 { + margin-bottom: 0.8vmin; +} + .mb-vmin0-8 { margin-bottom: 0.8vmin; } +.mb-vmin1-2 { + margin-bottom: 1.2vmin; +} + +.mb-vmin1-6 { + margin-bottom: 1.6vmin; +} + .pl-vmin0-8 { padding-left: 0.8vmin; } +.pl-vmax2 { + padding-left: 2vmax; +} + .pr-vmin1-2 { padding-right: 1.2vmin; } @@ -233,6 +284,10 @@ padding: 2.4vmin; } +.space-y-vmin0-8 { + column-gap: 0.8vmin; +} + .lg-backdrop { background-color: var(--background-light-color); } @@ -384,4 +439,28 @@ width: 100%; margin-left: 0; } -} \ No newline at end of file +} + +.star { + color: var(--color-yellow-100); + animation-name: blink; + animation-duration: 5s; + animation-iteration-count: infinite; + user-select: none; + -webkit-user-select: none; +} + +@keyframes blink { + 0% { + opacity: 1; + } + 20% { + opacity: 0.2; + } + 80% { + opacity: 0.2; + } + 100% { + opacity: 1; + } +} diff --git a/static/output.css b/static/output.css index 3b4e05f..2ba01ad 100644 --- a/static/output.css +++ b/static/output.css @@ -7,10 +7,19 @@ 'Noto Color Emoji'; --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace; + --color-yellow-100: oklch(97.3% 0.071 103.193); + --color-sky-100: oklch(95.1% 0.026 236.824); + --color-sky-200: oklch(90.1% 0.058 230.902); + --color-sky-300: oklch(82.8% 0.111 230.318); --spacing: 0.25rem; + --text-4xl: 2.25rem; + --text-4xl--line-height: calc(2.5 / 2.25); + --font-weight-medium: 500; + --font-weight-bold: 700; --font-weight-extrabold: 800; --radius-md: 0.375rem; --radius-lg: 0.5rem; + --radius-4xl: 2rem; --default-transition-duration: 150ms; --default-transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); --default-font-family: var(--font-sans); @@ -165,12 +174,21 @@ } } @layer utilities { + .absolute { + position: absolute; + } .fixed { position: fixed; } .relative { position: relative; } + .z-0 { + z-index: 0; + } + .z-1 { + z-index: 1; + } .z-10 { z-index: 10; } @@ -198,6 +216,15 @@ .m-2 { margin: calc(var(--spacing) * 2); } + .mx-auto { + margin-inline: auto; + } + .my-auto { + margin-block: auto; + } + .mt-2 { + margin-top: calc(var(--spacing) * 2); + } .mt-auto { margin-top: auto; } @@ -207,30 +234,81 @@ .mr-auto { margin-right: auto; } + .mb-4 { + margin-bottom: calc(var(--spacing) * 4); + } .mb-auto { margin-bottom: auto; } .ml-auto { margin-left: auto; } + .block { + display: block; + } .flex { display: flex; } + .h-4\/12 { + height: calc(4/12 * 100%); + } + .h-16 { + height: calc(var(--spacing) * 16); + } + .h-auto { + height: auto; + } .h-screen { height: 100vh; } + .min-h-16 { + min-height: calc(var(--spacing) * 16); + } + .w-6\/12 { + width: calc(6/12 * 100%); + } + .w-10\/12 { + width: calc(10/12 * 100%); + } + .w-16 { + width: calc(var(--spacing) * 16); + } + .max-w-full { + max-width: 100%; + } .flex-1 { flex: 1; } + .flex-3 { + flex: 3; + } + .flex-5 { + flex: 5; + } + .flex-grow { + flex-grow: 1; + } .grow { flex-grow: 1; } + .transform { + transform: var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,); + } .cursor-pointer { cursor: pointer; } .resize { resize: both; } + .list-inside { + list-style-position: inside; + } + .list-decimal { + list-style-type: decimal; + } + .list-disc { + list-style-type: disc; + } .flex-col { flex-direction: column; } @@ -243,15 +321,30 @@ .justify-center { justify-content: center; } + .justify-items-center { + justify-items: center; + } .gap-0 { gap: calc(var(--spacing) * 0); } + .gap-4 { + gap: calc(var(--spacing) * 4); + } + .justify-self-center { + justify-self: center; + } .overflow-hidden { overflow: hidden; } + .overflow-x-auto { + overflow-x: auto; + } .overflow-y-auto { overflow-y: auto; } + .rounded-4xl { + border-radius: var(--radius-4xl); + } .rounded-lg { border-radius: var(--radius-lg); } @@ -262,6 +355,14 @@ border-top-style: var(--tw-border-style); border-top-width: 4px; } + .border-r-1 { + border-right-style: var(--tw-border-style); + border-right-width: 1px; + } + .border-dashed { + --tw-border-style: dashed; + border-style: dashed; + } .border-dotted { --tw-border-style: dotted; border-style: dotted; @@ -269,6 +370,12 @@ .bg-repeat { background-repeat: repeat; } + .object-cover { + object-fit: cover; + } + .p-4 { + padding: calc(var(--spacing) * 4); + } .pr-2 { padding-right: calc(var(--spacing) * 2); } @@ -287,17 +394,42 @@ .font-spectral { font-family: var(--font-spectral); } + .text-4xl { + font-size: var(--text-4xl); + line-height: var(--tw-leading, var(--text-4xl--line-height)); + } + .font-bold { + --tw-font-weight: var(--font-weight-bold); + font-weight: var(--font-weight-bold); + } .font-extrabold { --tw-font-weight: var(--font-weight-extrabold); font-weight: var(--font-weight-extrabold); } + .font-medium { + --tw-font-weight: var(--font-weight-medium); + font-weight: var(--font-weight-medium); + } .italic { font-style: italic; } + .underline { + text-decoration-line: underline; + } + .opacity-70 { + opacity: 70%; + } + .opacity-100 { + opacity: 100%; + } .shadow-2xl { --tw-shadow: 0 25px 50px -12px var(--tw-shadow-color, rgb(0 0 0 / 0.25)); box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow); } + .shadow-lg { + --tw-shadow: 0 10px 15px -3px var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 4px 6px -4px var(--tw-shadow-color, rgb(0 0 0 / 0.1)); + box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow); + } .transition-colors { transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to; transition-timing-function: var(--tw-ease, var(--default-transition-timing-function)); @@ -322,8 +454,10 @@ --sidebar-stroke-color: var(--main-dark-color); --secondary-color: var(--main-light-color); --interlocked-hexagons-background: url('https://f003.backblazeb2.com/file/sayana-static/themes/olive/interlocked-hexagons.svg'); + --interlocked-hexagons-background-repeat: repeat; + --interlocked-hexagons-background-size: 10vw; --squares-and-triangles-background: url('https://f003.backblazeb2.com/file/sayana-static/themes/olive/squares-and-triangles.svg'); - --invert-colors-in-sidebar: false; + --squares-and-triangles-background-repeat: repeat; } [data-theme="lettuce"] { --main-dark-color: #384a0c; @@ -335,14 +469,34 @@ --sidebar-stroke-color: var(--background-dark-color); --secondary-color: var(--main-medium-color); --interlocked-hexagons-background: url('https://f003.backblazeb2.com/file/sayana-static/themes/lettuce/interlocked-hexagons.svg'); + --interlocked-hexagons-background-repeat: repeat; + --interlocked-hexagons-background-size: 10vw; --squares-and-triangles-background: url('https://f003.backblazeb2.com/file/sayana-static/themes/lettuce/squares-and-triangles.svg'); - --invert-colors-in-sidebar: true; + --squares-and-triangles-background-repeat: repeat; +} +[data-theme="night"] { + --main-dark-color: var(--color-sky-100); + --main-medium-color: var(--color-sky-200); + --main-light-color: var(--color-sky-300); + --background-dark-color: #13131b; + --background-light-color: #222230; + --sidebar-text-color: var(--main-dark-color); + --sidebar-stroke-color: var(--background-light-color); + --secondary-color: var(--main-light-color); + --interlocked-hexagons-background: radial-gradient(33.5% 25% at 100% 82%, rgba(190, 227, 248, 0.2) 0%, rgba(197, 179, 246, 0.13) 33.33%, rgba(255, 0, 0, 0) 100%), radial-gradient(54% 25% at 55% 100%, rgba(190, 227, 248, 0.2) 0%, rgba(197, 179, 246, 0.13) 33.33%, rgba(255, 0, 0, 0) 100%), radial-gradient(37% 19.5% at 20% 100%, rgba(176, 220, 248, 0.3) 0%, rgba(197, 172, 247, 0.2) 33.33%, rgba(255, 0, 0, 0) 100%), radial-gradient(63% 34.5% at 66% 77%, rgba(190, 227, 248, 0.15) 0%, rgba(197, 179, 246, 0.1) 33.33%, rgba(255, 0, 0, 0) 100%), linear-gradient(0deg, #2f5883 0%, #2f4e7a 4.75%, #2e4472 9.5%, #2a3065 19%, #272e57 26.5%, #242b4b 34%, #1f2437 49%, #1c2030 57.75%, #1a1b29 66.5%, #13131b 84%); + --interlocked-hexagons-background-repeat: no-repeat; + --interlocked-hexagons-background-size: 100vw 100vh; + --squares-and-triangles-background: url("data:image/svg+xml,"); + --squares-and-triangles-background-repeat: repeat; } .bg-interlocked-hexagons { background-image: var(--interlocked-hexagons-background); + background-repeat: var(--interlocked-hexagons-background-repeat); + background-size: var(--interlocked-hexagons-background-size); } .bg-squares-and-triangles { background-image: var(--squares-and-triangles-background); + background-repeat: var(--squares-and-triangles-background-repeat); } .text-sidebar { color: var(--sidebar-text-color); @@ -353,6 +507,9 @@ .text-main-dark { color: var(--main-dark-color); } +.text-main-medium { + color: var(--main-medium-color); +} .text-background-dark { color: var(--background-dark-color); } @@ -371,6 +528,9 @@ .border-main-dark { border-color: var(--main-dark-color); } +.border-main-medium { + border-color: var(--main-medium-color); +} .desktop-sidebar-custom { width: 5vw; background-size: 10vw; @@ -383,7 +543,7 @@ } .logo-custom { width: 3.5vw; - height: 25vw; + height: 20vw; font-size: 2.5vw; -webkit-text-stroke: 0.1vw var(--sidebar-stroke-color); writing-mode: sideways-lr; @@ -412,9 +572,6 @@ width: 0.5vw; border-left: 0.5vh dotted var(--main-dark-color); } -.bg-pattern-body { - background-size: 10vw; -} .inset-shadow { box-shadow: inset 0vh 1vh 1vh -1vh rgba(75, 81, 58, 0.5), inset 1vh 0vh 1vh -1vh rgba(75, 81, 58, 0.5), inset -1vh 0vh 1vh -1vh rgba(75, 81, 58, 0.5), inset 0vh -0.5vh rgba(75, 81, 58, 0.5); } @@ -442,12 +599,18 @@ .text-vmax1 { font-size: 1vmax !important; } +.text-vmax1-2 { + font-size: 1.2vmax; +} .text-vmax1-5 { font-size: 1.5vmax !important; } .text-vmax2 { font-size: 2vmax; } +.text-vmax2-5 { + font-size: 2.5vmax; +} .w-vw90 { width: 90vw; } @@ -470,18 +633,33 @@ .mb-vmin0-4 { margin-bottom: 0.4vmin; } +.mb-vmin0-6 { + margin-bottom: 0.8vmin; +} .mb-vmin0-8 { margin-bottom: 0.8vmin; } +.mb-vmin1-2 { + margin-bottom: 1.2vmin; +} +.mb-vmin1-6 { + margin-bottom: 1.6vmin; +} .pl-vmin0-8 { padding-left: 0.8vmin; } +.pl-vmax2 { + padding-left: 2vmax; +} .pr-vmin1-2 { padding-right: 1.2vmin; } .p-vmin2-4 { padding: 2.4vmin; } +.space-y-vmin0-8 { + column-gap: 0.8vmin; +} .lg-backdrop { background-color: var(--background-light-color); } @@ -604,6 +782,48 @@ margin-left: 0; } } +.star { + color: var(--color-yellow-100); + animation-name: blink; + animation-duration: 5s; + animation-iteration-count: infinite; + user-select: none; + -webkit-user-select: none; +} +@keyframes blink { + 0% { + opacity: 1; + } + 20% { + opacity: 0.2; + } + 80% { + opacity: 0.2; + } + 100% { + opacity: 1; + } +} +@property --tw-rotate-x { + syntax: "*"; + inherits: false; +} +@property --tw-rotate-y { + syntax: "*"; + inherits: false; +} +@property --tw-rotate-z { + syntax: "*"; + inherits: false; +} +@property --tw-skew-x { + syntax: "*"; + inherits: false; +} +@property --tw-skew-y { + syntax: "*"; + inherits: false; +} @property --tw-border-style { syntax: "*"; inherits: false; @@ -685,6 +905,11 @@ @layer properties { @supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) { *, ::before, ::after, ::backdrop { + --tw-rotate-x: initial; + --tw-rotate-y: initial; + --tw-rotate-z: initial; + --tw-skew-x: initial; + --tw-skew-y: initial; --tw-border-style: solid; --tw-font-weight: initial; --tw-shadow: 0 0 #0000; diff --git a/views/index.html b/views/index.html index 4e52710..cff3826 100644 --- a/views/index.html +++ b/views/index.html @@ -3,281 +3,112 @@ - SAYA TODAY // {{ .Title }} + SAYA TODAY // Заглавная - - - - + - + + +
*
+
*
+
*
+
*
+
*
+
*
+
*
+
*
+
*
+
*
+
*
+
*
+
*
+
*
+
*
+
*
+
*
+
*
+
*
+
*
+
*
+
*
+
*
+
*
+
*
-
-
- demo.saya.today -
-
- - - - -
-
- -
-
- -
-
- -

//

-

Демо-материал после демон-аэропорта

-

2025.07.21 20:34:44 UTC+3

-
-
- -
-

Ученик однажды попросил мудреца переименовать фотографические файлы формата JPG за 21 июля 2025 на своём телефоне, чтобы структура их имён была идентична. Ученик очень хотел поделиться своими двоякими впечатлениями от современных реалий российского авиатранспорта и хотел сначала загрузить свои фотографии в нужном формате. В ответ мудрец удалил их нахуй

-

Мудрец будет удалён к ебеням с телефона и оценён на 1 звезду.

-

В итоге, чтобы собрать материал под эту демо-страницу, я вспомнил про недавно купленную клавиатуру.

-

Это Apple Keyboard 1048 из 2003!

-
-
- -
-
-

Мотив был такой -- мне нравится её внешний вид, эта курватура аля склона холма. Ну и USB, ничего не мешает подключить куда угодно. И цена таким на рынке -- 2 тыщи на рынке (~25$).

-

Купил -- понравилась и тактильность, хоть это и мембранная клава!

-

Но затем я решил её почистить, ибо она была желтоватая и у неё слипались пробел и клавиша Mac. На выходе действительно она получилась белей, клавиши все нажимаются на ура... но идея опрыскать базу клавы перекисью была ошибкой. Теперь у неё работает только Enter. :(

-

Напоследок немного макросъёмки, ибо почему бы и нет:

-
-
- -
-
-
- - - -
-
- -
-
- -
-
- - - - -
-
- demo.saya.today -
-
- -
-
- -
-
- -

//

-

Демо-материал после демон-аэропорта

-

2025.07.21 20:34:44 UTC+3

-
-
- -
-

Ученик однажды попросил мудреца переименовать фотографические файлы формата JPG за 21 июля 2025 на своём телефоне, чтобы структура их имён была идентична. Ученик очень хотел поделиться своими двоякими впечатлениями от современных реалий российского авиатранспорта и хотел сначала загрузить свои фотографии в нужном формате. В ответ мудрец удалил их нахуй

-

Мудрец будет удалён к ебеням с телефона и оценён на 1 звезду.

-

В итоге, чтобы собрать материал под эту демо-страницу, я вспомнил про недавно купленную клавиатуру.

-

Это Apple Keyboard 1048 из 2003!

-
-
- -
+
+

saya.today

+
+ {{- range .BlogPages }} +
+ +
+ {{ .Title }} + {{ .ActionDate }} +

{{ .ShortDescription }}

-

Мотив был такой -- мне нравится её внешний вид, эта курватура аля склона холма. Ну и USB, ничего не мешает подключить куда угодно. И цена таким на рынке -- 2 тыщи на рынке (~25$).

-

Купил -- понравилась и тактильность, хоть это и мембранная клава!

-

Но затем я решил её почистить, ибо она была желтоватая и у неё слипались пробел и клавиша Mac. На выходе действительно она получилась белей, клавиши все нажимаются на ура... но идея опрыскать базу клавы перекисью была ошибкой. Теперь у неё работает только Enter. :(

-

Напоследок немного макросъёмки, ибо почему бы и нет:

-
-
- -
+
+

+ Тэги: {{ .Tags }} +

+

+ {{ .PublishedTime }} +

- -
-

- {{ .Title }} © 2025 by Saya Andy is licensed under CC BY-SA 4.0 -

- - - -
- -
+ {{- end }}
- -
- - - - - - - - - diff --git a/views/layouts/blog-page.html b/views/layouts/blog-page.html new file mode 100644 index 0000000..6ee7d85 --- /dev/null +++ b/views/layouts/blog-page.html @@ -0,0 +1,128 @@ + + + + + + SAYA TODAY // {{ .Title }} + + + + + + + + + + + + + + +
+
+ saya.today +
+
+ + + + +
+
+ +
+
+ +
+
+ +

//

+

{{ .Title }}

+

{{ .PublishedDate }}

+
+
+ +
+ {{ .ParsedMarkdownDesktop }} +
+ +
+

+ {{ .Title }} © {{ .PublishedYear }} by Saya Andy is licensed under CC BY-SA 4.0 +

+ + + +
+ +
+
+ +
+
+ +
+
+ + + + +
+
+ demo.saya.today +
+
+ +
+
+ +
+
+ +

//

+

{{ .Title }}

+

{{ .PublishedDate }}

+
+
+ +
+ {{ .ParsedMarkdownMobile }} +
+ +
+

+ {{ .Title }} © {{ .PublishedYear }} by Saya Andy is licensed under CC BY-SA 4.0 +

+ + + +
+ +
+
+ +
+
+ + + + + + + -- cgit v1.3.1+13