Some implementation details:
- It is implemented directly in JavaScipt. It does not use Google Web Toolkit or any big JavaScript libraries.
- It has been tested and found to work in the following browsers:
- On the Mac: Firefox 3.5 & 3.6, Safari 4.0, Opera 10.10 and Google Chrome 4.0.249.49.
- On Linux: Firefox 3.0.18 & 3.5, Opera 10.10.
- On the Android Dev Phone: Android Mobile Safari 3.0.4 & 3.1.2 and Android Opera Mini 4.2.
- The implementation consist of two JavaScript files: minibar.js and support.js The latter is also used in a couple of small web apps based on the SALDO web services.
- To access the GF web service, it uses the JSONP method mentioned in the GF web services paper, which allows the web app to be hosted on a different server from the GF web service. (To demonstrate this, I put the Minibar demo on www.cs.chalmers.se, while the GF server that it calls is on www.grammaticalframework.org.)
- As an experiment, it does no use the
grammars.xml
file, but instead calls a little CGI script, grammars.cgi which lists the .pgf files in the directory, in JSONP format. (Note: if you want to install this on your own computer,- if you click on the link,
the CGI script will be downloaded as
grammars.cgi.txt
, but it should be calledgrammars.cgi
and stored on the server in the same directory as the grammar files. - for CGI scripts to work with lighttpd,
"mod_cgi"
needs to be included in the definition ofserver.modules
in thelighttpd.conf
file.)
- if you click on the link,
the CGI script will be downloaded as
- [Added 2010-02-16] There is a button for generating random sentences.
- [Added 2010-02-23] All translations are shown, not just the first one, if there are multiple parses.
- [Added 2010-02-25] Next to each translation, there is now a little tree icon that you can click on to see a drawing of an abstract syntax tree or a parse tree. If you click on a drawing it collapses back into a tree icon.
- [Added 2010-04-09] Preparations to support different ways to access the grammar: currently we access a PGF server via JSONP, but I would also like to support AJAX, and local/downloaded JavaScript grammars.
- [Added 2010-04-19] A text entry field appears when you click in the sentence area (with a dashed border). This allows you to enter words by typing on the keyboard. As you start typing word magnets that don't match what you are typing are removed. When only one magnet remains, you can press enter to complete the word.
- [Added 2010-04-19] There is a menu for choosing the output language: you can pick "All" to translate to all available languages, or pick one particular language.
- [Added 2010-04-19] You can pass options to the function
start_minibar
to customize the user interface. The default is{show_abstract:true,show_trees:true}
to show the abstract syntax of parsed sentences, and to show icons that expand to syntax/parse trees next each translation. These features can be turned off by setting the fields tofalse
. - [Added 2010-04-30] The grammar menu is omitted if there is only one grammar in the grammar list.
- [Added 2010-04-30] Fewer hardwired constants and new
start_minibar
options (server, grammars_url, grammar_list, show_grouped_translations, delete_button_text) to makeminibar.js
more resuable.) - [Added 2010-05-26] The magnets are now created with
<input type=button>
tags to make them clickable in more browsers. - [Added 2010-05-26] The text entry field is now visible from the start, and it is removed when no more words can be added to the sentence. When you press enter, a word is added if there is only one magnet left, or if what you have entered exactly matches one of the remaining magnet.
- [Added 2010-05-28] Added a link to make it easy to try the same sentence in
Google Translate.This can be
turned off by passing the option
{try_google:false}
tostart_minibar
. - [Added 2010-06-02] Added support for Help and Feedback buttons, controlled
by the options
feedback_url
andhelp_url
passed tostart_minibar
. - [Added 2010-06-02] New option:
default_source_language
. - [Added 2010-09-10] Minibar now automatically uses XHR instead of JSONP when possible (i.e. when the HTML document and the PGF service are on the same server).
- [Added 2010-09-10] The default input language is now the user's preferred
language, if possible. This is implemented by consulting the
userLanguage
field in the grammar info output by pgf-server. - [Added 2010-10-27] Keyboard input and completion should now work much
more smoothly:
- When you press space, the current word will be completed (if incomplete) and a new magnet will be created. If there is more than one possible completion, no magnet is created, but the common prefix of the possible completions is added to the text box.
- Instead of asking the server for possible completions every time a new letter is added to the curent word, minibar only ask for completions for whole words and then filters the list locally when more letters are entered, speeding things up when server responses are slow.
- [Added 2010-10-27] Code restructuring:
- The PGF server API has been moved to its own file: pgf_online.js. This allows it to be reused in other applicaitons without importing the entire minibar. It also allows minibar to be used with different server interfaces. minibar.html has been updated to show how you use the new minibar.js and pgf_online.js.
- The minibar code has been rewritten to avoid storing state information in the document tree and accessing it by referring to named document elements. The code now also avoids using string literals containing the names of top-level functions to specify event handlers for buttons and menus. (The code is no longer introspective, so α conversion will not change its meaning.)
- [Added 2010-11-09] Some new documentation:
- gf-web-api-examples.html: examples illustrating the PGF server API provided by pgf_online.js.
- example.html: a minimal example of a web page that uses pgf_online.js to talk to the PGF server.
- [Added 2011-03-03] Added a button to display word alignment.
- [Changed 2011-03-22] Don't force focus to the typed input field after every word. On touch-based devices, the on-screen keyboard kept popping up after every word, which was very annoying if you were entering a sentence by tapping on the magnets.
- [Changed 2011-08-03] Moved the initialization code in minibar.html to minibar_online.js.
- [Changed 2011-08-08] For improved modularity and reusability, two smaller objects have been factored out from the Minibar object: Input and Translations. These have been placed in two separate files: minibar_input.js and minibar_translations.js. Some common auxiliary functions have also been moved to a separate file: minibar_support.js.
- [Added 2011-08-09] Added some Minibar API documentation.
- [Changed 2011-08-22] Quick fix to allow literals to be entered: if you press Enter, the current word will be accepted, even if there are no matching completions. (You can now use names of people when constructing sentences in the Letter grammar, for example.)
- [Added 2011-10-18] Added a button to display some grammar info and a
start category menu. The start category menu can be turned off by passing
the option
{startcat_menu:false}
when starting the minibar. - [Added 2012-02-10] New minibar option
initial_grammar
to control which of the available grammars is selected initially. - [Added 2012-03-08] Added the option
{tree_img_format: fmt}
to make it easy to select"gif"
,"png"
or"svg"
output for abstract synax trees, parse trees and word alignment diagrams. - [Added 2012-03-19] Minibar now remembers the most recently used grammar and automatically selects it the next time you return to the minibar. (This is implemented using localStorage, i.e. the data is stored locally on the user's device.)
- [Added 2012-03-26] Support for adding grammars from several servers to the grammar menu. You can also add grammars from several directories on the same server of course. The included minibar configuration file adds the user's own grammars from the grammar editor.
-
[Added 2012-04-02] Word-for-word replacements:
when a complete and
unambiguous sentence has been entered, the words glow blue and when you
click on one, possible replacements appear. (Replacements are shown as names
of functions in the abstract syntax for now. They should be shown as words
in the concrete syntax instead.) When you click on a replacement word,
the sentence is reconstructed with the new word, adjusting other words
as needed for agreement. This functionality is activated by passing the
option
{word_replacements:true}
when starting the minibar. - [Added 2012-04-03] If you leave the minibar and later return, the previous input will be restored. One input string per grammar is remembered, so you can also switch back and forth between grammars without losing the input. (This is implemented using localStorage, i.e. the data is stored locally on the user's device.)
- [Added 2012-04-04] Grammar editor integration: as part of the
word-for-word replacement interface, minibar can now show a button for
extending the grammar with a new word. This is activated by passing the
option
{extend_grammar:func}
when starting the minibar, where func is the editor function to call (to be document further). - [Added 2012-04-18] Added buttons to use generated translations as input. (This functionality is available in the original Fridge Poetry, but has been missing in Minibar, until now.)
- [Added 2012-11-23] Added support for switching back and forth between the
minibar and the new syntax tree editor. The default configuration in
minibar_online.js
shows how to enable it. - [Added 2012-11-29] After pressing the i button to view grammar info, there is now a More info button to get more detailed information about all categories and functions in the grammar.
- [Added 2013-03-25] Initial support for selecting an arbitrary subset of languages to appear in the translations and in word alignment diagrams.
- [Added 2013-03-26] Parse tree visualizations: click once to show parse trees without function names. Click again to add function names.
- [Added 2013-03-27] Click on a linearization to obtain a table with all variants and forms. Click again to hide the table.
- [Added 2013-04-02] Abstract syntax tree visualizations: click once to show abstract syntax trees without category names. Click again to add category names.
- [Added 2013-04-02] Minibar now remembers from one visit to the next the selected set of target languages for each grammar.
- [Added 2019-08-05] Minibar can now display grammar documentation.
The documentation is taken from a file called
Grammar
.pgf_info
, located next to the Grammar.pgf
file on the server. The first line of the documentation is displayed below the menu bar in the minibar. The rest of the documentation is displayed when you press the More info button (or the i button). The documentation can contain HTML markup. Blank lines are treated as paragraph breaks. - [Added 2019-11-21] It is now possible to configure a list of preferred
grammars.
A preferred grammar is selected when a user visits Minibar for the
first time. (Like before, Minibar remembers the selected grammar for
future visits.)
A preferred list of grammars can be specified in
config.js
in the…/minibar
directory on the server, e.g. like this:preferred_grammars=["/grammars/Foods.pgf","/grammars/ResourceDemo.pgf"]
The first available grammar from the list is used.