packages feed

network-minihttp-0.2: examples/example.tmpl

<html>
  <head>
   <link rel="stylesheet" href="screen.css" type="text/css" media="screen, projection">
   <link rel="stylesheet" href="print.css" type="text/css" media="print">
   <!--[if IE]><link rel="stylesheet" href="ie.css" type="text/css" media="screen, projection"><![endif]-->

   <style type="text/css">
     #header {
       background-color:  #2A3B63;
       border-bottom: 4px solid #000014;
       margin-bottom: 2em;
     }

     #header h1 {
       padding-top: 0.4em;
       padding-left: 0.3em;
       font-family: "Helvetica";
       color:   #ddd;
     }

     body {
       background-color:  #717C8C;
     }

     #main {
       background-color:  #FFF7CB;
       font-family: "Ariel";
     }

     #body {
       margin-left: 0.3em;
     }

     #body pre {
       margin-left: 1em;
       color: #555;
     }

     #body form {
       margin-bottom: 1em;
     }

     #body p {
       font-size: 1.05em;
     }
   </style>
  </head>
  <body>
    <div class="container" id="main">
      <div class="span-24" id="header">
        <h1><tt>Network.MiniHTTP</tt> Test Page</h1>
      </div>

      <div class="span-24" id="body">
        <h3>Session support</h3>

        <p>Sessions, at the moment, are serialised, encrypted, signed and
        stored in cookies on the user's browser. In <tt>MiniHTTP</tt> they are
        availible as a Map with bytestrings as the keys and values.</p>

        <p>Here's the current value of your session:</p>
        <pre>{{SESSION:h}}</pre>

        <p>You can set a value using the following form:</p>

        <form method="POST" action="/setsession">
          <input name="name" value="" type="text"/>
          <input name="submit" value="Set name" type="submit"/>
        </form>

        <h3>Templating</h3>

        <p>Templating is up to the user, nothing is built into
        <tt>MiniHTTP</tt>, however this code is using <a
          href="http://hackage.haskell.org/cgi-bin/hackage-scripts/package/ctemplate-0.1"><tt>ctemplate</tt></a>,
        which is Google's internal templating system. It's pretty basic
        compared to other templating systems (which the reader may take to be
        a virtue or a deficiency), but it does escaping very well.</p>

        <p>The wrapper still needs a little efficiency work, but is currently
        functional (as you can see). Due to ctemplate being a C++ library, you
        appear to need to compile anything which uses it; <tt>ghci</tt> will
        fail in glibc.</p>

        <h3>OpenID</h3>

        <p>My initial test of the code was to write an <a
          href="http://www.openid.net">OpenID</a> consumer. This
        involves both server and client HTTP code. It's currently fairly
        functional, though incomplete. I only have an account with
        <a href="http://www.myopenid.com">MyOpenID.com</a>, so I've not tested it with anything else.</p>

        <p><i>For the moment, the input must be a valid URL. So don't forget
        the <tt>http://</tt> at the beginning.</i></p>

        <p>Once you have logged in, you should see your OpenID in the session
        output, above.</p>

        <form method="POST" action="/openidlogin">
          <input name="id" value="" type="text"/>
          <input name="submit" value="Login via OpenID" type="submit"/>
        </form>

        <h3>HTTPS support</h3>

        <p>Running an HTTPS server is as easy as running an HTTP server (as
        long as you have the certificate and private key in the correct
        format). However, it's been known to tickle a bug which causes the RTS
        to fall into an infinite loop.</p>

        <p>HTTPS client support is comming.</p>

      </div>
    </div>
  </body>
</html>