Skip to content

Commit

Permalink
added Rakefile for minification
Browse files Browse the repository at this point in the history
  • Loading branch information
jmettraux committed Jun 6, 2008
1 parent 0727fd7 commit 4f52d4d
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 15 deletions.
77 changes: 76 additions & 1 deletion README.txt
@@ -1,3 +1,78 @@

not much for now.
= Reshell


== what's that ?

some kind of shell facility for the browser, inspired by the fine http://goosh.org


== how can I use it ?

It's a javascript

sudo gem install jsmin
git clone git://github.com/jmettraux/reshell.git
cd reshell
rake minify

Then you'll have a reshell-min.js file ready for your web app tree.

A simple example : http://github.com/jmettraux/reshell/tree/master/public/reshell.html

It boils down to :

<script src="/js/reshell.js"></script>

<div id="reshell_stdout"></div>
<form onsubmit="reshell.eval(); return false;">
$ <input id="reshell_stdin" type="text" />
</form>

<script>
var reshell = new Reshell('reshell');
reshell.def("alert", function(params) { alert("Aaaaalert !"); };
reshell.focus();
</script>


== base commands

clear clears the shell
env displays the current bindings in the shell environment


== mailing list

On the rufus-ruby list[http://groups.google.com/group/rufus-ruby] :

http://groups.google.com/group/rufus-ruby


== issue tracker

http://rubyforge.org/tracker/?atid=18584&group_id=4812&func=browse


== source

http://github.com/jmettraux/reshell

git clone git://github.com/jmettraux/reshell.git


== author

John Mettraux, jmettraux@gmail.com
http://jmettraux.wordpress.com


== the rest of Rufus

http://rufus.rubyforge.org


== license

MIT

36 changes: 36 additions & 0 deletions Rakefile
@@ -0,0 +1,36 @@

require 'rubygems'

require 'rake'
require 'rake/clean'
#require 'rake/packagetask'
#require 'rake/gempackagetask'
#require 'rake/rdoctask'
require 'rake/testtask'


#
# MINIFYING

require 'rubygems'
require 'jsmin' # sudo gem install jsmin

SOURCE = 'reshell.js'


#
# task minify
#
task :minify do

target = File.open "reshell-min.js", "w"

File.open "public/js/#{SOURCE}", "r" do |sourcefile|
target.puts(JSMin.minify(sourcefile))
end

puts
puts "..minified to reshell-min.js"
puts
end

36 changes: 24 additions & 12 deletions public/js/reshell.js
Expand Up @@ -35,12 +35,13 @@ var Reshell = function (prefix) {
this.stdin = document.getElementById(this.prefix+"_stdin");
this.stdout = document.getElementById(this.prefix+"_stdin");

this.puts = function (eid, clazz, text) {
this.puts = function (text, type) {

type = type || "out";

var t = document.createElement('div');
t['id'] = eid;
t.setAttribute('id', eid);
t.setAttribute('class', clazz);
t.setAttribute('id', this.prefix+"_"+type+"_"+this.count);
t.setAttribute('class', this.prefix+"_"+type);

var tt = document.createTextNode(text);

Expand All @@ -55,15 +56,17 @@ var Reshell = function (prefix) {
this.stdin.value = "";
this.stdin.focus();

var f = this.env[code];
this.puts("$ "+code, "in");

if (code == '') return;

var code = code.split(" ");
// TODO : use regex for quote oriented splits

if (f) {
f();
}
else {
this.puts("in_"+this.count, this.prefix+"_in", "$ "+code);
}
var f = this.env[code[0]];

if (f) f(code);
else this.puts("unknow command '"+code[0]+"'");

this.count++;
}
Expand All @@ -73,7 +76,8 @@ var Reshell = function (prefix) {
this.stdin.focus();
}

this.clear = function () {
this.clear = function (args) {

while(this.stdout.removeChild(this.stdout.lastChild)) {}
}

Expand All @@ -87,5 +91,13 @@ var Reshell = function (prefix) {

this.def('clear', this.clear);

this.def('env', function (args) {

var out = "";
out += "nada0\n"
out += "nada1"
this.puts(out);
});

}

4 changes: 2 additions & 2 deletions public/reshell.html
Expand Up @@ -25,7 +25,7 @@

</head>

<body>
<body onclick="reshell.focus();">

<div id="reshell_stdout"></div>
<form onsubmit="reshell.eval(); return false;">
Expand All @@ -34,7 +34,7 @@

<script>
var reshell = new Reshell('reshell');
reshell.puts("welcome", "welcome", "reshell v0.0.1 (c) 2008 john mettraux");
reshell.puts("reshell v0.0.1 (c) 2008 john mettraux");
reshell.focus();
</script>

Expand Down

0 comments on commit 4f52d4d

Please sign in to comment.