diff --git a/.gitignore b/.gitignore index fc8c347..435be92 100755 --- a/.gitignore +++ b/.gitignore @@ -1,40 +1,36 @@ -debug -test -gossa.go gossa gossa-linux64 gossa-linux-arm gossa-linux-arm64 gossa-mac gossa-windows.exe -gossa_test.go .vscode -fixture/* -fixture/*/* -!fixture/compress -!fixture/compress/foo* -!fixture/gzip -!fixture/gzip/fake_ecstatic* -!fixture/gzip/real_ecstatic -!fixture/curimit@gmail.com (40%) -!fixture/curimit@gmail.com (40%)/test.html -!fixture/show-dir$$href_encoding$$ -!fixture/show-dir$$href_encoding$$/aname+aplus.txt -!fixture/subdir -!fixture/subdir/e.html -!fixture/subdir_with space -!fixture/subdir_with space/file_with space.html -!fixture/中文 -!fixture/中文/檔案.html -!fixture/404* -!fixture/b.txt -!fixture/custom_mime_type* -!fixture/f_f -!fixture/hols -!fixture/hols/c.js -!fixture/hols/adler-2872995_1920.jpg -!fixture/hols/elephant-1822636_1920.jpg -!fixture/hols/glasgow.jpg -!fixture/hols/landscape-540116_1920.jpg -!fixture/hols/scotland-1761292_1920.jpg +test-fixture/* +test-fixture/*/* +!test-fixture/compress +!test-fixture/compress/foo* +!test-fixture/gzip +!test-fixture/gzip/fake_ecstatic* +!test-fixture/gzip/real_ecstatic +!test-fixture/curimit@gmail.com (40%) +!test-fixture/curimit@gmail.com (40%)/test.html +!test-fixture/show-dir$$href_encoding$$ +!test-fixture/show-dir$$href_encoding$$/aname+aplus.txt +!test-fixture/subdir +!test-fixture/subdir/e.html +!test-fixture/subdir_with space +!test-fixture/subdir_with space/file_with space.html +!test-fixture/中文 +!test-fixture/中文/檔案.html +!test-fixture/404* +!test-fixture/b.txt +!test-fixture/custom_mime_type* +!test-fixture/f_f +!test-fixture/hols +!test-fixture/hols/c.js +!test-fixture/hols/adler-2872995_1920.jpg +!test-fixture/hols/elephant-1822636_1920.jpg +!test-fixture/hols/glasgow.jpg +!test-fixture/hols/landscape-540116_1920.jpg +!test-fixture/hols/scotland-1761292_1920.jpg diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..b56b45e --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "gossa-ui"] + path = gossa-ui + url = https://github.com/pldubouilh/gossa-ui + branch = master diff --git a/Makefile b/Makefile index 2737343..a337574 100755 --- a/Makefile +++ b/Makefile @@ -1,33 +1,28 @@ build: - make embed + cp src/gossa.go gossa.go + make -C gossa-ui/ go vet && go fmt CGO_ENABLED=0 go build gossa.go rm gossa.go run: make build - ./gossa fixture - -watch: - ls src/** | entr -rc make run - -embed: - echo "embedding css and js into binary" - cp src/main.go gossa.go - perl -pe 's/template_will_be_here/`cat src\/template.go`/ge' -i gossa.go - perl -pe 's/css_will_be_here/`cat src\/style.css`/ge' -i gossa.go - perl -pe 's/js_will_be_here/`cat src\/script.js`/ge' -i gossa.go - perl -pe 's/favicon_will_be_here/`base64 -w0 src\/favicon.png`/ge' -i gossa.go + ./gossa test-fixture ci: timeout 10 make run & cp src/gossa_test.go . && sleep 5 && go test + rm gossa_test.go + +watch: + ls src/* gossa-ui/* | entr -rc make run ci-watch: - ls src/* | entr -rc make ci + ls src/* gossa-ui/* | entr -rc make ci build-all: - make embed + cp src/gossa.go gossa.go + make -C gossa-ui/ env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build gossa.go mv gossa gossa-linux64 env GOOS=linux GOARCH=arm go build gossa.go diff --git a/docker/readme.md b/docker/readme.md index 9681d7d..3ec07b1 100644 --- a/docker/readme.md +++ b/docker/readme.md @@ -2,17 +2,17 @@ the master branch is automatically built and pushed to [dockerhub](https://hub.d ```sh # pull from dockerhub and run -sudo docker run -v ~/LocalDirToShare:/shared -p 8001:8001 pldubouilh/gossa +% sudo docker run -v ~/LocalDirToShare:/shared -p 8001:8001 pldubouilh/gossa ``` if you prefer building the image yourself : ```sh # build gossa within a build container, needs to be ran within the sources, ../ from here -docker build -t gossa -f docker/build.Dockerfile . +% docker build -t gossa -f docker/build.Dockerfile . # and to run it simply -sudo docker run -v ~/LocalDirToShare:/shared -p 8001:8001 gossa +% sudo docker run -v ~/LocalDirToShare:/shared -p 8001:8001 gossa ``` @@ -20,10 +20,10 @@ a fancy docker image using [Caddy](https://caddyserver.com/) is also provided. a ```sh # run with caddy, checkout the config in the dockerfile -docker build -t gossa -f caddy.Dockerfile . +% docker build -t gossa -f caddy.Dockerfile . # run with caddy -sudo docker run -v ~/LocalDirToShare:/shared --net=host gossa +% sudo docker run -v ~/LocalDirToShare:/shared --net=host gossa ``` a docker-compose example image is also provided. running docker compose should be straightforward : `docker-compose up .` have a look in `docker-compose.yml` for further configuration. \ No newline at end of file diff --git a/fixture/hols/adler-2872995_1920.jpg b/fixture/hols/adler-2872995_1920.jpg deleted file mode 100644 index fa8a813..0000000 Binary files a/fixture/hols/adler-2872995_1920.jpg and /dev/null differ diff --git a/fixture/hols/elephant-1822636_1920.jpg b/fixture/hols/elephant-1822636_1920.jpg deleted file mode 100644 index 9e7ff1a..0000000 Binary files a/fixture/hols/elephant-1822636_1920.jpg and /dev/null differ diff --git a/fixture/hols/glasgow.jpg b/fixture/hols/glasgow.jpg deleted file mode 100644 index 251d00b..0000000 Binary files a/fixture/hols/glasgow.jpg and /dev/null differ diff --git a/fixture/hols/landscape-540116_1920.jpg b/fixture/hols/landscape-540116_1920.jpg deleted file mode 100644 index 81ac3ba..0000000 Binary files a/fixture/hols/landscape-540116_1920.jpg and /dev/null differ diff --git a/fixture/hols/scotland-1761292_1920.jpg b/fixture/hols/scotland-1761292_1920.jpg deleted file mode 100644 index 9b00393..0000000 Binary files a/fixture/hols/scotland-1761292_1920.jpg and /dev/null differ diff --git a/gossa-ui b/gossa-ui new file mode 160000 index 0000000..bbef5eb --- /dev/null +++ b/gossa-ui @@ -0,0 +1 @@ +Subproject commit bbef5ebf9ddd0c34e0863213e2dac622c9d60c60 diff --git a/readme.md b/readme.md index 7034a5d..3057bd0 100644 --- a/readme.md +++ b/readme.md @@ -8,9 +8,10 @@ gossa [](https://hub.docker.com/r/pldubouilh/gossa) [](https://github.com/pldubouilh/gossa/releases) -🎶 A fast and simple webserver for your files, that's dependency-free and with under 210 lines for the server code, easily code-reviewable. +a fast and simple webserver for your files, that's dependency-free and with only 210 lines of code, easy to review. + +a [simple UI](https://github.com/pldubouilh/gossa-ui) comes as default, featuring : -### features * 🔍 files/directories browser * 📩 drag-and-drop file/directory uploader * 🗺️ files handling - move/rename/delete @@ -20,16 +21,12 @@ gossa * ⌨️ keyboard shortcuts * 🥂 speed - showed rates above 100MB/s -### built blobs -built blobs are available on the [release page](https://github.com/pldubouilh/gossa/releases). +### build +built blobs are available on the [release page](https://github.com/pldubouilh/gossa/releases) - or simply `make build` this repo -### run +### usage ```sh -# build (or download release from github) -make - -# run -./gossa -h 192.168.100.33 ~/storage +% ./gossa -h 192.168.100.33 ~/storage ``` ### ui shortcuts @@ -60,5 +57,5 @@ a few docker/docker-compose files are provided in the [docker folder](https://gi ```sh # pull from dockerhub and run -sudo docker run -v ~/LocalDirToShare:/shared -p 8001:8001 pldubouilh/gossa +% sudo docker run -v ~/LocalDirToShare:/shared -p 8001:8001 pldubouilh/gossa ``` diff --git a/src/favicon.png b/src/favicon.png deleted file mode 100644 index 7e17946..0000000 Binary files a/src/favicon.png and /dev/null differ diff --git a/src/main.go b/src/gossa.go similarity index 98% rename from src/main.go rename to src/gossa.go index 308046a..568dfed 100755 --- a/src/main.go +++ b/src/gossa.go @@ -22,7 +22,7 @@ var host = flag.String("h", "127.0.0.1", "host to listen to") var port = flag.String("p", "8001", "port to listen to") var verb = flag.Bool("verb", true, "verbosity") var skipHidden = flag.Bool("k", true, "skip hidden files") -var initPath = "" +var initPath = "." var fs http.Handler var page, _ = template.New("pageTemplate").Parse(`template_will_be_here`) @@ -184,9 +184,7 @@ func checkPath(p string) (string, error) { func main() { flag.Parse() - if len(flag.Args()) == 0 { - initPath = "." - } else { + if len(flag.Args()) > 0 { initPath = flag.Args()[0] } diff --git a/src/gossa_test.go b/src/gossa_test.go index 39ca7f1..0182fbd 100644 --- a/src/gossa_test.go +++ b/src/gossa_test.go @@ -53,9 +53,7 @@ func postJSON(t *testing.T, url string, what string) string { return trimSpaces(string(body)) } -var mainPage = `
| compress/ | ||
| curimit@gmail.com (40%)/ | ||
| gzip/ | ||
| hols/ | ||
| show-dir$$href_encoding$$/ | ||
| subdir/ | ||
| subdir_with space/ | ||
| 中文/ | ||
13.0B | 404.html | ||
40.0B | 404.html.gz | ||
5.0B | b.txt | ||
211.0B | custom_mime_type.types |