http://qs1969.pair.com?node_id=1113072

adriang has asked for the wisdom of the Perl Monks concerning the following question:

Hi all
Hope this is the right place to post my question. I want to know how is possible to make some beautiful form(s) with CGI like for example the http://perlcritic.com web site.
Thanks in advance
Adrian

Replies are listed 'Best First'.
Re: beautiful form(s) with CGI
by karlgoethebier (Abbot) on Jan 13, 2015 at 12:49 UTC
Re: beautiful form(s) with CGI
by marto (Cardinal) on Jan 13, 2015 at 13:19 UTC

    perlcritic.com uses boostrap among other things. To make your task easier, download and customise bootstrap, once you've got everything looking the way you want witout involving Perl use this as the basis for your template. If you are considering using CGIs built in CGI HTML generation facilties I'd strongly advise against this. See Template/HTML::Template for example.

    On a related note there are other frameworks which can make this sort of development easier, (from CGI) note:

    CGI.pm HAS BEEN REMOVED FROM THE PERL CORE

    http://perl5.git.perl.org/perl.git/commitdiff/e9fa5a80

    If you upgrade to a new version of perl or if you rely on a system or vendor perl and get an updated version of perl through a system update, then you will have to install CGI.pm yourself with cpan/cpanm/a vendor package/manually. To make this a little easier the CGI::Fast module has been split into its own distribution, meaning you do not need acces to a compiler to install CGI.pm

    The rationale for this decision is that CGI.pm is no longer considered good practice for developing web applications, including quick prototyping and small web scripts. There are far better, cleaner, quicker, easier, safer, more scalable, more extensible, more modern alternatives available at this point in time. These will be documented with CGI::Alternatives.

    For more discussion on the removal of CGI.pm from core please see:

    http://www.nntp.perl.org/group/perl.perl5.porters/2013/05/msg202130.html

    Update: Edited formatting.

      Thanks all for the good advice,
      I will start to use a framework but I'm not sure if to start with Catalyst or dancer or dancer2?
Re: beautiful form(s) with CGI
by Anonymous Monk on Jan 13, 2015 at 13:08 UTC

    Yes it is, although CGI isn't directly involved since it's mostly done on the client side with a combination of CSS and JavaScript.

    So for example, a quick look at the source of perlcritic.com shows that it primarily uses Bootstrap, see http://getbootstrap.com/. There are nowadays a whole bunch of CSS frameworks available, and several JavaScript libraries, such as jQuery (http://jquery.com/).

    There are a couple of Perl web frameworks that are "more modern" than CGI which you might want to look at, see for example Mojolicious or Catalyst. But if you're using CGI, here's an example of how you might tie CSS & JavaScript libraries into your page, assuming you've downloaded http://necolas.github.com/normalize.css/3.0.2/normalize.css and http://code.jquery.com/jquery-1.11.2.min.js to your local directory:

    print start_html -style => { -src => [ 'normalize.css', 'mystyle.css' ] }, -script => [ { -type=>"text/javascript", -src=>"jquery-1.11.2.min.js" }, q{ alert("I'm some embedded JavaScript"); } ];

    You'll still need to read the documentation of whatever frameworks you decide to use to see how to access their functions, which is usually not a question of Perl but of CSS, HTML and JavaScript. CGI provides a -style argument for most of its HTML functions that can be used to specify CSS classes and other style elements.

Re: beautiful form(s) with CGI
by Anonymous Monk on Jan 13, 2015 at 23:26 UTC
Re: beautiful form(s) with CGI
by sundialsvc4 (Abbot) on Jan 13, 2015 at 18:18 UTC

    Design decisions like “which framework to use” go far, far beyond considerations of CSS and beauty.   I’d simply suggest that you fully design and map-out your intended application before you subsequently choose which framework ... or for that matter, which programming language(s) if any(!) ... to use in constructing it.

    (As great a language as Perl may be, never overlook the growing possibility that you do not, in fact, have to develop a new custom web-site at all in order to solve your business problem.)

    The implementation strategy (CGI, Perl module, FastCGI, etc.) is likewise something that you can and should defer for a long time.   I know of several production web-sites used by rather big companies which are ... “good ol’ CGI.”

    The definitive illustration of what can be done with CSS is, certainly, the CSS Zen Garden, which presents a wide variety of (perfectly nonsensical content ...) web site presentations from which you can freely pick and choose.   All of the variations of that content are devised using CSS, which is the key point that the site wishes to demonstrate.