mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
gfse: stay on the same page when compiling grammars
The link to the minibar (or compiler errors) are now shown below the grammar on the same page. If you go to the minibar, you only have to press the back button once to get back to the editor. Also some output formatting changes in GFServer.hs.
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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; }
|
||||
#sharing h1, #sharing .footer { display: none; }
|
||||
|
||||
div.compiler_output .back_to_editor { display: none; }
|
||||
|
||||
@@ -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)])])])])
|
||||
}
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user