Chapter 1.1: Helper

There is a Genelet::Helper package in Genelet. A shell command help.pl is distributed together. For novice developer, you are recommended to run this program. It generates a layout of basic Perl classes, templates, config.json and CGI script.

To use it, go to the directory containing help.pl, and run:

>$ ./help.pl [options] table1 table2 ...
 --dir project root, default '~/HOME/tutoperl'
 --dbtype database type 'sqlite', 'pg' or 'mysql', default 'mysql'
 --dbname database name, mandatory
 --dbuser database username, default ''
 --dbpass database password, default ''
 --project project name, default 'myproject'
 --script script name, default 'myscript'
 --force if to override existing files, default false
 --angular if to include Angular 1.3 files, default false

 

If it is successful, you will find the following tree structure in geneletperl:

geneletperl
          > bin
              - myscript
          > conf
              - config.json
          > lib
              > Myproject
                        - Model.pm
                        - Filter.pm
                        > Table1
                               - Model.pm
                               - Filter.pm
                               - component.json
                        > Table2
                               - Model.pm
                               - Filter.pm
                               - component.json
          > views
                > admin
                      > table1
                             - topics.html
                             - edit.html
                             - startnew.html
                             - insert.html
                             - update.html
                             - delete.html
                      > table1
                             - topics.html
                             - edit.html
                             - startnew.html
                             - insert.html
                             - update.html
                             - delete.html
                > public
                       > table1
                              - startnew.html
          > www

The layout shows a basic development environment in Genelet. If you are an experienced developer, you may manually build up the layout.

 

bin

A directory for executable programs. Here is the CGI program myscript.

conf

For configurations. Here is config.json. You may put your database schema and other initial settings here.

lib

For Perl packages and being under PERL5LIB. Project’s classes Model.pm and Filter.pm should be in the same directory as all component names, and each component has its own Model.pm and Filter.pm, and component.json for the configuration of the classes. In the inheritance hierarchy, project inherits from Genelet, and component inherits from project.

views

For HTML templates.  They are placed in the tree structure: role/component/action.html.

www

Optionally for the Angular 1.3 one-page web site. See here.

If you are an experienced developer, you can pass help.pl and go directly to manually create all the above files by yourself.

Comments are closed.