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/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 47 files changed, 5137 insertions(+) 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/www') diff --git a/src/www/gfse/Makefile b/src/www/gfse/Makefile new file mode 100644 index 000000000..00a97b337 --- /dev/null +++ b/src/www/gfse/Makefile @@ -0,0 +1,7 @@ + +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/www/gfse/P/1306856253_weather_06.png b/src/www/gfse/P/1306856253_weather_06.png new file mode 100644 index 000000000..3f01afcaa Binary files /dev/null and b/src/www/gfse/P/1306856253_weather_06.png differ diff --git a/src/www/gfse/P/1307545089_weather_04.png b/src/www/gfse/P/1307545089_weather_04.png new file mode 100644 index 000000000..8a7f1e3ae Binary files /dev/null and b/src/www/gfse/P/1307545089_weather_04.png differ diff --git a/src/www/gfse/P/w1s.jpg b/src/www/gfse/P/w1s.jpg new file mode 100644 index 000000000..199fcb7ba Binary files /dev/null and b/src/www/gfse/P/w1s.jpg differ diff --git a/src/www/gfse/P/w2s.jpg b/src/www/gfse/P/w2s.jpg new file mode 100644 index 000000000..9673758c0 Binary files /dev/null and b/src/www/gfse/P/w2s.jpg differ diff --git a/src/www/gfse/P/w3s.jpg b/src/www/gfse/P/w3s.jpg new file mode 100644 index 000000000..1a8680ec7 Binary files /dev/null and b/src/www/gfse/P/w3s.jpg differ diff --git a/src/www/gfse/P/w4s.jpg b/src/www/gfse/P/w4s.jpg new file mode 100644 index 000000000..5c685c134 Binary files /dev/null and b/src/www/gfse/P/w4s.jpg differ diff --git a/src/www/gfse/TODO b/src/www/gfse/TODO new file mode 100644 index 000000000..22974ebe0 --- /dev/null +++ b/src/www/gfse/TODO @@ -0,0 +1,43 @@ ++ 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/www/gfse/about.html b/src/www/gfse/about.html new file mode 100644 index 000000000..8660621a3 --- /dev/null +++ b/src/www/gfse/about.html @@ -0,0 +1,243 @@ + + + +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/www/gfse/cloud.js b/src/www/gfse/cloud.js new file mode 100644 index 000000000..f19b6ee37 --- /dev/null +++ b/src/www/gfse/cloud.js @@ -0,0 +1,148 @@ + +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