Browse Source

feat: hugo download with indicator

main
decentral1se 7 months ago
parent
commit
b8f6b195f4
No known key found for this signature in database GPG Key ID: 3789458B3D0C410
  1. 5
      app.go
  2. 4
      frontend/index.html

5
app.go

@ -3,6 +3,7 @@ package main
import ( import (
"bytes" "bytes"
"context" "context"
"errors"
"fmt" "fmt"
"io" "io"
"io/ioutil" "io/ioutil"
@ -61,7 +62,9 @@ func ensureHugoBin(homeDir string) error {
hugoTarPath := filepath.Join(hugoDir, fmt.Sprintf("hugo-%s.tar.gz", hugoVersion)) 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) 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 { if err := httpGetFile(hugoTarPath, url); err != nil {
return err return err
} }

4
frontend/index.html

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