Browse files

Changed Environment type

  • Loading branch information...
1 parent a8f9a12 commit a9327b29b564ac7ab125522f7f73691b14b60cd4 alson committed Nov 24, 2008
View
16 App/Controllers/Page.hs
@@ -0,0 +1,16 @@
+index :: Controller ()
+index = do pages <- quickQuery' "select * from page" []
+ return ()
+
+show :: Controller ()
+show = do e <- getEnvironment
+ let id' = getSetting "id" e :: Maybe String
+ doIO $ debugM e $ "XXXXXXXX id' = " ++ (Prelude.show id')
+ case id' of
+ Nothing -> redirectTo "/Home"
+ Just i -> do q <- quickQuery' "select title, content from page where id = ?" [toSql i]
+ e' <- doIO $ setViewDataValue "page-title" (Prelude.show $ (head q) !! 0) e
+ e''<- doIO $ setViewDataValue "page-content" (Prelude.show $ (head q) !! 1) e
+ put e''
+
+
View
4 App/Views/Page/Show.hs
@@ -0,0 +1,4 @@
+page :: View XML
+page = <div>
+ <% getViewDataValue "page-content" %>
+ </div>
View
27 Turbinado/Environment/Database.hs
@@ -0,0 +1,27 @@
+module Turbinado.Environment.Database (
+ addDatabaseToEnvironment,
+ Connection
+ ) where
+
+import Data.Typeable
+import Data.Dynamic
+import qualified Data.Map as M
+import Control.Monad
+import Control.Monad.State
+import Control.Monad.Trans
+import Data.Maybe
+import qualified Database.HDBC as HDBC
+import Database.HDBC (IConnection)
+
+import Config.Master
+import Turbinado.Controller.Monad
+import Turbinado.Environment.Types
+
+
+addDatabaseToEnvironment :: Controller ()
+addDatabaseToEnvironment = do e <- get
+ case databaseConnection of
+ Nothing -> return ()
+ Just conn -> do c <- doIO $ conn
+ put $ e {getDatabase = Just c}
+
View
118 Turbinado/Environment/Types.hs
@@ -0,0 +1,118 @@
+module Turbinado.Environment.Types where
+
+import Data.Dynamic
+import qualified Data.Map as M
+import Data.Maybe
+import System.IO
+import System.IO.Unsafe
+import System.Log.Logger
+import Text.Regex
+import Control.Concurrent.MVar
+import Control.Monad.State
+import qualified Network.HTTP as HTTP
+import HSX.XMLGenerator (XMLGenT(..), unXMLGenT)
+import Turbinado.View.XML
+import Config.Master
+import System.Time
+import System.Plugins
+
+-- Stuffing all Environment "types" into this file to avoid
+-- recursive imports...
+
+data Environment = Environment { getCodeStore :: Maybe CodeStore
+ , getDatabase :: Maybe Database
+ , getLoggerLock :: Maybe LoggerLock
+ , getMimeTypes :: Maybe MimeTypes
+ , getRequest :: Maybe HTTP.Request
+ , getResponse :: Maybe HTTP.Response
+ , getRoutes :: Maybe Routes
+ , getSettings :: Maybe Settings
+ , getViewData :: Maybe ViewData
+ , getAppEnvironment :: Maybe AppEnvironment
+ }
+
+-- type EnvironmentFilter = Environment -> IO Environment
+
+newEnvironment :: Environment
+newEnvironment = Environment { getCodeStore = Nothing
+ , getDatabase = Nothing
+ , getLoggerLock = Nothing
+ , getMimeTypes = Nothing
+ , getRequest = Nothing
+ , getResponse = Nothing
+ , getRoutes = Nothing
+ , getSettings = Nothing
+ , getViewData = Nothing
+ , getAppEnvironment = Nothing
+ }
+
+--
+-- * Types for CodeStore
+--
+
+data CodeType = CTView | CTController | CTLayout
+type CodeDate = ClockTime
+type Function = String
+type CodeLocation = (FilePath, Function)
+
+data CodeStore = CodeStore (MVar CodeMap)
+type CodeMap = M.Map CodeLocation CodeStatus
+data CodeStatus = CodeLoadFailure |
+ CodeLoadController (StateT Environment IO ()) Module CodeDate |
+ CodeLoadView (XMLGenT (StateT Environment IO) XML ) Module CodeDate
+
+--
+-- * Types for Database
+--
+
+type Database = Connection
+
+
+--
+-- * Types for Logger
+--
+
+type LoggerLock = MVar ()
+
+
+--
+-- * Types for MimeTypes
+--
+
+data MimeTypes = MimeTypes (M.Map String MimeType)
+data MimeType = MimeType String String
+
+instance Show MimeType where
+ showsPrec _ (MimeType part1 part2) = showString (part1 ++ '/':part2)
+
+--
+-- * Types for Request
+--
+
+-- Just a basic Request from Network.HTTP
+
+--
+-- * Types for Response
+--
+
+-- Just a basic Response from Network.HTTP
+
+--
+-- * Types for Routes
+--
+
+type Keys = [String]
+data Routes = Routes [(Regex, Keys)]
+
+--
+-- * Types for Settings
+--
+
+type Settings = M.Map String Dynamic
+
+--
+-- * Types for ViewData
+--
+
+type ViewData = M.Map String Dynamic
+
View
340 static/css/pressurized.css
@@ -0,0 +1,340 @@
+/*
+Design by Free CSS Templates
+http://www.freecsstemplates.org
+Released for free under a Creative Commons Attribution 2.5 License
+*/
+
+body {
+ margin: 20px;
+ background: #590000 url(/images/img01.jpg) repeat-x left top;
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 12px;
+ color: #CD7A7A;
+}
+
+h1, h2, h3 {
+ margin: 0;
+ font-family: Georgia, "Times New Roman", Times, serif;
+ font-weight: normal;
+ color: #FFFFFF;
+}
+
+h1 {
+ font-size: 2em;
+}
+
+h2 {
+ font-size: 1em;
+}
+
+h3 {
+ font-size: 1em;
+}
+
+p, ul, ol {
+ margin-top: 0;
+ line-height: 180%;
+}
+
+ul, ol {
+}
+
+a {
+ text-decoration: none;
+ border-bottom: 1px dotted #CC0001;
+ color: #CC0001;
+}
+
+a:hover {
+ background: none;
+}
+
+#wrapper {
+ width: 910px;
+ margin: 0 auto 20px auto;
+ /* padding: 20px; */
+}
+
+/* Header */
+
+#header {
+ width: 910px;
+ /* height: 44px; */
+ height: 186px;
+ margin: 0 auto;
+}
+
+/* Logo */
+
+#logo {
+ float: left;
+ width: 640px;
+ color: #FFFFFF;
+ position: relative;
+}
+
+#logo h1, #logo p {
+}
+
+#logo h1 {
+ float: left;
+ padding: 0;
+ margin-right: 10px;
+ /* letter-spacing: -1px;
+ text-transform: lowercase; */
+ font-size: 2.6em;
+}
+
+#logo p {
+ float: left;
+ margin: 11px 0 0 0;
+ background: #720000;
+ padding: 3px 10px;
+ font: normal 10px Georgia, "Times New Roman", Times, serif;
+ font-style: italic;
+}
+
+#logo a {
+ border: none;
+ background: none;
+ text-decoration: none;
+ color: #FFFFFF;
+}
+
+/* Search */
+
+#search {
+ float: right;
+ width: 230px;
+ padding: 0;
+}
+
+#search form {
+ height: 41px;
+ margin: 0;
+ padding: 70px 0 0 0px;
+}
+
+#search fieldset {
+ margin: 0;
+ padding: 0;
+ border: none;
+}
+
+#search-text {
+ width: 210px;
+ border: none;
+ text-transform: lowercase;
+ font: bold 1.2em Arial, Helvetica, sans-serif;
+ color: #FFFFFF;
+}
+
+#search-submit {
+ display: none;
+}
+
+/* Menu */
+
+#menu {
+ width: 910px;
+ height: 50px;
+ margin: 0 auto;
+ padding: 0;
+}
+
+#menu ul {
+ margin: 0;
+ padding: 0;
+ list-style: none;
+ line-height: normal;
+}
+
+#menu li {
+ float: left;
+}
+
+#menu a {
+ display: block;
+ margin-right: 3px;
+ padding: 7px 20px 7px 20px;
+ text-decoration: none;
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 12px;
+ color: #FFFFFF;
+ border: none;
+}
+
+#menu a:hover, #menu .current_page_item a {
+}
+
+#menu a:hover {
+ background: #590000;
+ margin-right: 3px;
+ text-decoration: none;
+}
+
+#menu .first {
+ background: #590000;
+ margin-right: 3px;
+}
+
+#menu .active {
+ background: #590000;
+ margin-right: 3px;
+}
+
+/* Page */
+
+#page {
+ width: 910px;
+ margin: 0 auto;
+ /* padding-top: 20px; */
+}
+
+/* Content */
+
+#content {
+ /* float: right; */
+ width: 590px;
+ /* padding: 20px 30px 0 0; */
+ padding: 0px 30px 0 0;
+}
+
+.post {
+}
+
+.post .title {
+ color: #000000;
+}
+
+.post .title a {
+ background: none;
+ color: #FFFFFF;
+ border: none;
+}
+
+.post .title a:hover {
+ text-decoration: underline;
+}
+
+.post .meta {
+ background: #3C0101;
+ border: 1px dashed #590000;
+ padding: 3px 10px;
+ text-align: left;
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 11px;
+}
+
+.post .meta .comments,.post .meta .permalink {
+}
+
+.post .entry {
+ padding: 10px 0 20px 0;
+ text-align: justify;
+}
+
+/* Sidebar */
+
+#sidebar {
+ float: left;
+ width: 200px;
+ padding: 20px 30px 0 30px;
+ background: #2F0000;
+ border: 1px dashed #590000;
+}
+
+#sidebar ul {
+ margin: 0;
+ padding: 0;
+ list-style: none;
+}
+
+#sidebar li {
+ margin: 0;
+ padding: 0;
+}
+
+#sidebar li ul {
+ padding-bottom: 30px;
+}
+
+#sidebar li li {
+ line-height: 35px;
+ border-bottom: 1px dashed #590000;
+}
+
+#sidebar li li span {
+ display: block;
+ margin-top: -20px;
+ padding: 0;
+ font-size: 11px;
+ font-style: italic;
+}
+
+#sidebar h2 {
+ letter-spacing: -.5px;
+ color: #FFFFFF;
+}
+
+#sidebar p {
+ padding-bottom: 20px;
+ text-align: justify;
+}
+
+#sidebar a {
+ color: #FFFFFF;
+ border: none;
+}
+
+#sidebar a:hover {
+ text-decoration: underline;
+ color: #787878;
+}
+
+/* Calendar */
+
+#calendar {
+}
+
+#calendar_wrap {
+ padding: 20px;
+}
+
+#calendar table {
+ width: 100%;
+}
+
+#calendar tbody td {
+ text-align: center;
+}
+
+#calendar #next {
+ text-align: right;
+}
+
+/* Footer */
+
+#footer {
+ width: 910px;
+ height: 20px;
+ margin: 0 auto;
+ padding: 20px 0 15px 0;
+ background: #2F0000;
+ border-top: 1px dashed #590000;
+ font-family: Arial, Helvetica, sans-serif;
+ color: #CD7A7A;
+}
+
+#footer p {
+ margin: 0;
+ line-height: normal;
+ font-size: 9px;
+ text-transform: uppercase;
+ text-align: center;
+}
+
+#footer a {
+ color: #FFFFFF;
+ border-bottom: 1px #FFFFFF dotted;
+}
View
BIN static/favicon.ico
Binary file not shown.
View
BIN static/images/img01.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN static/images/img02.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a9327b2

Please sign in to comment.