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 async function processFiles(filelist) { // TODO
const files = []; const files = [];
const detectFiletype = (file) => { 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 // https://stackoverflow.com/questions/25016442
// however the proposed answer is just wrong as it doesn't consider folder with // 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 // 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) { for (const currentFile of filelist) {
const type = await detectFiletype(currentFile); const type = await detectFiletype(currentFile);
const file = { type, date: currentFile.lastModified, name: currentFile.name, path: currentFile.name }; const file = { type, date: currentFile.lastModified, name: currentFile.name, path: currentFile.name };
if (type === "directory") file.path += "/"; if (type === "directory") {
else if (type === "file") { file.path += "/";
fs.push({ type: "file", path, exec: workerImplFile, entry: currentFile }); } else if (type === "file") {
} else assert.fail(`NOT_SUPPORTED type="${type}"`, type); file.entry = currentFile;
} else {
assert.fail(`NOT_SUPPORTED type="${type}"`, type);
}
file.exec = workerImplFile.bind(file); file.exec = workerImplFile.bind(file);
files.push(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.mergeMap((arr) => rxjs.from(loadMode(extname(getFilename()))).pipe(
rxjs.map((mode) => arr.concat([mode])), rxjs.map((mode) => arr.concat([mode])),
)), )),
rxjs.mergeMap((arr) => options(getCurrentPath()).pipe( rxjs.mergeMap((arr) => options().pipe(
rxjs.map((acl) => arr.concat([acl])), rxjs.map((acl) => arr.concat([acl])),
)), )),
)), )),
@ -145,13 +145,11 @@ export default async function(render) {
$fab.classList.remove("hidden"); $fab.classList.remove("hidden");
$fab.render($ICON.LOADING); $fab.render($ICON.LOADING);
$fab.disabled = true; $fab.disabled = true;
return rxjs.of(cm.getValue()).pipe( const content = cm.getValue();
save(), return save(content).pipe(rxjs.tap(() => {
rxjs.tap((content) => { $fab.removeAttribute("disabled");
$fab.removeAttribute("disabled"); content$.next(content);
content$.next(content); }));
}),
);
}), }),
rxjs.catchError(ctrlError()), rxjs.catchError(ctrlError()),
)); ));
@ -175,7 +173,10 @@ export default async function(render) {
); );
}); });
if (userAction === MODAL_RIGHT_BUTTON) { 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; return false;
}), }),

View File

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

View File

@ -1,9 +1,9 @@
import rxjs from "../../lib/rx.js"; import rxjs from "../../lib/rx.js";
import ajax from "../../lib/ajax.js"; import ajax from "../../lib/ajax.js";
import { getDownloadUrl } from "./common.js"; import { getDownloadUrl, getCurrentPath } from "./common.js";
export const options = (path) => ajax({ export const options = () => ajax({
url: `api/files/cat?path=${path}`, url: `api/files/cat?path=${encodeURIComponent(getCurrentPath())}`,
method: "OPTIONS", method: "OPTIONS",
}).pipe(rxjs.map((res) => res.responseHeaders.allow.replace(/\r/, "").split(", "))); }).pipe(rxjs.map((res) => res.responseHeaders.allow.replace(/\r/, "").split(", ")));
@ -11,9 +11,8 @@ export const cat = () => ajax(getDownloadUrl()).pipe(
rxjs.map(({ response }) => response), rxjs.map(({ response }) => response),
); );
export const save = () => { export const save = (content) => ajax({
return rxjs.pipe( url: getDownloadUrl(),
rxjs.delay(2000), method: "POST",
rxjs.tap((content) => console.log("SAVED")), 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) { 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") ua := req.Header.Get("User-Agent")
if strings.Contains(ua, "MSIE ") || strings.Contains(ua, "Trident/") || strings.Contains(ua, "Edge/") { if strings.Contains(ua, "MSIE ") || strings.Contains(ua, "Trident/") || strings.Contains(ua, "Edge/") {
// Microsoft is behaving on many occasion differently than Firefox / Chrome. // 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 return
} }
url = TrimBase(req.URL.Path) url := TrimBase(req.URL.Path)
if url != "/" && strings.HasPrefix(url, "/s/") == false && if url != "/" && strings.HasPrefix(url, "/s/") == false &&
strings.HasPrefix(url, "/view/") == false && strings.HasPrefix(url, "/files/") == false && strings.HasPrefix(url, "/view/") == false && strings.HasPrefix(url, "/files/") == false &&
url != "/login" && url != "/logout" && strings.HasPrefix(url, "/tags") == false { url != "/login" && url != "/logout" && strings.HasPrefix(url, "/tags") == false {