chore (canary): canary release for rewrite

This commit is contained in:
MickaelK
2024-06-24 23:19:40 +10:00
parent d020f4c1bd
commit 4f6ceb3fa0
5 changed files with 33 additions and 33 deletions

View File

@ -392,7 +392,7 @@ function workerImplDirectory({ error, progress }) {
async function processFiles(filelist) { // TODO
const files = [];
const detectFiletype = (file) => {
// the 4096 is an heuristic I've observed and taken from:
// the 4096 is an heuristic observed and taken from:
// https://stackoverflow.com/questions/25016442
// however the proposed answer is just wrong as it doesn't consider folder with
// name such as: test.png and as Stackoverflow favor consanguinity with their
@ -413,10 +413,13 @@ async function processFiles(filelist) { // TODO
for (const currentFile of filelist) {
const type = await detectFiletype(currentFile);
const file = { type, date: currentFile.lastModified, name: currentFile.name, path: currentFile.name };
if (type === "directory") file.path += "/";
else if (type === "file") {
fs.push({ type: "file", path, exec: workerImplFile, entry: currentFile });
} else assert.fail(`NOT_SUPPORTED type="${type}"`, type);
if (type === "directory") {
file.path += "/";
} else if (type === "file") {
file.entry = currentFile;
} else {
assert.fail(`NOT_SUPPORTED type="${type}"`, type);
}
file.exec = workerImplFile.bind(file);
files.push(file);
}

View File

@ -64,7 +64,7 @@ export default async function(render) {
rxjs.mergeMap((arr) => rxjs.from(loadMode(extname(getFilename()))).pipe(
rxjs.map((mode) => arr.concat([mode])),
)),
rxjs.mergeMap((arr) => options(getCurrentPath()).pipe(
rxjs.mergeMap((arr) => options().pipe(
rxjs.map((acl) => arr.concat([acl])),
)),
)),
@ -145,13 +145,11 @@ export default async function(render) {
$fab.classList.remove("hidden");
$fab.render($ICON.LOADING);
$fab.disabled = true;
return rxjs.of(cm.getValue()).pipe(
save(),
rxjs.tap((content) => {
const content = cm.getValue();
return save(content).pipe(rxjs.tap(() => {
$fab.removeAttribute("disabled");
content$.next(content);
}),
);
}));
}),
rxjs.catchError(ctrlError()),
));
@ -175,7 +173,10 @@ export default async function(render) {
);
});
if (userAction === MODAL_RIGHT_BUTTON) {
console.log("TODO: SAVE THE DATA");
const $fab = $dom.fab();
$fab.render($ICON.LOADING);
$fab.disabled = true;
await save(cm.getValue()).toPromise();
}
return false;
}),

View File

@ -7,8 +7,9 @@ import { createForm } from "../../lib/form.js";
import { formTmpl } from "../../components/form.js";
import ctrlError from "../ctrl_error.js";
import { transition, getFile$, saveFile$ } from "./common.js";
import { transition } from "./common.js";
import { $ICON } from "./common_fab.js";
import { cat, save } from "./model_files.js";
import "../../components/icon.js";
import "../../components/menubar.js";
@ -35,7 +36,7 @@ export default function(render) {
const file$ = new rxjs.ReplaySubject(1);
// feature1: setup the dom
effect(getFile$().pipe(
effect(cat().pipe(
rxjs.map((content) => JSON.parse(content)),
rxjs.mergeMap((formSpec) => rxjs.from(createForm(formSpec, formTmpl({
renderLeaf: ({ label, format, description, required }) => createElement(`
@ -100,8 +101,9 @@ export default function(render) {
$fab.disabled = true;
}),
rxjs.mergeMap(($fab) => rxjs.of(JSON.stringify(formState())).pipe(
saveFile$(),
rxjs.mergeMap(() => getFile$().pipe(rxjs.tap((formSpec) => file$.next(JSON.parse(formSpec))))),
rxjs.tap((a) => console.log(a)),
// rxjs.mergeMap((content) => save(content)),
rxjs.mergeMap(() => cat().pipe(rxjs.tap((formSpec) => file$.next(JSON.parse(formSpec))))),
)),
rxjs.tap(() => {
$fab.render($ICON.SAVING);

View File

@ -1,9 +1,9 @@
import rxjs from "../../lib/rx.js";
import ajax from "../../lib/ajax.js";
import { getDownloadUrl } from "./common.js";
import { getDownloadUrl, getCurrentPath } from "./common.js";
export const options = (path) => ajax({
url: `api/files/cat?path=${path}`,
export const options = () => ajax({
url: `api/files/cat?path=${encodeURIComponent(getCurrentPath())}`,
method: "OPTIONS",
}).pipe(rxjs.map((res) => res.responseHeaders.allow.replace(/\r/, "").split(", ")));
@ -11,9 +11,8 @@ export const cat = () => ajax(getDownloadUrl()).pipe(
rxjs.map(({ response }) => response),
);
export const save = () => {
return rxjs.pipe(
rxjs.delay(2000),
rxjs.tap((content) => console.log("SAVED")),
);
};
export const save = (content) => ajax({
url: getDownloadUrl(),
method: "POST",
body: content,
});

View File

@ -194,11 +194,6 @@ func ServeBackofficeHandler(ctx *App, res http.ResponseWriter, req *http.Request
}
func ServeFrontofficeHandler(ctx *App, res http.ResponseWriter, req *http.Request) {
url := req.URL.Path
if filepath.Ext(filepath.Base(url)) != "" {
ServeFile("/")(ctx, res, req)
return
}
ua := req.Header.Get("User-Agent")
if strings.Contains(ua, "MSIE ") || strings.Contains(ua, "Trident/") || strings.Contains(ua, "Edge/") {
// Microsoft is behaving on many occasion differently than Firefox / Chrome.
@ -214,7 +209,7 @@ func ServeFrontofficeHandler(ctx *App, res http.ResponseWriter, req *http.Reques
`)))
return
}
url = TrimBase(req.URL.Path)
url := TrimBase(req.URL.Path)
if url != "/" && strings.HasPrefix(url, "/s/") == false &&
strings.HasPrefix(url, "/view/") == false && strings.HasPrefix(url, "/files/") == false &&
url != "/login" && url != "/logout" && strings.HasPrefix(url, "/tags") == false {