diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/compiler/GFServer.hs | 18 | ||||
| -rw-r--r-- | src/www/gfse/cloud2.js | 26 | ||||
| -rw-r--r-- | src/www/gfse/editor.css | 4 | ||||
| -rw-r--r-- | src/www/gfse/editor.js | 11 | ||||
| -rw-r--r-- | src/www/gfse/index.html | 6 |
5 files changed, 49 insertions, 16 deletions
diff --git a/src/compiler/GFServer.hs b/src/compiler/GFServer.hs index 149cb1864..685b9d76f 100644 --- a/src/compiler/GFServer.hs +++ b/src/compiler/GFServer.hs @@ -224,18 +224,17 @@ handle state0 cache execute1 resultpage cwd dir cmd (ecode,stdout,stderr) files = unlines $ "<!DOCTYPE html>": - "<title>Uploaded</title>": + wrap "title" "Uploaded": "<link rel=stylesheet type=\"text/css\" HREF=\"/gfse/editor.css\" title=\"Normal\">": - "<h1>Uploaded</h1>": - "<pre>":escape cmd:"":escape (rel stderr):escape (rel stdout): - "</pre>": + wrap "h1" "Uploaded": + concatMap (pre.escape) [cmd,rel stderr,rel stdout]: (if ecode==ExitSuccess - then "<h3>OK</h3>":links + then wrap "h3" "OK":links else "<h3 class=error_message>Error</h3>":listing) where links = "<dl>": ("<dt>▸ <a href=\"/minibar/minibar.html?"++dir++pgf++"\">Minibar</a>"): - "<dt>◂ <a href=\"javascript:history.back()\">Back to Editor</a>": + "<dt class=back_to_editor>◂ <a href=\"javascript:history.back()\">Back to Editor</a>": "</dl>": [] @@ -246,12 +245,17 @@ resultpage cwd dir cmd (ecode,stdout,stderr) files = listing = concatMap listfile files listfile (name,source) = - ("<h4>"++name++"</h4><pre class=plain>"):number source:"</pre>":[] + (wrap "h4" name++"<pre class=plain>"):number source:"</pre>":[] number = unlines . zipWith num [1..] . lines num n s = pad (show n)++" "++escape s pad s = replicate (5-length s) ' '++s + pre = wrap "pre" + wrap t s = tag t++s++endtag t + tag t = "<"++t++">" + endtag t = tag ('/':t) + rel = unlines . map relative . lines -- remove absolute file paths from error messages: diff --git a/src/www/gfse/cloud2.js b/src/www/gfse/cloud2.js index 7b3d90f0f..c9e59a21d 100644 --- a/src/www/gfse/cloud2.js +++ b/src/www/gfse/cloud2.js @@ -26,7 +26,7 @@ function remove_cloud_grammar(g) { } // Upload the grammar to the server and check it for errors -function upload(g) { +function old_upload(g) { function upload2(dir) { var form=node("form",{method:"post",action:"/cloud"}, [hidden("dir",dir),hidden("command","make"), @@ -42,12 +42,34 @@ function upload(g) { form.submit(); form.parentNode.removeChild(form); } - + function upload3(message) { if(message) alert(message); } with_dir(upload2) } +// Upload the grammar to the server and check it for errors +function upload(g) { + function upload2(dir) { + var pre="dir="+encodeURIComponent(dir) + var form= {command:"make"} + form[encodeURIComponent(g.basename+".gf")]=show_abstract(g) + for(var i in g.concretes) { + var cname=g.basename+g.concretes[i].langcode+".gf"; + form[encodeURIComponent(cname)]=show_concrete(g)(g.concretes[i]); + } + ajax_http_post("/cloud",pre+encodeArgs(form),upload3) + } + + function upload3(message) { + var dst=element("compiler_output") + if(dst) dst.innerHTML=message; + else alert(message); + } + + with_dir(upload2) +} + // Upload the grammar to store it in the cloud function upload_json(cont) { function upload2(dir,unique_id) { diff --git a/src/www/gfse/editor.css b/src/www/gfse/editor.css index 302548371..74d15345e 100644 --- a/src/www/gfse/editor.css +++ b/src/www/gfse/editor.css @@ -89,4 +89,6 @@ 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 +#sharing h1, #sharing .footer { display: none; } + +div.compiler_output .back_to_editor { display: none; } diff --git a/src/www/gfse/editor.js b/src/www/gfse/editor.js index d2c41f30f..885a6871c 100644 --- a/src/www/gfse/editor.js +++ b/src/www/gfse/editor.js @@ -120,7 +120,12 @@ function open_grammar(i) { edit_grammar(g); } -function close_grammar(g) { save_grammar(g); draw_grammar_list(); } +function close_grammar(g) { + var o=element("compiler_output"); + if(o) o.innerHTML=""; + save_grammar(g); + draw_grammar_list(); +} function reload_grammar(g) { save_grammar(g); edit_grammar(g); } function save_grammar(g) { @@ -143,8 +148,8 @@ function draw_grammar(g) { function draw_namebar(g,files) { return div_class("namebar", [table([tr([td(draw_name(g)), - td_right([draw_plainbutton(g,files), - upload_button(g), + td_right([upload_button(g), + draw_plainbutton(g,files), draw_closebutton(g)])])])]) } diff --git a/src/www/gfse/index.html b/src/www/gfse/index.html index 52c96a34f..a3b9559e9 100644 --- a/src/www/gfse/index.html +++ b/src/www/gfse/index.html @@ -16,14 +16,14 @@ <body class=hover> <h2>GF online editor for simple multilingual grammars</h2> -<div id=editor> -</div> +<div id=editor></div> <small class="hidden"> <span class=more>+</span>=Add an item, <span class=delete>×</span>=Delete item, <span class=edit>%</span>=Edit item. </small> <small class="ifhover">Hover over items for hints and editing options.</small> +<div id=compiler_output class=compiler_output></div> <noscript> This page does not work without JavaScript. @@ -32,7 +32,7 @@ This page does not work without JavaScript. <hr> <div class=modtime><small> HTML -<!-- hhmts start --> Last modified: Mon Oct 10 19:24:05 CEST 2011 <!-- hhmts end --> +<!-- hhmts start --> Last modified: Fri Feb 10 17:47:16 CET 2012 <!-- hhmts end --> </small></div> <a href="about.html">About</a> <pre id=debug></pre> |
