mirror of
https://github.com/pldubouilh/gossa.git
synced 2026-08-31 06:16:54 -04:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
df85a1c5a2 | ||
|
|
e2aa4f149e | ||
|
|
8a7a542b22 | ||
|
|
e490853baa | ||
|
|
557b3fd50d |
+2
-1
@@ -5,6 +5,7 @@ gossa-linux-arm64
|
|||||||
gossa-mac
|
gossa-mac
|
||||||
gossa-windows.exe
|
gossa-windows.exe
|
||||||
gossa_test.go
|
gossa_test.go
|
||||||
|
build-all
|
||||||
|
|
||||||
.vscode
|
.vscode
|
||||||
test-fixture/*
|
test-fixture/*
|
||||||
@@ -39,4 +40,4 @@ test-fixture/*/*
|
|||||||
!test-fixture/fancy-path
|
!test-fixture/fancy-path
|
||||||
!test-fixture/fancy-path/*
|
!test-fixture/fancy-path/*
|
||||||
!test-fixture/ext/*
|
!test-fixture/ext/*
|
||||||
!test-fixture/ext
|
!test-fixture/ext
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
|
FLAGS := -ldflags "-s -w"
|
||||||
|
NOCGO := CGO_ENABLED=0
|
||||||
|
|
||||||
build:
|
build:
|
||||||
cp src/gossa.go gossa.go
|
cp src/gossa.go gossa.go
|
||||||
make -C gossa-ui/
|
make -C gossa-ui/
|
||||||
go vet && go fmt
|
go vet && go fmt
|
||||||
CGO_ENABLED=0 go build
|
${NOCGO} go build ${FLAGS} -o gossa
|
||||||
rm gossa.go
|
rm gossa.go
|
||||||
|
|
||||||
install:
|
install:
|
||||||
@@ -19,18 +22,22 @@ run-extra:
|
|||||||
|
|
||||||
test:
|
test:
|
||||||
make build
|
make build
|
||||||
-rm gossa_test.go
|
rm -rf gossa_test.go
|
||||||
-@cd test-fixture && ln -s ../support .
|
-@cd test-fixture && ln -s ../support .; true
|
||||||
cp src/gossa_test.go .
|
cp src/gossa_test.go .
|
||||||
-@killall gossa
|
|
||||||
make run &
|
-@killall gossa; true
|
||||||
|
-make run &
|
||||||
go test -run TestNormal
|
go test -run TestNormal
|
||||||
|
|
||||||
killall gossa
|
killall gossa
|
||||||
make run-extra &
|
-make run-extra &
|
||||||
go test -run TestExtra
|
go test -run TestExtra
|
||||||
|
|
||||||
killall gossa
|
killall gossa
|
||||||
make run-ro &
|
-make run-ro &
|
||||||
go test -run TestRo
|
go test -run TestRo
|
||||||
|
|
||||||
killall gossa
|
killall gossa
|
||||||
|
|
||||||
watch:
|
watch:
|
||||||
@@ -48,11 +55,11 @@ watch-test:
|
|||||||
build-all:
|
build-all:
|
||||||
cp src/gossa.go gossa.go
|
cp src/gossa.go gossa.go
|
||||||
make -C gossa-ui/
|
make -C gossa-ui/
|
||||||
env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o gossa-linux64
|
${NOCGO} GOOS=linux GOARCH=amd64 go build ${FLAGS} -o build-all/gossa-linux64
|
||||||
env CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -o gossa-linux-arm
|
${NOCGO} GOOS=linux GOARCH=arm go build ${FLAGS} -o build-all/gossa-linux-arm
|
||||||
env CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o gossa-linux-arm64
|
${NOCGO} GOOS=linux GOARCH=arm64 go build ${FLAGS} -o build-all/gossa-linux-arm64
|
||||||
env CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o gossa-mac
|
${NOCGO} GOOS=darwin GOARCH=amd64 go build ${FLAGS} -o build-all/gossa-mac
|
||||||
env CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o gossa-windows.exe
|
${NOCGO} GOOS=windows GOARCH=amd64 go build ${FLAGS} -o build-all/gossa-windows.exe
|
||||||
rm gossa.go
|
rm gossa.go
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@@ -64,3 +71,4 @@ clean:
|
|||||||
-rm gossa-linux-arm64
|
-rm gossa-linux-arm64
|
||||||
-rm gossa-mac
|
-rm gossa-mac
|
||||||
-rm gossa-windows.exe
|
-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
|
* ⌨️ keyboard navigation
|
||||||
* 🥂 fast golang static server
|
* 🥂 fast golang static server
|
||||||
* 🔒 easy/secure multi account setup, read-only mode
|
* 🔒 easy/secure multi account setup, read-only mode
|
||||||
|
* ✨ PWA enabled
|
||||||
|
|
||||||
### build
|
### build
|
||||||
built blobs are available on the [release page](https://github.com/pldubouilh/gossa/releases) - or simply `make build` this repo.
|
built blobs are available on the [release page](https://github.com/pldubouilh/gossa/releases) - or simply `make build` this repo.
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
name: gossa
|
||||||
|
version: git
|
||||||
|
summary: a fast and simple webserver for your files.
|
||||||
|
description: |
|
||||||
|
a fast and simple webserver for your files, that's dependency-free and easy to review.
|
||||||
|
confinement: strict
|
||||||
|
base: core18
|
||||||
|
parts:
|
||||||
|
gossa:
|
||||||
|
plugin: go
|
||||||
|
go-importpath: github.com/pldubouilh/gossa
|
||||||
|
source: .
|
||||||
|
source-type: git
|
||||||
|
build-packages:
|
||||||
|
- gcc
|
||||||
|
apps:
|
||||||
|
gossa:
|
||||||
|
command: gossa
|
||||||
+12
-3
@@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"archive/zip"
|
"archive/zip"
|
||||||
|
"compress/gzip"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"flag"
|
"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)
|
_files, err := ioutil.ReadDir(fullPath)
|
||||||
check(err)
|
check(err)
|
||||||
sort.Slice(_files, func(i, j int) bool { return strings.ToLower(_files[i].Name()) < strings.ToLower(_files[j].Name()) })
|
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) {
|
func doContent(w http.ResponseWriter, r *http.Request) {
|
||||||
@@ -132,7 +141,7 @@ func doContent(w http.ResponseWriter, r *http.Request) {
|
|||||||
check(errStat)
|
check(errStat)
|
||||||
|
|
||||||
if stat.IsDir() {
|
if stat.IsDir() {
|
||||||
replyList(w, fullPath, path)
|
replyList(w, r, fullPath, path)
|
||||||
} else {
|
} else {
|
||||||
fs.ServeHTTP(w, r)
|
fs.ServeHTTP(w, r)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user