gdritter repos frontit / cde8760
Default to using the Gitit root page Getty Ritter 7 years ago
1 changed file(s) with 5 addition(s) and 4 deletion(s). Collapse all Expand all
110110 Gitit.DocBook -> Pandoc.readDocBook
111111 Gitit.MediaWiki -> Pandoc.readMediaWiki
112112
113 getLocalPath :: BS.ByteString -> Maybe FilePath
114 getLocalPath req
113 getLocalPath :: FrontitConf -> BS.ByteString -> Maybe FilePath
114 getLocalPath conf req
115115 | BS.any (== '.') req = Nothing
116 | req == "/" = Just ("Index.page")
116 | req == "/" = Just (Gitit.frontPage (fcGititConfig conf) <> ".page")
117117 | otherwise = Just (BS.unpack (req <> ".page"))
118118
119119 app :: FrontitConf -> Wai.Application
120120 app conf = \ req respond -> do
121121 let respond' st pg = respond (Wai.responseLBS st [] (LBS.pack pg))
122 case getLocalPath (Wai.rawPathInfo req) of
122 case getLocalPath conf (Wai.rawPathInfo req) of
123123 Nothing -> respond' Http.status403 "invalid URL"
124124 Just path -> do
125 putStrLn ("fetching: " <> path)
125126 result <- fetchPage conf path
126127 case result of
127128 Found pg -> respond' Http.status200 (renderPage conf pg)