diff --git a/Makefile b/Makefile index 36b02c2..63c2521 100755 --- a/Makefile +++ b/Makefile @@ -8,6 +8,7 @@ embed: cp src/main.go 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 run: make build diff --git a/readme.md b/readme.md index ab49e1b..61735a5 100644 --- a/readme.md +++ b/readme.md @@ -8,34 +8,30 @@ gossa 🎶 A fast and simple webserver for your files. It's dependency-free and with under 250 lines for the server code, easily code-reviewable. ### features - * browse throughout files/directories - * upload files and folders with drag-and-drop + * browse through files/directories + * upload with drag-and-drop * create new folders - * move files to different directories with drag-and-drop and keyboard - * browse throughout pictures with a full-screen carousel + * move files with drag-and-drop and keyboard + * browse through pictures with a full-screen carousel * simple keyboard navigation/shortcuts * fast ; fills my 80MB/s AC wifi link ### run ```sh -# run on test fixture folder -make run - # build make -./gossa --help -# run CI tests -make ci +# run +./gossa -h 192.168.100.33 ~/storage ``` ### keyboard shortcuts * Arrows/Enter browse throughout the files/directories and pictures - * Ctrl/Meta + C copy selected path to clipboard + * Ctrl/Meta + C copy URL to clipboard * Ctrl/Meta + D create a new directory * Ctrl/Meta + X cut selected path - * Ctrl/Meta + V paste paths previously selected with the above shortcut to directory - * \ search on first letters in filename + * Ctrl/Meta + V paste previously selected paths to directory + * \ search ### built blobs built blobs are available on the [release page](https://github.com/pldubouilh/gossa/releases). diff --git a/src/favicon.png b/src/favicon.png new file mode 100644 index 0000000..7e17946 Binary files /dev/null and b/src/favicon.png differ diff --git a/src/main.go b/src/main.go index 01720b1..5a68e8f 100755 --- a/src/main.go +++ b/src/main.go @@ -17,30 +17,30 @@ import ( "strings" ) -func check(e error) { - if e != nil { - panic(e) - } -} - -var fs http.Handler - 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 css = `css_will_be_here` // js will be embedded here -var jsTag = `js_will_be_here` // id. css +var css = `css_will_be_here` // js will be embedded here +var js = `js_will_be_here` // id. css +var favicon = "data:image/png;base64,favicon_will_be_here" // id. b64 favicon var units = [8]string{"k", "M", "G", "T", "P", "E", "Z", "Y"} -var favicon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgBAMAAACBVGfHAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAGFBMVEUAAACAgIDAwMAAAAD//////wAAAP+AgACyGYBKAAAAAXRSTlMAQObYZgAAAAFiS0dEBI9o2VEAAAAHdElNRQfiBhgXAzXpQrjsAAAArklEQVQoz3WQQQ7CIBBF4QbS4gEsYV8DHkAc3Rev0Buw8PoOQ9KZjPGlm76+hE+N+cdJvdughC+r+OqcAxCJB8CHE1vqBiASH6OHFycj2NEE50g8KdgxybBSMQI0oTYqKOim3EjcR9BNQGGnhSmJVh08PG45R+aScctUmS3jXFlEXdRroKHMnOgqzNxUQcNk8W7jd/CQ1IUcklSx6KImo45pRh1D4iPowiTBan74AnnnVMHA9EjhAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDE4LTA2LTI0VDIzOjAzOjUzLTA0OjAwyUvdTwAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxOC0wNi0yNFQyMzowMzo1My0wNDowMLgWZfMAAAAASUVORK5CYII=" + +var fs http.Handler type rpcCall struct { Call string `json:"call"` Args []string `json:"args"` } +func check(e error) { + if e != nil { + panic(e) + } +} + func logVerb(s ...interface{}) { if *verb { log.Println(s...) @@ -56,11 +56,9 @@ func sizeToString(bytes float64) string { bytes = bytes / 1024 u++ if bytes < 1024 { - break + return strconv.FormatFloat(bytes, 'f', 1, 64) + units[u] } } - - return strconv.FormatFloat(bytes, 'f', 1, 64) + units[u] } func row(name string, href string, size float64, ext string) string { @@ -87,7 +85,7 @@ func replyList(w http.ResponseWriter, path string) { ` + html.EscapeString(path) + ` - +