Appendix: Developer notes

The complete MOLTO TT prototype editor code is downloadable as an eclipse (Helios) project archive http://tfs.cc/molto/molto-tt-0.9-linux-eclipse-20120529.zip. The TT editor's database back-end Haskell source code is packaged as http://tfs.cc/molto/molto-tt-server-0.9-linux-20120529.zip.

Apache web server settings

Install apache and fastcgi with apt-get: sudo apt-get install apache2 libapache2-mod-fastcgi

Here is a sample Apache2 virtual host below to handle the MOLTO TT back end services from port 8888 (the default). The back end server is supposed to be in the same domain as the editor to avoid cross-domain scripting violations. Copy the text below to /etc/apache2/sites-available/default

<VirtualHost *:8888>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www
    AddDefaultCharset UTF-8

    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>

        # Allow fastcgi services from fcgi-bin. 

    <Directory "/var/www/fcgi-bin/">
        Options +ExecCGI 
        AddDefaultCharset UTF-8
        SetHandler fastcgi-script
    </Directory>

        # Identify pgf-service as a fastcgi server
        FastCgiServer /var/www/fcgi-bin/pgf-service 

        # Identify content-service as a fastcgi server
        FastCgiServer /var/www/fcgi-bin/content-service 

        # Make action pgf-service handle pgf files
    Action pgf-service /fcgi-bin/pgf-service
    AddHandler pgf-service .pgf
    AddCharset UTF-8 .pgf
</VirtualHost>

After you have copied the above to /etc/apache2/sites-available/default, activate the changes:

sudo a2enmod fastcgi
sudo a2enmod actions

Finally, restart apache by typing sudo service apache2 restart.

Some attested problems

  1. Server doesn't start, error message is just "fail". If you copy and paste conf files, make sure they don't override any previous confs you might have.
  2. "Permission denied" error messages when trying to access (chmod 775) files in /var/www.
    Solution was to change the ownership group from root to all users: sudo chown -R root:www-data /var/www/ (the name of the group might vary, you can see yours by seeing which group has /var/www; do grep "/var/www" /etc/passwd).

GF server settings

Get the latest sources for GF from darcs repository. The instructions are here: http://www.grammaticalframework.org/download/index.html

Assuming you have the source files, go to src/server and type sudo cabal install -f content --global. It is important to use the option --global, because by default they are installed in the home directory, and that doesn't go well with Apache. The binaries will be installed in /usr/local/bin. Because of Apache, you need to set their owner group to the apache group (depending on machine, e.g. www-data or apache).

The next step is to link the binaries to /var/www/fcgi-bin.

/var/www$ sudo ln -s /usr/local/bin/content-service fcgi-bin/
/var/www$ sudo ln -s /usr/local/bin/pgf-service fcgi-bin/

Some attested problems

  1. gf-server-1.0 depends on fastcgi-3001.0.2.3 which failed to install.
    If you get the following error, you must first have C library fcgi. First install libfcgi-dev (sudo apt-get install libfcgi-dev), then try again to install PGF service and content service: sudo cabal install -f content --global

Developer version settings

This applies only if you want to use the editor from Eclipse. Otherwise you don't need any of this.

To test the TT editor under eclipse using GWT devMode, we found it necessary to recompile content-service to add the gwt code server port parameter to page URLs. To do so activate the following lines in ContentService.hs . We have been using eclipse 3.6 JEE with Google Web Toolkit version 2.3.1.

-- devModeScriptName = (liftM2 (++)) (getVarWithDefault "SCRIPT_NAME" "") (return "?gwt.codesvr=127.0.0.1:9997") 
-- path <- devModeScriptName

A corresponding change is neeeded in the client code. Activate the following line in TT-0.9/src/org/grammaticalframework/ui/gwt/client/SettingsPanel.java

// String defaultUrl = "/fcgi-bin/content-service?gwt.codesvr=127.0.0.1:9997";

Launch settings for building and testing under devMode under eclipse (in $HOME/workspace/.metadata/.plugins/org.eclipse.debug.core/.launches):

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="com.google.gdt.eclipse.suite.webapp">
<booleanAttribute key="com.google.gdt.eclipse.core.RUN_SERVER" 
                  value="false"/>
<stringAttribute key="com.google.gdt.eclipse.core.SERVER_PORT"
                  value="80"/>
