Properly encode path links, remove unused password settings

This commit is contained in:
2023-05-30 16:59:11 +02:00
parent 0299b730a5
commit 8377ac1fab
9 changed files with 34 additions and 45 deletions

View File

@@ -1,4 +1,6 @@
<script>
import { fs_encode_path } from "./FilesystemUtil";
export let state = {}
export let fs_navigator
</script>
@@ -6,7 +8,7 @@ export let fs_navigator
{#each state.path as node, i (node.path)}
{@const shared = node.id !== undefined && node.id !== "me"}
<a
href={state.path_root+node.path}
href={"/d"+fs_encode_path(node.path)}
class="breadcrumb button"
class:button_highlight={state.base_index === i}
on:click|preventDefault={() => {fs_navigator.navigate(node.path, true)}}

View File

@@ -23,8 +23,6 @@ export const edit = (f, oae = false, t = "file") => {
file_name = file.name
shared = !(file.id === undefined || file.id === "")
read_password = file.read_password ? file.read_password : ""
write_password = file.write_password ? file.write_password : ""
visible = true
}
@@ -33,8 +31,6 @@ let open_after_edit = false
let file_name = ""
let shared = false
let read_password = ""
let write_password = ""
const save = async () => {
console.debug("Saving file", file.path)
@@ -42,11 +38,7 @@ const save = async () => {
dispatch("loading", true)
await fs_update(
file.path,
{
shared: shared,
read_password: read_password,
write_password: write_password,
},
{shared: shared},
)
if (file_name !== file.name) {
@@ -138,10 +130,6 @@ const delete_file = async () => {
<input bind:checked={shared} id="shared" type="checkbox" class="form_input"/>
<label for="shared">Share this file or directory</label>
</div>
<label for="read_password">Read password:</label>
<input bind:value={read_password} id="read_password" type="text" class="form_input"/>
<label for="write_password">Write password:</label>
<input bind:value={write_password} id="write_password" type="text" class="form_input"/>
</div>
{/if}
</form>

View File

@@ -30,14 +30,6 @@ let state = {
// Shortcuts
base: window.initial_node.path[window.initial_node.base_index],
// Passwords for accessing this bucket. Passwords are not always required
// but sometimes they are
read_password: "",
write_password: "",
// Root path of the bucket. Used for navigation by prepending it to a file
// path
path_root: "/d/"+window.initial_node.path[0].id,
shuffle: false,
}

View File

@@ -69,12 +69,6 @@ export const fs_update = async (path, opts) => {
if (opts.shared !== undefined) {
form.append("shared", opts.shared)
}
if (opts.read_password !== undefined) {
form.append("read_password", opts.read_password)
}
if (opts.write_password !== undefined) {
form.append("write_password", opts.write_password)
}
return await fs_check_response(
await fetch(fs_path_url(path), { method: "POST", body: form })

View File

@@ -15,14 +15,6 @@ export let state = {
// The part of the path that base_index points to
base: {},
// Passwords for accessing this bucket. Passwords are not always required
// but sometimes they are
read_password: "",
write_password: "",
// Root path of the bucket. Used for navigation by prepending it to a file
// path
path_root: "",
shuffle: false,
}

View File

@@ -1,7 +1,7 @@
<script>
import { createEventDispatcher } from "svelte";
import { fs_search } from "./FilesystemAPI";
import { fs_thumbnail_url } from "./FilesystemUtil";
import { fs_encode_path, fs_thumbnail_url } from "./FilesystemUtil";
export let state
export let fs_navigator
@@ -117,7 +117,7 @@ const open_result = index => {
</tr>
{#each search_results as result, index}
<a
href={state.path_root+result}
href={"/d"+fs_encode_path(result)}
on:click|preventDefault={() => open_result(index)}
class="node"
>

View File

@@ -32,6 +32,12 @@ const node_click = e => {
state.children[index].fm_selected = !state.children[index].fm_selected
}
}
const node_share_click = e => {
let index = e.detail
creating_dir = false
fs_navigator.navigate(state.children[index].id, true)
}
const node_settings = e => {
edit_window.edit(state.children[e.detail], false)
@@ -198,9 +204,20 @@ onMount(() => {
</div>
{#if directory_view === "list"}
<ListView state={state} show_hidden={show_hidden} on:node_click={node_click} on:node_settings={node_settings}></ListView>
<ListView
state={state}
show_hidden={show_hidden}
on:node_click={node_click}
on:node_share_click={node_share_click}
on:node_settings={node_settings}
/>
{:else if directory_view === "gallery"}
<GalleryView state={state} show_hidden={show_hidden} on:node_click={node_click} on:node_settings={node_settings}></GalleryView>
<GalleryView
state={state}
show_hidden={show_hidden}
on:node_click={node_click}
on:node_settings={node_settings}
/>
{/if}
</div>

View File

@@ -1,6 +1,6 @@
<script>
import { createEventDispatcher } from "svelte"
import { fs_node_icon, fs_node_type } from "../FilesystemUtil";
import { fs_encode_path, fs_node_icon, fs_node_type } from "../FilesystemUtil";
let dispatch = createEventDispatcher()
export let state
@@ -10,7 +10,7 @@ export let show_hidden = false
<div class="gallery">
{#each state.children as child, index (child.path)}
<a class="file"
href={state.path_root+child.path_uri}
href={"/d"+fs_encode_path(child.path)}
on:click|preventDefault={() => {dispatch("node_click", index)}}
class:selected={child.fm_selected}
class:hidden={child.name.startsWith(".") && !show_hidden}

View File

@@ -1,7 +1,7 @@
<script>
import { createEventDispatcher } from "svelte";
import { formatDataVolume } from "../../util/Formatting.svelte";
import { fs_node_icon } from "../FilesystemUtil";
import { fs_encode_path, fs_node_icon } from "../FilesystemUtil";
let dispatch = createEventDispatcher()
@@ -18,7 +18,7 @@ export let show_hidden = false
</tr>
{#each state.children as child, index (child.path)}
<a
href={state.path_root+child.path_uri}
href={"/d"+fs_encode_path(child.path)}
on:click|preventDefault={() => {dispatch("node_click", index)}}
class="node"
class:node_selected={child.fm_selected}
@@ -37,7 +37,11 @@ export let show_hidden = false
</td>
<td class="node_icons">
{#if child.id}
<a href="/d/{child.id}" on:click|stopPropagation class="button small_button">
<a
href="/d/{child.id}"
on:click|preventDefault|stopPropagation={() => {dispatch("node_share_click", index)}}
class="button small_button"
>
<i class="icon" title="This file / directory is shared. Click to open public link">share</i>
</a>
{/if}