mirror of
https://github.com/mickael-kerjean/filestash
synced 2025-12-06 08:22:24 +01:00
chore (release): prepare release
This commit is contained in:
parent
db86daf867
commit
ae7e6d0801
12 changed files with 47 additions and 22 deletions
|
|
@ -31,7 +31,7 @@ export default async function main() {
|
|||
$error(msg);
|
||||
}
|
||||
}
|
||||
main();
|
||||
await main();
|
||||
|
||||
/// /////////////////////////////////////////
|
||||
async function setup_xdg_open() {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ export function isSDK() {
|
|||
|
||||
export function urlSDK(url) {
|
||||
if (url.startsWith("blob:")) return url;
|
||||
else if (url.startsWith("http://") || url.startsWith("https://")) return url;
|
||||
|
||||
const importURL = new URL(import.meta.url);
|
||||
if (new RegExp("^/").test(url) === false) {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
//
|
||||
//
|
||||
//
|
||||
import { createRender, createElement } from "./lib/skeleton/index.js";
|
||||
import { createRender } from "./lib/skeleton/index.js";
|
||||
import { loadCSS } from "./helpers/loader.js";
|
||||
|
||||
export function render(module, $app, opts = {}) {
|
||||
|
|
@ -41,14 +41,5 @@ function execute(module, $app, opts) {
|
|||
|
||||
return Promise.all(priors)
|
||||
.then(async() => await module.default(createRender($app), opts))
|
||||
.then(() => $app.appendChild(poweredBy()))
|
||||
.catch((err) => console.error(err));
|
||||
}
|
||||
|
||||
function poweredBy($app) {
|
||||
return createElement(`
|
||||
<div style="position: absolute; bottom: 0; left: 0; font-size: 0.9rem; display: inline-block; z-index: 2">
|
||||
Powered By <a href="https://www.filestash.app" style="text-decoration:underline;">Filestash</a>
|
||||
</div>
|
||||
`);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ export default function(opts) {
|
|||
opts.headers["X-Requested-With"] = "XmlHttpRequest";
|
||||
if (window.BEARER_TOKEN) opts.headers["Authorization"] = `Bearer ${window.BEARER_TOKEN}`;
|
||||
|
||||
if (opts.url.startsWith("data:")) return rxjs.of({ response: parseDataUrl(opts.url) });
|
||||
if (isSDK()) {
|
||||
if (["/api/config"].indexOf(opts.url) === -1) opts.withCredentials = false;
|
||||
opts.url = urlSDK(opts.url);
|
||||
|
|
@ -36,6 +37,26 @@ export default function(opts) {
|
|||
);
|
||||
}
|
||||
|
||||
function parseDataUrl(url) {
|
||||
const matches = url.match(/^data:(.*?)(;base64)?,(.*)$/);
|
||||
if (!matches) throw new Error("Invalid Data URL");
|
||||
|
||||
const isBase64 = !!matches[2];
|
||||
const data = matches[3];
|
||||
if (isBase64) {
|
||||
const binaryString = atob(data);
|
||||
const len = binaryString.length;
|
||||
const bytes = new Uint8Array(len);
|
||||
for (let i = 0; i < len; i++) {
|
||||
bytes[i] = binaryString.charCodeAt(i);
|
||||
}
|
||||
return bytes.buffer;
|
||||
}
|
||||
const decodedData = decodeURIComponent(data);
|
||||
const encoder = new TextEncoder();
|
||||
return encoder.encode(decodedData).buffer;
|
||||
}
|
||||
|
||||
function processError(xhr, err) {
|
||||
let responseText = "";
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import { AjaxError, ApplicationError } from "../lib/error.js";
|
|||
import "../components/icon.js";
|
||||
|
||||
export default function(render) {
|
||||
let hasBack = true;
|
||||
let hasBack = window.self === window.top;
|
||||
if (!render) {
|
||||
render = createRender(document.body);
|
||||
try { render = createRender(qs(document.body, "[role=\"main\"]")); }
|
||||
|
|
@ -21,10 +21,13 @@ export default function(render) {
|
|||
const [msg, trace] = processError(err);
|
||||
|
||||
const shouldRedirectLogin = err instanceof AjaxError && err.err().status === 401;
|
||||
let link = forwardURLParams(calculateBacklink(fromHref(window.location.pathname)), ["share"]);
|
||||
let link = "";
|
||||
if (hasBack) {
|
||||
link = forwardURLParams(calculateBacklink(fromHref(window.location.pathname)), ["share"]);
|
||||
if (shouldRedirectLogin) {
|
||||
link = fromHref("/login?next=" + encodeURIComponent(forwardURLParams(fromHref(window.location.pathname), ["share"])));
|
||||
}
|
||||
}
|
||||
const $page = createElement(`
|
||||
<div>
|
||||
<style>${css}</style>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ body:not(.dark-mode) .component_imageviewer .component_image_container .fullscre
|
|||
display: flex;
|
||||
overflow: hidden;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,10 +18,10 @@ import componentPager, { init as initPager } from "./component_pager.js";
|
|||
|
||||
import { renderMenubar, buttonDownload, buttonFullscreen } from "./component_menubar.js";
|
||||
|
||||
export default function(render, { getFilename, getDownloadUrl }) {
|
||||
export default function(render, { getFilename, getDownloadUrl, hasMenubar = true }) {
|
||||
const $page = createElement(`
|
||||
<div class="component_imageviewer">
|
||||
<component-menubar filename="${getFilename()}"></component-menubar>
|
||||
<component-menubar filename="${getFilename()}" class="${!hasMenubar && "hidden"}"></component-menubar>
|
||||
<div class="component_image_container">
|
||||
<div class="images_wrapper">
|
||||
<img class="photo idle hidden" src="${getDownloadUrl()}&size=${window.innerWidth}">
|
||||
|
|
@ -93,6 +93,7 @@ export default function(render, { getFilename, getDownloadUrl }) {
|
|||
export function init() {
|
||||
return Promise.all([
|
||||
loadCSS(import.meta.url, "./application_image.css"),
|
||||
loadCSS(import.meta.url, "./component_menubar.css"),
|
||||
initPager(), initMetadata(),
|
||||
]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class IMap {
|
|||
toGeoJSON() { throw new Error("NOT_IMPLEMENTED"); }
|
||||
}
|
||||
|
||||
export default async function(render, { mime, getDownloadUrl = nop, getFilename = nop, acl$ }) {
|
||||
export default async function(render, { mime, getDownloadUrl = nop, getFilename = nop, acl$ = rxjs.EMPTY }) {
|
||||
const $page = createElement(`
|
||||
<div class="component_map">
|
||||
<component-menubar filename="${getFilename() || ""}"></component-menubar>
|
||||
|
|
@ -33,7 +33,11 @@ export default async function(render, { mime, getDownloadUrl = nop, getFilename
|
|||
rxjs.mergeMap(async({ response }) => {
|
||||
const loader = await loadPlugin(mime);
|
||||
if (!loader) {
|
||||
componentDownloader(render, { mime, acl$, getFilename, getDownloadUrl });
|
||||
try {
|
||||
loadGeoJSON(map, JSON.parse(new TextDecoder().decode(response)));
|
||||
window.L.tileLayer("https://tile.openstreetmap.org/{z}/{x}/{y}.png", { maxZoom: 21 }).addTo(map);
|
||||
}
|
||||
catch (err) { componentDownloader(render, { mime, acl$, getFilename, getDownloadUrl }); }
|
||||
return rxjs.EMPTY;
|
||||
}
|
||||
const mapImpl = new (await loader(IMap))(response, {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@
|
|||
height: 100%;
|
||||
background: var(--bg-color);
|
||||
}
|
||||
.component_table_container:has(.component_loader) .table {
|
||||
display: none;
|
||||
}
|
||||
.component_tableviewer component-menubar input[type="search"] {
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
border: none;
|
||||
|
|
|
|||
|
|
@ -141,6 +141,7 @@ export default async function(render, { mime, getDownloadUrl = nop, getFilename
|
|||
export function init() {
|
||||
return Promise.all([
|
||||
loadCSS(import.meta.url, "./application_table.css"),
|
||||
loadCSS(import.meta.url, "./component_menubar.css"),
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -192,7 +193,7 @@ function buildHead(STATE, $dom, padding) {
|
|||
$img.style.transform = "rotate(0deg)";
|
||||
});
|
||||
if (ascending) e.target.style.transform = "rotate(180deg)";
|
||||
$dom.tbody.scrollTo(0, 0);
|
||||
$dom.tbody.scrollTo($dom.tbody.scrollLeft, 0);
|
||||
buildRows(STATE.rows.slice(0, MAX_ROWS), STATE.header, $dom.tbody, padding, false, true);
|
||||
};
|
||||
$tr.appendChild($th);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
const VERSION = "v1";
|
||||
const CACHENAME = "assets";
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ func Build(a App) *mux.Router {
|
|||
// Application Resources
|
||||
middlewares = []Middleware{ApiHeaders, SecureHeaders, PluginInjector}
|
||||
r.HandleFunc(WithBase("/api/backend"), NewMiddlewareChain(AdminBackend, middlewares, a)).Methods("GET")
|
||||
r.HandleFunc(WithBase("/api/plugin"), NewMiddlewareChain(PluginExportHandler, middlewares, a)).Methods("GET")
|
||||
r.HandleFunc(WithBase("/api/plugin"), NewMiddlewareChain(PluginExportHandler, append(middlewares, PublicCORS), a)).Methods("GET", "OPTIONS")
|
||||
r.HandleFunc(WithBase("/api/config"), NewMiddlewareChain(PublicConfigHandler, append(middlewares, PublicCORS), a)).Methods("GET", "OPTIONS")
|
||||
middlewares = []Middleware{StaticHeaders, SecureHeaders, PublicCORS, PluginInjector}
|
||||
if os.Getenv("CANARY") == "" { // TODO: remove after migration is done
|
||||
|
|
|
|||
Loading…
Reference in a new issue