cgictrl-0.4(CGI framework for Ruby)


Google

Japanese

Copyright (C) 2009 Masahiko Ito

These programs is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

These programs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with these programs; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Mail suggestions and bug reports for these programs to "Masahiko Ito" <m-ito@myh.no-ip.org>

Download

What's this ?

A kind of cgi framework for ruby.

Feature

Cgictrl is not semblant to another cgi framework(Ruby on Rails etc). Main feature of cgictrl is that you can use a structure of mainframe program (like on IBM's CICS) for cgi program.

Executing cgi program is selected by transaction code. and cgi program indicate next transaction code to continue conversation process.

Basically, one cgi program send only one kind of view, and process input data from only this view.

cgi program put/get internal data into/from special area called SPA(Scratch Pad Area) in server. SPA is allocated uniquely per session by cgictrl.

Features are ...

How to install

How to use

Setting files

cgictrl.cgi(Cgi Control Program)

~/cgictrl/resource.txt setting

Format : RESOURCE_ID=REAL_RESOURCE_NAME
  ex. RES1=/home/m-ito/dat/database.txt
You must define resource which cgi program control exclusive for. cgictrl control exclusive for only resource which is defined in resource.txt. cgictrl can recognise resource by only resource id. real resource name is no use for cgictrl, so real resource name should not be real one except following special resource.

Special resource

these are resource for internal use, so you can't use these resource id as user define resource.

`LOGFILE' means logging file. default value is defined in cgictrl_common.rb. If you don't know what you are doing, you should not change `LOGFILE'.

`SPADIR' means directory which include SPA. default value is defined in cgictrl_common.rb. If you don't know what you are doing, you should not change `SPADIR'.

~/cgictrl/tran2pgm.txt setting

Format : TRANSACTION_CODE=PATH_TO_CGI:RESOURCE_ID/ACCESS_MODE, RESOURCE_ID/ACCESS_MODE, ...
  ex. SAMPLE1=/home/m-ito/public_html/RubyFrameWork/cgi-bin/sample1.cgi:RES1/A,RES2/G,RES3/A
You must define cgi program and resource id which transaction code relate to. Resource id must be defined in resource.txt too.

Access mode is only comment now. Access mode is always fixed to `A'. In the future, you can select following as access mode.

~/cgictrl/usertran.txt setting

Format : USER_ID=TRANSACTION_CODE (regex is ok)
  ex. m-ito=TEST|SAMP_.*
You must define permit transaction for users who are authenticated by httpd(Basic authenticate etc).

If cgictrl is not configed to use httpd's authentication, user id is setted to `anonymous'. so you can define permit transaction for `anonymous'.

Some default values in cgictrl_common.cgi

Default value which must be changed

Default values which may be changed

Default values which sould keep default value.

How to invoke

Set first transaction to param `SYS_init_tran', and call cgictrl.cgi.
  ex. http://foo.org/cgi-bin/cgictrl.cgi?SYS_init_tran=TRANSACTION_CODE

How to create view file.

Make view design into html-like view file. you should not put HTML tag directory from your cgi program. you should put view file into ~/cgictrl/html/.

Differential from ordinary html file is

User cgi program

See sample cgi program. Basically, you can put your coding in following.
  #--- user coding start ---
  #--- user coding end   ---
  
In principle, you should not change out of `#--- user coding start ---' to `#--- user coding end ---'. But if you need to change, you should understand logic well.

Method which is defined in Cgictrl class for user.

Sample

This is sample which calculate area of circular and volume of ball.

Epilogue

I hope cgictrl will be help for persons who had invaluable experience on mainframe computer but getting hard to develop web application.
m-ito@myh.no-ip.org

[Update]