Skip to content

Commit

Permalink
Website: shuffle some stuff around, wrap api docs in a frameset navbar
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorycollins committed May 18, 2010
1 parent 7245f1a commit 86b6f27
Show file tree
Hide file tree
Showing 28 changed files with 848 additions and 767 deletions.
41 changes: 30 additions & 11 deletions src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,13 @@ site :: TemplateState Snap
-> MVar (Map ByteString [Node])
-> Snap ()
site origTs tsMVar staticMVar =
catch500 $
withCompression $ h1
<|> templateServe origTs tsMVar staticMVar
<|> h3
catch500 $ withCompression hndl

where
hndl = route [ ("docs/api", apidoc tsMVar) ] <|> fallThru

fallThru = templateServe origTs tsMVar staticMVar
<|> fileServe "static"


catch500 :: Snap a -> Snap ()
Expand All @@ -120,13 +123,6 @@ catch500 m = (m >> return ()) `catch` \(e::SomeException) -> do
r = setResponseStatus 500 "Internal Server Error" emptyResponse


h1 :: Snap ()
h1 = fileServe "static"

h3 :: Snap ()
h3 = path "throwException" (throw $ ErrorCall "jlkfdjfldskjlf")


bindMarkdownTag :: TemplateState Snap -> IO (TemplateState Snap)
bindMarkdownTag = return . bindSplice "markdown" markdownSplice

Expand Down Expand Up @@ -212,6 +208,29 @@ instance Show MarkdownException where
instance Exception MarkdownException


apidoc :: MVar (TemplateState Snap) -> Snap ()
apidoc mvar = do
ts <- liftIO $ readMVar mvar
-- remainder of pathInfo is the doc to lookup
whichDoc <- liftM rqPathInfo getRequest

title <- maybe pass return $ Map.lookup whichDoc titles
let href = B.concat ["/docs/latest/", whichDoc, "/index.html"]

let ts' = bindSplice "docframe" (docframe href) $
bindSplice "subtitle" (return [mkText title]) ts

maybe pass writeBS =<< renderTemplate ts' "docs/api"

where
titles = Map.fromList [ ("snap-core", ": snap-core APIs")
, ("snap-server", ": snap-server APIs")
, ("heist", ": heist APIs") ]

docframe :: ByteString -> Splice Snap
docframe src = return [ mkElement "frame" [ ("id" , "docframe")
, ("src", src ) ] [] ]

pandoc :: FilePath -> FilePath -> IO ByteString
pandoc pandocPath inputFile = do
(ex, sout, serr) <- readProcessWithExitCode pandocPath args ""
Expand Down
145 changes: 0 additions & 145 deletions static/docs/0.1.1/snap-core/Snap-Internal-Http-Types.html
Original file line number Diff line number Diff line change
Expand Up @@ -805,24 +805,6 @@
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AgetParam"
>getParam</A
> :: <A HREF="http://hackage.haskell.org/packages/archive/bytestring/latest/doc/html/Data-ByteString.html#t%3AByteString"
>ByteString</A
> -&gt; <A HREF="Snap-Internal-Http-Types.html#t%3ARequest"
>Request</A
> -&gt; <A HREF="http://hackage.haskell.org/packages/archive/base/latest/doc/html/Data-Maybe.html#t%3AMaybe"
>Maybe</A
> <A HREF="http://hackage.haskell.org/packages/archive/bytestring/latest/doc/html/Data-ByteString.html#t%3AByteString"
>ByteString</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3ArqModifyParams"
>rqModifyParams</A
> :: (<A HREF="Snap-Internal-Http-Types.html#t%3AParams"
Expand Down Expand Up @@ -1109,22 +1091,6 @@
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3Achar"
>char</A
> :: <A HREF="http://hackage.haskell.org/packages/archive/base/latest/doc/html/Data-Char.html#t%3AChar"
>Char</A
> -&gt; <A HREF="http://hackage.haskell.org/packages/archive/attoparsec/latest/doc/html/Data-Attoparsec.html#t%3AParser"
>Parser</A
> <A HREF="http://hackage.haskell.org/packages/archive/base/latest/doc/html/Data-Word.html#t%3AWord8"
>Word8</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AfromStr"
>fromStr</A
> :: <A HREF="http://hackage.haskell.org/packages/archive/base/latest/doc/html/Data-Char.html#t%3AString"
Expand Down Expand Up @@ -3024,87 +2990,6 @@
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:getParam"
><A NAME="v%3AgetParam"
></A
></A
><B
>getParam</B
></TD
><TD CLASS="declbut"
><A HREF="src/Snap-Internal-Http-Types.html#getParam"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="body"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="arg"
>:: <A HREF="http://hackage.haskell.org/packages/archive/bytestring/latest/doc/html/Data-ByteString.html#t%3AByteString"
>ByteString</A
></TD
><TD CLASS="rdoc"
>parameter name to look up
</TD
></TR
><TR
><TD CLASS="arg"
>-&gt; <A HREF="Snap-Internal-Http-Types.html#t%3ARequest"
>Request</A
></TD
><TD CLASS="rdoc"
>HTTP request
</TD
></TR
><TR
><TD CLASS="arg"
>-&gt; <A HREF="http://hackage.haskell.org/packages/archive/base/latest/doc/html/Data-Maybe.html#t%3AMaybe"
>Maybe</A
> <A HREF="http://hackage.haskell.org/packages/archive/bytestring/latest/doc/html/Data-ByteString.html#t%3AByteString"
>ByteString</A
></TD
><TD CLASS="rdoc"
></TD
></TR
><TR
><TD CLASS="ndoc" COLSPAN="2"
><P
>See <TT
><A HREF="Snap-Internal-Http-Types.html#v%3ArqParam"
>rqParam</A
></TT
>. Looks up a value for the given named parameter. If more
than one value was entered for the given parameter name, <TT
><A HREF="Snap-Internal-Http-Types.html#v%3AgetParam"
>getParam</A
></TT
> gloms
the values together with:
</P
><PRE
> <TT
><A HREF="http://hackage.haskell.org/packages/archive/bytestring/latest/doc/html/Data-ByteString.html#v%3Aintercalate"
>intercalate</A
></TT
> &quot; &quot;</PRE
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:rqModifyParams"
><A NAME="v%3ArqModifyParams"
></A
Expand Down Expand Up @@ -3906,36 +3791,6 @@
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:char"
><A NAME="v%3Achar"
></A
></A
><B
>char</B
> :: <A HREF="http://hackage.haskell.org/packages/archive/base/latest/doc/html/Data-Char.html#t%3AChar"
>Char</A
> -&gt; <A HREF="http://hackage.haskell.org/packages/archive/attoparsec/latest/doc/html/Data-Attoparsec.html#t%3AParser"
>Parser</A
> <A HREF="http://hackage.haskell.org/packages/archive/base/latest/doc/html/Data-Word.html#t%3AWord8"
>Word8</A
></TD
><TD CLASS="declbut"
><A HREF="src/Snap-Internal-Http-Types.html#char"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:fromStr"
><A NAME="v%3AfromStr"
></A
Expand Down
Loading

0 comments on commit 86b6f27

Please sign in to comment.