Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Some website tweaks

  • Loading branch information...
commit 46e85c0e89125b98582dca5edb0bf42f65b617b0 1 parent 23065f5
@gregorycollins gregorycollins authored
View
2  snap-website.cabal
@@ -24,6 +24,8 @@ Executable snap-website
snap-server,
heist,
filepath
+
+ ghc-prof-options: -prof -auto-all
if impl(ghc >= 6.12.0)
ghc-options: -O2 -Wall -fwarn-tabs -funbox-strict-fields
View
32 src/Main.hs
@@ -1,11 +1,15 @@
+{-# LANGUAGE ScopedTypeVariables #-}
+
module Main where
import System
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Control.Applicative
-import Control.Concurrent.MVar
+import Control.Concurrent
+import Control.Exception
import Control.Monad.Trans
+import System.Exit
import Snap.Http.Server
import Snap.Types
import Snap.Util.FileServe
@@ -32,8 +36,19 @@ reloadTemplates tsMVar = do
liftIO $ modifyMVar_ tsMVar (const $ loadTemplates "templates")
site :: MVar (TemplateState IO) -> Snap ()
-site tsMVar = withCompression $ templateServe tsMVar <|>
- fileServe "static"
+site tsMVar = withCompression $ h1 <|> h2 tsMVar
+
+
+h1 :: Snap ()
+h1 = fileServe "static"
+
+h2 :: MVar (TemplateState IO) -> Snap ()
+h2 m = templateServe m
+
+
+-- FIXME: remove
+killMe :: ThreadId -> Snap ()
+killMe t = liftIO (exitSuccess >> killThread t)
main :: IO ()
main = do
@@ -44,8 +59,11 @@ main = do
ts <- loadTemplates "templates"
tsMVar <- newMVar ts
- httpServe "*" port "achilles"
- (Just "access.log")
- (Just "error.log")
- (site tsMVar)
+ (try $ httpServe "*" port "achilles"
+ (Just "access.log")
+ (Just "error.log")
+ (site tsMVar)) :: IO (Either SomeException ())
+
+ putStrLn "exiting"
+ return ()
View
46 templates/about.tpl
@@ -3,10 +3,9 @@
<div class="inner">
<h2>What is the Snap Framework?</h2>
- <p>
- <strong>Snap</strong> is a simple web development framework in
- development, written in the purely functional programming
- language <a href="http://www.haskell.org">Haskell</a>.
+ <p><strong>Snap</strong> is a simple web development framework for unix
+ systems, written in <a href="http://www.haskell.org">Haskell</a>
+ programming language.
</p>
<p>
@@ -20,11 +19,30 @@
<li>Robustness and high test coverage</li>
</ul>
</p>
+
<h2>What is the project's status?</h2>
<p>
- <strong>Snap</strong> is still in the planning and design stages.
+ The first developer prerelease of the Snap framework is available
+ now.</p>
+
+ <p>
+ This developer prerelease contains only the Snap core system, namely:
+ <ul>
+ <li>A fast HTTP server library with an optional high-concurrency
+ backend using
+ the <a href="http://software.schmorp.de/pkg/libev.html">libev</a>
+ event loop library.</li>
+ <li>A sensible and clean monad for web programming.</li>
+ <li>an XML-based templating system for generating HTML that allows
+ you to bind Haskell functionality to XML tags without getting
+ PHP-style tag soup all over your pants</li>
+ </ul>
</p>
+ <p>
+ Snap currently only runs on Unix platforms; it has been tested on
+ Linux and Mac OSX Snow Leopard.
+ </p>
</div>
</div><!--end about-->
@@ -47,9 +65,9 @@
analytics startup.
</p>
<p>
- <strong><a href="http://softwaresimply.blogspot.com/">Doug Beardsley</a></strong>
- loves Haskell and has been playing with Haskell web
- developement using Happstack since 2008. He currently
+ <strong><a href="http://softwaresimply.blogspot.com/">Doug
+ Beardsley</a></strong> loves Haskell and has been playing with
+ Haskell web development using Happstack since 2008. He currently
works for a finance company doing Haskell development.
</p>
<p>
@@ -60,6 +78,18 @@
enthusiast.
</p>
</div><!--end developers-->
+ <div>
+ <h2>Contacting us</h2>
+ <ul>
+ <li><b>IRC:</b> You can discuss snap in the <tt>#snapframework</tt>
+ channel on the <a href="http://freenode.net/">freenode</a> IRC
+ network.</li>
+
+ <li><b>Email:</b> join
+ the <a href="http://mailman-mail5.webfaction.com/listinfo/snap">mailing
+ list.</a></li>
+ </ul>
+ </div><!--end mailing list -->
</div><!--end inner-->
</div><!--end project-status-->
</apply>
View
11 templates/contribute.tpl
@@ -1,11 +0,0 @@
-<apply template="page">
- <h2>Contributing</h2>
- <p>The Snap project welcomes contributors. Before you start
-coding, there are a few things you should read.</p>
- <ol>
- <li><a href="/about">philosophy and roadmap</a></li>
- <li><a href="/style-guide">style guide</a></li>
- </ol>
- <p>You can discuss snap on #snapframework on freenode IRC.</p>
- <p>Also be sure to join the <a href="http://mailman-mail5.webfaction.com/listinfo/snap">mailing list.</a></p>
-</apply>
View
7 templates/docs.tpl
@@ -8,6 +8,11 @@
<li><a href="tutorials/heist">Heist Template Tutorial</a></li>
</ul>
</div>
+
+ <div class="inner">
+ <h2>Resources</h2>
+ <ul><li><a href="/style-guide">Haskell Style Guide</a></li></ul>
+ </div>
</div>
<div id="about" class="section left">
<div class="inner">
@@ -15,7 +20,7 @@
<ul>
<li><a href="docs/snap-core/index.html">snap-core</a></li>
<li><a href="docs/snap-server/index.html">snap-server</a></li>
- <li><a href="docs/heist/index.html">heist</a></li>
+ <li><a href="docs/heist/index.html">heist</a> <em>(experimental)</em></li>
</ul>
</div>
</div>
View
32 templates/index.tpl
@@ -41,24 +41,34 @@
<h2>What is Snap?</h2>
<p>
- <strong>Snap</strong> is a simple web development framework
- written in the pure functional programming language
- <a href="http://www.haskell.org">Haskell</a>.
+ <strong>Snap</strong> is a simple web development framework for
+ unix systems, written in the
+ <a href="http://www.haskell.org">Haskell</a> programming
+ language.
</p>
+ <p>Snap is well-documented and has a test suite with a high level
+ of code coverage.</p>
+
</div>
</div><!--end about-->
<div id="project-status" class="section right">
<div class="inner">
- <h2>Snap gives you:</h2>
-
- <ul>
- <li>Speed and Scalability</li>
- <li>Clean design</li>
- <li>Simplicity and ease of use</li>
- <li>Excellent documentation</li>
- </ul>
+ <h2>Snap Features:</h2>
+
+ <p>
+ Snap comes with:
+ <ul>
+ <li>A fast HTTP server library with an optional
+ high-concurrency backend using
+ the <a href="http://software.schmorp.de/pkg/libev.html">libev</a>
+ event loop library</li>
+ <li>A sensible and clean monad for web programming</li>
+ <li>An XML-based templating system for generating HTML</li>
+ </ul>
+ </p>
+
</div><!--end inner-->
</div><!--end project-status-->
View
5 templates/nav.tpl
@@ -20,9 +20,6 @@
<a href="/docs">Docs</a>
</li>
<li>
- <a href="/contribute">Contribute</a>
- </li>
- <li>
<a href="/about">About</a>
</li>
</ul>
@@ -30,4 +27,4 @@
</div>
</div>
-</div>
+</div>
View
2  templates/page.tpl
@@ -11,7 +11,7 @@
<div id="main">
<apply template="nav"/>
- <div id="content">
+ <div id="content" class="content">
<div class="newspaper">
View
27 templates/style-guide.tpl
@@ -4,8 +4,12 @@
>Haskell Style Guide</h1
><sub>(adapted from <a
href="http://github.com/tibbe/haskell-style-guide/blob/master/haskell-style.md">Johan
-Tibell's style guide</a>.)</sub><p
- >This document describes coding and comment style for the Snap projects. Currently we're more interested in building a working web framework than being code nazis and enforcing this style guide. However, it will be easier on everyone in the long run if contributors follow these guidelines. When something isn't covered by this guide you should stay consistent with the style used in our existing code.</p
+Tibell's style guide</a>.)</sub>
+
+<p><b>FIXME: check in markdown source</b></p>
+
+<p
+ >This document describes coding and comment style for the Snap projects. Currently we're more interested in building a working web framework than strictly enforcing this style guide; think of these as “aspirational” guidelines. When something isn't covered by this guide you should stay consistent with the style used in our existing code.</p
><div id="table-of-contents"
><h2
>Formatting</h2
@@ -14,7 +18,7 @@ Tibell's style guide</a>.)</sub><p
>Line Length</h3
><p
>Maximum line length is <em
- >80 characters</em
+ >78 characters</em
>.</p
></div
><div id="indentation"
@@ -49,7 +53,7 @@ filter p (x:xs)
><h3
>Blank Lines</h3
><p
- >One blank line between top-level definitions. No blank lines between type signatures and function definitions. Add one blank line between functions in a type class instance declaration if the functions bodies are large. Use your judgement.</p
+ ><s>One blank line between top-level definitions.</s> Two blank lines between top-level definitions, and a line of “<tt>-</tt>” characters to delineate top-level definitions from each other. No blank lines between type signatures and function definitions. Add one blank line between functions in a type class instance declaration if the functions bodies are large. Use your <s>judgement</s> judgment.</p
></div
><div id="whitespace"
><h3
@@ -61,7 +65,7 @@ filter p (x:xs)
><h3
>Data Declarations</h3
><p
- >Align the constructors in a data type definition. Example:</p
+ ><b>Vertically</b> align the constructors in a data type definition. Example:</p
><pre
><code
>data Tree a = Branch a (Tree a) (Tree a)
@@ -165,11 +169,11 @@ foo = alloca 10 $ \a -&gt;
>local application/library specific imports</li
></ol
><p
- >Put a blank line between each group of imports. The imports in each group should be sorted alphabetically, by module name.</p
+ >Put a blank line between each group of imports. The imports in each group should be sorted alphabetically, by module name. We also like to line up the module names; e.g. if a module is not imported <tt>qualified</tt> then we will add an extra ten spaces between the &ldquo;<tt>import</tt>&rdquo; keyword and the module name. <b>FIXME: example</b> </p
><p
>Always use explicit import lists or <code
>qualified</code
- > imports for standard and third party libraries. This makes the code more robust against changes in these libraries. Exception: The Prelude.</p
+ > imports for standard and third party libraries. <i>(Note: we don't follow this very well).</i> This makes the code more robust against changes in these libraries. Exception: The Prelude.</p
></div
><div id="comments"
><h2
@@ -185,7 +189,7 @@ foo = alloca 10 $ \a -&gt;
>Line Length</h3
><p
>Maximum line length is <em
- >70 characters</em
+ >78 characters</em
>. This increases readability as the eye has to travel back to the start of the next line.</p
></div
><div id="punctuation"
@@ -209,13 +213,16 @@ foo = alloca 10 $ \a -&gt;
>Comment every top level function (particularly exported functions), and provide a type signature; use Haddock syntax in the comments. Comment every exported data type. Some examples:</p
><pre
><code
- >-- | Sends a message on a socket. The socket must be in a connected
+ >
+------------------------------------------------------------------------------
+-- | Sends a message on a socket. The socket must be in a connected
-- state. Returns the number of bytes sent. Applications are
-- responsible for ensuring that all data has been sent.
send :: Socket -- ^ Connected socket
-&gt; ByteString -- ^ Data to send
-&gt; IO Int -- ^ Bytes sent
+------------------------------------------------------------------------------
-- | Bla bla bla.
data Person = Person
{ age :: Int -- ^ Age
@@ -267,7 +274,7 @@ foo n = salt * 32 + 9
>Warnings</h3
><p
>Code should be compilable with <code
- >-Wall -Werror</code
+ >-Wall -Werror -Wno-warn-unused-binds</code
>. There should be no warnings.</p
></div
></div
View
35 templates/tutorials/snap-api.tpl
@@ -1,8 +1,37 @@
<apply template="page">
<div id="getting-started-with-snap"
-><h2
- >Getting Started with Snap</h2
- ><p
+><h2>Getting Started with Snap</h2>
+
+<h2>FIXMEs</h2>
+
+<ul>
+ <li>
+ check the markdown source for this document into source control
+ </li>
+
+ <li>
+ what's an iteratee? why did we choose iteratee-based i/o? what's the
+ difference between an iteratee and an enumerator? emphasize that if you
+ don't want to worry about iteratees you generally don't really have
+ to. Note also when explaining enumerators that when you use
+ writeLBS/writeBS/addToOutput, you're not sending the data out of the socket
+ immediately; instead you're assembling a <i>program</i> that will write
+ your output to an arbitrary iteratee consumer at the end of the
+ computation.
+ </li>
+
+ <li>
+ what's a snap handler? what does the snap monad do? emphasize that we're
+ carrying a copy of the request and a copy of the response.
+ </li>
+
+ <li>some <i>pictures</i>, for the love of god</li>
+
+ <li>explain how snap-core, snap-server, heist relate to each other</li>
+
+</ul>
+
+<p
>This document provides an overview of some of the Snap API functions that you will use most frequently in web development.</p
></div
><div id="creating-responses"
Please sign in to comment.
Something went wrong with that request. Please try again.