2025-03-28 14:16:20 +01:00
|
|
|
<script lang="ts">
|
2025-10-13 16:05:50 +02:00
|
|
|
import { run } from 'svelte/legacy';
|
|
|
|
|
import { domain_url } from "util/Util";
|
2025-03-27 15:38:59 +01:00
|
|
|
import CopyButton from "layout/CopyButton.svelte";
|
2025-03-28 14:16:20 +01:00
|
|
|
import { formatDate } from "util/Formatting";
|
2025-10-13 23:20:42 +02:00
|
|
|
import { type FSNode, type NodeOptions } from "lib/FilesystemAPI.svelte";
|
2025-10-09 15:48:23 +02:00
|
|
|
import AccessControl from "./AccessControl.svelte";
|
2024-02-16 21:07:01 +01:00
|
|
|
|
2025-10-13 16:05:50 +02:00
|
|
|
let {
|
|
|
|
|
file = $bindable(),
|
|
|
|
|
options = $bindable(),
|
|
|
|
|
}: {
|
|
|
|
|
file?: FSNode;
|
|
|
|
|
options: NodeOptions;
|
|
|
|
|
} = $props();
|
2024-02-16 21:07:01 +01:00
|
|
|
|
2025-10-13 16:05:50 +02:00
|
|
|
let embed_html: string = $state()
|
|
|
|
|
let preview_area: HTMLDivElement = $state()
|
2024-02-16 21:07:01 +01:00
|
|
|
|
2025-10-09 15:48:23 +02:00
|
|
|
const embed_iframe = (file: FSNode, options: NodeOptions) => {
|
2025-10-13 23:20:42 +02:00
|
|
|
if (!file.is_shared()) {
|
2024-02-16 21:07:01 +01:00
|
|
|
example = false
|
|
|
|
|
embed_html = "File is not shared, can't generate embed code"
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let url = domain_url()+"/d/"+file.id
|
|
|
|
|
embed_html = `<iframe ` +
|
|
|
|
|
`src="${url}" ` +
|
2025-10-09 15:48:23 +02:00
|
|
|
`style="border: none; width: 100%; max-width 90vw; height: 800px; max-height: 75vh; border-radius: 6px;" ` +
|
2024-05-29 17:13:37 +02:00
|
|
|
`allowfullscreen` +
|
2024-02-16 21:07:01 +01:00
|
|
|
`></iframe>`
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-13 16:05:50 +02:00
|
|
|
let example = $state(false)
|
2024-02-16 21:07:01 +01:00
|
|
|
const toggle_example = () => {
|
2025-10-13 23:20:42 +02:00
|
|
|
if (file.is_shared()) {
|
2024-02-16 21:07:01 +01:00
|
|
|
example = !example
|
|
|
|
|
if (example) {
|
|
|
|
|
preview_area.innerHTML = embed_html
|
|
|
|
|
} else {
|
|
|
|
|
preview_area.innerHTML = ""
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-30 12:28:42 +02:00
|
|
|
|
2025-10-13 16:05:50 +02:00
|
|
|
let share_link = $derived(window.location.protocol+"//"+window.location.host+"/d/"+file.id)
|
|
|
|
|
run(() => {
|
|
|
|
|
embed_iframe(file, options)
|
|
|
|
|
});
|
2024-02-16 21:07:01 +01:00
|
|
|
</script>
|
|
|
|
|
|
2025-01-27 22:54:47 +01:00
|
|
|
<fieldset>
|
|
|
|
|
<legend>Public link</legend>
|
2024-05-17 16:32:53 +02:00
|
|
|
|
2025-01-27 22:54:47 +01:00
|
|
|
{#if file.abuse_type !== undefined}
|
|
|
|
|
<div class="highlight_red">
|
|
|
|
|
This file or directory has received an abuse report. It cannot be
|
|
|
|
|
shared.<br/>
|
|
|
|
|
Type of abuse: {file.abuse_type}<br/>
|
|
|
|
|
Report time: {formatDate(file.abuse_report_time, true, true, true)}
|
|
|
|
|
</div>
|
2024-02-16 21:07:01 +01:00
|
|
|
{/if}
|
|
|
|
|
|
2025-05-14 11:56:52 +02:00
|
|
|
<div class="link_grid">
|
2025-10-09 15:48:23 +02:00
|
|
|
<a href={share_link}>{share_link}</a>
|
2025-01-27 22:54:47 +01:00
|
|
|
<CopyButton text={share_link}>Copy</CopyButton>
|
|
|
|
|
</div>
|
|
|
|
|
</fieldset>
|
|
|
|
|
|
2025-10-09 15:48:23 +02:00
|
|
|
<AccessControl options={options}/>
|
|
|
|
|
|
2025-01-27 22:54:47 +01:00
|
|
|
<fieldset>
|
|
|
|
|
<legend>Embedding</legend>
|
|
|
|
|
<p>
|
2026-06-10 23:53:03 +02:00
|
|
|
If you have a website you can embed Nova directories and files in your
|
2025-01-27 22:54:47 +01:00
|
|
|
own webpages with the code below. If you embed a directory then all
|
|
|
|
|
subdirectories and files will be accessible through the frame. Branding
|
|
|
|
|
options will also apply in the frame, but only when applied to this
|
|
|
|
|
directory. It will not inherit the style from parent directories.
|
|
|
|
|
</p>
|
|
|
|
|
<p>
|
|
|
|
|
Put this code in your website to embed the file or directory.
|
|
|
|
|
</p>
|
|
|
|
|
<div class="center">
|
|
|
|
|
<textarea bind:value={embed_html} style="width: 100%; height: 4em;"></textarea>
|
|
|
|
|
<br/>
|
|
|
|
|
<CopyButton text={embed_html}>Copy HTML</CopyButton>
|
2025-10-13 23:20:42 +02:00
|
|
|
<button onclick={toggle_example} class:button_highlight={example} disabled={!file.is_shared()}>
|
2025-01-27 22:54:47 +01:00
|
|
|
<i class="icon">visibility</i> Show example
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
<hr/>
|
2024-02-16 21:07:01 +01:00
|
|
|
|
2025-01-27 22:54:47 +01:00
|
|
|
<div bind:this={preview_area} style="text-align: center;"></div>
|
|
|
|
|
</fieldset>
|
2024-02-16 21:07:01 +01:00
|
|
|
|
2025-05-14 11:56:52 +02:00
|
|
|
<!-- <fieldset>
|
|
|
|
|
<legend>Custom domain</legend>
|
|
|
|
|
<p>
|
|
|
|
|
Experimental options
|
|
|
|
|
</p>
|
|
|
|
|
<div class="form_grid">
|
|
|
|
|
<label for="custom_domain_name">Domain name</label>
|
|
|
|
|
<input
|
|
|
|
|
id="custom_domain_name"
|
|
|
|
|
bind:value={options.custom_domain_name}
|
|
|
|
|
type="text"
|
|
|
|
|
disabled={!options.shared}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<label for="custom_domain_cert">Certificate</label>
|
|
|
|
|
<textarea id="custom_domain_cert" bind:value={options.custom_domain_cert} style="height: 4em;"></textarea>
|
|
|
|
|
|
|
|
|
|
<label for="custom_domain_key">Key</label>
|
|
|
|
|
<textarea id="custom_domain_key" bind:value={options.custom_domain_key} style="height: 4em;"></textarea>
|
|
|
|
|
</div>
|
|
|
|
|
</fieldset> -->
|
|
|
|
|
|
2024-02-16 21:07:01 +01:00
|
|
|
<style>
|
|
|
|
|
.center {
|
|
|
|
|
text-align: center;
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-14 11:56:52 +02:00
|
|
|
.link_grid {
|
2024-02-16 21:07:01 +01:00
|
|
|
display: grid;
|
|
|
|
|
grid-template-columns: 10fr auto;
|
|
|
|
|
align-items: center;
|
|
|
|
|
}
|
2025-05-14 11:56:52 +02:00
|
|
|
/* .form_grid {
|
|
|
|
|
display: grid;
|
|
|
|
|
grid-template-columns: 1fr;
|
|
|
|
|
align-items: center;
|
|
|
|
|
} */
|
2024-02-16 21:07:01 +01:00
|
|
|
</style>
|