diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/editor/simple/Makefile | 2 | ||||
| -rw-r--r-- | src/editor/simple/editor.css | 2 | ||||
| -rw-r--r-- | src/editor/simple/editor.js | 47 | ||||
| -rw-r--r-- | src/editor/simple/index.html | 9 | ||||
| -rw-r--r-- | src/editor/simple/upload.cgi | 16 |
5 files changed, 60 insertions, 16 deletions
diff --git a/src/editor/simple/Makefile b/src/editor/simple/Makefile index be40c0944..00a97b337 100644 --- a/src/editor/simple/Makefile +++ b/src/editor/simple/Makefile @@ -4,4 +4,4 @@ save: save.hs install:: @make save - rsync -avz P *.html *.css *.js ../../runtime/javascript/minibar/support.js *.cgi *.manifest save www.grammaticalframework.org:/usr/local/www/GF/demos/gfse + rsync -avz --exclude .DS_Store P *.html *.css *.js ../../runtime/javascript/minibar/support.js *.cgi *.manifest save www.grammaticalframework.org:/usr/local/www/GF/demos/gfse diff --git a/src/editor/simple/editor.css b/src/editor/simple/editor.css index ebb0a9baa..d7a415186 100644 --- a/src/editor/simple/editor.css +++ b/src/editor/simple/editor.css @@ -79,4 +79,6 @@ input.string_edit { font-family: inherit; font-size: inherit; } ul.languages { -moz-column-width: 20em; } +li { margin-top: 0.5ex; margin-bottom: 0.5ex; } + #sharing h1, #sharing .footer { display: none; }
\ No newline at end of file diff --git a/src/editor/simple/editor.js b/src/editor/simple/editor.js index 90d85274b..5c08078fe 100644 --- a/src/editor/simple/editor.js +++ b/src/editor/simple/editor.js @@ -66,9 +66,9 @@ function draw_grammar_list() { } } if(local.get("count",null)==null) - editor.appendChild(text("You have not created any grammars yet.")); + home.appendChild(text("You have not created any grammars yet.")); else if(local.count==0) - editor.appendChild(text("Your grammar list is empty.")); + home.appendChild(text("Your grammar list is empty.")); home.appendChild(gs); home.appendChild( @@ -866,6 +866,7 @@ function upload(g) { function upload_json(cont) { function upload3(resptext,status) { local.put("json_uploaded",Date.now()); + //debug("Upload complete") if(cont) cont(); else { var sharing=element("sharing"); @@ -874,7 +875,10 @@ function upload_json(cont) { } function upload2(dir) { var prefix=dir.substr(10)+"-" // skip "/tmp/gfse." - var form=new FormData(); + //debug("New form data"); + //var form=new FormData(); // !!! Doesn't work on Android 2.2! + var form="",sep=""; + //debug("Preparing form data"); for(var i=0;i<local.count;i++) { var g=local.get(i,null); if(g) { @@ -882,9 +886,13 @@ function upload_json(cont) { g.unique_name=prefix+i; save_grammar(g) } - form.append(g.unique_name+".json",JSON.stringify(g)); + //form.append(g.unique_name+".json",JSON.stringify(g)); + form+=sep+encodeURIComponent(g.unique_name+".json")+"="+ + encodeURIComponent(JSON.stringify(g)) + sep="&" } } + //debug("Upload to "+prefix); ajax_http_post("upload.cgi"+dir,form,upload3,cont) } @@ -984,6 +992,7 @@ function download_json() { function download_files(ls) { local.put("current",0); if(ls) { + //debug("Downloading "+ls); var files=ls.split(" "); cleanup_deleted(files); for(var i in files) get_file(files[i],file_downloaded,file_failed); @@ -1001,14 +1010,21 @@ function download_from_cloud() { var newdir="/tmp/"+location.hash.substr(1) function download2(olddir) { + //debug("Starting grammar sharing in the cloud") if(newdir!=olddir) { ajax_http_get("upload.cgi?rmdir="+olddir+"&newdir="+newdir, download3) } else download4() } - function download3() { upload_json(download4) } - function download4() { download_json() } + function download3() { + //debug("Uploading local grammars to cloud"); + upload_json(download4) + } + function download4() { + //debug("Downloading grammars from the cloud"); + download_json() + } get_dir(download2) } @@ -1149,7 +1165,26 @@ function touch_edit() { //document.body.appendChild(empty_id("div","debug")); +function dir_bugfix() { + // remove trailing newline caused by bug in older version + var dir=local.get("dir"); + if(dir) { + var n=dir.length; + while(dir[dir.length-1]=="\n" || dir[dir.length-1]=="\r") + dir=dir.substr(0,dir.length-1) + if(dir.length<n) { + debug("removing trailing newline") + local.put("dir",dir); + } + //debug("Server directory: "+JSON.stringify(dir)) + } + else debug("No server directory yet") +} + if(editor) { initial_view(); touch_edit(); + dir_bugfix(); } + +//console.log("hi") diff --git a/src/editor/simple/index.html b/src/editor/simple/index.html index d325985c3..aab014b42 100644 --- a/src/editor/simple/index.html +++ b/src/editor/simple/index.html @@ -1,7 +1,8 @@ -<!DOCTYPE HTML> -<html manifest="gfse.manifest"> +<!DOCTYPE html> +<html> <!-- manifest="gfse.manifest" --> <head> <title>GF online editor for simple multilingual grammars</title> +<meta charset="UTF-8"> <link rel="stylesheet" type="text/css" href="editor.css" title="Cloud"> <link rel="alternate stylesheet" type="text/css" href="molto.css" title="MOLTO"> @@ -9,7 +10,6 @@ <meta name = "viewport" content = "width = device-width"> <meta http-equiv="Content-type" content="text/html;charset=UTF-8"> -<meta charset="UTF-8"> </head> @@ -32,9 +32,10 @@ This page does not work without JavaScript. <hr> <div class=modtime><small> HTML -<!-- hhmts start --> Last modified: Mon Mar 28 16:45:53 CEST 2011 <!-- hhmts end --> +<!-- hhmts start --> Last modified: Mon Jul 25 21:01:48 CEST 2011 <!-- hhmts end --> </small></div> <a href="about.html">About</a> +<pre id=debug></pre> <script type="text/javascript" src="support.js"></script> <script type="text/javascript" src="localstorage.js"></script> <script type="text/javascript" src="gf_abs.js"></script> diff --git a/src/editor/simple/upload.cgi b/src/editor/simple/upload.cgi index 18d584b54..3da386dd6 100644 --- a/src/editor/simple/upload.cgi +++ b/src/editor/simple/upload.cgi @@ -162,11 +162,17 @@ case "$REQUEST_METHOD" in if [ -d "$path" ] ; then ContentType="text/plain; charset=$charset" cgiheaders - cd "$path" - shopt -s nullglob - rm *.gf *.gfo *-*.json *.pgf grammars.cgi - cd .. - rmdir "$path" + if [ -h "$path" ] ; then + cd "$path" + cd .. + rm "$path" + else + cd "$path" + shopt -s nullglob + rm *.gf *.gfo *-*.json *.pgf grammars.cgi + cd .. + rmdir "$path" + fi newdir=$(qparse "$QUERY_STRING" newdir) case "$newdir" in /tmp/gfse.*) # shouldn't allow .. in path !!! |
