mirror of
https://github.com/osnr/TabFS.git
synced 2024-05-19 14:06:34 +02:00
add window symlink in tab folder
This commit is contained in:
parent
f3ea7349c0
commit
ab34a525dc
|
@ -242,6 +242,13 @@ router["/tabs/by-id"] = {
|
||||||
router["/tabs/by-id/*/title.txt"] = withTab(tab => tab.title + "\n");
|
router["/tabs/by-id/*/title.txt"] = withTab(tab => tab.title + "\n");
|
||||||
router["/tabs/by-id/*/text.txt"] = fromScript(`document.body.innerText`);
|
router["/tabs/by-id/*/text.txt"] = fromScript(`document.body.innerText`);
|
||||||
})();
|
})();
|
||||||
|
router["/tabs/by-id/*/window"] = {
|
||||||
|
// a symbolic link to /windows/[id for this window]
|
||||||
|
async readlink({path}) {
|
||||||
|
const tabId = parseInt(pathComponent(path, -2)); const tab = await browser.tabs.get(tabId);
|
||||||
|
return { buf: "../../../windows/" + tab.windowId };
|
||||||
|
}
|
||||||
|
};
|
||||||
router["/tabs/by-id/*/control"] = {
|
router["/tabs/by-id/*/control"] = {
|
||||||
// echo remove > mnt/tabs/by-id/1644/control
|
// echo remove > mnt/tabs/by-id/1644/control
|
||||||
async write({path, buf}) {
|
async write({path, buf}) {
|
||||||
|
@ -318,9 +325,9 @@ router["/tabs/by-id/*/control"] = {
|
||||||
})();
|
})();
|
||||||
|
|
||||||
router["/tabs/by-title"] = {
|
router["/tabs/by-title"] = {
|
||||||
getattr() {
|
getattr() {
|
||||||
return {
|
return {
|
||||||
st_mode: unix.S_IFDIR | 0777, // writable
|
st_mode: unix.S_IFDIR | 0777, // writable so you can delete tabs
|
||||||
st_nlink: 3,
|
st_nlink: 3,
|
||||||
st_size: 0,
|
st_size: 0,
|
||||||
};
|
};
|
||||||
|
@ -331,8 +338,8 @@ router["/tabs/by-title"] = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
router["/tabs/by-title/*"] = {
|
router["/tabs/by-title/*"] = {
|
||||||
// a symbolic link to /tabs/by-id/[id for this tab]
|
// TODO: date
|
||||||
async readlink({path}) {
|
async readlink({path}) { // a symbolic link to /tabs/by-id/[id for this tab]
|
||||||
const parts = path.split("_"); const tabId = parts[parts.length - 1];
|
const parts = path.split("_"); const tabId = parts[parts.length - 1];
|
||||||
return { buf: "../by-id/" + tabId };
|
return { buf: "../by-id/" + tabId };
|
||||||
},
|
},
|
||||||
|
@ -434,7 +441,7 @@ for (let i = 10; i >= 0; i--) {
|
||||||
if (TESTING) { // I wish I could color this section with... a pink background, or something.
|
if (TESTING) { // I wish I could color this section with... a pink background, or something.
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
(async () => {
|
(async () => {
|
||||||
assert.deepEqual(await router['/tabs/by-id/*'].readdir(), { entries: ['.', '..', 'url.txt', 'title.txt', 'text.txt', 'control', 'debugger'] });
|
assert.deepEqual(await router['/tabs/by-id/*'].readdir(), { entries: ['.', '..', 'url.txt', 'title.txt', 'text.txt', 'window', 'control', 'debugger'] });
|
||||||
assert.deepEqual(await router['/'].readdir(), { entries: ['.', '..', 'windows', 'extensions', 'tabs', 'runtime'] });
|
assert.deepEqual(await router['/'].readdir(), { entries: ['.', '..', 'windows', 'extensions', 'tabs', 'runtime'] });
|
||||||
assert.deepEqual(await router['/tabs'].readdir(), { entries: ['.', '..', 'create', 'by-id', 'by-title', 'last-focused'] });
|
assert.deepEqual(await router['/tabs'].readdir(), { entries: ['.', '..', 'create', 'by-id', 'by-title', 'last-focused'] });
|
||||||
|
|
||||||
|
|
2
test.c
2
test.c
|
@ -24,7 +24,7 @@ char* expand(char* phrase) { // expand path with wildcard
|
||||||
|
|
||||||
// integration tests
|
// integration tests
|
||||||
int main() {
|
int main() {
|
||||||
assert(system("node extension/background.js") == 0); // run quick local JS tests
|
assert(system("node extension/background.js --unhandled-rejections=strict") == 0); // run quick local JS tests
|
||||||
|
|
||||||
// reload the extension so we know it's the latest code.
|
// reload the extension so we know it's the latest code.
|
||||||
system("echo reload > fs/mnt/runtime/reload"); // this may error, but it should still have effect
|
system("echo reload > fs/mnt/runtime/reload"); // this may error, but it should still have effect
|
||||||
|
|
Loading…
Reference in a new issue