Menu

Home

Chee Chuen Sim

Welcome to your wiki!

What is enblok

enblok is a rapid web development tool for business applications. Its design is modeled
after a block based 4GL tool popular in the 90s.

You assemble *blocks* in your django template, with each block wired to a tastypie resource, which
in turn is mapped to a django model. Each *block* will reside in a dijit ContentPane which you must
define in your template. You have a choice of 2 layouts for each *block*, Form or
Grid based. Form displays a single record in either a 1, 2 or 3 column layout while Grid displays
many rows in a spreadsheet like grid. You can perform edits in place on fields in both layouts.

You can define the master-detail relationship between the *blocks* and enblok will
automatically display the related detail *block* rows as the user navigates the master *block*'s 
rows.

You get for free the default *CRUD* functionality for each block, together with Search. You are not limited
to just a 2 level master-detail relationship, in fact enblok can support n-th level relationships but we 
do not advise you to go beyond 3.

You can also run the same enblok program in query mode by setting *queryOnly* to true for the Program.
You do this by passing a *query_only* parameter into the django template, have a look at enblok/urls.py
and enblok/ChoiceList.html template.

We also bundle enblok-admin, a django admin replacement. You define the *blocks* of your admin program
in a json specifications file and enblok will do the rest. Check out our enblok/admin/ChoiceList.json.

How to install

You can install from a release zip or tgz file, named "maeblok-x.y.z.zip" or "maeblok-x.y.z.tgz" 
where x.y.z is the release version.

Pre-requisites

    0) You are a django, tastypie and javascript web developer
    1) python 2.7 but not 3.x (yet)
    2) django >= 1.7
    3) django-tastypie >= 0.12

From release file, these instructions assumes you are using Linux and has django experience

    1) Extract enblok-x.y.x.zip (or tgz) to a working directory, eg ~/work
    -- replace x.y.z with the release version number.
    2) rename ~/work/x.y.z to ~/work/maeblok
    -- if you use another directory, change all settings below accordingly

One time setup

    1) edit your .profile with,
        export DJANGO_SETTINGS_MODULE=maeblok.settings
        export PYTHONPATH=~/work/maeblok
        and relogin. Unix users can do ". ./.profile" instead of relogging in.
    2) cd ~/work/maeblok (or whichever directory you installed, ~ means your home directory)
    3) ./manage.py migrate
    4) ./manage.py loaddata choice_list

Running maeblok using Django's development server

1) cd ~/work/maeblok
2) ./manage.py runserver 8000
3) fire up browser and http://localhost:8000/enblok/ChoiceList/
   -- this runs template enblok/ChoiceList.html
4) fire up your editor and open enblok/templates/enblok/ChoiceList.html to see how things work

Running from compiled js

1) cd ~/work/maeblok
2) ./manage.py collectstatic
3) cd dojo-src
4) util/buildscripts/build.sh --profile maeblok.profile.js
   make sure there are 0 errors. If there are then this is a bug. Inform us.
   The compressed js will be in ../maerun/dojo-1.10
5) edit maeblok/urls.py
   in the bottom half of this file, there are 2 'dojo/...' urls. Comment out the first one
   (which serves dojo-src) and uncomment the second (which serves compiled dojo in the run home
   directory where you built the compressed js in previous step)

enblok admin

1) You can define admin programs against 1 or more models using a json specification file.
2) run http://localhost:8000/enblok/EnblokAdmin/enblok/ChoiceList/
3) edit enblok/admin/ChoiceList.json to see how it works. Note that ChoiceList is a parent of
   ChoiceValue, joined by Foreign Key
4) enblok/admin/readme.txt has details on all admin specs

Windows installation

1) Instead of editing your .profile, add DJANGO_SETTINGS_MODULE and PYTHONPATH above to your
   Environment Variables.
2) The rest of the instructions should be run from a Command Prompt after you have changed your
   Environment Variables. As usual, mind the forward slashes (use back slash instead)

Creating your own enblok programs

You should perform the following steps and remember to 'copy and modify' at all times :-

    1) Create your own django app, eg myapp
    2) Optionally edit maefra/urls.py and add the following :-

            url(r'^myapp/', include('myapp.urls')),

       This allows you to have your own urls.py under your own myapp directory. Copy 
       our enblok/urls.py.

    3) Create your django model
    4) Optionally create a form for each model if you want to perform validation at the 
       backend.
    5) Create a tastypie resource for each of your model. 
    6) Create an enblok model definition file for each tastypie resource
    7) Create a translation file for each model fields' prompt and labels.
    8) Use either enblok-admin or your own django template to write the program

        enblok-admin

            1) create a json specs file MyModel.json in myapp/admin. See enblok/admin/readme.txt.
            2) run it with the url "http://localhost:8000/enblok/EnblokAdmin/myapp/MyModel/"

        own template

            1) Copy and modify our enblok/ChoiceList.html
            2) Start with the html layout at the bottom. You should read up a bit on
               dijit BorderContainer, ContentPane, TabContainer, StackContainer and etc
               to design the layout that you want.
            3) You must provide a dijit Container and a ContentPane for the Program and Toolbar
               respectively. For each block, you must provide a ContentPane. We do not restrict
               you in any way on the layout. You can use any of dijit's containers as parent to all 
               the blocks' ContentPane.
            4) Replace our ChoiceList and ChoiceValue blocks in the template. If you have 2 or 
               more blocks, then you must define the relationships between them in the Program's
               definition.
            5) Remove all feature demo code from the template. We added them to show you how
               to use certain features.
            6) Add 2 url entries in your myapp/urls.py, the 2nd one for query_only mode. 
            7) Run it using the url you have just created

    If you are having trouble getting the above to work, see our pre-requisites ;-). But seriously,
    run our 2 example programs and look at the browser's source code to understand how it works before
    attempting to write any new programs. The browser's debugger will also be very helpful to find out
    what happens behind the scenes with the server.

Project Members: