@samitouri / QOSami-HFS / commits / 2d6942ab

get=list to offer full urls

Massimo Melina committed May 8, 2023 at 20:16 UTC 2d6942ab4e4304b95573f08790585e70555b9164
4 files changed +8 -6
frontend/src/fileMenu.ts
+1 -1
@@ -17,7 +17,7 @@ export function openFileMenu(entry: DirEntry, ev: MouseEvent, addToMenu: FileMen
17 const menu = [
18 !cantDownload && { label: t`Download`, href: uri + (isFolder ? '?get=zip' : '?dl'), icon: 'download' },
19 ...addToMenu,
20 - isFolder && { label: t`Get list`, href: uri + '?get=list&folders=*', icon: 'menu' }
20 + isFolder && { label: t`Get list`, href: uri + '?get=list&folders=*&prepend=' + encodeURIComponent(location.href + uri), icon: 'menu' }
21 ]
22 const props = [
23 [t(`Name`), entry.name]
src/langs/hfs-lang-en.json
+2 -1
@@ -110,6 +110,7 @@
110 "file_open": "Open",
111 "Download": "Download",
112 "Missing permission": "Missing permission",
113 - "Reload": "Reload"
113 + "Reload": "Reload",
114 + "Get list": "Get list"
115 }
116 }
src/langs/hfs-lang-it.json
+2 -1
@@ -104,6 +104,7 @@
104 "file_open": "Apri",
105 "Download": "Download",
106 "Missing permission": "Permesso mancante",
107 - "Reload": "Ricarica"
107 + "Reload": "Ricarica",
108 + "Get list": "Lista"
109 }
110 }
src/middlewares.ts
+3 -3
@@ -9,7 +9,7 @@ import {
9 HTTP_FORBIDDEN, HTTP_NOT_FOUND, HTTP_FOOL,
10 } from './const'
11 import { FRONTEND_URI } from './const'
12 -import { statusCodeForMissingPerm, nodeIsDirectory, urlToNode, vfs, walkNode, VfsNode } from './vfs'
12 +import { statusCodeForMissingPerm, nodeIsDirectory, urlToNode, vfs, walkNode, VfsNode, getNodeName } from './vfs'
13 import {
14 asyncGeneratorToReadable,
15 dirTraversal,
@@ -150,13 +150,13 @@ export const serveGuiAndSharedFiles: Koa.Middleware = async (ctx, next) => {
150 }
151
152 async function sendFolderList(node: VfsNode, ctx: Koa.Context) {
153 - const { depth=0, folders } = ctx.query
153 + const { depth=0, folders, prepend='' } = ctx.query
154 ctx.type = 'text'
155 const walker = walkNode(node, ctx, depth === '*' ? Infinity : Number(depth))
156 ctx.body = asyncGeneratorToReadable(filterMapGenerator(walker, async el => {
157 const isFolder = await nodeIsDirectory(el)
158 return !folders && isFolder ? undefined
159 - : el.name + (isFolder ? '/' : '') + '\n'
159 + : prepend + getNodeName(el) + (isFolder ? '/' : '') + '\n'
160 }))
161 }
162