diff --git a/clite/core.js b/clite/core.js index bd8cb82..96a801d 100644 --- a/clite/core.js +++ b/clite/core.js @@ -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; diff --git a/data/about.txt b/data/about.txt new file mode 100644 index 0000000..6f58b39 --- /dev/null +++ b/data/about.txt @@ -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. diff --git a/data/filesys.txt b/data/filesys.txt index ab2cad1..e259557 100644 --- a/data/filesys.txt +++ b/data/filesys.txt @@ -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-- diff --git a/data/intro b/data/intro deleted file mode 100644 index 9627a0f..0000000 --- a/data/intro +++ /dev/null @@ -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. diff --git a/data/intro.txt b/data/intro.txt new file mode 100644 index 0000000..6f58b39 --- /dev/null +++ b/data/intro.txt @@ -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.