"Nick Roberts" wrote in message news:blnaim$ebkh3$1@ID-25716.news.uni-berlin.de... > I've had an idea (not a blindingly original one) which might be a way to > help promote Ada. Dynamic web content is all the rage these days; there are > dozens of techniques used by millions of people to achieve it, including but > not limited to SSI, ASP, JSP, PHP, CGI, and many other acronyms. > > How to get Ada into this picture? > > I think one of the big attractions of schemes like ASP, JSP, and PHP (to > name but three) is that to use them you merely have to embed a few special > directives into an otherwise ordinary HTML file, and often the directives > are very simple. > > So, it seems to me, an attractive scheme would be to allow Ada code to be > embedded into an HTML file. A special program would transform this file into > a complete Ada program (procedure Main is ...) in a .adb file. The Ada > program would be a complete CGI program: you upload it, and compile it into > your cgi-bin directory. It could 'with' a simple package providing support > for the CGI protocol (and HTTP/HTML web page generation); I'm aware of an > existing AdaCGI package that might suit this. > > Since a TLA (three-letter acronym) seems to be obligatory for these things, > we might call it 'WPG' for Web Page Generation. The source file containing > the HTML with embedded Ada could then have the .wpg extension. Other > possibilities that occur to me are: DWP (Dynamic Web Pages); HRA (Hypertext > Response with Ada). The sillier the better, really. > > The special program doing the translation (from WPG to Ada) - let's call it > the WPGT - would (naturally!) be written in Ada, and I think it should be > quite simple to write. Obviously I'm volunteering, if nobody else makes a > claim. > > I propose the following embedding syntax. > > Ada code would be embedded between an opening bracket and a closing bracket, > forming an 'insertion' into the HTML file. There would be three sets of > brackets for this: one set would be used for an expression whose value is to > replace the insertion; another set would be used for Ada statements to be > executed at the point of the insertion (which is replaced by nothing); the > third set would be used for any declarations the expressions or statements > might need (also replaced by nothing). I propose the brackets be [= and =] > for the expressions [# and #] for the statements and [: and :] for the > declarations. > > I also propose that [$ and $] brackets can be used to surround the name of a > macro file to be included (and then itself expanded), since this would be > easily done by the WPGT at the same time as the transformation, and is a > very handy facility. > > So, for example, I might have a file "showtime.wpg" as follows: > > ~~~ > [$pagehead.txt$] > [=Film.Title=] - Showing Times > [$pagetop.txt$] >

Showing Times for the Film: href="filminfo?num=[=Film.Ref=]">[=Film.Title=]

> > > [# for i in Film.Screenings.all'Range loop #] > > > [# end loop; #] >
date time
[=Film.Screenings(i).Date=][=Film.Screenings(i).Time=]
> [$pagebtm.txt$] > > > ~~~ > > The idea is that the WPGT would translate this into something like the > following program file "showtime.adb": > > ~~~ > procedure Main is > begin > Put_Line("Content-type: text/html"); > New_Line; > ... stuff from pagehead.txt > New_Line; > Put(""); > Put(Film.Title); > Put(" - Showing Times"); > New_Line; > ... stuff from pagetop.txt > New_Line; > Put("

Showing Times for the Film: "); > Put(Film.Title); > Put("

"); > New_Line; > Put(""); > New_Line; > Put(""); > New_Line; > for i in Film.Screenings.all'Range loop > New_Line; > Put(""); > New_Line; > end loop; > New_Line; > Put("
date time
"); > Put(Film.Screenings(i).Date); > Put(" "); > Put(Film.Screenings(i).Time); > Put("
"); > New_Line; > ... stuff from pagebtm.txt > New_Line; > Put(""); > New_Line; > Put(""); > New_Line; > end; > ~~~ > > One big selling point would be that your dynamic web pages are generated by > a native code compiled program; a bit more efficient than a script. Another > point is that you have the full facilities of Ada programming available to > you (utility packages, bindings, and so on). > > Other possibilities include: allow the name of a package to be 'withed' > between [+ +] brackets; provide some handy translation-time values, e.g. > [?UPDATE?] to be replaced by the date and time the translation is executed. > > Some issues I can see are: > > (1) HTTP headers. You'll see my example program above generates one HTTP > header line. I get the impression that the headers a CGI program is supposed > to generate are not very well defined anywhere. I think AdaCGI has a > procedure to generate CGI headers; handy, but correct? > > (2) Conversion of < > and & characters into escaped forms in fields. I think > AdaCGI has a function to do this; could it be done automatically? > > (3) Access to databases. Most CGI programs and web scripts need to get their > information from a database, and some update databases too. I'm aware of a > project to produce a binding to PostgreSQL and MySQL; might this be what is > needed? > > (4) Most hosting companies don't allow binary CGI programs, for "security > reasons" (i.e. their own stupidity). Of those which do, many refuse to > install GNAT (despite providing GCC C++). Outrageous. However, I know at > least one hosting company (Liquid Web, http://www.liquidweb.com/ ) who is > willing to install GNAT, so maybe this isn't a hopeless problem. > > Comments? > > If I do this, I would like to make it a project at BerliOS ( > http://developer.berlios.de ). I've been a bit disappointed with the service > at SourceForge recently, but they have got new servers in recently. So, if I > do this project, where should I host it? > > -- > Nick Roberts > Jabber: debater@charente.de [ICQ: 159718630] > > Hey that sounds like it could make sense to me. Would we need to compile it into an ada program after? or perhaps all we need is an ada interpreter to perform the actions and assign variables and such? Ada can already compile to Java bytecode maybe there's a way to use that for our purposes? Dare I say "AdaScript" or something like it? With AWS as Server or executioner of this AdaScript perhaps. make it all fit together? Or are you talking about using Ada much like PHP as in make it usable with Appache or other server technologies like that one and not confine it to Ada Web Server usage only? -- St�phane Richard "Ada World" Webmaster http://www.adaworld.com