fix bug in vfs link resolution, add some files

This commit is contained in:
Lisa Milne 2023-11-09 14:02:20 +10:00
parent ae1b79a286
commit 43ada86383
5 changed files with 63 additions and 7 deletions

View file

@ -94,7 +94,8 @@ var clite = {
var d = `
clite/core.js:/usr/clite/core.js:0:0:-rw-r-----
clite/core.css:/usr/clite/web/core.css:0:0:-rw-r-----
data/intro:/usr/share/introduction:0:0:-rw-rw-r--`;
data/intro.txt:/usr/share/introduction:0:0:-rw-rw-r--
data/about.txt:/usr/share/site/about:0:0:-rw-rw-r--`;
init2(d);
return;
}
@ -531,7 +532,12 @@ clite.vfs = {
var n = vfsdata.fs;
var parts = path.split('/');
while (parts.length > 0) {
if (!n.data.isdir || !checkCanOpen(n))
if (!checkCanOpen(n))
return null;
if (n.data.islink) {
n = vfsdata.api.getNode(n.data.content);
}
if (!n.data.isdir)
return null;
var p = parts.shift();
if (!p || p == '')
@ -749,6 +755,48 @@ clite.term = {
if (typeof clite.state.input.type == 'object' && typeof clite.state.input.type.type == 'string')
return clite.state.input.type.type;
return 'text';
},
api:{
clear:function() { // clears the terminal
clite.term.clear(false);
},
getTTY:function() { // gets an empty element with key events (allows view/less to display content in a clean element)
var tty = {
handleKeys:function(cb) {
this.data.cb = cb;
},
draw:function(data) {
if (typeof data == 'string') {
this.data.el.innerHTML += data;
return true;
}else if (data instanceof HTMLImageElement) {
this.data.el.appendChild(data);
return true;
}
return false;
},
data:{
cb:null,
el:null,
onkeypress:function(e) {
try{
this.cb(e);
}catch(err) {}
return false;
}
}
};
tty.data.el = document.createElement('div');
tty.data.el.onkeypress = tty.data.onkeypress;
var p = document.getElementById('terminal').parentNode;
p.appendChild(tty.data.el);
tty.data.el.focus();
return tty;
},
dropTTY:function(tty) {
tty.data.el.parentNode.removeChild(tty.data.el);
delete tty;
}
}
};
@ -796,6 +844,9 @@ clite.shell = {
case 'stdio':
return clite.io;
break;
case 'term':
return clite.term.api;
break;
default:
return null;
break;

4
data/about.txt Normal file
View file

@ -0,0 +1,4 @@
Welcome, this site runs on CLIte, the command line site management system.
CLIte works like a Unix terminal, a guest login will be automatically generated for you.
CLIte has many Unix-like commands for navigating the website, simply type in a command and press enter to run it.
Not sure how this works? Use the `help' command at any time.

View file

@ -11,4 +11,5 @@
clite/core.js:/usr/clite/core.js:0:0:-rw-r-----
clite/core.css:/usr/clite/web/core.css:0:0:-rw-r-----
data/intro:/usr/share/introduction:0:0:-rw-rw-r--
data/intro.txt:/usr/share/introduction:0:0:-rw-rw-r--
data/about.txt:/usr/share/site/about:0:0:-rw-rw-r--

View file

@ -1,4 +0,0 @@
Welcome, this site runs on Clite, the command line site management system.
Clite works like a Unix terminal, a guest login will be automatically generated for you.
Clite has many Unix-like commands for navigating the website, simply type in a command and press enter to run it.
Not sure how this works? Use the `help' command at any time.

4
data/intro.txt Normal file
View file

@ -0,0 +1,4 @@
Welcome, this site runs on CLIte, the command line site management system.
CLIte works like a Unix terminal, a guest login will be automatically generated for you.
CLIte has many Unix-like commands for navigating the website, simply type in a command and press enter to run it.
Not sure how this works? Use the `help' command at any time.