feat: Windows WebUI uses correct path separator

This commit is contained in:
garethgeorge
2024-02-14 23:26:45 -08:00
parent 276b1d2c60
commit f5521e7b56
9 changed files with 39 additions and 6 deletions

View File

@@ -11,8 +11,9 @@ version: 1
before:
hooks:
- go mod tidy
- go generate ./...
- sh -c "ls && cd ./webui && npm i && npm run build && gzip ./dist/*"
- npm --prefix webui install
- sh -c "GOOS=linux go generate ./..."
- sh -c "GOOS=windows go generate ./..."
builds:
- main: .

View File

@@ -5,7 +5,7 @@
Backrest is a web-accessible backup solution built on top of [restic](https://restic.net/). Backrest provides a WebUI which wraps the restic CLI and makes it easy to create repos, browse snapshots, and restore files. Additionally, Backrest can run in the background and take an opinionated approach to scheduling snapshots and orchestrating repo health operations.
By building on restic Backrest gets the advantages of restic mature feature set: restic provides fast, reliable (used by tens of thousands of individuals and by corporations in production environments), and secure backup operations. Backrest itself is built in Golang (matching restic's implementation) and is shipped as a self-contained and light weight (<20 MB on all platforms) binary with no dependecies other than restic (which backrest can download for you and keep up to date).
By building on restic, Backrest leverages restic's mature feature set. Restic provides fast, reliable (used by tens of thousands of individuals and by corporations in production environments), and secure backup operations. Backrest itself is built in Golang (matching restic's implementation) and is shipped as a self-contained and light weight (<20 MB on all platforms) binary with no dependecies other than restic (which backrest can download for you and keep up to date).
This project aims to be the easiest way to setup and get started with backups on any system. You can expect to be able to perform all operations from the web interface but should you ever need more poworeful control, you are free to browse your repo and perform operations using the [restic cli](https://restic.readthedocs.io/en/latest/manual_rest.html). Backrest safely detects and imports external operations (e.g. manual backups).

View File

@@ -13,7 +13,6 @@ import (
"sync"
"syscall"
rice "github.com/GeertJohan/go.rice"
"github.com/garethgeorge/backrest/gen/go/v1/v1connect"
"github.com/garethgeorge/backrest/internal/api"
"github.com/garethgeorge/backrest/internal/auth"
@@ -94,7 +93,7 @@ func main() {
mux := http.NewServeMux()
if box, err := rice.FindBox("webui/dist"); err == nil {
if box, err := WebUIBox(); err == nil {
mux.Handle("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if strings.HasSuffix(r.URL.Path, "/") {
r.URL.Path += "index.html"

3
go.work Normal file
View File

@@ -0,0 +1,3 @@
go 1.21.3
use .

5
go.work.sum Normal file
View File

@@ -0,0 +1,5 @@
cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA=
github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cncf/udpa/go v0.0.0-20220112060539-c52dc94e7fbe/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI=
github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=

1
webui/.gitignore vendored
View File

@@ -1,3 +1,4 @@
.parcel-cache
node_modules
dist
dist-windows

View File

@@ -5,7 +5,7 @@
"scripts": {
"start": "parcel serve src/index.html",
"build": "BACKREST_BUILD_VERSION=$(git describe --tags --abbrev=0) UI_OS=unix parcel build src/index.html",
"build-windows": "set UI_OS=windows & parcel build src/index.html",
"build-windows": "BACKREST_BUILD_VERSION=$(git describe --tags --abbrev=0) UI_OS=windows parcel build src/index.html --dist-dir dist-windows",
"test": "echo \"Error: no test specified\" && exit 1",
"check": "tsc --noEmit"
},

12
webuinix.go Normal file
View File

@@ -0,0 +1,12 @@
//go:build linux || darwin
// +build linux darwin
//go:generate sh -c "rm -rf ./webui/dist && UI_OS=unix npm --prefix webui run build && gzip ./webui/dist/*"
package main
import rice "github.com/GeertJohan/go.rice"
func WebUIBox() (*rice.Box, error) {
return rice.FindBox("webui/dist")
}

12
webuiwin.go Normal file
View File

@@ -0,0 +1,12 @@
//go:build windows
// +build windows
//go:generate sh -c "rm -rf ./webui/dist-windows && npm --prefix webui run build-windows && gzip ./webui/dist-windows/*"
package main
import rice "github.com/GeertJohan/go.rice"
func WebUIBox() (*rice.Box, error) {
return rice.FindBox("webui/dist-windows")
}