<stringAttribute key="com.google.gdt.eclipse.suiteMainTypeProcessor.
PREVIOUSLY_SET_MAIN_TYPE_NAME" value="com.google.gwt.dev.DevMode"/>
<booleanAttribute key="com.google.gdt.eclipse.
suiteWarArgumentProcessor.IS_WAR_FROM_PROJECT_PROPERTIES" value="true"/>
<listAttribute key="com.google.gwt.eclipse.core.ENTRY_POINT_MODULES">
<listEntry value="org.grammaticalframework.ui.gwt.EditorApp"/>
</listAttribute>
<stringAttribute key="com.google.gwt.eclipse.core.URL"
                 value="editor"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/TT-0.9-ORIGINAL"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER"
                 value="com.google.gwt.eclipse.core.moduleClasspathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE"
                 value="com.google.gwt.dev.DevMode"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS"
                 value="-startupUrl editor -war $HOME/workspace/TT-0.9/www/editor \
                 -noserver -remoteUI "${gwt_remote_ui_server_port}:${unique_id}" \
                 -logLevel INFO -codeServerPort 9997 \
                  org.grammaticalframework.ui.gwt.EditorApp"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="TT-0.9"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx512m"/>
</launchConfiguration>

Database settings

HSQL and HSQL-MySQL installation

First you need to install HSQL. It's in hackage, so it can be installed by typing sudo cabal install hsql --global.

The public version of the Haskell MySQL package hsql-mysql-1.8.1 used by the TT content service appears to have a bug that prevents multiple successive mysql procedure calls. A debugged version of the package can be found at http://tfs.cc/molto/hsql-mysql-1.8.1-molto.zip.

Install the debugged version:

  • Download and extract the files in hsql-mysql-1.8.1-molto.zip
  • Go to the top level directory, where you can find hsql-mysql.cabal
  • Install by typing sudo cabal install --global

Some attested problems

  1. HSQL 1.8.2 doesn't install. Solution: try HSQL 1.8.1. You can choose it by typing sudo cabal install hsql-1.8.1 --global or downloading the version from hackage.

MySQL server settings

In addition to the above, you need a mysql server. You can install one by typing sudo apt-get install mysql-server.

Content-service uses a mysql database to store users, grammars and documents.

To create the database connection you need to do the following steps:

  1. create the database for molto content service
  2. create the content service database owner user
  3. give that user all rights for the database
  4. create key file fpath somewhere with the unholy quartet host db user pwd in format known to haskell readFile.
  5. call service with fpath as the only argument to create user, grammar and document tables:
    content-service fpath

Now create the database:

$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
...

mysql> CREATE DATABASE moltodb;
CREATE USER moltouser IDENTIFIED BY 'moltopass';
GRANT ALL on moltodb.* to moltouser;

Query OK, 1 row affected (0.02 sec)

mysql> Query OK, 0 rows affected (0.00 sec)

mysql> Query OK, 0 rows affected (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| moltodb            |
+--------------------+
2 rows in set (0.00 sec)

mysql> quit
Bye

Next, create the database files.

/usr/local/bin$ ./content-service fpath

And then log in to mysql with the user moltouser.

mysql -u moltouser -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.

mysql> use moltodb;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+-------------------+
| Tables_in_moltodb |
+-------------------+
| Documents         |
| GrammarUsers      |
| Grammars          |
| Users             |
+-------------------+

4 rows in set (0.00 sec)

If so the tables got created ok. There is nothing yet in the tables. After you first sign in with your google account, then your user account will be in the table Users. You can query any of the tables by writing select * from <table>.

Tabular editor (stand-alone version)

To install the tabular equivalents editor source, do this:

  1. checkout the whole source code directory from https://svn.it.helsinki.fi/repos/molto/trunk/molto_term_editor/ and put it in any place where the apache server can reach, i.e. /var/www/.
  2. download the extjs-4.0.2a package from http://extjs.cachefly.net/ext-4.0.2a-gpl.zip, and uncompress it as extjs-4.0.3 under the directory molto_term_editor/.
  3. then, you can open the link http://localhost/molto_term_editor/editor_sparql.html, if you put the source code under /var/www/.

GlobalSight

The GlobalSight installation values are kept in $HOME/workspace/GS-8.2.2.1/main6/tools/build/dist/GlobalSight/install/data/installValues.properties. The following shows settings used for a MOLTO GlobalSight eclipse installation (with $HOME replacing the installation directory and PASSWORD the password/s) :

#Mon May 28 22:52:03 EEST 2012
mailserver=mail.domain.com
system_log_directory_forwardslash=$HOME/workspace/GS-8.2.2.1/main6/tools/build/dist/GlobalSight/logs
install_data_dir_forwardslash=$HOME/workspace/GS-8.2.2.1/main6/tools/build/dist/GlobalSight/install/data
server_host=localhost
database_password=PASSWORD
database_server=localhost
database_username=globalsight
ldap_password=PASSWORD
ldap_install_dir=/var/lib/ldap
server_port=9090
ldap_host=localhost
gs_home=$HOME/workspace/GS-8.2.2.1/main6/tools/build/dist/GlobalSight
ldap_username=ldap_connection
admin_email=WelocalizeAdmin@domain.com
system4_admin_username=gsAdmin
ldap_base=globalsight.com
ldap_port=389
GS_HOME=$HOME/workspace/GS-8.2.2.1/main6/tools/build/dist/GlobalSight
cap_login_url=http\://127.0.1.1\:9090/globalsight