Skip to content

Commit

Permalink
chore: fix static assets for otto8
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuildthecloud committed Jan 22, 2025
1 parent b7f2168 commit 439d793
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 24 deletions.
17 changes: 16 additions & 1 deletion pkg/api/static/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,20 @@ func Wrap(next http.Handler, dir string) (http.Handler, error) {
mux := http.NewServeMux()
mux.Handle("/", next)

fs := http.FileServer(http.Dir(dir))
target := http.FileServer(http.Dir(dir))
fs := http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
if len(req.URL.Path) > 1 {
if strings.HasSuffix(req.URL.Path, "/") {
req.URL.Path = req.URL.Path[:len(req.URL.Path)-1] + ".html"
} else {
parts := strings.Split(req.URL.Path, "/")
if !strings.Contains(parts[len(parts)-1], ".") {
req.URL.Path += ".html"
}
}
}
target.ServeHTTP(rw, req)
})

entries, err := os.ReadDir(dir)
if err != nil {
Expand All @@ -32,6 +45,8 @@ func Wrap(next http.Handler, dir string) (http.Handler, error) {

if entry.Name() == "index.html" {
mux.Handle("GET /{$}", fs)
} else if trimmed, ok := strings.CutSuffix(entry.Name(), ".html"); ok {
mux.Handle("GET /"+trimmed, fs)
}
}

Expand Down
45 changes: 22 additions & 23 deletions ui/user/src/lib/components/Navbar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,30 @@
w-full
via-80%"
>
<div class="bg-white px-3 py-3 dark:bg-black lg:px-5 lg:pl-3">
<div class="p-3">
<div class="flex items-center justify-between">
<Logo />
<div class="flex items-center gap-1 pr-2">
{#if hasTool('tasks')}
<Tasks />
{/if}
{#if hasTool('database')}
<Tables />
{/if}
{#if hasTool('knowledge')}
<KnowledgeFile />
{/if}
{#if hasTool('workspace-files')}
<Files />
{/if}
{#if hasTool('shell')}
<Term />
{/if}
{#if hasOptionalTools()}
<Tools />
{/if}
<DarkModeToggle />
<Profile />
</div>
<div class="grow"></div>
{#if hasTool('tasks')}
<Tasks />
{/if}
{#if hasTool('database')}
<Tables />
{/if}
{#if hasTool('knowledge')}
<KnowledgeFile />
{/if}
{#if hasTool('workspace-files')}
<Files />
{/if}
{#if hasTool('shell')}
<Term />
{/if}
{#if hasOptionalTools()}
<Tools />
{/if}
<DarkModeToggle />
<Profile />
</div>
</div>
</nav>

0 comments on commit 439d793

Please sign in to comment.