Default to using the Gitit root page
Getty Ritter
8 years ago
| 110 | 110 | Gitit.DocBook -> Pandoc.readDocBook |
| 111 | 111 | Gitit.MediaWiki -> Pandoc.readMediaWiki |
| 112 | 112 | |
| 113 | getLocalPath :: BS.ByteString -> Maybe FilePath | |
| 114 | getLocalPath req | |
| 113 | getLocalPath :: FrontitConf -> BS.ByteString -> Maybe FilePath | |
| 114 | getLocalPath conf req | |
| 115 | 115 | | BS.any (== '.') req = Nothing |
| 116 |
| req == "/" = Just ( |
|
| 116 | | req == "/" = Just (Gitit.frontPage (fcGititConfig conf) <> ".page") | |
| 117 | 117 | | otherwise = Just (BS.unpack (req <> ".page")) |
| 118 | 118 | |
| 119 | 119 | app :: FrontitConf -> Wai.Application |
| 120 | 120 | app conf = \ req respond -> do |
| 121 | 121 | let respond' st pg = respond (Wai.responseLBS st [] (LBS.pack pg)) |
| 122 |
case getLocalPath |
|
| 122 | case getLocalPath conf (Wai.rawPathInfo req) of | |
| 123 | 123 | Nothing -> respond' Http.status403 "invalid URL" |
| 124 | 124 | Just path -> do |
| 125 | putStrLn ("fetching: " <> path) | |
| 125 | 126 | result <- fetchPage conf path |
| 126 | 127 | case result of |
| 127 | 128 | Found pg -> respond' Http.status200 (renderPage conf pg) |