mirror of
https://github.com/pldubouilh/gossa
synced 2025-12-06 08:22:32 +01:00
small cleanup
This commit is contained in:
parent
1457c3927f
commit
cafc46f3c1
4 changed files with 23 additions and 28 deletions
1
Makefile
1
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
|
||||
|
|
|
|||
22
readme.md
22
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
|
||||
* \<any letter\> search on first letters in filename
|
||||
* Ctrl/Meta + V paste previously selected paths to directory
|
||||
* \<any letter\> search
|
||||
|
||||
### built blobs
|
||||
built blobs are available on the [release page](https://github.com/pldubouilh/gossa/releases).
|
||||
|
|
|
|||
BIN
src/favicon.png
Normal file
BIN
src/favicon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 470 B |
28
src/main.go
28
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) {
|
|||
<meta name="viewport" content="width=device-width">
|
||||
<title>` + html.EscapeString(path) + `</title>
|
||||
<link href="` + favicon + `" rel="icon" type="image/png"/>
|
||||
<script>window.onload = function(){` + jsTag + `}</script>
|
||||
<script>window.onload = function(){` + js + `}</script>
|
||||
<style type="text/css">` + css + `</style>
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
|||
Loading…
Reference in a new issue