Skip to content

refactor(console): Inline script templates, remove /scripts endpoint#54

Merged
mojatter merged 1 commit intomainfrom
refactor/inline-scripts
Apr 10, 2026
Merged

refactor(console): Inline script templates, remove /scripts endpoint#54
mojatter merged 1 commit intomainfrom
refactor/inline-scripts

Conversation

@mojatter
Copy link
Copy Markdown
Owner

@mojatter mojatter commented Apr 10, 2026

Summary

  • Replace hx-get="/scripts" runtime fetch with a static {{template "scripts:buckets/objects.html" .}} include in index.html.
  • Delete scripts.go along with handleScripts, scriptTemplates, and RegisterTemplateWithScripts.
  • Revert objects.go to use server.RegisterTemplate directly.

This works because loadTemplates parses objects.html (which contains the {{define "scripts:..."}} block) before index.html, so the named template is available at parse time.

What's removed

Removed Reason
GET /scripts endpoint Replaced by static template include
scripts.go No longer needed
RegisterTemplateWithScripts server.RegisterTemplate suffices
hx-get="/scripts" div Replaced by {{template}}
Extra HTTP round-trip on page load Eliminated
Race condition (scripts not loaded before user clicks) Eliminated

Test plan

  • go test ./... passes
  • golangci-lint run ./... clean
  • Manual: preview modal works
  • Manual: gallery/list view toggle works
  • Manual: no /scripts request in browser Network tab

Replace the hx-get="/scripts" runtime fetch with a static
{{template "scripts:buckets/objects.html" .}} include in index.html.
Since loadTemplates parses objects.html before index.html, the
{{define "scripts:..."}} block is already available at parse time.

This eliminates the /scripts endpoint, scripts.go, scriptTemplates
slice, and RegisterTemplateWithScripts — removing an HTTP round-trip
and the associated race condition on page load.
@mojatter mojatter merged commit 809d3b6 into main Apr 10, 2026
2 checks passed
@mojatter mojatter deleted the refactor/inline-scripts branch April 10, 2026 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant