From 44d1a5a9f71b03d9aceeccd760a63fcdc45f8bad Mon Sep 17 00:00:00 2001 From: hallgren Date: Wed, 12 Oct 2011 17:03:54 +0000 Subject: Improvements of "gf -server" mode and related setup "gf -server" mode now contains everything needed to run the minibar and the grammar editor (including example-based grammar writing). The Setup.hs script installs the required files where gf -server can find them. These files have been moved to a new directory: src/www. The separate server program pgf-http is now obsolete. --- src/compiler/GFServer.hs | 20 +- src/editor/simple/Makefile | 7 - src/editor/simple/P/1306856253_weather_06.png | Bin 2311 -> 0 bytes src/editor/simple/P/1307545089_weather_04.png | Bin 2376 -> 0 bytes src/editor/simple/P/w1s.jpg | Bin 26163 -> 0 bytes src/editor/simple/P/w2s.jpg | Bin 25953 -> 0 bytes src/editor/simple/P/w3s.jpg | Bin 29664 -> 0 bytes src/editor/simple/P/w4s.jpg | Bin 22005 -> 0 bytes src/editor/simple/TODO | 43 - src/editor/simple/about.html | 243 ----- src/editor/simple/cloud.js | 148 --- src/editor/simple/cloud2.js | 159 --- src/editor/simple/editor.css | 88 -- src/editor/simple/editor.js | 1114 -------------------- src/editor/simple/example_based.js | 158 --- src/editor/simple/gf_abs.js | 226 ---- src/editor/simple/gfse.manifest | 4 - src/editor/simple/grammars.cgi | 19 - src/editor/simple/index.html | 48 - src/editor/simple/localstorage.js | 21 - src/editor/simple/molto.css | 82 -- src/editor/simple/save.hs | 25 - src/editor/simple/share.html | 27 - src/editor/simple/slideshow.js | 86 -- src/editor/simple/upload.cgi | 252 ----- src/runtime/javascript/minibar/about.html | 180 ---- src/runtime/javascript/minibar/align-btn.png | Bin 138 -> 0 bytes src/runtime/javascript/minibar/brushed-metal.png | Bin 36233 -> 0 bytes src/runtime/javascript/minibar/example.html | 57 - src/runtime/javascript/minibar/feedback.cgi | 44 - src/runtime/javascript/minibar/feedback.html | 48 - .../javascript/minibar/gf-web-api-examples.html | 151 --- src/runtime/javascript/minibar/minibar-api.html | 235 ----- src/runtime/javascript/minibar/minibar.css | 53 - src/runtime/javascript/minibar/minibar.html | 41 - src/runtime/javascript/minibar/minibar.js | 176 ---- src/runtime/javascript/minibar/minibar_input.js | 277 ----- src/runtime/javascript/minibar/minibar_online.js | 25 - src/runtime/javascript/minibar/minibar_support.js | 46 - .../javascript/minibar/minibar_translations.js | 162 --- src/runtime/javascript/minibar/pgf_offline.js | 96 -- src/runtime/javascript/minibar/pgf_online.js | 52 - src/runtime/javascript/minibar/phrasebook.html | 56 - src/runtime/javascript/minibar/saldotest.html | 30 - src/runtime/javascript/minibar/saldotest.js | 340 ------ src/runtime/javascript/minibar/support.js | 300 ------ src/runtime/javascript/minibar/tree-btn.png | Bin 149 -> 0 bytes src/www/gfse/Makefile | 7 + src/www/gfse/P/1306856253_weather_06.png | Bin 0 -> 2311 bytes src/www/gfse/P/1307545089_weather_04.png | Bin 0 -> 2376 bytes src/www/gfse/P/w1s.jpg | Bin 0 -> 26163 bytes src/www/gfse/P/w2s.jpg | Bin 0 -> 25953 bytes src/www/gfse/P/w3s.jpg | Bin 0 -> 29664 bytes src/www/gfse/P/w4s.jpg | Bin 0 -> 22005 bytes src/www/gfse/TODO | 43 + src/www/gfse/about.html | 243 +++++ src/www/gfse/cloud.js | 148 +++ src/www/gfse/cloud2.js | 159 +++ src/www/gfse/editor.css | 88 ++ src/www/gfse/editor.js | 1114 ++++++++++++++++++++ src/www/gfse/example_based.js | 158 +++ src/www/gfse/gf_abs.js | 226 ++++ src/www/gfse/gfse.manifest | 4 + src/www/gfse/grammars.cgi | 19 + src/www/gfse/index.html | 48 + src/www/gfse/localstorage.js | 21 + src/www/gfse/molto.css | 82 ++ src/www/gfse/save.hs | 25 + src/www/gfse/share.html | 27 + src/www/gfse/slideshow.js | 86 ++ src/www/gfse/upload.cgi | 252 +++++ src/www/index.html | 18 + src/www/minibar/about.html | 180 ++++ src/www/minibar/align-btn.png | Bin 0 -> 138 bytes src/www/minibar/brushed-metal.png | Bin 0 -> 36233 bytes src/www/minibar/example.html | 57 + src/www/minibar/feedback.cgi | 44 + src/www/minibar/feedback.html | 48 + src/www/minibar/gf-web-api-examples.html | 151 +++ src/www/minibar/minibar-api.html | 235 +++++ src/www/minibar/minibar.css | 53 + src/www/minibar/minibar.html | 41 + src/www/minibar/minibar.js | 176 ++++ src/www/minibar/minibar_input.js | 277 +++++ src/www/minibar/minibar_online.js | 25 + src/www/minibar/minibar_support.js | 46 + src/www/minibar/minibar_translations.js | 162 +++ src/www/minibar/pgf_offline.js | 96 ++ src/www/minibar/pgf_online.js | 52 + src/www/minibar/phrasebook.html | 56 + src/www/minibar/saldotest.html | 30 + src/www/minibar/saldotest.js | 340 ++++++ src/www/minibar/support.js | 300 ++++++ src/www/minibar/tree-btn.png | Bin 0 -> 149 bytes 94 files changed, 5146 insertions(+), 5130 deletions(-) delete mode 100644 src/editor/simple/Makefile delete mode 100644 src/editor/simple/P/1306856253_weather_06.png delete mode 100644 src/editor/simple/P/1307545089_weather_04.png delete mode 100644 src/editor/simple/P/w1s.jpg delete mode 100644 src/editor/simple/P/w2s.jpg delete mode 100644 src/editor/simple/P/w3s.jpg delete mode 100644 src/editor/simple/P/w4s.jpg delete mode 100644 src/editor/simple/TODO delete mode 100644 src/editor/simple/about.html delete mode 100644 src/editor/simple/cloud.js delete mode 100644 src/editor/simple/cloud2.js delete mode 100644 src/editor/simple/editor.css delete mode 100644 src/editor/simple/editor.js delete mode 100644 src/editor/simple/example_based.js delete mode 100644 src/editor/simple/gf_abs.js delete mode 100644 src/editor/simple/gfse.manifest delete mode 100644 src/editor/simple/grammars.cgi delete mode 100644 src/editor/simple/index.html delete mode 100644 src/editor/simple/localstorage.js delete mode 100644 src/editor/simple/molto.css delete mode 100644 src/editor/simple/save.hs delete mode 100644 src/editor/simple/share.html delete mode 100644 src/editor/simple/slideshow.js delete mode 100644 src/editor/simple/upload.cgi delete mode 100644 src/runtime/javascript/minibar/about.html delete mode 100644 src/runtime/javascript/minibar/align-btn.png delete mode 100644 src/runtime/javascript/minibar/brushed-metal.png delete mode 100644 src/runtime/javascript/minibar/example.html delete mode 100644 src/runtime/javascript/minibar/feedback.cgi delete mode 100644 src/runtime/javascript/minibar/feedback.html delete mode 100644 src/runtime/javascript/minibar/gf-web-api-examples.html delete mode 100644 src/runtime/javascript/minibar/minibar-api.html delete mode 100644 src/runtime/javascript/minibar/minibar.css delete mode 100644 src/runtime/javascript/minibar/minibar.html delete mode 100644 src/runtime/javascript/minibar/minibar.js delete mode 100644 src/runtime/javascript/minibar/minibar_input.js delete mode 100644 src/runtime/javascript/minibar/minibar_online.js delete mode 100644 src/runtime/javascript/minibar/minibar_support.js delete mode 100644 src/runtime/javascript/minibar/minibar_translations.js delete mode 100644 src/runtime/javascript/minibar/pgf_offline.js delete mode 100644 src/runtime/javascript/minibar/pgf_online.js delete mode 100644 src/runtime/javascript/minibar/phrasebook.html delete mode 100644 src/runtime/javascript/minibar/saldotest.html delete mode 100644 src/runtime/javascript/minibar/saldotest.js delete mode 100644 src/runtime/javascript/minibar/support.js delete mode 100644 src/runtime/javascript/minibar/tree-btn.png create mode 100644 src/www/gfse/Makefile create mode 100644 src/www/gfse/P/1306856253_weather_06.png create mode 100644 src/www/gfse/P/1307545089_weather_04.png create mode 100644 src/www/gfse/P/w1s.jpg create mode 100644 src/www/gfse/P/w2s.jpg create mode 100644 src/www/gfse/P/w3s.jpg create mode 100644 src/www/gfse/P/w4s.jpg create mode 100644 src/www/gfse/TODO create mode 100644 src/www/gfse/about.html create mode 100644 src/www/gfse/cloud.js create mode 100644 src/www/gfse/cloud2.js create mode 100644 src/www/gfse/editor.css create mode 100644 src/www/gfse/editor.js create mode 100644 src/www/gfse/example_based.js create mode 100644 src/www/gfse/gf_abs.js create mode 100644 src/www/gfse/gfse.manifest create mode 100644 src/www/gfse/grammars.cgi create mode 100644 src/www/gfse/index.html create mode 100644 src/www/gfse/localstorage.js create mode 100644 src/www/gfse/molto.css create mode 100644 src/www/gfse/save.hs create mode 100644 src/www/gfse/share.html create mode 100644 src/www/gfse/slideshow.js create mode 100644 src/www/gfse/upload.cgi create mode 100644 src/www/index.html create mode 100644 src/www/minibar/about.html create mode 100644 src/www/minibar/align-btn.png create mode 100644 src/www/minibar/brushed-metal.png create mode 100644 src/www/minibar/example.html create mode 100644 src/www/minibar/feedback.cgi create mode 100644 src/www/minibar/feedback.html create mode 100644 src/www/minibar/gf-web-api-examples.html create mode 100644 src/www/minibar/minibar-api.html create mode 100644 src/www/minibar/minibar.css create mode 100644 src/www/minibar/minibar.html create mode 100644 src/www/minibar/minibar.js create mode 100644 src/www/minibar/minibar_input.js create mode 100644 src/www/minibar/minibar_online.js create mode 100644 src/www/minibar/minibar_support.js create mode 100644 src/www/minibar/minibar_translations.js create mode 100644 src/www/minibar/pgf_offline.js create mode 100644 src/www/minibar/pgf_online.js create mode 100644 src/www/minibar/phrasebook.html create mode 100644 src/www/minibar/saldotest.html create mode 100644 src/www/minibar/saldotest.js create mode 100644 src/www/minibar/support.js create mode 100644 src/www/minibar/tree-btn.png (limited to 'src') diff --git a/src/compiler/GFServer.hs b/src/compiler/GFServer.hs index 6e9b26a8d..bc5bdbdaf 100644 --- a/src/compiler/GFServer.hs +++ b/src/compiler/GFServer.hs @@ -27,21 +27,19 @@ import qualified ExampleService as ES import Paths_gf(getDataDir) import RunHTTP(Options(..),cgiHandler) --- * Configuraiton - -options = Options { documentRoot = "." {-datadir"www"-}, port = gfport } -gfport = 41296 - -- * HTTP server server execute1 state0 = do state <- newMVar M.empty cache <- PS.newPGFCache - --datadir <- getDataDir - putStrLn $ "Starting server on port "++show gfport - initServer gfport (modifyMVar state . handle state0 cache execute1) + datadir <- getDataDir + let options = Options { documentRoot = datadir"www", port = 41296 } + putStrLn $ "Starting HTTP server, open http://localhost:" + ++show (port options)++"/ in your web browser." + initServer (port options) + (modifyMVar state . handle options state0 cache execute1) -- * HTTP request handler -handle state0 cache execute1 +handle options state0 cache execute1 rq@(Request method URI{uriPath=upath,uriQuery=q} hdrs body) state = do let qs = decodeQ $ case method of @@ -67,6 +65,8 @@ handle state0 cache execute1 where root = documentRoot options + translatePath rpath = rootrpath -- hmm, check for ".." + wrapCGI cgi = do resp <- cgiHandler root (handleErrors . handleCGIErrors $ cgi) rq return (state,resp) @@ -191,8 +191,6 @@ escape1 c = [c] -- * Static content -translatePath path = documentRoot optionspath -- hmm, check for ".." - serveStaticFile path = do b <- doesDirectoryExist path let path' = if b then path "index.html" else path diff --git a/src/editor/simple/Makefile b/src/editor/simple/Makefile deleted file mode 100644 index 00a97b337..000000000 --- a/src/editor/simple/Makefile +++ /dev/null @@ -1,7 +0,0 @@ - -save: save.hs - ghc --make save.hs - -install:: - @make save - 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/P/1306856253_weather_06.png b/src/editor/simple/P/1306856253_weather_06.png deleted file mode 100644 index 3f01afcaa..000000000 Binary files a/src/editor/simple/P/1306856253_weather_06.png and /dev/null differ diff --git a/src/editor/simple/P/1307545089_weather_04.png b/src/editor/simple/P/1307545089_weather_04.png deleted file mode 100644 index 8a7f1e3ae..000000000 Binary files a/src/editor/simple/P/1307545089_weather_04.png and /dev/null differ diff --git a/src/editor/simple/P/w1s.jpg b/src/editor/simple/P/w1s.jpg deleted file mode 100644 index 199fcb7ba..000000000 Binary files a/src/editor/simple/P/w1s.jpg and /dev/null differ diff --git a/src/editor/simple/P/w2s.jpg b/src/editor/simple/P/w2s.jpg deleted file mode 100644 index 9673758c0..000000000 Binary files a/src/editor/simple/P/w2s.jpg and /dev/null differ diff --git a/src/editor/simple/P/w3s.jpg b/src/editor/simple/P/w3s.jpg deleted file mode 100644 index 1a8680ec7..000000000 Binary files a/src/editor/simple/P/w3s.jpg and /dev/null differ diff --git a/src/editor/simple/P/w4s.jpg b/src/editor/simple/P/w4s.jpg deleted file mode 100644 index 5c685c134..000000000 Binary files a/src/editor/simple/P/w4s.jpg and /dev/null differ diff --git a/src/editor/simple/TODO b/src/editor/simple/TODO deleted file mode 100644 index 22974ebe0..000000000 --- a/src/editor/simple/TODO +++ /dev/null @@ -1,43 +0,0 @@ -+ Safety question before deleting a grammar -+ Check identifier syntax -+ Allow lincat for deleted cat to be deleted -+ Allow lin for deleted fun to be deleted -+ Apply category alpha conversion in concrete syntax -+ Remove a concrete syntax -+ Apply function alpha conversion in concrete syntax -+ Change lhs of lins when function type is changed - -+ Allow languages other than the ones in the given list to be added -+ Export as plain text -+ Allow definitions to be reordered - -+ 1. possibility to compile the grammar set, returning a URL to a translator app -+ 2a. possibility to import modules - resource libraries -- 2b. possibility to import modules - user's own auxiliaries -- 3. possibility to upload own modules -+ 4. access to the created files in an on-line shell (making testing possible) -- 5. rule-to-rule type checking and guidance (e.g. with library oper - suggestions) -+ Try grammars in the Translation Quiz -+ Show lincat and lin before params and opers below -+ Create a new concrete syntax by copying an existing one. -- Easy access to compute_concrete from the editor -- Instead of starting with an empty grammar, start a new grammar by copying - an example. -+ Cloning grammars -- Allow grammars to contain a resoure module. Create the resource module by - factoring out common parts of the concrete syntaxes. -- Integrate example-based concrete syntax construction (using Ramona's tool) -- Open lexicon modules? They are not installed by default! - DictEng, MorphalouFre, DictSwe, DictTur, DictBul, DictFun, DictLav - -+ compile only the uploaded grammar even if other grammars are present -+ 'flags startcat' is needed for grammars with only one category (since the - default startcat is S, even if it doesn't exist) - -- Bug! After adding a 2nd def of a fun with a different type and then deleting - the old fun, the corresponding lin will have the wrong lhs. - -+ Bug! The startcat menu shows the first category by default, but the startcat - flag is actually not set until a selection is made from the menu. - diff --git a/src/editor/simple/about.html b/src/editor/simple/about.html deleted file mode 100644 index 8660621a3..000000000 --- a/src/editor/simple/about.html +++ /dev/null @@ -1,243 +0,0 @@ - - - -About: GF online editor for simple multilingual grammars - - - - - - - - - - - - - - -

GF online editor for simple multilingual grammars

- -
-
- [GF online editor screen shoot] - - - -
-
-

Introduction

- -Traditionally, GF -grammars are created in a text editor and tested in the -GF shell. Text editors know very little (if anything) about the syntax of -GF grammars, and thus provide little guidance for novice GF users. Also, the -grammar author has to download and install the GF software on his/her own -computer. - -

-In contrast, the -GF online editor for simple multilingual grammars -is available online, making it easier to get started. All that -is needed is a reasonably modern web browser. Even Android and iOS devices -can be used. -

-The editor -also guides the grammar author by showing a skeleton grammar file and -hinting how the parts should be filled in. When a new part is added to the -grammar, it is immediately checked for errors. - -

-Editing operations are accessed by clicking on editing symbols embedded -in the grammar display: -+=Add an item, -×=Delete an item, -%=Edit an item. -These are revealed when hovering over items. On touch devices, hovering is -in some cases simulated by tapping, but there is also a button at the bottom -of the display to "Enable editing on touch devices" that reveals all editing -symbols. - -

-In spite of its name, the editor runs entierly in the web -browser, so once you have opened the web page, you can -continue editing grammars even while you are -offline. - -

Current status

- -

-At the moment, the editor supports only a small subset of the GF grammar -notation. -Proper error checking is done for abstract syntax, but not (yet) for concrete -syntax. - -

-The grammars created with this editor always consists of one file for the -abstract syntax, and one file for each concrete syntax. - -

Abstract syntax

- -The supported abstract syntax corresponds to context-free grammars -(no dependent types). The definition of an abstract syntax is limited to - - -Available editing operations: - - -Error checks: - - - -

Concrete syntax

- -At the moment, the concrete syntax for a language L is limited to - - -Available editing operations: - -Also, - - - -Error checks: - - -

Compiling and testing grammars

- -When pressing the Compile button, the grammar will be compiled -with GF, and any errors not detected by the editor will be reported. -If the grammar is free from errors the user can then -test the grammar by clicking on links to the online GF shell, the Minibar or -the Translation Quiz. - -

-Grammars in the -cloud

- -While the editor normally stores grammars locally in the browser, it is also -possible to store grammars in the cloud. Grammars can be stored in the cloud -just for backup, or to make them accessible from multiple devices. - -

-There is no automatic synchronization between local grammars and the cloud. -Instead, the user should press -[Cloud Upload] -to upload the grammars to the cloud, and press -[Cloud download] -to download grammars from the cloud. In both cases, complete grammars -are copied and older versions at the destination will be overwritten. -When a grammar is deleted, both the local copy and the copy in the cloud -is deleted. - -

-Each device is initially assigned to its own unique cloud. Each device can thus -have its own set of grammars that are not available on other devices. It is -also possible to merge clouds and share a common set of grammars between -multiple devices: when uploading grammars to the cloud, a link to this grammar -cloud appears. Accessing this link from another device will cause the clouds of -the two devices to be merged. After this, grammars uploaded from one of the -devices can be downloaded on the other devices. Any number devices can join the -same grammar cloud in this way. - -

-Note that while it is possible to copy grammars between -multiple devices, there is no way to merge concurrent edits from multiple -devices. If the same grammar is uploaded to the -cloud from multiple devices, the last upload wins. Thus the current -implementation is suitable for a single user switching between different -devices, but not recommended for sharing grammars between multiple users. - -

-Also note that each grammar is assigned a unique identity -when it is first created. Renaming a grammar does not change its identity. -This means that name changes are propagated between devices like other changes. - -

Example-based grammar writing

- -This is work in progress... - -

Future work

- -This prototype gives an idea of how a web based GF grammar editor could work. -While this editor is implemented in JavaScript and runs in the web browser, -we do not expect to create a full implementation of GF that runs in the -web browser, but let the editor communicate with a server running GF. -

-By developing a GF server with an appropriate API, it should -be possible to extend the editor to support a larger fragment of GF, -to do proper error checking and make more of the existing GF shell functionality -accessible directly from the editor. -

-The current grammar cloud service is very primitive. In particular, it is not -suitable for multiple users developing a grammar in collaboration. - -

Related documents

- - -
-
- Last modified: Fri Oct 7 14:06:14 CEST 2011 -
-
-TH - -
- diff --git a/src/editor/simple/cloud.js b/src/editor/simple/cloud.js deleted file mode 100644 index f19b6ee37..000000000 --- a/src/editor/simple/cloud.js +++ /dev/null @@ -1,148 +0,0 @@ - -function with_dir(cont) { - var dir=local.get("dir",""); - if(dir) cont(dir); - else ajax_http_get("upload.cgi?dir", - function(dir) { - local.put("dir",dir); - cont(dir); - }); -} - -function remove_cloud_grammar(g) { - var dir=local.get("dir") - if(dir && g.unique_name) { - var path=dir+"/"+g.unique_name+".json" - ajax_http_get("upload.cgi?rm="+encodeURIComponent(path),debug); - } -} - -// Upload the grammar to the server and check it for errors -function upload(g) { - function upload2(dir) { - var form=node("form",{method:"post",action:"upload.cgi"+dir}, - [hidden(g.basename+".gf",show_abstract(g))]) - for(var i in g.concretes) - form.appendChild(hidden(g.basename+g.concretes[i].langcode+".gf", - show_concrete(g.basename)(g.concretes[i]))); - editor.appendChild(form); - form.submit(); - form.parentNode.removeChild(form); - } - - with_dir(upload2); -} - -// Upload the grammar to store it in the cloud -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"); - if(sharing) sharing.innerHTML=resptext; - } - } - function upload2(dir) { - var prefix=dir.substr(10)+"-" // skip "/tmp/gfse." - //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