I am writing a small suite of standalone applications for the back end of a client I am working with right now. The front end of the site is very extensive, and totally non-portable because it has grown organic over a period of years. Sort of like a big ecosystem. Pull a script out and it dies unless you take its liver (filesystem), kidneys (associated shell scripts), heart (symlinks), and so on with it. So these applications are being built to withstand the test of (more) time, and should be highly portable, as well as modular so that re-use is possible, and programmer time is spent more effectively.

So I actually have written highly portable code that works on any of our servers, through any of the clients looking at it, and does what I need it to do.

The problem is I have written code that does not have a pretty interface, and no provisions therein.

Here's an overview of how stuff is currently done:

======== ============== = = perl = javascript = = HTML = <------- cgi <-------============== = = = html = ======== ============== ^ | | ============== = oracle = ==============

When the url is requested, the perl program answers. The output in html is essentially a composite of three things. First, you have the oracle data. So, say we have "name" and "address". You also have an HTML template so that the web design people can just create a page look-and-feel. However, if you want to be able to provide names and addresses for people in hawaii, alaska, new york, it might be nice to be able to have palm trees, sky scrapers (or rude people, ymmv), and snow as a theme, depending upon which user you are sending data to. The javascript allows us to create interface-specific stuff that might be difficult to do in perl/html (that was not my call, and isnt up for discussion).

The challenge thus, is to be able to have perl programs that run independantly of the database, and still provide them with a uniform style. Javascript is not necessary. Images and tables may well be. You have perl content that needs to be displayed in a fashion that is configurable to some extent by the users (after all, it is their interface), and also configurable by the site/application owner.

Take this for example:

sub enter_data { print start_form, textarea( -name => 'name', -default => 'Smith, John' ), end_form; return 1; }
Do we then extrapolate from the above that we can do:
sub be_pretty { print img( -src => '/img/purdy.png' ), br(), img( -src => '/img/splashlogo.png' ); } be_pretty(); enter_data();
But what about more complicated schemes, like having a top logo bar and a left navigation bar, and a footer, and having your form in the middle? Because HTML is highly linear, i.e., it renders top-to-bottom, left-to-right, its not possible to paint the page and then add a form smack in the middle (well, at least not without frames, and nuh-uh, no frames on this 'ere site).

So, what, then, is the best way to allow for stylistic changes and a "graphical" side of your average perl cgi? Or, perhaps that is an open-ended question I should tie down a little. What ways have you used and which ones were successful? Not successful? Any other insights?

brother dep.

--
Laziness, Impatience, Hubris, and Generosity.


In reply to Creating Stylized Perl Applications With Uniformity (code) by deprecated

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.