Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 49 lines (41 sloc) 1.418 kb
235a15e preping for Google release
Mark Lentczner authored
1 -- Copyright 2010 Google Inc.
2 --
3 -- Licensed under the Apache License, Version 2.0 (the "License");
4 -- you may not use this file except in compliance with the License.
5 -- You may obtain a copy of the License at
6 --
7 -- http://www.apache.org/licenses/LICENSE-2.0
8 --
9 -- Unless required by applicable law or agreed to in writing, software
10 -- distributed under the License is distributed on an "AS IS" BASIS,
11 -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 -- See the License for the specific language governing permissions and
13 -- limitations under the License.
14
1d0565b @mzero fix line endings
authored
15 module Documentation where
16
17 import DevUtils
18
19 import Control.Monad (liftM)
20 import qualified Data.ByteString.Char8 as C
21 import Data.Maybe
22 import qualified Data.Text as T
23 import qualified Data.Text.Encoding as T
24 import Snap.Types
25 import Text.Html
26
27 handler :: Snap ()
28 handler = do
29 docparam <- getParam (C.pack "doc")
30 let docid = fromMaybe defaultdoc (fmap C.unpack docparam >>= finddoc)
31 htmlResponse $ docpage docid
32
33 docpage :: Doc -> Html
34 docpage doc = devpage "Documentation"
35 [ tag "iframe" ! [ src (docUrl doc), identifier "documentation" ] << noHtml
36 ]
37 [] -- modules
38 [] -- scripts
39
40 finddoc :: String -> Maybe Doc
41 finddoc x = go documents x
42 where
43 go (d:ds) x | docId d == x = Just d
44 | otherwise = go ds x
45 go [] _ = Nothing
46
47 defaultdoc :: Doc
48 defaultdoc = head documents
Something went wrong with that request. Please try again.