More changes to uploads:

- Have got upload images appearing in the post list
- Allowed for deleting uploads
- Allowed for seeing the upload progress
- Fixed the setting of upload properties like the MIME type
- Removed the stripe exif logic with just re-encoding PNGs and JPEGs by loading them and saving them
This commit is contained in:
Leon Mika 2026-03-04 22:33:39 +11:00
parent d0cebe6564
commit 199ff9feb9
21 changed files with 471 additions and 65 deletions

View file

@ -2,6 +2,7 @@ package sitebuilder
import (
"bytes"
"context"
"fmt"
"html/template"
"io"
@ -10,18 +11,15 @@ import (
"sort"
"strings"
"github.com/yuin/goldmark"
"github.com/yuin/goldmark/extension"
"github.com/yuin/goldmark/parser"
"github.com/yuin/goldmark/renderer/html"
"golang.org/x/sync/errgroup"
"lmika.dev/lmika/weiro/models"
"lmika.dev/lmika/weiro/models/pubmodel"
"lmika.dev/lmika/weiro/providers/markdown"
)
type Builder struct {
site pubmodel.Site
gmMarkdown goldmark.Markdown
mdRenderer *markdown.Renderer
opts Options
tmpls *template.Template
}
@ -35,18 +33,10 @@ func New(site pubmodel.Site, opts Options) (*Builder, error) {
}
return &Builder{
site: site,
opts: opts,
tmpls: tmpls,
gmMarkdown: goldmark.New(
goldmark.WithExtensions(extension.GFM),
goldmark.WithParserOptions(
parser.WithAutoHeadingID(),
),
goldmark.WithRendererOptions(
html.WithUnsafe(),
),
),
site: site,
opts: opts,
tmpls: tmpls,
mdRenderer: markdown.NewRendererForSite(),
}, nil
}
@ -121,7 +111,7 @@ func (b *Builder) renderPost(post *models.Post) (postSingleData, error) {
}
var md bytes.Buffer
if err := b.gmMarkdown.Convert([]byte(post.Body), &md); err != nil {
if err := b.mdRenderer.RenderTo(context.Background(), &md, post.Body); err != nil {
return postSingleData{}, fmt.Errorf("failed to write post %s: %w", post.Slug, err)
}