Permalink
Browse files

Removing the website from the framework.

  • Loading branch information...
1 parent 6d9277e commit 52c55a195a01546f37770e9560edab2f779fa60b @alsonkemp committed Dec 18, 2008
Showing 374 changed files with 0 additions and 7,976 deletions.
@@ -1,5 +0,0 @@
-
-index :: Controller ()
-index = return ()
-
-
@@ -1,17 +0,0 @@
-
-index :: Controller ()
-index = return ()
-
-performance :: Controller ()
-performance = return ()
-
-install :: Controller ()
-install = return ()
-
-architecture :: Controller ()
-architecture= return ()
-
-hello :: Controller ()
-hello = clearLayout
-
-
@@ -1,58 +0,0 @@
-import App.Models.PageModel
-
-index :: Controller ()
-index = do conn <- liftIO $ fromJust $ databaseConnection
- pages <- liftIO $ findAll conn
- setViewDataValue "pages-list" $ map (\p -> (title p, _id p)) pages
-
-show :: Controller ()
-show = do conn <- liftIO $ fromJust $ databaseConnection
- e <- get
- id' <- getSetting "id"
- case id' of
- Nothing -> redirectTo "/Home"
- Just i -> do p <- find conn i
- setViewDataValue "page-title" (title p)
- setViewDataValue "page-content" (content p)
-
-new :: Controller ()
-new = do conn <- liftIO $ fromJust $ databaseConnection
- e <- get
- id' <- getSetting "id"
- case id' of
- Nothing -> redirectTo "/Home"
- Just i -> do setViewDataValue "save-url" ("/Page/Create/" ++ i)
-
-create :: Controller ()
-create = do conn <- liftIO $ fromJust $ databaseConnection
- e <- get
- id' <- getSetting "id"
- _title <- getParam_u "title"
- _content <- getParam_u "content"
- case id' of
- Nothing -> redirectTo "/Home"
- Just i -> do App.Models.PageModel.insert conn Page {authorId = Nothing,_id = i, title = _title, content = _content, version = 1}
- redirectTo $ "/Page/Show/" ++ i
-edit :: Controller ()
-edit = do conn <- liftIO $ fromJust $ databaseConnection
- e <- get
- id' <- getSetting "id"
- case id' of
- Nothing -> redirectTo "/Home"
- Just i -> do p <- find conn i
- setViewDataValue "save-url" ("/Page/Save/" ++ i)
- setViewDataValue "page-title" (title p)
- setViewDataValue "page-content" (content p)
-
-save :: Controller ()
-save = do conn <- liftIO $ fromJust $ databaseConnection
- e <- get
- id' <- getSetting "id"
- _title <- getParam_u "title"
- _content <- getParam_u "content"
- case id' of
- Nothing -> redirectTo "/Home"
- Just i -> do p <- find conn i
- App.Models.PageModel.update conn p {title = _title, content = _content}
- redirectTo $ "/Page/Show/" ++ i
-
@@ -1,5 +0,0 @@
-
-index :: Controller ()
-index = return ()
-
-
@@ -1,5 +0,0 @@
-module App.Models.AuthorModel
- ( module App.Models.AuthorModel
- , module App.Models.Bases.AuthorModelBase
- ) where
-import App.Models.Bases.AuthorModelBase
@@ -1,58 +0,0 @@
-{- DO NOT EDIT THIS FILE
- THIS FILE IS AUTOMAGICALLY GENERATED AND YOUR CHANGES WILL BE EATEN BY THE GENERATOR OVERLORD
-
- All changes should go into the Model file (e.g. App/Models/ExampleModel.hs) and
- not into the base file (e.g. App/Models/Bases/ExampleModelBase.hs) -}
-
-module App.Models.Bases.AuthorModelBase (
- module App.Models.Bases.AuthorModelBase,
- module App.Models.Bases.ModelBase) where
-
-import App.Models.Bases.ModelBase
-import qualified Database.HDBC as HDBC
-import System.Time
-
-data Author = Author {
- id :: Int64, name :: Maybe String
- } deriving (Eq, Show)
-
-instance DatabaseModel Author where
- tableName _ = "author"
-
-instance IsModel Author where
- insert conn m = do
- res <- liftIO $ HDBC.run conn " INSERT INTO author (id,name) VALUES (?,?)"
- [HDBC.toSql $ id m , HDBC.toSql $ name m]
- liftIO $ HDBC.commit conn
- i <- liftIO $ HDBC.catchSql (HDBC.quickQuery' conn "SELECT lastval()" []) (\_ -> HDBC.commit conn >> (return $ [[HDBC.toSql (0 :: Int)]]) )
- return $ HDBC.fromSql $ head $ head i
- findAll conn = do
- res <- liftIO $ HDBC.quickQuery' conn "SELECT id , name FROM author" []
- return $ map (\r -> Author (HDBC.fromSql (r !! 0)) (HDBC.fromSql (r !! 1))) res
- findAllBy conn ss sp = do
- res <- liftIO $ HDBC.quickQuery' conn ("SELECT id , name FROM author WHERE (" ++ ss ++ ") ") sp
- return $ map (\r -> Author (HDBC.fromSql (r !! 0)) (HDBC.fromSql (r !! 1))) res
- findOneBy conn ss sp = do
- res <- liftIO $ HDBC.quickQuery' conn ("SELECT id , name FROM author WHERE (" ++ ss ++ ") LIMIT 1") sp
- return $ (\r -> Author (HDBC.fromSql (r !! 0)) (HDBC.fromSql (r !! 1))) (head res)
-instance HasFindByPrimaryKey Author (Int64) where
- find conn pk@(pk1) = do
- res <- liftIO $ HDBC.quickQuery' conn ("SELECT id , name FROM author WHERE (id = ? )") [HDBC.toSql pk1]
- case res of
- [] -> throwDyn $ HDBC.SqlError
- {HDBC.seState = "",
- HDBC.seNativeError = (-1),
- HDBC.seErrorMsg = "No record found when finding by Primary Key:author : " ++ (show pk)
- }
- r:[] -> return $ Author (HDBC.fromSql (r !! 0)) (HDBC.fromSql (r !! 1))
- _ -> throwDyn $ HDBC.SqlError
- {HDBC.seState = "",
- HDBC.seNativeError = (-1),
- HDBC.seErrorMsg = "Too many records found when finding by Primary Key:author : " ++ (show pk)
- }
-
- update conn m = do
- res <- liftIO $ HDBC.run conn "UPDATE author SET (id , name) = (?,?) WHERE (id = ? )"
- [HDBC.toSql $ id m , HDBC.toSql $ name m, HDBC.toSql $ id m]
- liftIO $ HDBC.commit conn
- return ()
@@ -1,36 +0,0 @@
-{- DO NOT EDIT THIS FILE
- THIS FILE IS AUTOMAGICALLY GENERATED AND YOUR CHANGES WILL BE EATEN BY THE GENERATOR OVERLORD -}
-
-module App.Models.Bases.ModelBase (
- module App.Models.Bases.ModelBase,
- module Control.Exception,
- module Control.Monad.Trans,
- module Data.Int
- ) where
-
-import Control.Monad.Trans
-import Control.Exception
-import Database.HDBC
-import Data.Int
-
-import Turbinado.Controller.Monad
-
--- Using phantom types here
-class DatabaseModel m where
- tableName :: m -> String
-
-type SelectString = String
-type SelectParams = [SqlValue]
-
-class (DatabaseModel model) =>
- IsModel model where
- insert :: (MonadIO m, IConnection conn) => conn -> model -> m Integer
- findAll :: (MonadIO m, IConnection conn) => conn -> m [model]
- findAllBy :: (MonadIO m, IConnection conn) => conn -> SelectString -> SelectParams -> m [model]
- findOneBy :: (MonadIO m, IConnection conn) => conn -> SelectString -> SelectParams -> m model
-
-class (DatabaseModel model) =>
- HasFindByPrimaryKey model primaryKey | model -> primaryKey where
- find :: (MonadIO m, IConnection conn) => conn -> primaryKey -> m model
- update :: (MonadIO m, IConnection conn) => conn -> model -> m ()
-
@@ -1,58 +0,0 @@
-{- DO NOT EDIT THIS FILE
- THIS FILE IS AUTOMAGICALLY GENERATED AND YOUR CHANGES WILL BE EATEN BY THE GENERATOR OVERLORD
-
- All changes should go into the Model file (e.g. App/Models/ExampleModel.hs) and
- not into the base file (e.g. App/Models/Bases/ExampleModelBase.hs) -}
-
-module App.Models.Bases.PageModelBase (
- module App.Models.Bases.PageModelBase,
- module App.Models.Bases.ModelBase) where
-
-import App.Models.Bases.ModelBase
-import qualified Database.HDBC as HDBC
-import System.Time
-
-data Page = Page {
- _id :: String, authorId :: Maybe Int64, content :: String, title :: String, version :: Int64
- } deriving (Eq, Show)
-
-instance DatabaseModel Page where
- tableName _ = "page"
-
-instance IsModel Page where
- insert conn m = do
- res <- liftIO $ HDBC.run conn " INSERT INTO page (_id,author_id,content,title,version) VALUES (?,?,?,?,?)"
- [HDBC.toSql $ _id m , HDBC.toSql $ authorId m , HDBC.toSql $ content m , HDBC.toSql $ title m , HDBC.toSql $ version m]
- liftIO $ HDBC.commit conn
- i <- liftIO $ HDBC.catchSql (HDBC.quickQuery' conn "SELECT lastval()" []) (\_ -> HDBC.commit conn >> (return $ [[HDBC.toSql (0 :: Int)]]) )
- return $ HDBC.fromSql $ head $ head i
- findAll conn = do
- res <- liftIO $ HDBC.quickQuery' conn "SELECT _id , author_id , content , title , version FROM page" []
- return $ map (\r -> Page (HDBC.fromSql (r !! 0)) (HDBC.fromSql (r !! 1)) (HDBC.fromSql (r !! 2)) (HDBC.fromSql (r !! 3)) (HDBC.fromSql (r !! 4))) res
- findAllBy conn ss sp = do
- res <- liftIO $ HDBC.quickQuery' conn ("SELECT _id , author_id , content , title , version FROM page WHERE (" ++ ss ++ ") ") sp
- return $ map (\r -> Page (HDBC.fromSql (r !! 0)) (HDBC.fromSql (r !! 1)) (HDBC.fromSql (r !! 2)) (HDBC.fromSql (r !! 3)) (HDBC.fromSql (r !! 4))) res
- findOneBy conn ss sp = do
- res <- liftIO $ HDBC.quickQuery' conn ("SELECT _id , author_id , content , title , version FROM page WHERE (" ++ ss ++ ") LIMIT 1") sp
- return $ (\r -> Page (HDBC.fromSql (r !! 0)) (HDBC.fromSql (r !! 1)) (HDBC.fromSql (r !! 2)) (HDBC.fromSql (r !! 3)) (HDBC.fromSql (r !! 4))) (head res)
-instance HasFindByPrimaryKey Page (String) where
- find conn pk@(pk1) = do
- res <- liftIO $ HDBC.quickQuery' conn ("SELECT _id , author_id , content , title , version FROM page WHERE (_id = ? )") [HDBC.toSql pk1]
- case res of
- [] -> throwDyn $ HDBC.SqlError
- {HDBC.seState = "",
- HDBC.seNativeError = (-1),
- HDBC.seErrorMsg = "No record found when finding by Primary Key:page : " ++ (show pk)
- }
- r:[] -> return $ Page (HDBC.fromSql (r !! 0)) (HDBC.fromSql (r !! 1)) (HDBC.fromSql (r !! 2)) (HDBC.fromSql (r !! 3)) (HDBC.fromSql (r !! 4))
- _ -> throwDyn $ HDBC.SqlError
- {HDBC.seState = "",
- HDBC.seNativeError = (-1),
- HDBC.seErrorMsg = "Too many records found when finding by Primary Key:page : " ++ (show pk)
- }
-
- update conn m = do
- res <- liftIO $ HDBC.run conn "UPDATE page SET (_id , author_id , content , title , version) = (?,?,?,?,?) WHERE (_id = ? )"
- [HDBC.toSql $ _id m , HDBC.toSql $ authorId m , HDBC.toSql $ content m , HDBC.toSql $ title m , HDBC.toSql $ version m, HDBC.toSql $ _id m]
- liftIO $ HDBC.commit conn
- return ()
@@ -1,5 +0,0 @@
-module App.Models.PageModel
- ( module App.Models.PageModel
- , module App.Models.Bases.PageModelBase
- ) where
-import App.Models.Bases.PageModelBase
@@ -1,19 +0,0 @@
-page = <div>
- <h2>! Windows</h2>
- <p>This software doesn't work on Windows. Linux/Unix only at this point.</p>
-
- <h2>Git Repo</h2>
- <p> The <em>git</em> repo is at <% anchorTag "http://github.com/alsonkemp/turbinado/tree/master" "http://github.com/alsonkemp/turbinado/tree/master" %>. Push patches into the repo.</p>
-
- <h2>To Do</h2>
- <ul class="standard-list">
- <li>
- Move to a simpler templating system (e.g. <% anchorTag "http://haml.hamptoncatlin.com/" "HAML" %>-like ). HSX is a lovely piece of work, but it's pretty finicky and I feel like I'm trying to "see the Matrix" when I read its compilation error messages.
- </li>
- <li>Build a mini-CMS to manage these pages.</li>
- <li>Complete the ORM in Turbinado/Database/ORM.</li>
- <li>Implement cookie sessions.</li>
- <li>Implement authentication.</li>
- <li>Copy a couple of tutorial apps from Rails/Django tutorials.</li>
- </ul>
- </div>
@@ -1,4 +0,0 @@
-page = <div>
- <h1>Architecture</h1>
- <p>coming soon</p>
- </div>
@@ -1 +0,0 @@
-page = return $ cdata $ "Hello World"
@@ -1,32 +0,0 @@
-page = <div>
- <h1>Turbinado?</h1>
- <div style="float:right">
- <img src="http://upload.wikimedia.org/wikipedia/en/thumb/0/0e/TurbinadoSugar.jpg/757px-TurbinadoSugar.jpg" width="300" />
- </div>
- <p><a href="http://en.wikipedia.org/wiki/Turbinado">Turbinado</a> is that yummy, not-so-refined sugar.
- Sounds like Haskell...
- </p>
- <p>Turbinado is also an easy-to-use web application framework for Haskell which is fricking <% anchorTag "/Home/Performance" "fast" %>. Naturally, this website is written in Turbinado, so head over to the <% anchorTag "http://github.com/alsonkemp/turbinado/tree/master" "Git repo" %> to see how easy it is to code websites in Turbinado.</p>
-
- <h1>Why?</h1>
- <p>Haskell has no easy-to-use web framework. Turbinado is an effort to build one by lazily stealing the best ideas from <% anchorTag "http://www.rubyonrails.org" "Ruby On Rails" %>, <% anchorTag "http://www.asp.net" "ASP.NET" %>, etc.</p>
- <h1>Features</h1>
- <p>Turbinado gives you all of the benefits of coding in Haskell and adds:</p>
- <ul class="standard-list">
- <li> A fast HTTP server with static- and dynamic-content serving capabilities; </li>
- <li> Views built using a simple HTML-like templating syntax combined with tag-matching to guard against invalid HTML; </li>
- <li> Automagic recompilation of Controllers, Layouts and Views; </li>
- <li> <span style="font-size:10px; font-style:italic">coming soon</span> A database <% anchorTag "http://en.wikipedia.org/wiki/Object-relational_mapping" "ORM" %> to make database interaction (especially with PostgreSQL) joyful; </li>
- <li> A rich set of tags to make designing pages simpler;. </li>
- </ul>
-
- <h1>... On The Backs of Giants ... </h1>
- <p>Turbinado wouldn't be possible without the original work of the following people:</p>
- <ul class="standard-list">
- <li> <% anchorTag "http://www.haskell.org/ghc" "The GHC Team" %> for something as insane as Haskell and GHC</li>
- <li> <% anchorTag "http://www.cs.chalmers.se/~d00nibro/" "Niklas Broberg" %> for Haskell Server Pages, the HSP Runtime, Haskell Source Extensions and Haskell Regular Expressions</li>
- <li> <% anchorTag "http://www.cse.unsw.edu.au/~dons/hs-plugins/" "Don Stewart" %> for hs-plugins </li>
- <li> <% anchorTag "http://www.cs.chalmers.se/~bringert/projects.html" "Bjorn Bringert" %> for HTTP </li>
- <li> <% anchorTag "http://software.complete.org/software/projects/show/hdbc" "John Goerzen" %> for Haskell Database Connectivity.</li>
- </ul>
- </div>
@@ -1,46 +0,0 @@
-page = <div>
- <h1>Installation == Pain, Pain == Love</h1>
- <p>
- Given the relative immaturity of Haskell's package installation tools, installation of Turbinado is fairly challenging. With <% anchorTag "http://hackage.haskell.org/trac/hackage/wiki/CabalInstall" "cabal-install" %> this should get better, but, for now, installation is an adventure.
- </p>
- <p>
- In addition to its many other joys, the ORM in Turbinado only works with PostgreSQL right now.
- </p>
- <h1>Suit up</h1>
- <p>
- You'll need to have the following packages installed to have a go at installation:
- </p>
- <ul class="standard-list">
- <li><a href="http://www.haskell.org/ghc">GHC</a><em> (darcs) </em></li>
- <li><a href="http://code.haskell.org/HSP/haskell-src-exts/">haskell-src-exts</a><em> (darcs) </em></li>
- <li><a href="http://code.haskell.org/HSP/harp/">harp</a><em> (darcs) </em></li>
- <li><a href="http://git.complete.org/hslogger">hslogger</a><em> (git) </em></li>
- <li><a href="http://code.haskell.org/encoding/">encoding</a><em> (darcs) </em></li>
- <li><a href="http://code.haskell.org/HSP/hsx/">hsx</a><em> (darcs) </em></li>
- <li><a href="http://code.haskell.org/hs-plugins">hs-plugins</a><em> (darcs) </em></li>
- <li><a href="http://code.haskell.org/http">http</a><em> (darcs) </em></li>
- <li><a href="http://git.complete.org/hdbc">HDBC</a><em> (git) </em></li>
- <li><a href="http://git.complete.org/hdbc-postgresql">HDBC-PostgreSQL</a><em> (git) </em></li>
- </ul>
- <h1>Grab the code:</h1>
- <pre>
- git clone git://github.com/alsonkemp/turbinado.git
- </pre>
- <h1>Build it</h1>
- <p>
- With all of the packages installed, wait for a new moon, stand on tip-toes, and do the following:
- </p>
- <pre>
- runghc Setup.lhs configure
- runghc Setup.lhs build
- </pre>
- <p>
- If everything goes well, you should be able to do:
- </p>
- <pre>
- dist/build/turbinado/turbinado -p 9999
- </pre>
- <p>
- Try browsing to http://the-machines-name:9999/images/1x1.gif.
- </p>
- </div>
Oops, something went wrong.

0 comments on commit 52c55a1

Please sign in to comment.