Tuesday, February 27, 2007

Web CGI idears

I bumped into AT who was building a CGI interface in C++ and complaing over the extra 800k the C++ cgilib adds to each CGI script.

I suggested the idea of doing a Ruby on rails with C. I have two suggestions

1. An XML/HTML document format that mixes HTML with C code like this ( filemycgi.XCGI )


[HTML]
[TITLE] HELLO [/TITLE]
{bODY]
[TABLE]
[% int i ; for( i = 0 ; i < 100 ; i++ ) { !%]
[T-D] [!% printf("%d i"); !%]
[ !% } // NEXT !%]
[/TABLE]
[/HTML]



each CGI would then be run through COMPILER which would take the HTML and embed it as printf()s into a c source code file then pass the C file to gcc with a small library. producing the mycgi.exe or a.out. This way when you run the CGI you get a high speed response and a pre compiled language. Even the CGI source can be removed to make the code work.

The system would come with a number of libaries that would make working with a database and other files work. Possibly even a template re-writing system.

2. Second and slightly diffrent idea.
Have a pre-adaptive system. In essance you set up a watcher that scans the file system/database/time/ to pre-build html files then write them out to disk.

It would work like this. In your watcher file.

Database "urbanist" on localhost with user 'watcher' and password 'bobo' has trigger 'triggerone'
change to table products -> doreformatproducts.watcher ;

Database "urbanist" on localhost with user 'watcher' and password 'bobo' has trigger 'triggerTwo'
change to table users
-> donewuser.watcher < { (select * from users where time > last_time } ;
-> last_time = getimeseconds() ;

file template.css hashchanges -> doformatproducts.watcher ; // this generates producs.html

// touched is any ateration.

file products.html touched -> email( "sheep@mywerbsite.com" , products rechanged ) ;
// backward changes sidebar.html depends upon template
file sidebar.html <-( directory /usr/web/html/www/mysite/folders changes ) dosidebar // generates sidebar.html

file sidebar.html touched -> ssh it to sheep@website.com:password // moves it to website on outside firewall.

change can have multiple dependaces and multiple actions
// time acts like
time every day at 1:00am -> doformatproducts.watcher ; // update products once per day.
time every week -> doformatproducts.watcher ; email("me@myself.com" , "products changed " ) ;

so conceptually a combination of cron,triggers and file updates with make.

No comments: