Commits

Luke Plant committed 02cb28b

Added menu page for blog admin

Comments (0)

Files changed (4)

src/Blog/Links.hs

 feedsUrl          = Settings.root_url ++ "feeds/"
 loginUrl          = Settings.root_url ++ "login/"
 
-adminMenuUrl      = Settings.root_url 
+adminMenuUrl      = Settings.root_url ++ "admin/"
+adminCategories   = Settings.root_url ++ "admin/category/"
+adminPosts        = Settings.root_url ++ "admin/post/"
+adminEditPost p   = Settings.root_url ++ "admin/post/edit/" ++ (show $ P.uid p) ++ "/"
+adminNewPost      = Settings.root_url ++ "admin/post/new/"

src/Blog/Routes.hs

          , "feeds/" <+/> empty                        //-> infoPageView "feeds"   $ []
          , "login/" <+/> empty                        //-> loginView              $ []
          , "logout/" <+/> empty                       //-> logoutView             $ []
+         , "admin/" <+/> empty                        //-> adminMenu              $ [adminRequired]
          , "admin/category/" <+/> empty               //-> adminCategories        $ [adminRequired]
+         , "admin/post/" <+/> empty                   //-> adminPosts             $ [adminRequired]
          , "admin/post/new/" <+/> empty               //-> adminNewPost           $ [adminRequired]
          , "admin/post/edit/" <+/> anyParam           //-> adminEditPost          $ [adminRequired]
          , "debug/" <+/> anyParam                     //-> debug                  $ []

src/Blog/Views.hs

 import Text.StringTemplate
 import Text.StringTemplate.GenericStandard
 import qualified Blog.Category as Ct
+import qualified Blog.Links as Links
 import qualified Blog.Post as P
 import qualified Blog.Settings as Settings
 import qualified Data.Map as Map
 -- Category editing is very simple and doesn't require
 -- much validation.
 
+adminMenu req = do
+  t <- get_template "admin_menu"
+  return $ Just $ standardResponseTT req $
+         (renderf t
+          ("pagetitle", "Blog admin - menu")
+          ("newPostLink", Links.adminNewPost)
+          ("postsLink", Links.adminPosts)
+          ("categoriesLink", Links.adminCategories)
+         )
+
+adminPosts = undefined
+
+
 -- | View that handles all editing of categories (add/edit/delete)
 adminCategories req = do
   cn <- connect

src/templates/admin_menu.st

+$pagestart()$
+<h1>$pagetitle$</h1>
+
+<p><a href="$newPostLink$">Add post</a></p>
+<p><a href="$postsLink$">Edit posts</a></p>
+<p><a href="$categoriesLink$">Edit categories</a></p>
+
+$pageend()$