From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b1150caefb87348f,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-10-04 13:29:13 PST Path: archiver1.google.com!news2.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!fu-berlin.de!uni-berlin.de!82-43-33-75.cable.ubr01.croy.blueyonder.co.UK!not-for-mail From: "Nick Roberts" Newsgroups: comp.lang.ada Subject: Ada Advocacy - WPG (Web Page Generation) scheme Date: Sat, 4 Oct 2003 21:29:12 +0100 Message-ID: NNTP-Posting-Host: 82-43-33-75.cable.ubr01.croy.blueyonder.co.uk (82.43.33.75) X-Trace: news.uni-berlin.de 1065299351 15061539 82.43.33.75 (16 [25716]) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 Xref: archiver1.google.com comp.lang.ada:232 Date: 2003-10-04T21:29:12+01:00 List-Id: 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: [=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]