Status of qxotica Tools


Contents

What's New
Introduction
Requirements
Installing the qxotica tools
Getting started - Unicodum demo app
Getting started - creating a qooxdoo app
Developing a qooxdoo app
Future topics and to-do list


What's New


Introduction

These notes describe the status of the qxotica tools for creating mobile Web apps with the qooxdoo JavaScript framework.

The tools consist of these parts:

All source code for the tools and demo app is released under the same modified LGPL licence as Free Pascal.


Requirements

  1. qooxdoo SDK

    qooxdoo.org

    Download and unzip the qooxdoo SDK anywhere you want. Support for both mobile and desktop browsers is included in the same SDK. (Note that the qxotica tools currently only support developing mobile Web apps.)

    Note that the qooxdoo tools require Python somewhere on your computer's path. Python comes set up on OS X and some Linuxes; if needed, download and install Python 2.x from here: python.org/.

    Note also that qooxdoo now uses Sass to convert .scss files to .css. You can download Sass from here: http://sass-lang.com.

  2. Lazarus IDE and Free Pascal compiler

    www.lazarus.freepascal.org

  3. Web server

    You don't need a Web server if you'll be developing a client-only Web app, but you will need a Web server to develop a Pascal server app for your qooxdoo app. You can use a local Web server installed on your development computer.

  4. qxotica source files

    Check out the files from SourceForge. Change to the directory where you want to put the qxotica files and enter this:

    svn checkout svn://svn.code.sf.net/p/qxotica/code/trunk .
    

Installing the qxotica tools

  1. Install Qx_Proj package in Lazarus

    Start Lazarus, choose Package | Open Package File, and select the qx_proj.lpk file (under qx_proj in the qxotica checkout folder). Click Compile to compile the package, then click Use | Install to install the package in Lazarus.

    Once installed, you'll see qooxdoo-related items in the Lazarus File | New dialog.

  2. Compile the rungen helper program.

    In order to "compile" a qooxdoo app (run its generate.py script) from Lazarus, you need to compile the rungen helper program. In Lazarus, choose File | Open and select the rungen.lpi file (under utils in the qxotica checkout folder). Choose Run | Compile to compile it.


Getting started - Unicodum demo app

At this point you could just start Lazarus, choose File | New, select qooxdoo JavaScript App, and enter the required information to create a new mobile Web app. However, if you've never worked with qooxdoo before, the resulting JavaScript files might not make much sense to you. So let's start with the Unicodum demo app.

Once you get the Unicodum client app running in your browser and its Pascal server app running under your local Web server, it should look like this screenshot.

Note: Even though Unicodum is a mobile Web app designed for iOS and Android devices, you can also run it in Firefox or any WebKit-based desktop browser like Safari, iCab or Chrome. It will not work with older versions of IE, however. To fully support both mobile and desktop browsers, you could create two different clients since the qooxdoo mobile and desktop widgetsets are different.

Create the Unicode database

The Unicodum client app running in your browser will request Unicode data from the server app. So the first thing we need to do is create a database of Unicode data for use by the server app.

  1. Download files Blocks.txt and UnicodeData.txt from here:

    http://www.unicode.org/Public/UNIDATA/

    Place both files in the qxotica checkout folder's demos/Unicodum/db folder.

  2. Compile the cvtuni.pas program in demos/Unicodum/db.

    fpc cvtuni.pas
    
  3. Create the Unicode database.

    The Pascal server app expects a SQLite database, so run cvtuni like this:

    cvtuni -s
    
    This will create file Unicode.sqlitedb from Blocks.txt and UnicodeData.txt.

    Note: You must have the SQLite library somewhere on your path to run cvtuni. SQLite comes pre-installed on OS X and some Linuxes, but with Windows you may need to download it: www.sqlite.org/.

    If you want to use the PHP server script instead, run cvtuni like this:

    cvtuni -i
    
    This will create files Blocks.ini and UnicodeData.ini. Note that the following steps assume you'll be running the Pascal server app.

Compile the Pascal server app

  1. Get FCGIApp package.

    The Pascal getunicode server app requires the FCGIApp units from the ExtPascal project. The source for the FCGIApp and related units is here and consists of these files:

    fcgiapp_pkg.lpk
    fcgiapp_pkg.pas
    FCGIApp.pas
    BlockSocket.pas
    ExtPascalClasses.pas
    ExtPascalUtils.pas
    cgigateway.lpi
    CGIGateway.dpr
    
  2. Compile the FCGIApp package.

    In Lazarus, choose Package | Open Package File, select fcgiapp_pkg.lpk and click Compile. You don't have to install the package in Lazarus since it's not a design package.

  3. Compile the getunicode server app.

    In Lazarus, choose File | Open, navigate to qxotica's demos/Unicodum/pascal_server folder and select getunicode.lpi, then choose Run | Compile to compile it.

  4. Compile CGIGateway app (optional).

    If your Web server does not support FCGI (or if you're not sure), you can use the intermediate CGIGateway app along with getunicode.

    In Lazarus, choose File | Open, navigate to where you checked out or saved the ExtPascal files and select cgigateway.lpi. Then choose Run | Compile to compile it.

    Copy the resulting cgigateway.cgi file to your Web server's cgi-bin folder (on OS X, this is /Library/WebServer/CGI-Executables).

    Note: If your Web server supports FCGI, you would instead copy getunicode.fcgi (renamed on Linux or OS X) or getunicode.exe (Windows). You would also need to edit the client app's config.json file and change cgigateway.cgi to getunicode.fcgi or getunicode.exe.

  5. Copy Unicode.sqlitedb

    Place Unicode.sqlitedb in demos/Unicodum/pascal_server so the server app can find its database.

Prepare the qooxdoo client app

  1. Edit the client app's qooxdoo path.

    With a text editor, navigate to qxotica's demos/Unicodum/client/unicodum folder and open file config.json. Scroll down a bit and look for QOOXDOO_PATH. Change its value to the path to your qooxdoo SDK.

  2. Generate the client app's unicodum.js script.

    In Lazarus, navigate to qxotica's demos/Unicodum/client/unicodum/source/class/unicodum folder and open unicodum.lpi.

    Choose Run | Compile to run the client project's generate.py script, which will generate the unicodum.js script in the unicodum/source/script folder.

    Important! Don't be alarmed if this takes a couple minutes. The generate.py script creates a large cache the first time it's run. Subsequent runs will take only a few seconds.

Run Unicodum

  1. Open the Pascal getunicode.lpi project in Lazarus as described above, but this time choose Run | Run. The server app will run and wait for requests from the client.

  2. Double-click index.html in qxotica's demos/Unicodum/client/unicodum/source folder or open it manually in your browser. If the page doesn't display a list of Unicode blocks, review the above steps for mistakes.

  3. Windows note: As indicated above, if the app doesn't work you may need to change its URL to specify localhost:8080. With a text editor, open the client app's config.json file and edit the uniurl setting under source-usecgi.

(What about the PHP server?)

If your Web server supports PHP, you can test the getunicode.php script in qxotica's demos/Unicodum/php_server folder. This script is functionally equivalent to the Pascal getunicode program.

To tell the client app to use the PHP server script, you'll need to do two things:

  1. With a text editor, open the client app's config.json file and edit the uniurl setting under source-usephp. This setting needs to point to where getunicode.php will be located on your Web server.

  2. Open unicodum.lpi in Lazarus and choose Project | Project Options. Click Compilation and change the Execute before Command's last parameter from source-usecgi to source-usephp. Close the dialog and choose Run | Compile to refresh the unicodum.js script.


Getting started - creating a qooxdoo app

Creating the qooxdoo app

A qooxdoo app's folder structure

Figure 1 shows the Unicodum demo app's folders and files.

   Figure 1. Folders and files in a typical qooxdoo app.

config.json - this file defines the "jobs" that generate.py can do; since Unicodum can use two different server apps, custom jobs in this file define the URLs for them.

generate.py - when you "compile" a qooxdoo app in Lazarus, this script is run to generate the files under script (below).

license.txt - this file was added for Unicodum; not created for new app.

Manifest.json - information about the app.

Under source/class:

Application.js - a qooxdoo mobile app is a loosely bound collection of pages managed by this file.

page - The Unicodum app has four pages, each in its own JavaScript file in this folder.

unicodum.lpi - Lazarus project info file; open this in Lazarus to edit the app's JavaScript files.

index.html - double-click this file to load the client app into your browser.

Under source/resource:

styles.css - add CSS styles to this file for use with widgets in your pages. (Edit: qooxdoo now looks for your styles in _styles.scss in source/theme/appname/scss.)

If you have additional local files that your app needs (images, JSON, etc.), place them in the project's folder under resource.

Under source/script:

Files generated by generate.py are placed here.


Preparing to run a qooxdoo app

Running a qooxdoo app

Deploying a qooxdoo app

   Figure 2. Folders and files in a typical qooxdoo deployment.



Developing a qooxdoo app

Documentation

JavaScript gotchas

Here are a few things that Pascal programmers need to remember when starting out with JavaScript.

Future topics and to-do list

  1. Support for desktop browser apps (if interest warrants). --> In general, qooxdoo mobile apps now work fine in desktop browsers too.

  2. Discuss converting qooxdoo app to native mobile app via PhoneGap. --> See tech note 1 (QxoticaTechNote1.html).

  3. Discuss various offline and online storage options available to Web apps (session, local, Web SQL Database, IndexedDB, Dropbox).


Copyright 2012 by Phil Hess.

macpgmr (at) icloud (dot) com

First posted Oct. 3, 2012; last edited March 18, 2017.