feat: hugo download with indicator

This commit is contained in:
decentral1se 2024-04-11 13:41:04 +02:00
parent 10ad82eee7
commit b8f6b195f4
No known key found for this signature in database
GPG Key ID: 03789458B3D0C410
2 changed files with 6 additions and 3 deletions

5
app.go
View File

@ -3,6 +3,7 @@ package main
import (
"bytes"
"context"
"errors"
"fmt"
"io"
"io/ioutil"
@ -61,7 +62,9 @@ func ensureHugoBin(homeDir string) error {
hugoTarPath := filepath.Join(hugoDir, fmt.Sprintf("hugo-%s.tar.gz", hugoVersion))
url := fmt.Sprintf("https://github.com/gohugoio/hugo/releases/download/v%s/hugo_extended_%s_linux-amd64.tar.gz", hugoVersion, hugoVersion)
if _, err := os.Stat(hugoBinPath); err != nil && os.IsNotExist(err) {
if _, err := os.Stat(hugoBinPath); err == nil {
return nil
} else if errors.Is(err, os.ErrNotExist) {
if err := httpGetFile(hugoTarPath, url); err != nil {
return err
}

View File

@ -8,7 +8,7 @@
<script src="https://unpkg.com/htmx.org@1.9.6"></script>
</head>
<body>
<!-- TODO(d1): hx-indicator for loading... -->
<div id="app" hx-get="/init" hx-trigger="load once"></div>
<div id="app" hx-get="/init" hx-trigger="load once" hx-indicator="#initial-loader"></div>
<p id="initial-loader" class="htmx-indicator">Initialising Hugo...</p>
</body>
</html>