Permalink
Browse files

Additional CGI mods

  • Loading branch information...
1 parent 7e7d61d commit cd6ca726d952d8b4616df105dd896b56d0535d8a @alsonkemp committed Mar 11, 2009
Showing with 43 additions and 3 deletions.
  1. +3 −0 App/Layouts/Default.hs
  2. +3 −0 App/Views/Develop/Index.hs
  3. +30 −0 Config/Routes.hs
  4. +7 −3 Turbinado/Environment/CodeStore.hs
View
@@ -1,3 +1,6 @@
+module App.Layout.Default where
+
+import Turbinado.Layout
import Control.Monad.Trans
import Data.List
import Data.Maybe
@@ -1,3 +1,6 @@
+module App.Views.Develop.Index where
+import Turbinado.View
+
markup = <div>
<h2>! Windows</h2>
<p>This software doesn't work on Windows. Linux/Unix only at this point.</p>
View
@@ -1,9 +1,39 @@
module Config.Routes where
+--
+-- Import modules for which you'll be creating static routes.
+--
+import App.Layouts.Default
+import App.Controllers.Home
+import App.Controllers.Develop
+import App.Views.Home.Index
+import App.Views.Develop.Index
+
+--
+-- Configure dynamic routes for on-the-fly compiled-and-loaded
+-- modules (ala Rails)
+--
routes = [ "/:controller/:action/:id.:format"
, "/:controller/:action/:id"
, "/:controller/:action.:format"
, "/:controller/:action"
, "/:controller"
, "/home"
]
+
+--
+-- Statically compile and load these Layouts, Controllers and Views
+--
+staticLayouts =
+ [ ("App/Layouts/Default.hs", "markup", App.Layouts.Default.markup)
+ ]
+
+staticControllers =
+ [ ("App/Controllers/Home.hs", "index", App.Controllers.Home.index)
+ , ("App/Controllers/Develop.hs", "index", App.Controllers.Develop.index)
+ ]
+
+staticViews =
+ [ ("App/Views/Home/Index.hs", "markup", Apps.Views.Home.Index.markup)
+ , ("App/Views/Develop/Index.hs", "markup", Apps.Views.Develop.Index.markup)
+ ]
@@ -199,9 +199,13 @@ customMergeToDir stb src dir = do
MergeFailure ["Source file does not exist : "++stb]
_ -> do
src_str <- liftIO $ readFile src
- stb_str <- liftIO $ readFile stb
- let (stbimps, stbdecls) = span ( not . isPrefixOf "-- SPLIT HERE") $ lines stb_str
- mrg_str = outTitle ++ (unlines stbimps) ++ src_str ++ (unlines stbdecls)
+ stb_str <- liftIO $ readFile stb
+ -- Check to see whether the file start with "module ". If so, the user
+ -- should already have added the require preamble. Otherwise, merge the stub.
+ let mrg_str = case src_str of
+ ('m':'o':'d':'u':'l':'e':' ':_) -> src_str
+ _ -> let (stbimps, stbdecls) = span ( not . isPrefixOf "-- SPLIT HERE") $ lines stb_str
+ in outTitle ++ (unlines stbimps) ++ src_str ++ (unlines stbdecls)
liftIO $ createDirectoryIfMissing True outDir
hdl <- liftIO $ openFile outFile WriteMode -- overwrite!
liftIO $ hPutStr hdl mrg_str

0 comments on commit cd6ca72

Please sign in to comment.