mirror of
https://github.com/pldubouilh/gossa.git
synced 2026-08-28 12:56:35 -04:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e2aa4f149e | ||
|
|
8a7a542b22 | ||
|
|
e490853baa | ||
|
|
557b3fd50d |
+2
-1
@@ -5,6 +5,7 @@ gossa-linux-arm64
|
||||
gossa-mac
|
||||
gossa-windows.exe
|
||||
gossa_test.go
|
||||
build-all
|
||||
|
||||
.vscode
|
||||
test-fixture/*
|
||||
@@ -39,4 +40,4 @@ test-fixture/*/*
|
||||
!test-fixture/fancy-path
|
||||
!test-fixture/fancy-path/*
|
||||
!test-fixture/ext/*
|
||||
!test-fixture/ext
|
||||
!test-fixture/ext
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
FLAGS := -ldflags "-s -w"
|
||||
NOCGO := CGO_ENABLED=0
|
||||
|
||||
build:
|
||||
cp src/gossa.go gossa.go
|
||||
make -C gossa-ui/
|
||||
go vet && go fmt
|
||||
CGO_ENABLED=0 go build
|
||||
${NOCGO} go build ${FLAGS} -o gossa
|
||||
rm gossa.go
|
||||
|
||||
install:
|
||||
@@ -19,18 +22,22 @@ run-extra:
|
||||
|
||||
test:
|
||||
make build
|
||||
-rm gossa_test.go
|
||||
-@cd test-fixture && ln -s ../support .
|
||||
rm -rf gossa_test.go
|
||||
-@cd test-fixture && ln -s ../support .; true
|
||||
cp src/gossa_test.go .
|
||||
-@killall gossa
|
||||
make run &
|
||||
|
||||
-@killall gossa; true
|
||||
-make run &
|
||||
go test -run TestNormal
|
||||
|
||||
killall gossa
|
||||
make run-extra &
|
||||
-make run-extra &
|
||||
go test -run TestExtra
|
||||
|
||||
killall gossa
|
||||
make run-ro &
|
||||
-make run-ro &
|
||||
go test -run TestRo
|
||||
|
||||
killall gossa
|
||||
|
||||
watch:
|
||||
@@ -48,11 +55,11 @@ watch-test:
|
||||
build-all:
|
||||
cp src/gossa.go gossa.go
|
||||
make -C gossa-ui/
|
||||
env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o gossa-linux64
|
||||
env CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -o gossa-linux-arm
|
||||
env CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o gossa-linux-arm64
|
||||
env CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o gossa-mac
|
||||
env CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o gossa-windows.exe
|
||||
${NOCGO} GOOS=linux GOARCH=amd64 go build ${FLAGS} -o build-all/gossa-linux64
|
||||
${NOCGO} GOOS=linux GOARCH=arm go build ${FLAGS} -o build-all/gossa-linux-arm
|
||||
${NOCGO} GOOS=linux GOARCH=arm64 go build ${FLAGS} -o build-all/gossa-linux-arm64
|
||||
${NOCGO} GOOS=darwin GOARCH=amd64 go build ${FLAGS} -o build-all/gossa-mac
|
||||
${NOCGO} GOOS=windows GOARCH=amd64 go build ${FLAGS} -o build-all/gossa-windows.exe
|
||||
rm gossa.go
|
||||
|
||||
clean:
|
||||
@@ -64,3 +71,4 @@ clean:
|
||||
-rm gossa-linux-arm64
|
||||
-rm gossa-mac
|
||||
-rm gossa-windows.exe
|
||||
|
||||
|
||||
+1
-1
Submodule gossa-ui updated: 26b93fd4bd...a057f08e1d
@@ -22,6 +22,7 @@ a [simple UI](https://github.com/pldubouilh/gossa-ui) comes as default, featurin
|
||||
* ⌨️ keyboard navigation
|
||||
* 🥂 fast golang static server
|
||||
* 🔒 easy/secure multi account setup, read-only mode
|
||||
* ✨ PWA enabled
|
||||
|
||||
### build
|
||||
built blobs are available on the [release page](https://github.com/pldubouilh/gossa/releases) - or simply `make build` this repo.
|
||||
|
||||
+12
-3
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"archive/zip"
|
||||
"compress/gzip"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"flag"
|
||||
@@ -80,7 +81,7 @@ func humanize(bytes int64) string {
|
||||
}
|
||||
}
|
||||
|
||||
func replyList(w http.ResponseWriter, fullPath string, path string) {
|
||||
func replyList(w http.ResponseWriter, r *http.Request, fullPath string, path string) {
|
||||
_files, err := ioutil.ReadDir(fullPath)
|
||||
check(err)
|
||||
sort.Slice(_files, func(i, j int) bool { return strings.ToLower(_files[i].Name()) < strings.ToLower(_files[j].Name()) })
|
||||
@@ -116,7 +117,15 @@ func replyList(w http.ResponseWriter, fullPath string, path string) {
|
||||
}
|
||||
}
|
||||
|
||||
page.Execute(w, p)
|
||||
if strings.Contains(r.Header.Get("Accept-Encoding"), "gzip") {
|
||||
w.Header().Set("Content-Type", "text/html")
|
||||
w.Header().Add("Content-Encoding", "gzip")
|
||||
gz, _ := gzip.NewWriterLevel(w, gzip.BestSpeed) // BestSpeed is much faster than Default on a very unscientific local test, and only ~30% larger (compression remains still very effective, ~6x)
|
||||
defer gz.Close()
|
||||
page.Execute(gz, p)
|
||||
} else {
|
||||
page.Execute(w, p)
|
||||
}
|
||||
}
|
||||
|
||||
func doContent(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -132,7 +141,7 @@ func doContent(w http.ResponseWriter, r *http.Request) {
|
||||
check(errStat)
|
||||
|
||||
if stat.IsDir() {
|
||||
replyList(w, fullPath, path)
|
||||
replyList(w, r, fullPath, path)
|
||||
} else {
|
||||
fs.ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user