feat: hugo download with indicator
This commit is contained in:
parent
10ad82eee7
commit
b8f6b195f4
5
app.go
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
|
||||||
}
|
}
|
||||||
|
@ -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>
|
||||||
|
Reference in New Issue
Block a user