Compare commits
17 Commits
Author | SHA1 | Date |
---|---|---|
Alexander Andreev | df3ea75ca9 | |
Alexander Andreev | cbe0292e4c | |
Alexander Andreev | d6463e81e8 | |
Alexander Andreev | 99e39fc6c1 | |
Alexander Andreev | 5cc9b12030 | |
Alexander Andreev | 8b39e60a01 | |
Alexander Andreev | c06eaecbfc | |
Alexander Andreev | f23e4d713b | |
Alexander Andreev | 1a5d32f1b9 | |
Alexander Andreev | 775eef657e | |
Alexander Andreev | 06961fc7c4 | |
Alexander Andreev | 391f589a90 | |
Alexander Andreev | 404f88c099 | |
Alexander Andreev | 54bc8d744d | |
Alexander Andreev | 6cf74599cc | |
Alexander Andreev | 4657319d52 | |
Alexander Andreev | c5ffe37c52 |
17
Makefile
17
Makefile
|
@ -6,19 +6,20 @@ SYSDDIR=${SYSDDIR_:/%=%}
|
||||||
DESTDIR:=
|
DESTDIR:=
|
||||||
PREFIX:=/usr/local
|
PREFIX:=/usr/local
|
||||||
|
|
||||||
VERSION=23.24.0
|
VERSION=23.32.0
|
||||||
|
|
||||||
|
FLAGS=-buildmode=pie -modcacherw -mod=readonly -trimpath
|
||||||
LDFLAGS=-ldflags "-s -w -X main.version=${VERSION}" -tags osusergo,netgo
|
LDFLAGS=-ldflags "-s -w -X main.version=${VERSION}" -tags osusergo,netgo
|
||||||
|
|
||||||
all: web/*.jade.go ${TARGET}
|
.PHONY: run install uninstall clean
|
||||||
|
|
||||||
.PHONY: ${TARGET}
|
${TARGET}: web/*.jade.go
|
||||||
|
go build -o bin/$@ ${LDFLAGS} ${FLAGS} cmd/$@/main.go
|
||||||
${TARGET}:
|
|
||||||
go build -o bin/$@ ${LDFLAGS} cmd/$@/main.go
|
|
||||||
|
|
||||||
web/*.jade.go: web/templates/*.jade
|
web/*.jade.go: web/templates/*.jade
|
||||||
|
ifeq (,$(wildcard $(shell go env GOPATH)/bin/jade))
|
||||||
go install github.com/Joker/jade/cmd/jade@latest
|
go install github.com/Joker/jade/cmd/jade@latest
|
||||||
|
endif
|
||||||
go generate web/web.go
|
go generate web/web.go
|
||||||
|
|
||||||
run:
|
run:
|
||||||
|
@ -33,3 +34,7 @@ uninstall:
|
||||||
rm ${DESTDIR}${PREFIX}/bin/${TARGET}
|
rm ${DESTDIR}${PREFIX}/bin/${TARGET}
|
||||||
|
|
||||||
rm ${DESTDIR}/${SYSDDIR}/${TARGET}.service
|
rm ${DESTDIR}/${SYSDDIR}/${TARGET}.service
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f web/*.jade.go
|
||||||
|
go clean
|
|
@ -1,6 +1,6 @@
|
||||||
# Maintainer: Alexander "Arav" Andreev <me@arav.su>
|
# Maintainer: Alexander "Arav" Andreev <me@arav.su>
|
||||||
pkgname=dwelling-files
|
pkgname=dwelling-files
|
||||||
pkgver=23.24.0
|
pkgver=23.32.0
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
pkgdesc="Arav's dwelling / Files"
|
pkgdesc="Arav's dwelling / Files"
|
||||||
arch=('i686' 'x86_64' 'arm' 'armv6h' 'armv7h' 'aarch64')
|
arch=('i686' 'x86_64' 'arm' 'armv6h' 'armv7h' 'aarch64')
|
||||||
|
|
|
@ -7,10 +7,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/netip"
|
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"strings"
|
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"git.arav.su/Arav/httpr"
|
"git.arav.su/Arav/httpr"
|
||||||
|
@ -32,23 +30,6 @@ func main() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var network string
|
|
||||||
if !strings.ContainsRune(*listenAddress, ':') {
|
|
||||||
network = "unix"
|
|
||||||
defer os.Remove(*listenAddress)
|
|
||||||
} else {
|
|
||||||
ap, err := netip.ParseAddrPort(*listenAddress)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalln(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if ap.Addr().Is4() {
|
|
||||||
network = "tcp4"
|
|
||||||
} else if ap.Addr().Is6() {
|
|
||||||
network = "tcp6"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
hand := dwhttp.New(directoryPath, !*enableFileHandler)
|
hand := dwhttp.New(directoryPath, !*enableFileHandler)
|
||||||
r := httpr.New()
|
r := httpr.New()
|
||||||
|
|
||||||
|
@ -58,7 +39,7 @@ func main() {
|
||||||
r.Handler(http.MethodGet, "/", hand.Index)
|
r.Handler(http.MethodGet, "/", hand.Index)
|
||||||
|
|
||||||
srv := dwhttp.NewHttpServer(r)
|
srv := dwhttp.NewHttpServer(r)
|
||||||
if err := srv.Start(network, *listenAddress); err != nil {
|
if err := srv.Start(*listenAddress); err != nil {
|
||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -2,4 +2,4 @@ module dwelling-files
|
||||||
|
|
||||||
go 1.16
|
go 1.16
|
||||||
|
|
||||||
require git.arav.su/Arav/httpr v0.2.0
|
require git.arav.su/Arav/httpr v0.3.2
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -1,2 +1,2 @@
|
||||||
git.arav.su/Arav/httpr v0.2.0 h1:rtwUVl4ZDfvMf9DeLktxvups5GDY0ARVcUuUHR7Eb9E=
|
git.arav.su/Arav/httpr v0.3.2 h1:a+ifu+9+FnQe6p/Kd4kgTDKAFN6zBOJjBTMjbAuHxVk=
|
||||||
git.arav.su/Arav/httpr v0.2.0/go.mod h1:z0SVYwe5dBReeVuFU9QH2PmBxICJwchxqY5OfZbeVzU=
|
git.arav.su/Arav/httpr v0.3.2/go.mod h1:z0SVYwe5dBReeVuFU9QH2PmBxICJwchxqY5OfZbeVzU=
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"dwelling-files/web"
|
"dwelling-files/web"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"git.arav.su/Arav/httpr"
|
"git.arav.su/Arav/httpr"
|
||||||
)
|
)
|
||||||
|
@ -30,22 +31,26 @@ func New(directoryPath *string, noFileHandling bool) *FilesHandlers {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *FilesHandlers) Index(w http.ResponseWriter, r *http.Request) {
|
func (h *FilesHandlers) Index(w http.ResponseWriter, r *http.Request) {
|
||||||
path := "/" + httpr.Param(r, "filepath") + "/"
|
path := "/" + httpr.Param(r, "filepath")
|
||||||
|
if !strings.HasSuffix(path, "/") {
|
||||||
|
path += "/"
|
||||||
|
}
|
||||||
|
|
||||||
currentPath := files.CurrentPath(path)
|
currentPath := files.CurrentPath(path)
|
||||||
|
|
||||||
entries, stats, err := files.ScanDirectory(h.directoryPath+path, path)
|
entries, stats, err := files.ScanDirectory(h.directoryPath+path, path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
|
Error(w, http.StatusNotFound, "", "", r.Referer())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
web.Index(utils.MainSite(r.Host), currentPath, &stats, &entries, r, w)
|
web.Index("Files", utils.MainSite(r.Host), currentPath, &stats, &entries, r, w)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *FilesHandlers) File(w http.ResponseWriter, r *http.Request) {
|
func (h *FilesHandlers) File(w http.ResponseWriter, r *http.Request) {
|
||||||
if h.noFileHandling {
|
if h.noFileHandling {
|
||||||
w.WriteHeader(http.StatusServiceUnavailable)
|
Error(w, http.StatusServiceUnavailable, "File handling is turned off.", "", r.Referer())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
r.URL.Path = httpr.Param(r, "filepath")
|
r.URL.Path = httpr.Param(r, "filepath")
|
||||||
|
@ -56,3 +61,8 @@ func RobotsTxt(w http.ResponseWriter, r *http.Request) {
|
||||||
fc, _ := web.AssetsGetFile("robots.txt")
|
fc, _ := web.AssetsGetFile("robots.txt")
|
||||||
w.Write(fc)
|
w.Write(fc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Error(w http.ResponseWriter, code int, reason, message, referer string) {
|
||||||
|
w.WriteHeader(code)
|
||||||
|
web.ErrorXXX("/ "+http.StatusText(code), reason, message, referer, code, w)
|
||||||
|
}
|
||||||
|
|
|
@ -5,12 +5,15 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/netip"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type HttpServer struct {
|
type HttpServer struct {
|
||||||
s http.Server
|
s http.Server
|
||||||
|
addr net.Addr
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewHttpServer(r http.Handler) *HttpServer {
|
func NewHttpServer(r http.Handler) *HttpServer {
|
||||||
|
@ -20,7 +23,23 @@ func NewHttpServer(r http.Handler) *HttpServer {
|
||||||
Handler: r}}
|
Handler: r}}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *HttpServer) Start(network, address string) error {
|
func (s *HttpServer) Start(address string) error {
|
||||||
|
var network string
|
||||||
|
if !strings.ContainsRune(address, ':') {
|
||||||
|
network = "unix"
|
||||||
|
} else {
|
||||||
|
ap, err := netip.ParseAddrPort(address)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if ap.Addr().Is4() {
|
||||||
|
network = "tcp4"
|
||||||
|
} else if ap.Addr().Is6() {
|
||||||
|
network = "tcp6"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
listener, err := net.Listen(network, address)
|
listener, err := net.Listen(network, address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -30,6 +49,8 @@ func (s *HttpServer) Start(network, address string) error {
|
||||||
os.Chmod(address, 0777)
|
os.Chmod(address, 0777)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s.addr = listener.Addr()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
if err = s.s.Serve(listener); err != nil && err != http.ErrServerClosed {
|
if err = s.s.Serve(listener); err != nil && err != http.ErrServerClosed {
|
||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
|
@ -43,6 +64,10 @@ func (s *HttpServer) Stop() error {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
|
if s.addr.Network() == "unix" {
|
||||||
|
defer os.Remove(s.addr.String())
|
||||||
|
}
|
||||||
|
|
||||||
if err := s.s.Shutdown(ctx); err != nil {
|
if err := s.s.Shutdown(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
|
|
||||||
const FileDateFormat = "2006-01-02 15:04:05 MST"
|
const FileDateFormat = "2006-01-02 15:04:05 MST"
|
||||||
|
|
||||||
type DirStats struct {
|
type DirStat struct {
|
||||||
Files int64
|
Files int64
|
||||||
FilesSize string
|
FilesSize string
|
||||||
Directories int64
|
Directories int64
|
||||||
|
@ -22,16 +22,16 @@ type DirEntry struct {
|
||||||
Size string
|
Size string
|
||||||
}
|
}
|
||||||
|
|
||||||
func ScanDirectory(path, urlBase string) (entries []DirEntry, stats DirStats, err error) {
|
func ScanDirectory(path, urlBase string) (entries []DirEntry, stats DirStat, err error) {
|
||||||
var dirEntries []DirEntry = make([]DirEntry, 0)
|
|
||||||
var fileEntries []DirEntry = make([]DirEntry, 0)
|
|
||||||
var totalFilesSize int64 = 0
|
|
||||||
|
|
||||||
dir, err := os.ReadDir(path)
|
dir, err := os.ReadDir(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var dirEntries []DirEntry = make([]DirEntry, 0)
|
||||||
|
var fileEntries []DirEntry = make([]DirEntry, 0)
|
||||||
|
var totalFilesSize int64 = 0
|
||||||
|
|
||||||
for _, ent := range dir {
|
for _, ent := range dir {
|
||||||
entry, _ := ent.Info()
|
entry, _ := ent.Info()
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package files
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
const path = "/mnt/data/music/Various"
|
||||||
|
const urlBase = "/srv/ftp/"
|
||||||
|
|
||||||
|
func BenchmarkScanDirectory(b *testing.B) {
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
/*e, _, _ :=*/ ScanDirectory(path, urlBase)
|
||||||
|
// b.Log(e[len(e)-1], len(e))
|
||||||
|
}
|
||||||
|
}
|
|
@ -30,6 +30,8 @@
|
||||||
|
|
||||||
::placeholder { color: var(--primary-color); }
|
::placeholder { color: var(--primary-color); }
|
||||||
|
|
||||||
|
.hidden { display: none; }
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: var(--primary-color);
|
color: var(--primary-color);
|
||||||
text-decoration: none; }
|
text-decoration: none; }
|
||||||
|
@ -58,8 +60,6 @@ h2 {
|
||||||
font-size: 1.4rem;
|
font-size: 1.4rem;
|
||||||
margin: 1rem 0; }
|
margin: 1rem 0; }
|
||||||
|
|
||||||
.hidden { display: none; }
|
|
||||||
|
|
||||||
html { margin-left: calc(100vw - 100%); }
|
html { margin-left: calc(100vw - 100%); }
|
||||||
|
|
||||||
body {
|
body {
|
||||||
|
@ -69,6 +69,7 @@ body {
|
||||||
font-size: 1.1rem;
|
font-size: 1.1rem;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
max-width: 960px;
|
max-width: 960px;
|
||||||
|
min-height: 100vh;
|
||||||
width: 98%; }
|
width: 98%; }
|
||||||
|
|
||||||
header {
|
header {
|
||||||
|
@ -76,24 +77,22 @@ header {
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
justify-content: space-between; }
|
justify-content: space-between; }
|
||||||
|
|
||||||
#logo {
|
header svg { width: 360px; }
|
||||||
display: block;
|
|
||||||
width: 360px; }
|
|
||||||
|
|
||||||
#logo text { fill: var(--text-color); }
|
header svg text { fill: var(--text-color); }
|
||||||
|
|
||||||
#logo .logo {
|
header svg text:first-child {
|
||||||
font-size: 2rem;
|
font-size: 2rem;
|
||||||
font-variant-caps: small-caps;
|
font-variant-caps: small-caps;
|
||||||
font-weight: bold; }
|
font-weight: bold; }
|
||||||
|
|
||||||
|
header svg text:last-child { font-size: .88rem; }
|
||||||
|
|
||||||
@media screen and (-webkit-min-device-pixel-ratio:0) {
|
@media screen and (-webkit-min-device-pixel-ratio:0) {
|
||||||
#logo .logo { font-size: 2.082rem; } }
|
header svg text:first-child { font-size: 2.082rem; } }
|
||||||
|
|
||||||
@-moz-document url-prefix() {
|
@-moz-document url-prefix() {
|
||||||
#logo .logo { font-size: 2rem; } }
|
header svg text:first-child { font-size: 2rem; } }
|
||||||
|
|
||||||
#logo .under { font-size: .88rem; }
|
|
||||||
|
|
||||||
nav { margin-top: .5rem; }
|
nav { margin-top: .5rem; }
|
||||||
|
|
||||||
|
@ -105,6 +104,60 @@ nav h1 {
|
||||||
|
|
||||||
section { margin-top: 1rem; }
|
section { margin-top: 1rem; }
|
||||||
|
|
||||||
|
input[name="filter"] {
|
||||||
|
background-color: var(--background-color);
|
||||||
|
border: none;
|
||||||
|
border-bottom: 1px solid var(--primary-color);
|
||||||
|
color: var(--text-color);
|
||||||
|
font: inherit;
|
||||||
|
width: 100%; }
|
||||||
|
|
||||||
|
table {
|
||||||
|
overflow-y: scroll;
|
||||||
|
width: 100%; }
|
||||||
|
|
||||||
|
tr { vertical-align: top; }
|
||||||
|
|
||||||
|
tr:hover,
|
||||||
|
tr:focus-within {
|
||||||
|
background-color: var(--primary-color);
|
||||||
|
color: white; }
|
||||||
|
|
||||||
|
tr:hover a,
|
||||||
|
tr:focus-within a { color: white; }
|
||||||
|
|
||||||
|
th { text-align: left; }
|
||||||
|
|
||||||
|
th:nth-child(2),
|
||||||
|
th:last-child {
|
||||||
|
width: 1%;
|
||||||
|
white-space: nowrap; }
|
||||||
|
|
||||||
|
th,
|
||||||
|
td { line-break: strict; }
|
||||||
|
|
||||||
|
th:nth-child(2),
|
||||||
|
td:nth-child(2) { padding: 0 1rem; }
|
||||||
|
|
||||||
|
td a {
|
||||||
|
display: block;
|
||||||
|
width: 100%; }
|
||||||
|
|
||||||
|
td a:hover { transition: none; }
|
||||||
|
|
||||||
|
td:nth-child(2),
|
||||||
|
td:last-child { white-space: nowrap; }
|
||||||
|
|
||||||
|
thead tr th.clickable { cursor: pointer; }
|
||||||
|
|
||||||
|
thead tr th.clickable:hover { color: var(--secondary-color); }
|
||||||
|
|
||||||
|
thead tr th.clickable:not(.sort-up):not(.sort-down)::after { content: '⇅'; }
|
||||||
|
|
||||||
|
thead tr th.clickable.sort-up::after { content: '↑'; }
|
||||||
|
|
||||||
|
thead tr th.clickable.sort-down::after { content: '↓'; }
|
||||||
|
|
||||||
#overlay {
|
#overlay {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
background-color: var(--overlay-background-color);
|
background-color: var(--overlay-background-color);
|
||||||
|
@ -152,51 +205,13 @@ section { margin-top: 1rem; }
|
||||||
background-color: var(--background-color);
|
background-color: var(--background-color);
|
||||||
color: var(--primary-color); }
|
color: var(--primary-color); }
|
||||||
|
|
||||||
input[name="filter"] {
|
#error {
|
||||||
background-color: var(--background-color);
|
font-size: 3.5rem;
|
||||||
border: none;
|
line-height: 5rem;
|
||||||
border-bottom: 1px solid var(--primary-color);
|
text-align: center;
|
||||||
color: var(--text-color);
|
margin: 6rem 0; }
|
||||||
font: inherit;
|
|
||||||
width: 100%; }
|
|
||||||
|
|
||||||
table { overflow-y: scroll; width: 100%; }
|
#error h1 { font-size: 8rem; }
|
||||||
|
|
||||||
tr { vertical-align: top; }
|
|
||||||
|
|
||||||
tr:hover,
|
|
||||||
tr:focus-within { background-color: var(--primary-color); color: white; }
|
|
||||||
|
|
||||||
tr:hover a,
|
|
||||||
tr:focus-within a { color: white; }
|
|
||||||
|
|
||||||
th { text-align: left; }
|
|
||||||
|
|
||||||
th:nth-child(2),
|
|
||||||
th:last-child { width: 1%; white-space: nowrap; }
|
|
||||||
|
|
||||||
th,
|
|
||||||
td { line-break: strict; }
|
|
||||||
|
|
||||||
th:nth-child(2),
|
|
||||||
td:nth-child(2) { padding: 0 1rem; }
|
|
||||||
|
|
||||||
td a { display: block; width: 100%; }
|
|
||||||
|
|
||||||
td a:hover { transition: none; }
|
|
||||||
|
|
||||||
td:nth-child(2),
|
|
||||||
td:last-child { white-space: nowrap; }
|
|
||||||
|
|
||||||
thead tr th.clickable { cursor: pointer; }
|
|
||||||
|
|
||||||
thead tr th.clickable:hover { color: var(--secondary-color); }
|
|
||||||
|
|
||||||
thead tr th.clickable:not(.sort-up):not(.sort-down)::after { content: '⇅'; }
|
|
||||||
|
|
||||||
thead tr th.clickable.sort-up::after { content: '↑'; }
|
|
||||||
|
|
||||||
thead tr th.clickable.sort-down::after { content: '↓'; }
|
|
||||||
|
|
||||||
footer {
|
footer {
|
||||||
font-size: .8rem;
|
font-size: .8rem;
|
||||||
|
@ -206,7 +221,7 @@ footer {
|
||||||
@media screen and (max-width: 640px) {
|
@media screen and (max-width: 640px) {
|
||||||
header { display: block; }
|
header { display: block; }
|
||||||
|
|
||||||
#logo {
|
header svg {
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
width: 100%; }
|
width: 100%; }
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
doctype html
|
||||||
|
html(lang='en')
|
||||||
|
head
|
||||||
|
block head
|
||||||
|
title Arav's dwelling / #{title}
|
||||||
|
meta(charset='utf-8')
|
||||||
|
meta(http-equiv='X-UA-Compatible' content='IE=edge')
|
||||||
|
meta(name='viewport' content='width=device-width, initial-scale=1.0')
|
||||||
|
meta(name='theme-color' content='#cd2682')
|
||||||
|
meta(name='description' content='My file share.')
|
||||||
|
link(rel='icon' type='image/svg+xml' href='/assets/img/favicon.svg' sizes='any')
|
||||||
|
link(href='/assets/css/main.css' rel='stylesheet')
|
||||||
|
script(src='/assets/js/main.js' defer='')
|
||||||
|
body
|
||||||
|
header
|
||||||
|
svg(viewBox='0 -25 216 40')
|
||||||
|
text Arav's dwelling
|
||||||
|
text(y='11') Welcome to my sacred place, wanderer
|
||||||
|
nav
|
||||||
|
block nav
|
||||||
|
block content
|
||||||
|
footer
|
||||||
|
| 2017—2023 Alexander "Arav" Andreev <#[a(href='mailto:me@arav.su') me@arav.su]> #[a(href='/privacy') Privacy statements]
|
|
@ -0,0 +1,21 @@
|
||||||
|
extends base.jade
|
||||||
|
|
||||||
|
block meta_description
|
||||||
|
meta(name='description' content=http.StatusText(code))
|
||||||
|
|
||||||
|
block nav
|
||||||
|
a(href='/') Back to index page
|
||||||
|
h1 #{http.StatusText(code)}
|
||||||
|
|
||||||
|
block content
|
||||||
|
:go:func ErrorXXX(title, reason, message, referer string, code int)
|
||||||
|
section#error
|
||||||
|
h1 #{code}
|
||||||
|
| #{http.StatusText(code)}
|
||||||
|
if reason != ""
|
||||||
|
p #{reason}
|
||||||
|
if message != ""
|
||||||
|
p #{message}
|
||||||
|
if referer != ""
|
||||||
|
section
|
||||||
|
h2 #[a(href=referer) Go back]
|
|
@ -1,56 +1,39 @@
|
||||||
:go:func Index(mainSite, currentPath string, stats *files.DirStats, items *[]files.DirEntry, r *http.Request)
|
extends base.jade
|
||||||
|
|
||||||
:go:import "dwelling-files/pkg/files"
|
block nav
|
||||||
:go:import "dwelling-files/pkg/utils"
|
a(href=mainSite) Back to main website
|
||||||
|
h1 Files
|
||||||
|
|
||||||
doctype html
|
block content
|
||||||
html(lang='en')
|
:go:func Index(title, mainSite, currentPath string, stats *files.DirStat, items *[]files.DirEntry, r *http.Request)
|
||||||
head
|
:go:import "dwelling-files/pkg/files"
|
||||||
title Arav's dwelling / Files
|
:go:import "dwelling-files/pkg/utils"
|
||||||
meta(charset='utf-8')
|
section
|
||||||
meta(http-equiv='X-UA-Compatible' content='IE=edge')
|
span!= currentPath
|
||||||
meta(name='viewport' content='width=device-width, initial-scale=1.0')
|
p Files: #{stats.Files} (#{stats.FilesSize}); Directories: #{stats.Directories}.
|
||||||
meta(name='theme-color' content='#cd2682')
|
input.hidden(type="text", name="filter" placeholder="Type in to filter this directory (case insensitive)")
|
||||||
meta(name='description' content='My file share.')
|
table
|
||||||
link(rel='icon' type='image/svg+xml' href='/assets/img/favicon.svg' sizes='any')
|
thead
|
||||||
link(href='/assets/css/main.css' rel='stylesheet')
|
tr
|
||||||
script(src='/assets/js/main.js' defer='')
|
th Name
|
||||||
body
|
th Date
|
||||||
header
|
th Size
|
||||||
svg#logo(viewBox='0 -25 216 40')
|
tr(tabindex=0)
|
||||||
text.logo Arav's dwelling
|
td #[a(href="../") ../]
|
||||||
text.under(y='11') Welcome to my sacred place, wanderer
|
tbody
|
||||||
nav
|
each item, i in *items
|
||||||
a(href=mainSite) Back to main website
|
tr(tabindex=i+1)
|
||||||
h1 Files
|
td #[a(href=item.Link) #{item.Name}]
|
||||||
section#files
|
td!= utils.ToClientTimezone(item.Datetime, r).Format(files.FileDateFormat)
|
||||||
span!= currentPath
|
td= item.Size
|
||||||
p Files: #{stats.Files} (#{stats.FilesSize}); Directories: #{stats.Directories}.
|
section
|
||||||
input.hidden(type="text", name="filter" placeholder="Type in to filter this directory (case insensitive)")
|
span!= currentPath
|
||||||
table
|
section
|
||||||
thead
|
p On a page use up and down arrow keys to navigate through list. Use home and end keys to go to the start and end of a list. Use Ctrl+Backspace to return to a parent directory.
|
||||||
tr
|
p In an overlay use a mouse wheel to change a scale of a video or a picture. Use left and right arrow keys to go through media. Use space key to toggle pause. Use escape key to close an overlay, or click outside a media. An audio volume is being kept across site using LocalStorage API.
|
||||||
th Name
|
div#overlay
|
||||||
th Date
|
button(name='prev') ❰
|
||||||
th Size
|
div
|
||||||
tr(tabindex=0)
|
|
||||||
td #[a(href="../") ../]
|
|
||||||
tbody
|
|
||||||
each item, i in *items
|
|
||||||
tr(tabindex=i+1)
|
|
||||||
td #[a(href=item.Link) #{item.Name}]
|
|
||||||
td!= utils.ToClientTimezone(item.Datetime, r).Format(files.FileDateFormat)
|
|
||||||
td= item.Size
|
|
||||||
section
|
|
||||||
span!= currentPath
|
|
||||||
section#usage
|
|
||||||
p On a page use up and down arrow keys to navigate through list. Use home and end keys to go to the start and end of a list. Use Ctrl+Backspace to return to a parent directory.
|
|
||||||
p In an overlay use a mouse wheel to change a scale of a video or a picture. Use left and right arrow keys to go through media. Use space key to toggle pause. Use escape key to close an overlay, or click outside a media. An audio volume is being kept across site using LocalStorage API.
|
|
||||||
footer
|
|
||||||
| 2017—2023 Arav <#[a(href='mailto:me@arav.su') me@arav.su]> #[a(href=mainSite+'/privacy') Privacy statements]
|
|
||||||
div#overlay
|
|
||||||
button(name='prev') ❰
|
|
||||||
div
|
div
|
||||||
div
|
span
|
||||||
span
|
button(name='next') ❱
|
||||||
button(name='next') ❱
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:generate $GOPATH/bin/jade -pkg=web -stdbuf -writer templates/index.jade
|
//go:generate $GOPATH/bin/jade -pkg=web -stdbuf -writer templates/index.jade
|
||||||
|
//go:generate $GOPATH/bin/jade -pkg=web -stdbuf -writer templates/errorXXX.jade
|
||||||
|
|
||||||
//go:embed assets
|
//go:embed assets
|
||||||
var assetsDir embed.FS
|
var assetsDir embed.FS
|
||||||
|
|
Loading…
Reference in New Issue