From 670fadcfbcef7d139ebb81e3d4aa5f8ccac804ee Mon Sep 17 00:00:00 2001
From: Alexander Neonxp Kiryukhin
Date: Wed, 28 Aug 2024 15:22:01 +0300
Subject: [PATCH] separate html dir
---
Dockerfile | 1 +
Makefile | 5 +++--
go.mod | 3 +++
go.sum | 4 ++++
html/index.html | 39 +++++++++++++++++++++++++++++++++++++++
main.go | 24 +++++++++++++++++-------
storage/index.html | 36 +-----------------------------------
upload.go | 2 +-
8 files changed, 69 insertions(+), 45 deletions(-)
create mode 100644 html/index.html
diff --git a/Dockerfile b/Dockerfile
index 1035e2b..1dc5eb6 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -14,6 +14,7 @@ FROM scratch
WORKDIR /app
COPY --from=go /app/nixshare ./nixshare
+COPY --from=go /app/html ./html
EXPOSE 8000
diff --git a/Makefile b/Makefile
index db4ded9..5621cdf 100644
--- a/Makefile
+++ b/Makefile
@@ -6,5 +6,6 @@ deploy:
docker push gitrepo.ru/neonxp/nixshare:latest
docker context use curie
docker pull gitrepo.ru/neonxp/nixshare:latest
- docker rm nixshare || true
- docker run --name nixshare -d -p 8095:8000 -v nixshare:/app/storage gitrepo.ru/neonxp/nixshare
\ No newline at end of file
+ docker rm -f nixshare || true
+ docker volume rm -f nixshare_html || true
+ docker run --name nixshare -d -p 8095:8000 -v nixshare:/app/storage -v nixshare_html:/app/html gitrepo.ru/neonxp/nixshare
\ No newline at end of file
diff --git a/go.mod b/go.mod
index ad3e9c2..13d2043 100644
--- a/go.mod
+++ b/go.mod
@@ -4,5 +4,8 @@ go 1.23.0
require (
github.com/google/uuid v1.6.0
+ go.neonxp.ru/mux v0.0.0-20240729221623-376839b264c7
golang.org/x/sync v0.8.0
)
+
+require go.neonxp.ru/objectid v0.0.2 // indirect
diff --git a/go.sum b/go.sum
index b1eeaf3..520d67f 100644
--- a/go.sum
+++ b/go.sum
@@ -1,4 +1,8 @@
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+go.neonxp.ru/mux v0.0.0-20240729221623-376839b264c7 h1:b/AgHRmzwI+FMNrf/HYEILmntTPSRDarOMTYEmL7AS8=
+go.neonxp.ru/mux v0.0.0-20240729221623-376839b264c7/go.mod h1:5OlVmN/OgaWjghQMV8oOzUQC0lUqAoplpQsUiqL5Pgc=
+go.neonxp.ru/objectid v0.0.2 h1:Z/G6zvBxmUq0NTq681oGH8pTbBWwi6VA22YOYludIPs=
+go.neonxp.ru/objectid v0.0.2/go.mod h1:s0dRi//oe1liiKcor1KmWx09WzkD6Wtww8ZaIv+VLBs=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
diff --git a/html/index.html b/html/index.html
new file mode 100644
index 0000000..3d3b20e
--- /dev/null
+++ b/html/index.html
@@ -0,0 +1,39 @@
+
+
+
+
+
+ Nixshare
+ Usage:
+ Upload file:
+
+ curl -d @FILENAME https://nixshare.ru/upload
+
+ Upload clipboard:
+
X:
++ xclip -o | curl -d @- https://nixshare.ru/upload ++
Wayland (wl-clipboard
required):
+ wl-paste | curl -d @- https://nixshare.ru/upload ++
You can add shell aliases to .bashrc or .zshrc file:
+X:
++ alias nsh="xclip -o | curl -d @- https://nixshare.ru/upload 2>/dev/null | xclip" ++
Wayland (wl-clipboard
required):
+ alias nsh="wl-paste | curl -d @- https://nixshare.ru/upload 2>/dev/null | wl-copy" ++
Alexander NeonXP Kiryukhin <a.kiryukhin@mail.ru>
+- curl -d @FILENAME https://nixshare.ru/upload --
X:
-- xclip -o | curl -d @- https://nixshare.ru/upload --
Wayland (wl-clipboard
required):
- wl-paste | curl -d @- https://nixshare.ru/upload --
You can add shell aliases to .bashrc or .zshrc file:
-X:
-- alias nsh="xclip -o | curl -d @- https://nixshare.ru/upload 2>/dev/null | xclip" --
Wayland (wl-clipboard
required):
- alias nsh="wl-paste | curl -d @- https://nixshare.ru/upload 2>/dev/null | wl-copy" -- - \ No newline at end of file +nothing here \ No newline at end of file diff --git a/upload.go b/upload.go index 719e519..95a6913 100644 --- a/upload.go +++ b/upload.go @@ -36,7 +36,7 @@ func uploadHandler(w http.ResponseWriter, r *http.Request) { h.Set("Content-Type", "text/plain; charset=utf-8") h.Set("X-Content-Type-Options", "nosniff") w.WriteHeader(http.StatusCreated) - u, err := url.JoinPath(host, section, uid) + u, err := url.JoinPath(host, "s", section, uid) if err != nil { log.Println(err) http.Error(w, "can't get file url", http.StatusInternalServerError)