Skip to content

Commit

Permalink
Add static resources and additional markup.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Trinkle committed Nov 15, 2013
1 parent 403fc64 commit 6e7d1d5
Show file tree
Hide file tree
Showing 6 changed files with 1,127 additions and 8 deletions.
3 changes: 2 additions & 1 deletion memoise.cabal
@@ -1,5 +1,5 @@
Name: memoise
Version: 0.4
Version: 0.5
License: BSD3
Author: Ryan Trinkle
Maintainer: ryan.trinkle@gmail.com
Expand All @@ -16,6 +16,7 @@ Executable memoise
Main-is: Main.hs
Build-depends: base >= 4 && < 5
, snap >= 0.12 && < 0.13
, snap-core >= 0.9 && < 0.10
, lens >= 3.9 && < 3.10
GHC-options: -threaded -O2
Extensions: OverloadedStrings
Expand Down
27 changes: 26 additions & 1 deletion snaplets/heist/templates/index.tpl
@@ -1,5 +1,30 @@
<!DOCTYPE html>
<html>
<head>
<title>memoi.se</title>
<link rel="stylesheet" type="text/css" href="static/bootstrap.min.css">
<link rel="icon" type="image/png" href="/static/favicon.png">
</head>
<body>
Hello, world!
<div class="container-fluid">
<div class="navbar navbar-inverse">
<div class="navbar-inner">
<a class="brand" href="/">memoi.se</a>
<ul class="nav">
</ul>
</div>
</div>
<div class="hero-unit">
<h1>Hello, world!</h1>
</div>
<div class="navbar navbar-fixed-bottom container-fluid">
<div class="navbar-inner">
<a class="brand" style="padding-left:38px;"><img src="static/logo.svg"></a>
<ul class="nav pull-right">
<li class=""><a href="http://opensource.org/licenses/BSD-3-Clause">Available under BSD3 License</a></li>
</ul>
</div>
</div>
</div>
</body>
</html>
12 changes: 6 additions & 6 deletions src/Main.hs
@@ -1,8 +1,8 @@
import Snap
import Snap.Snaplet.Heist
import Snap.Util.FileServe
import Control.Lens

-- | The Memoise type identifies our application and holds anything our snaplet needs to function.
data Memoise
= Memoise { _heist :: Snaplet (Heist Memoise)
}
Expand All @@ -11,19 +11,19 @@ makeLenses ''Memoise
instance HasHeist Memoise where
heistLens = subSnaplet heist

-- | The indexHandler will be invoked whenever someone accesses the root URL, "/".
indexHandler :: Handler Memoise Memoise ()
indexHandler = render "index"

-- | Build a new Memoise snaplet.
memoiseInit :: SnapletInit Memoise Memoise
memoiseInit = makeSnaplet "memoise" "The world's laziest hyperlink shortener" Nothing $ do
h <- nestSnaplet "heist" heist $ heistInit "templates"
addRoutes [("", indexHandler)]
addRoutes [ ("static", serveDirectory "static")
, ("", indexHandler)
]
return $ Memoise { _heist = h
}

main :: IO ()
main = do
(_, site, _) <- runSnaplet Nothing memoiseInit -- Initialize a Memoise snaplet
quickHttpServe site -- Start the Snap server
(_, site, _) <- runSnaplet Nothing memoiseInit
quickHttpServe site

0 comments on commit 6e7d1d5

Please sign in to comment.