comp.lang.ada
 help / color / mirror / Atom feed
* Ada Advocacy - WPG (Web Page Generation) scheme
@ 2003-10-04 20:29 Nick Roberts
  2003-10-04 21:17 ` Larry Kilgallen
                   ` (6 more replies)
  0 siblings, 7 replies; 38+ messages in thread
From: Nick Roberts @ 2003-10-04 20:29 UTC (permalink / raw)


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$]
<title>[=Film.Title=] - Showing Times</title>
[$pagetop.txt$]
<h2>Showing Times for the Film: <a
href="filminfo?num=[=Film.Ref=]">[=Film.Title=]</a></h2>
<table>
<tr> <th>date</th> <th>time</th> </tr>
[# for i in Film.Screenings.all'Range loop #]
<tr> <td>[=Film.Screenings(i).Date=]</td>
<td>[=Film.Screenings(i).Time=]</td> </tr>
[# end loop; #]
</table>
[$pagebtm.txt$]
</body>
</html>
~~~

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("<title>");
Put(Film.Title);
Put(" - Showing Times</title>");
New_Line;
... stuff from pagetop.txt
New_Line;
Put("<h2>Showing Times for the Film: <a href=""filminfo?num=");
Put(Film.Ref);
Put(""">");
Put(Film.Title);
Put("</a></h2>");
New_Line;
Put("<table>");
New_Line;
Put("<tr> <th>date</th> <th>time</th> </tr>");
New_Line;
 for i in Film.Screenings.all'Range loop
New_Line;
Put("<tr> <td>");
Put(Film.Screenings(i).Date);
Put("</td> <td>");
Put(Film.Screenings(i).Time);
Put("</td> </tr>");
New_Line;
 end loop;
New_Line;
Put("</table>");
New_Line;
... stuff from pagebtm.txt
New_Line;
Put("</body>");
New_Line;
Put("</html>");
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]





^ permalink raw reply	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2003-10-10 18:26 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-04 20:29 Ada Advocacy - WPG (Web Page Generation) scheme Nick Roberts
2003-10-04 21:17 ` Larry Kilgallen
2003-10-05  3:32   ` Nick Roberts
2003-10-05  3:51     ` Larry Kilgallen
2003-10-05  9:19       ` Stephane Richard
2003-10-04 21:18 ` Stephane Richard
2003-10-05  3:21   ` Nick Roberts
2003-10-05  9:16     ` Preben Randhol
2003-10-05  9:26     ` Pascal Obry
2003-10-06  0:00       ` Nick Roberts
2003-10-06  0:06         ` Stephane Richard
2003-10-06  8:56         ` chris
2003-10-06 16:31         ` Pascal Obry
2003-10-06 18:30           ` Wiljan Derks
2003-10-06 19:45             ` Martin Dowie
2003-10-08 18:22               ` Wiljan Derks
2003-10-09 17:48                 ` Pascal Obry
2003-10-09 21:19                   ` Wiljan Derks
2003-10-10  7:42                     ` Preben Randhol
2003-10-10 18:26                       ` Wiljan Derks
2003-10-07 17:21             ` Pascal Obry
2003-10-08  7:18               ` Jean-Pierre Rosen
2003-10-08 19:09               ` Wiljan Derks
2003-10-06  1:07     ` Wes Groleau
2003-10-06  3:15       ` Nick Roberts
2003-10-05  9:14   ` Preben Randhol
2003-10-05  1:00 ` Wes Groleau
2003-10-05  3:05   ` Nick Roberts
2003-10-06  1:03     ` Wes Groleau
2003-10-08 18:14   ` Jacob Sparre Andersen
2003-10-05  9:17 ` Pascal Obry
2003-10-06  3:53   ` David Trudgett
2003-10-06  7:41   ` Dmitriy Anisimkov
2003-10-06 16:09     ` Pascal Obry
2003-10-06 20:28     ` Georg Bauhaus
2003-10-05  9:41 ` Preben Randhol
2003-10-05 11:30 ` Simon Wright
2003-10-05 14:59 ` Georg Bauhaus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox