# HG changeset patch # User Pascal Bellard # Date 1230560827 0 # Node ID 4da64a9e223217ba8b2331bf7244599bb34d1027 # Parent 5117bf55356232d4640b660342a3f42afb0e19c5 Add ajaxterm diff -r 5117bf553562 -r 4da64a9e2232 ajaxterm/receipt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ajaxterm/receipt Mon Dec 29 14:27:07 2008 +0000 @@ -0,0 +1,101 @@ +# SliTaz package receipt. + +PACKAGE="ajaxterm" +VERSION="0.10" +CATEGORY="network" +SHORT_DESC="Login terminal for the web." +MAINTAINER="pascal.bellard@slitaz.org" +SOURCE="Ajaxterm" +TARBALL="$SOURCE-$VERSION.tar.gz" +WEB_SITE="http://antony.lesuisse.org/qweb/trac/wiki/AjaxTerm" +WGET_URL="http://antony.lesuisse.org/qweb/files/$TARBALL" +DEPENDS="python" +SUGGESTED="apache lighttpd-ssl lighttpd-modules" + +# Rules to gen a SliTaz package suitable for Tazpkg. +genpkg_rules() +{ + mkdir -p $fs/usr/share/ajaxterm + cp -a $src/*.py $src/*.js $src/*.css $src/*.html $fs/usr/share/ajaxterm + cp -a stuff/* $fs/ +} + +post_install() +{ + grep ^RUN_DAEMONS $1/etc/rcS.conf | grep -q "ajaxterm" || sed -i \ + 's/RUN_DAEMONS="slim/RUN_DAEMONS="slim ajaxterm/' $1/etc/rcS.conf + # Configure lighttpd server + if [ -f $1/usr/lib/lighttpd/mod_proxy.so ]; then +#https://www.dupnet.org/dotclear/index.php/2007/10/07/11-ajaxterm-et-lighttpd +#http://www.lighttpd.net + grep -q mod_proxy $1/etc/lighttpd/lighttpd.conf || + cat >> $1/etc/lighttpd/lighttpd.conf <> $1/etc/lighttpd/lighttpd.conf < + ( ( "host" => "127.0.0.1", "port" => 8022 ) ) +) +EOT + grep -q mod_redirect $1/etc/lighttpd/lighttpd.conf || + cat >> $1/etc/lighttpd/lighttpd.conf <> $1/etc/lighttpd/lighttpd.conf < "https://%1/ajaxterm/" ) + } +} +EOT + if [ -z "$1" ]; then + # Start Web server. + /etc/init.d/lighttpd stop + /etc/init.d/lighttpd start + fi + fi + # Configure apache server + if [ -f $1/etc/apache/httpd.conf ]; then +#http://smhteam.info/wiki/index.linux.php5?wiki=AjaxTerm + if [ ! -f $1/etc/apache/conf.d/ajaxterm ]; then + cat > $1/etc/apache/conf.d/ajaxterm < + ProxyRequests Off + + Order deny,allow + Allow from all + + ProxyPass /ajaxterm/ http://localhost:8022/ + ProxyPassReverse /ajaxterm/ http://localhost:8022/ + + + + RewriteEngine On + RewriteCond %{SERVER_PORT} !^443$ + RewriteRule ^/ajaxterm https://%{SERVER_NAME}/ajaxterm/ [L,R=303] + +EOT + if [ -z "$1" ]; then + # Start Web server. + /etc/init.d/apache stop + sleep 2 + /etc/init.d/apache start + fi + fi + fi + [ -z "$1" ] && /etc/init.d/ajaxterm start + [ ! -f $1/usr/lib/lighttpd/mod_proxy.so -a \ + ! -f $1/etc/apache/httpd.conf ] && cat <more info'); + return undefined; + } + var clip = Components.classes["@mozilla.org/widget/clipboard;1"].createInstance(Components.interfaces.nsIClipboard); + var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable); + if (!clip || !trans) { + return undefined; + } + trans.addDataFlavor("text/unicode"); + clip.getData(trans,clip.kGlobalClipboard); + var str=new Object(); + var strLength=new Object(); + try { + trans.getTransferData("text/unicode",str,strLength); + } catch(err) { + return ""; + } + if (str) { + str=str.value.QueryInterface(Components.interfaces.nsISupportsString); + } + if (str) { + return str.data.substring(0,strLength.value / 2); + } else { + return ""; + } + } + function do_paste(event) { + var p=undefined; + if (window.clipboardData) { + p=window.clipboardData.getData("Text"); + } else if(window.netscape) { + p=mozilla_clipboard(); + } + if (p) { + debug('Pasted'); + queue(encodeURIComponent(p)); + } else { + } + } + function do_popup(event) { + window.open(''+self.location,'',popupargs); + } + function do_close(event) { + window.close(); + } + function update() { +// debug("ts: "+((new Date).getTime())+" rmax:"+rmax); + if(debugmsg==0) sdebug.innerHTML=(new Date).toString(); + if(sending==0) { + sending=1; + sled.className='on'; + var r=new XMLHttpRequest(); + var send=""; + while(keybuf.length>0) { + send+=keybuf.pop(); + } + var query=query1+send; + if(opt_get.className=='on') { + r.open("GET","u?"+query,true); + if(ie) { + r.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); + } + } else { + r.open("POST","u",true); + } + r.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); + r.onreadystatechange = function () { +// debug("xhr:"+((new Date).getTime())+" state:"+r.readyState+" status:"+r.status+" statusText:"+r.statusText); + if (r.readyState==4) { + if(r.status==200) { + window.clearTimeout(error_timeout); + de=r.responseXML.documentElement; + if(de.tagName=="pre") { + if(ie) { + Sarissa.updateContentFromNode(de, dterm); + } else { + Sarissa.updateContentFromNode(de, dterm); +// old=div.firstChild; +// div.replaceChild(de,old); + } + rmax=100; + } else { + rmax*=2; + if(rmax>2000) + rmax=2000; + } + sending=0; + sled.className='off'; + timeout=window.setTimeout(update,rmax); + } else { + debug("Connection error status:"+r.status); + } + } + } + error_timeout=window.setTimeout(error,5000); + if(opt_get.className=='on') { + r.send(null); + } else { + r.send(query); + } + } + } + function queue(s) { + keybuf.unshift(s); + if(sending==0) { + window.clearTimeout(timeout); + timeout=window.setTimeout(update,1); + } + } + function keypress(ev) { + if (!ev) var ev=window.event; +// s="kp keyCode="+ev.keyCode+" which="+ev.which+" shiftKey="+ev.shiftKey+" ctrlKey="+ev.ctrlKey+" altKey="+ev.altKey; +// debug(s); +// return false; +// else { if (!ev.ctrlKey || ev.keyCode==17) { return; } + var kc; + var k=""; + if (ev.keyCode) + kc=ev.keyCode; + if (ev.which) + kc=ev.which; + if (ev.altKey) { + if (kc>=65 && kc<=90) + kc+=32; + if (kc>=97 && kc<=122) { + k=String.fromCharCode(27)+String.fromCharCode(kc); + } + } else if (ev.ctrlKey) { + if (kc>=65 && kc<=90) k=String.fromCharCode(kc-64); // Ctrl-A..Z + else if (kc>=97 && kc<=122) k=String.fromCharCode(kc-96); // Ctrl-A..Z + else if (kc==54) k=String.fromCharCode(30); // Ctrl-^ + else if (kc==109) k=String.fromCharCode(31); // Ctrl-_ + else if (kc==219) k=String.fromCharCode(27); // Ctrl-[ + else if (kc==220) k=String.fromCharCode(28); // Ctrl-\ + else if (kc==221) k=String.fromCharCode(29); // Ctrl-] + else if (kc==219) k=String.fromCharCode(29); // Ctrl-] + else if (kc==219) k=String.fromCharCode(0); // Ctrl-@ + } else if (ev.which==0) { + if (kc==9) k=String.fromCharCode(9); // Tab + else if (kc==8) k=String.fromCharCode(127); // Backspace + else if (kc==27) k=String.fromCharCode(27); // Escape + else { + if (kc==33) k="[5~"; // PgUp + else if (kc==34) k="[6~"; // PgDn + else if (kc==35) k="[4~"; // End + else if (kc==36) k="[1~"; // Home + else if (kc==37) k="[D"; // Left + else if (kc==38) k="[A"; // Up + else if (kc==39) k="[C"; // Right + else if (kc==40) k="[B"; // Down + else if (kc==45) k="[2~"; // Ins + else if (kc==46) k="[3~"; // Del + else if (kc==112) k="[[A"; // F1 + else if (kc==113) k="[[B"; // F2 + else if (kc==114) k="[[C"; // F3 + else if (kc==115) k="[[D"; // F4 + else if (kc==116) k="[[E"; // F5 + else if (kc==117) k="[17~"; // F6 + else if (kc==118) k="[18~"; // F7 + else if (kc==119) k="[19~"; // F8 + else if (kc==120) k="[20~"; // F9 + else if (kc==121) k="[21~"; // F10 + else if (kc==122) k="[23~"; // F11 + else if (kc==123) k="[24~"; // F12 + if (k.length) { + k=String.fromCharCode(27)+k; + } + } + } else { + if (kc==8) + k=String.fromCharCode(127); // Backspace + else + k=String.fromCharCode(kc); + } + if(k.length) { +// queue(encodeURIComponent(k)); + if(k=="+") { + queue("%2B"); + } else { + queue(escape(k)); + } + } + ev.cancelBubble=true; + if (ev.stopPropagation) ev.stopPropagation(); + if (ev.preventDefault) ev.preventDefault(); + return false; + } + function keydown(ev) { + if (!ev) var ev=window.event; + if (ie) { +// s="kd keyCode="+ev.keyCode+" which="+ev.which+" shiftKey="+ev.shiftKey+" ctrlKey="+ev.ctrlKey+" altKey="+ev.altKey; +// debug(s); + o={9:1,8:1,27:1,33:1,34:1,35:1,36:1,37:1,38:1,39:1,40:1,45:1,46:1,112:1, + 113:1,114:1,115:1,116:1,117:1,118:1,119:1,120:1,121:1,122:1,123:1}; + if (o[ev.keyCode] || ev.ctrlKey || ev.altKey) { + ev.which=0; + return keypress(ev); + } + } + } + function init() { + sled.appendChild(document.createTextNode('\xb7')); + sled.className='off'; + dstat.appendChild(sled); + dstat.appendChild(document.createTextNode(' ')); + opt_add(opt_color,'Colors'); + opt_color.className='on'; + opt_add(opt_get,'GET'); + opt_add(opt_paste,'Paste'); + opt_add(opt_popup,'New'); + opt_add(opt_close,'Close'); + dstat.appendChild(sdebug); + dstat.className='stat'; + div.appendChild(dstat); + div.appendChild(dterm); + if(opt_color.addEventListener) { + opt_get.addEventListener('click',do_get,true); + opt_color.addEventListener('click',do_color,true); + opt_paste.addEventListener('click',do_paste,true); + opt_popup.addEventListener('click',do_popup,true); + opt_close.addEventListener('click',do_close,true); + } else { + opt_get.attachEvent("onclick", do_get); + opt_color.attachEvent("onclick", do_color); + opt_paste.attachEvent("onclick", do_paste); + opt_popup.attachEvent("onclick", do_popup); + opt_close.attachEvent("onclick", do_close); + } + document.onkeypress=keypress; + document.onkeydown=keydown; + timeout=window.setTimeout(update,100); + if (document.width <= 25+(width*7)) { + document.title=prompt("Window title"); + } + } + init(); +} +ajaxterm.Terminal=function(id,width,height) { + return new this.Terminal_ctor(id,width,height); +} + diff -r 5117bf553562 -r 4da64a9e2232 ajaxterm/stuff/usr/share/ajaxterm/login --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ajaxterm/stuff/usr/share/ajaxterm/login Mon Dec 29 14:27:07 2008 +0000 @@ -0,0 +1,14 @@ +#!/bin/sh + +server="" +if [ -x /usr/bin/ssh ]; then + echo -n "Server: " + read -t 300 server || exit 1 +fi +[ -n "$server" ] || exec /bin/login +case "$server" in +*@*);; *) echo -n "$server login: "; read user; server="$user@$server";; +esac +sshargs="-oPreferredAuthentications=keyboard-interactive,password -oNoHostAuthenticationForLocalhost=yes -oLogLevel=FATAL -F/dev/null"; +[ -L /usr/bin/ssh ] && sshargs="" +exec ssh $sshargs $server