1
0
forked from GitHub/gf-core

gfse: various small improvements

This commit is contained in:
hallgren
2011-07-25 19:21:46 +00:00
parent 848373e29e
commit 0f7743992b
5 changed files with 60 additions and 16 deletions

View File

@@ -4,4 +4,4 @@ save: save.hs
install:: install::
@make save @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

View File

@@ -79,4 +79,6 @@ input.string_edit { font-family: inherit; font-size: inherit; }
ul.languages { -moz-column-width: 20em; } ul.languages { -moz-column-width: 20em; }
li { margin-top: 0.5ex; margin-bottom: 0.5ex; }
#sharing h1, #sharing .footer { display: none; } #sharing h1, #sharing .footer { display: none; }

View File

@@ -66,9 +66,9 @@ function draw_grammar_list() {
} }
} }
if(local.get("count",null)==null) 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) 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(gs);
home.appendChild( home.appendChild(
@@ -866,6 +866,7 @@ function upload(g) {
function upload_json(cont) { function upload_json(cont) {
function upload3(resptext,status) { function upload3(resptext,status) {
local.put("json_uploaded",Date.now()); local.put("json_uploaded",Date.now());
//debug("Upload complete")
if(cont) cont(); if(cont) cont();
else { else {
var sharing=element("sharing"); var sharing=element("sharing");
@@ -874,7 +875,10 @@ function upload_json(cont) {
} }
function upload2(dir) { function upload2(dir) {
var prefix=dir.substr(10)+"-" // skip "/tmp/gfse." 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++) { for(var i=0;i<local.count;i++) {
var g=local.get(i,null); var g=local.get(i,null);
if(g) { if(g) {
@@ -882,9 +886,13 @@ function upload_json(cont) {
g.unique_name=prefix+i; g.unique_name=prefix+i;
save_grammar(g) 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) ajax_http_post("upload.cgi"+dir,form,upload3,cont)
} }
@@ -984,6 +992,7 @@ function download_json() {
function download_files(ls) { function download_files(ls) {
local.put("current",0); local.put("current",0);
if(ls) { if(ls) {
//debug("Downloading "+ls);
var files=ls.split(" "); var files=ls.split(" ");
cleanup_deleted(files); cleanup_deleted(files);
for(var i in files) get_file(files[i],file_downloaded,file_failed); 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) var newdir="/tmp/"+location.hash.substr(1)
function download2(olddir) { function download2(olddir) {
//debug("Starting grammar sharing in the cloud")
if(newdir!=olddir) { if(newdir!=olddir) {
ajax_http_get("upload.cgi?rmdir="+olddir+"&newdir="+newdir, ajax_http_get("upload.cgi?rmdir="+olddir+"&newdir="+newdir,
download3) download3)
} }
else download4() else download4()
} }
function download3() { upload_json(download4) } function download3() {
function download4() { download_json() } //debug("Uploading local grammars to cloud");
upload_json(download4)
}
function download4() {
//debug("Downloading grammars from the cloud");
download_json()
}
get_dir(download2) get_dir(download2)
} }
@@ -1149,7 +1165,26 @@ function touch_edit() {
//document.body.appendChild(empty_id("div","debug")); //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) { if(editor) {
initial_view(); initial_view();
touch_edit(); touch_edit();
dir_bugfix();
} }
//console.log("hi")

View File

@@ -1,7 +1,8 @@
<!DOCTYPE HTML> <!DOCTYPE html>
<html manifest="gfse.manifest"> <html> <!-- manifest="gfse.manifest" -->
<head> <head>
<title>GF online editor for simple multilingual grammars</title> <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="stylesheet" type="text/css" href="editor.css" title="Cloud">
<link rel="alternate stylesheet" type="text/css" href="molto.css" title="MOLTO"> <link rel="alternate stylesheet" type="text/css" href="molto.css" title="MOLTO">
@@ -9,7 +10,6 @@
<meta name = "viewport" content = "width = device-width"> <meta name = "viewport" content = "width = device-width">
<meta http-equiv="Content-type" content="text/html;charset=UTF-8"> <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<meta charset="UTF-8">
</head> </head>
@@ -32,9 +32,10 @@ This page does not work without JavaScript.
<hr> <hr>
<div class=modtime><small> <div class=modtime><small>
HTML 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> </small></div>
<a href="about.html">About</a> <a href="about.html">About</a>
<pre id=debug></pre>
<script type="text/javascript" src="support.js"></script> <script type="text/javascript" src="support.js"></script>
<script type="text/javascript" src="localstorage.js"></script> <script type="text/javascript" src="localstorage.js"></script>
<script type="text/javascript" src="gf_abs.js"></script> <script type="text/javascript" src="gf_abs.js"></script>

View File

@@ -162,11 +162,17 @@ case "$REQUEST_METHOD" in
if [ -d "$path" ] ; then if [ -d "$path" ] ; then
ContentType="text/plain; charset=$charset" ContentType="text/plain; charset=$charset"
cgiheaders cgiheaders
cd "$path" if [ -h "$path" ] ; then
shopt -s nullglob cd "$path"
rm *.gf *.gfo *-*.json *.pgf grammars.cgi cd ..
cd .. rm "$path"
rmdir "$path" else
cd "$path"
shopt -s nullglob
rm *.gf *.gfo *-*.json *.pgf grammars.cgi
cd ..
rmdir "$path"
fi
newdir=$(qparse "$QUERY_STRING" newdir) newdir=$(qparse "$QUERY_STRING" newdir)
case "$newdir" in case "$newdir" in
/tmp/gfse.*) # shouldn't allow .. in path !!! /tmp/gfse.*) # shouldn't allow .. in path !!!