diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..196d9bc --- /dev/null +++ b/COPYING @@ -0,0 +1,14 @@ +Copyright (c) 2021 Willy Goiffon +Copyright (c) 2023-present Izuru Yakumo + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 4d2861a..0000000 --- a/LICENSE +++ /dev/null @@ -1,13 +0,0 @@ -Copyright (c) 2021 Willy Goiffon - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. diff --git a/LICENSE b/LICENSE new file mode 120000 index 0000000..5ecd9c6 --- /dev/null +++ b/LICENSE @@ -0,0 +1 @@ +COPYING diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..aac2610 --- /dev/null +++ b/Makefile @@ -0,0 +1,25 @@ +GO ?= go +GOFLAGS ?= -v -ldflags "-w -X `go list`.Version=${VERSION} -X `go list`.Commit=${COMMIT} -X `go list`.Build=${BUILD}" +CGO ?= 0 + +VERSION = `git describe --abbrev=0 --tags 2>/dev/null || echo "$VERSION"` +COMMIT = `git rev-parse --short HEAD || echo "$COMMIT"` +BRANCH = `git rev-parse --abbrev-ref HEAD` +BUILD = `git show -s --pretty=format:%cI` + +PREFIX ?= /usr/local + +all: marisa marisa-trash + +marisa: + CGO_ENABLED=${CGO} go build ${GOFLAGS} ./cmd/marisa +marisa-trash: + CGO_ENABLED=${CGO} go build ${GOFLAGS} ./cmd/marisa-trash +clean: + rm -f marisa marisa-trash +install: + install -Dm0755 marisa ${PREFIX}/bin/marisa + install -Dm0755 marisa-trash ${PREFIX}/bin/marisa-trash + install -Dm0644 marisa.1 ${PREFIX}/share/man/man1/marisa.1 + install -Dm0644 marisa.conf.5 ${PREFIX}/share/man/man5/marisa.conf.5 +.PHONY: marisa marisa-trash diff --git a/README b/README.md similarity index 67% rename from README rename to README.md index 364c43c..e487c7d 100644 --- a/README +++ b/README.md @@ -1,9 +1,7 @@ -partage -======= +marisa +====== HTTP based File upload system. -![screenshot](https://z3bra.org/partage/screenshot.png) - Features -------- + Link expiration @@ -17,11 +15,11 @@ Features Usage ----- -Refer to the partage(1) manual page for details and examples. +Refer to the marisa(1) manual page for details and examples. - partage [-v] [-f partage.conf] + marisa [-v] [-f marisa.conf] -Configuration is done through its configuration file, partage.conf(5). +Configuration is done through its configuration file, marisa.conf(5). The format is that of the INI file format. Uploading files is done via PUT and POST requests. Multiple files can @@ -34,5 +32,5 @@ Installation ------------ Edit the `config.mk` file to match your setup, then run the following: - $ mk - # mk install + $ (b)make + # (b)make install diff --git a/partage-trash/partage-trash.go b/cmd/marisa-trash/main.go similarity index 100% rename from partage-trash/partage-trash.go rename to cmd/marisa-trash/main.go diff --git a/partage.go b/cmd/marisa/main.go similarity index 98% rename from partage.go rename to cmd/marisa/main.go index 6efe844..98e0b27 100644 --- a/partage.go +++ b/cmd/marisa/main.go @@ -22,6 +22,7 @@ import ( "github.com/dustin/go-humanize" "gopkg.in/ini.v1" + "marisa.chaotic.ninja/marisa" ) type templatedata struct { @@ -329,7 +330,7 @@ func main() { var listener net.Listener /* default values */ - conf.listen = "0.0.0.0:8080" + conf.listen = "127.0.0.1:8080" conf.baseuri = "http://127.0.0.1:8080" conf.rootdir = "static" conf.tmplpath = "templates" @@ -408,6 +409,7 @@ func main() { http.Handle(conf.filectx, http.StripPrefix(conf.filectx, http.FileServer(http.Dir(conf.filepath)))) if verbose { + log.Printf("Starting marisa %v\n", marisa.FullVersion()) log.Printf("Listening on %s", conf.listen) } diff --git a/example/partage.conf b/example/marisa.conf similarity index 87% rename from example/partage.conf rename to example/marisa.conf index 89f3c60..fa93bef 100644 --- a/example/partage.conf +++ b/example/marisa.conf @@ -1,6 +1,6 @@ # TCP or unix Socket to listen on. # When unix sockets are used, the content will be served over FastCGI. -#listen = /var/run/partage-fcgi.sock +#listen = /var/run/marisa-fcgi.sock listen = 127.0.0.1:9000 # Base to use when constructing URI to files uploaded. @@ -20,10 +20,10 @@ baseuri = http://127.0.0.1:9000 # Path to the different path used by the server. Must take into account # the chroot if set. -rootdir = example/static -tmplpath = example/templates -filepath = example/files -metapath = example/meta +rootdir = static +tmplpath = templates +filepath = files +metapath = meta # URI context that files will be served on filectx = /f/ diff --git a/example/static/favicon.ico b/example/static/favicon.ico deleted file mode 100644 index 61a250e..0000000 Binary files a/example/static/favicon.ico and /dev/null differ diff --git a/example/static/marisa.png b/example/static/marisa.png new file mode 100644 index 0000000..df4444c Binary files /dev/null and b/example/static/marisa.png differ diff --git a/example/static/marisa_98.css b/example/static/marisa_98.css new file mode 100644 index 0000000..7756464 --- /dev/null +++ b/example/static/marisa_98.css @@ -0,0 +1,90 @@ +body { + padding: 5%; + margin: auto; + max-width: 540px; + font-family: sans-serif; + font-size: 1.5rem; + text-align: center; + background-color: #550000; + color: #ff4444; +} + +header { + display: flex; + flex-direction: column; + flex-wrap: wrap-reverse; + align-items: center; + align-content: center; +} + +section { + display: flex; + justify-content: flex-end; + font-size: initial; +} + +section#formsettings > * { + margin-top: 20px; + margin-left: 20px; +} + +img#logo { + height: 100%; + max-height: 30vh; +} + +h1 { + font-size: 4.0rem; +} + +#uploads { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; +} + +#uploads > ul { + list-style: none; + text-align: left; + padding: 0; +} + +#uploads > button { + align-self: flex-end; + margin-right: 10%; +} + +.dropzone { + padding-top: 60px; + padding-bottom: 60px; + border: 2px dashed #888888; + border-radius: 8px; + text-align: center; + margin: auto; + color: #888888; +} + +.dropzone.dragover { + color: #222222; + border-color: #222222; +} + +/* font attributes are not inherited by default */ +input, input::file-selector-button { + text-align: inherit; + font-family: inherit; + font-size: inherit; +} + +@media (min-aspect-ratio: 18/9) { + header { + flex-direction: row; + } + h1 { font-size: 3rem; margin-right: 10px; } + img#logo { + height: 50%; + max-height: 20vh; + order: 2; + } +} diff --git a/example/static/partage.css b/example/static/partage.css deleted file mode 100644 index e4f64c4..0000000 --- a/example/static/partage.css +++ /dev/null @@ -1,106 +0,0 @@ -body { - padding: 5%; - margin: auto; - max-width: 540px; - font-family: serif; - font-size: 1.5rem; - text-align: center; - background-color: #eeeeee; - color: #222222; -} - -header { - display: flex; - flex-direction: column; - flex-wrap: wrap-reverse; - align-items: center; - align-content: center; -} - -section { - display: flex; - justify-content: flex-end; - font-size: initial; -} - -section#formsettings > * { - margin-top: 20px; - margin-left: 20px; -} - -img#logo { - height: 100%; - max-height: 30vh; -} - -h1 { - font-size: 4.0rem; -} - -#uploads { - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; -} - -#uploads > ul { - list-style: none; - text-align: left; - padding: 0; -} - -#uploads > button { - align-self: flex-end; - margin-right: 10%; -} - -.dropzone { - padding-top: 60px; - padding-bottom: 60px; - border: 2px dashed #888888; - border-radius: 8px; - text-align: center; - margin: auto; - color: #888888; -} - -.dropzone.dragover { - color: #222222; - border-color: #222222; -} - -/* font attributes are not inherited by default */ -input, input::file-selector-button { - text-align: inherit; - font-family: inherit; - font-size: inherit; -} - -@media (min-aspect-ratio: 18/9) { - header { - flex-direction: row; - } - h1 { font-size: 3rem; margin-right: 10px; } - img#logo { - height: 50%; - max-height: 20vh; - order: 2; - } -} - -@media (prefers-color-scheme: light) { - a { color: black; } - body { - color: #222222; - background-color: #eeeeee; - } -} - -@media (prefers-color-scheme: dark) { - a { color: white; } - body { - color: #eeeeee; - background-color: #222222; - } -} diff --git a/example/static/partage.png b/example/static/partage.png deleted file mode 100644 index c3db0cf..0000000 Binary files a/example/static/partage.png and /dev/null differ diff --git a/example/templates/index.html b/example/templates/index.html index 07ba874..d4d7315 100644 --- a/example/templates/index.html +++ b/example/templates/index.html @@ -1,42 +1,42 @@ - - - - - - - - Partage - - -
- -

partage

-
-
-
-
- - - -
-
- - -
-
-

File size limited to {{.Maxsize}}.

-
{{if .Links}} -
    - {{range .Links}}
  • {{.}}
  • {{end}} -
- {{end}}
- + + + + + + + + Marisa + + +
+ +

marisa

+
+
+
+
+ + + +
+
+ + +
+
+

File size limited to {{.Maxsize}}.

+
{{if .Links}} +
    + {{range .Links}}
  • {{.}}
  • {{end}} +
+ {{end}}
+ diff --git a/go.mod b/go.mod index ebfe7bf..d989832 100644 --- a/go.mod +++ b/go.mod @@ -1,9 +1,10 @@ -module git.z3bra.org/partage +module marisa.chaotic.ninja/marisa go 1.17 require ( - github.com/dustin/go-humanize v1.0.0 // indirect - github.com/vharitonsky/iniflags v0.0.0-20180513140207-a33cd0b5f3de // indirect - gopkg.in/ini.v1 v1.63.2 // indirect + github.com/dustin/go-humanize v1.0.0 + gopkg.in/ini.v1 v1.63.2 ) + +require github.com/stretchr/testify v1.8.4 // indirect diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..56d5331 --- /dev/null +++ b/go.sum @@ -0,0 +1,20 @@ +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= +github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/ini.v1 v1.63.2 h1:tGK/CyBg7SMzb60vP1M03vNZ3VDu3wGQJwn7Sxi9r3c= +gopkg.in/ini.v1 v1.63.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/partage-trash/partage-trash.1 b/marisa-trash.1 similarity index 100% rename from partage-trash/partage-trash.1 rename to marisa-trash.1 diff --git a/partage.1 b/marisa.1 similarity index 100% rename from partage.1 rename to marisa.1 diff --git a/partage.conf.5 b/marisa.conf.5 similarity index 100% rename from partage.conf.5 rename to marisa.conf.5 diff --git a/mkfile b/mkfile deleted file mode 100644 index b74aaaf..0000000 --- a/mkfile +++ /dev/null @@ -1,30 +0,0 @@ -