Commits

Luke Plant committed 73cc250

Implemented aboutView

Comments (0)

Files changed (5)

         ella >= 0.1.1
   Main-is: BlogCgi.hs
   hs-source-dirs: src
+  ghc-options: -O2
     format_id INTEGER REFERENCES format(id)
   );
 
+
+CREATE UNIQUE INDEX post_slug_index ON posts (slug);
+CREATE UNIQUE INDEX post_id_index ON posts (id);
+CREATE INDEX post_ts_index ON posts (timestamp);
+CREATE UNIQUE INDEX category_id_index ON categories (id);
+CREATE UNIQUE INDEX category_slug_index ON categories (slug);
+CREATE INDEX postcat_pid_index ON post_categories (post_id);
+CREATE INDEX postcat_cid_index ON post_categories (category_id);
+CREATE UNIQUE INDEX comment_id_index ON comments (id);
+CREATE INDEX comment_pid_index ON comments (post_id);
+CREATE INDEX comment_ts_index ON comments (timestamp);
 
 ---- Public API for queries ----
 
-getPostBySlug :: (SqlType a, IConnection conn) => conn -> a -> IO (Maybe P.Post)
+getPostBySlug :: (IConnection conn) => conn -> String -> IO (Maybe P.Post)
 getPostBySlug cn slug = do
   res <- quickQuery' cn getPostBySlugQuery [toSql slug]
   case res of

src/Blog/Templates.hs

 
 formatRelated = postLink
 
+aboutPage post =
+    page $ defaultPageVars
+             { pcontent = (h1 << "About this blog")
+                          +++
+                          (thediv ! [theclass "post"]
+                                      << (primHtml $ P.post_formatted post)
+                          )
+             , ptitle = "About"
+             }
+
+
 -- General HTML fragments
 
 -- TODO - fix this to be able to work with URLs that have query
              setStatus 404
             ]
 
--- Temporary view
-dummyView req = return $ Just $ standardResponse ("TODO" :: String) :: IO (Maybe Response)
-
 ---- Views
 
 -- View for the main page
             related <- getRelatedPosts cn post cats
             return $ Just $ standardResponse $ postPage post cats comments related
 
-aboutView = dummyView
+aboutView req = do
+  cn <- connect
+  Just post <- getPostBySlug cn "about"
+  return $ Just $ standardResponse $ aboutPage post
 
 -- Utilities