start moving file from its parent directory, cleanup some style/text

This commit is contained in:
Iris Lightshard 2022-06-15 21:41:06 -06:00
parent 87333f9d87
commit 4333461b75
Signed by: Iris Lightshard
GPG key ID: 3B7FBC22144E6398
4 changed files with 22 additions and 10 deletions

View file

@ -20,6 +20,7 @@ type FileData struct {
Error string Error string
Path string Path string
Name string Name string
Parent string
IsDir bool IsDir bool
} }
@ -76,10 +77,11 @@ func (self *SimpleFileManager) ListSubTree(root string) FileListing {
} }
levels := strings.Split(root, "/") levels := strings.Split(root, "/")
if list.Root != "/" { if list.Root != "/" {
list.Up = "/" list.Up = "/"
} }
if len(levels) >= 2 { if len(levels) >= 2 && list.Root != "/" {
list.Up = strings.Join(levels[:len(levels)-1], "/") list.Up = strings.Join(levels[:len(levels)-1], "/")
if !strings.HasPrefix(list.Up, "/") { if !strings.HasPrefix(list.Up, "/") {
list.Up = "/" + list.Up list.Up = "/" + list.Up
@ -120,10 +122,11 @@ func (self *SimpleFileManager) GetFileData(slug string) FileData {
cleanedSlug := filepath.Clean(slug) cleanedSlug := filepath.Clean(slug)
fileBase := filepath.Base(cleanedSlug) fileBase := filepath.Base(cleanedSlug)
parent := strings.TrimSuffix("/"+cleanedSlug, "/"+fileBase)
return FileData{ return FileData{
Path: filepath.Clean(slug), Path: filepath.Clean(slug),
Name: fileBase, Name: fileBase,
Parent: parent,
IsDir: fileInfo.IsDir(), IsDir: fileInfo.IsDir(),
} }
} }

View file

@ -58,6 +58,7 @@ body {
font-size: 200%; font-size: 200%;
color: lightgray; color: lightgray;
padding: 0.2em; padding: 0.2em;
max-width: calc(100vw - 2em);
} }
.login form input[type="text"], .login form input[type="password"] { .login form input[type="text"], .login form input[type="password"] {
@ -117,6 +118,7 @@ nav {
nav ul { nav ul {
list-style: none; list-style: none;
padding: 0;
} }
nav ul li { nav ul li {
@ -363,3 +365,9 @@ input[type="file"]:valid + .file-feedback::after {
.upload-wrapper { .upload-wrapper {
position: relative; position: relative;
} }
@media screen and (max-width: 512px) {
body {
font-size: 75%;
}
}

View file

@ -19,6 +19,7 @@
<div class="action-panel"> <div class="action-panel">
<form class="file-move" method="GET" action="/file-move/{{($file).Path}}"> <form class="file-move" method="GET" action="/file-move/{{($file).Path}}">
<span>/{{($file).Path}}</span> <span>/{{($file).Path}}</span>
<input hidden type="text" name="dest" value="{{($file).Parent}}"/>
<input type="submit" value="Move/Rename"/> <input type="submit" value="Move/Rename"/>
</form> </form>
<details class="danger-zone"><summary>Danger Zone</summary> <details class="danger-zone"><summary>Danger Zone</summary>

View file

@ -15,7 +15,7 @@
<h2>File Move/Rename Success</h2> <h2>File Move/Rename Success</h2>
<span class="adapter-success">File moved from {{$slug}} to {{$dest}}{{$name}} </span> <span class="adapter-success">File moved from /{{$slug}} to {{$dest}}{{$name}} </span>
{{ end }} {{ end }}