Improving cat, implementing wget (thanks tragic0mic)
This commit is contained in:
parent
b1b6206baa
commit
66562780cf
7 changed files with 99 additions and 5 deletions
|
@ -35,7 +35,10 @@
|
|||
} else if ( dir[i].link_to && dir[i].link_to.length > 0 ) {
|
||||
return this.action ( dir[i].link_to );
|
||||
} else if ( dir[i].content ) {
|
||||
return '<pre>' + dir[i].content + "</pre>";
|
||||
var replaced=dir[i].content.replace(/(https?:\/\/(www\.)?[0-9a-zA-Z-_\.\/:]*)/g, "<a href='$1'>$1</a>");
|
||||
replaced = replaced.replace(".'>", "'>");
|
||||
replaced = replaced.replace(".</a>", "</a>.");
|
||||
return "<pre>"+replaced+"</pre>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
16
commands/chown.js
Normal file
16
commands/chown.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"name" : "chown",
|
||||
|
||||
"info" : {
|
||||
"syntax" : "chown <new_user> <file|directory>",
|
||||
"brief" : "Change the access permissions to a file or directory for one or more users or groups, example: \"chmod user1,user2,@group1,@group2+r /path\", \"chmod @all+rw /path\""
|
||||
},
|
||||
|
||||
"action" : function ( arg )
|
||||
{
|
||||
var out = '';
|
||||
|
||||
if ( !arg.match ( /^\s*([^+|-]*)(\+|\-)((r|w)+)\s+(.+)\s*$/ ))
|
||||
{
|
||||
return "Usage: " + this.info.syntax + "<br/>\n";
|
||||
}
|
58
commands/wget.json
Normal file
58
commands/wget.json
Normal file
|
@ -0,0 +1,58 @@
|
|||
{
|
||||
"name" : "wget",
|
||||
|
||||
"info" : {
|
||||
"syntax" : "wget <file>",
|
||||
"brief" : "Creates a static textual version of the selected file, suitable for download",
|
||||
},
|
||||
|
||||
"action" : function ( arg )
|
||||
{
|
||||
var out = '';
|
||||
var found = false;
|
||||
var dir = shell.files;
|
||||
|
||||
if ( !arg || arg.length == 0 )
|
||||
{
|
||||
return "Argument required<br/>\n";
|
||||
}
|
||||
|
||||
arg = shell.expandPath ( arg );
|
||||
|
||||
for ( var i=0; i < dir.length && !found; i++ )
|
||||
{
|
||||
if ( dir[i].path == arg )
|
||||
{
|
||||
found = true;
|
||||
|
||||
if ( dir[i].type == 'directory' )
|
||||
{
|
||||
return "wget: " + dir[i].path + ": Is a directory<br/>\n";
|
||||
} else {
|
||||
if ( dir[i].content ) {
|
||||
var wgetWin = window.open("_blank","");
|
||||
if(wgetWin)
|
||||
{
|
||||
wgetWin.document.write(dir[i].content);
|
||||
return "<br />";
|
||||
}
|
||||
else
|
||||
return "wget: cannot open new window.<br />";
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( !found )
|
||||
{
|
||||
arg = arg.replace ( '<', '<' );
|
||||
arg = arg.replace ( '>', '>' );
|
||||
return "wget: " + arg + ": No such file or directory<br/>\n";
|
||||
}
|
||||
|
||||
out = out.replace ( /<br\/?>\s*$/, '' );
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Blash - An AJAX interactive shell emulator for web browsing</title>
|
||||
<title>blash</title>
|
||||
<script type="text/javascript" language="javascript" src="system/blash.js"></script>
|
||||
<script type="text/javascript" language="javascript" src="system/md5.js"></script>
|
||||
<link rel="stylesheet" href="blash.css" type="text/css">
|
||||
|
|
|
@ -850,6 +850,25 @@ function blash ()
|
|||
}
|
||||
}
|
||||
|
||||
if ( arg.match ( /\*/ ))
|
||||
{
|
||||
args = shell.expandStar ( arg );
|
||||
|
||||
if ( args.length == 1 )
|
||||
{
|
||||
return args[0].path;
|
||||
} else {
|
||||
var out = '';
|
||||
|
||||
for ( var i in args )
|
||||
{
|
||||
out += args[i].path + ' ';
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
||||
return arg;
|
||||
}
|
||||
|
||||
|
|
|
@ -78,6 +78,7 @@
|
|||
"useradd",
|
||||
"userdel",
|
||||
"users",
|
||||
"wget",
|
||||
"whoami"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -10,9 +10,6 @@ $files_json = <<<JSON
|
|||
, {"path": "/software", "type": "directory"}
|
||||
, {"path": "/etc", "type": "directory"}
|
||||
, {"path": "/home", "type": "directory"}
|
||||
, {"path": "/blog/post1", "type": "file", "content": "This is my first post"}
|
||||
, {"path": "/blog/post2", "type": "file", "content": "This is my second post"}
|
||||
, {"path": "/blog/post3", "type": "file", "content": "This is my third post"}
|
||||
, {"path": "/etc/blashrc", "type": "file", "content": "This is the default blash configuration file"}
|
||||
, {"path": "/forum/post1", "type": "file", "content": "lol"}
|
||||
, {"path": "/forum/post2", "type": "file", "content": "lol"}
|
||||
|
|
Loading…
Reference in a new issue