Commit 42344b7d authored by Ibnu Daru Aji's avatar Ibnu Daru Aji

modified templates.

parent 39711d9e
......@@ -172,3 +172,40 @@ allowedToAdmin = do
case group of
Administrator -> return (uid, name, group)
_ -> permissionDenied "You are not allowed to administer this site."
adminLayout :: Key Users -> Text -> Grouping -> Widget -> Handler Html
adminLayout uid name group widget = do
mcurrentroute <- getCurrentRoute
mmessage <- getMessage
pagecontent <- widgetToPageContent $ do
addStylesheet $ StaticR css_normalize_css
addStylesheet $ StaticR css_milligram_min_css
addStylesheet $ StaticR css_main_css
$(widgetFile "adm")
withUrlRenderer $(hamletFile "templates/wrapper.hamlet")
adminRouteToText :: Route App -> Text
adminRouteToText AdmR = "Index"
adminRouteToText AdmBanR = "Manage Ban"
adminRouteToText AdmBanOptionsR = "Ban Options"
adminRouteToText AdmCategoryR = "Manage Categories"
adminRouteToText AdmForumR = "Manage Forums"
profileLayout ::
Key Users -> Text -> Grouping -> Entity Users -> Widget -> Handler Html
profileLayout uid name group user widget = do
let allowededit = allowedToEditProfile uid group (entityKey user)
mcurrentroute <- getCurrentRoute
mmessage <- getMessage
pagecontent <- widgetToPageContent $ do
addStylesheet $ StaticR css_normalize_css
addStylesheet $ StaticR css_milligram_min_css
addStylesheet $ StaticR css_main_css
$(widgetFile "profile")
withUrlRenderer $(hamletFile "templates/wrapper.hamlet")
allowedToEditProfile uid group profileid =
profileid == uid || group == Administrator || group == Moderator
profileRouteToText :: Route App -> Text
profileRouteToText ProfileR = "Common Information"
......@@ -9,4 +9,4 @@ import Import
getAdmR :: Handler Html
getAdmR = do
(uid, name, group) <- allowedToMod
defaultLayout $(widgetFile "adm")
adminLayout uid name group [whamlet|Hello there. |]
......@@ -32,11 +32,11 @@ banUserForm = renderDivs $ BanUserForm <$> areq textField "Username" Nothing
getAdmBanR :: Handler Html
getAdmBanR = do
(uid, name, gruop) <- allowedToMod
(uid, name, group) <- allowedToMod
(wid, enct) <- generateFormPost banUserForm
bans <- getAllBanneds
let banneds = map (\(Value uid, b, Value ename) -> (uid, b, ename)) bans
defaultLayout $(widgetFile "adm-ban")
adminLayout uid name group $(widgetFile "adm-ban")
postAdmBanR :: Handler Html
postAdmBanR = do
......@@ -71,5 +71,5 @@ postAdmBanOptionsR = do
FormSuccess r -> do
(wid, enct) <-
generateFormPost . banUserOptionsForm . banUserFormUsername $ r
defaultLayout $(widgetFile "adm-ban-options")
adminLayout uid name group $(widgetFile "adm-ban-options")
_ -> invalidArgs ["Fill your input correctly."]
......@@ -36,7 +36,7 @@ getAdmCategoryR = do
(widc, enctc) <- generateFormPost createCategoryForm
allcategories <- getAllCategories
(widl, enctl) <- generateFormPost $ selectCategoryForm allcategories
defaultLayout $ do
adminLayout uid name group $ do
setTitle "Category Administration"
$(widgetFile "adm-category")
......
......@@ -32,7 +32,7 @@ getAdmForumR = do
allcategories <- getAllCategories
catfnamekeys <- getForumsAndItsCategory
(wid, enct) <- generateFormPost $ createForumForm allcategories
defaultLayout $ do
adminLayout u n g $ do
$(widgetFile "adm-forum")
postAdmForumR :: Handler Html
......
......@@ -15,7 +15,7 @@ data RegisterForm = RegisterForm
{ registerFormUsername :: Text
, registerFormPassword :: Text
, registerFormEmail :: Text
} deriving (Show)
}
registerForm :: Form RegisterForm
registerForm =
......@@ -45,22 +45,17 @@ postRegisterR = do
_ ->
invalidArgs
[ "Your input doesn't contribute sufficiently"
, " for this capitalistic society. Think about it."
, "For this capitalistic society. Think about it."
]
getProfileR :: Handler Html
getProfileR = do
(Just (Entity userid user)) <- maybeAuth
defaultLayout $ do
setTitle "Nice"
[whamlet|
<p> You are: #{usersUsername user}
<p> Userid: #{fromSqlKey userid}
<p> Your email: #{usersEmail user}
|]
(ruid, name, group) <- allowedToPost
user'@(Entity uid' user) <- getUserById ruid
profileLayout ruid name group user' $(widgetFile "profile-info")
getUserR :: Int64 -> Handler Html
getUserR uid = do
(ruid, name, group) <- allowedToPost
(Entity uid' user ) <- getUserById $ toSqlKey uid
defaultLayout $(widgetFile "profile")
user'@(Entity uid' user) <- getUserById $ toSqlKey uid
profileLayout ruid name group user' $(widgetFile "profile-info")
<p>
<a href=@{AdmBanR}> Ban
$case group
$of Administrator
<p>
<a href=@{AdmCategoryR}> Category
<p>
<a href=@{AdmForumR}> Forum
$of Moderator
$of Member
$of Banned
<nav .navigation>
<section .container>
<ul .navigation-list.float-left>
<li .navigation-item>
<a .navigation-link href=@{HomeR}> Home
<li .navigation-item>
<a .navigation-link href=@{AdmR} title="Management"> Management
<li .navigation-item>
<a .navigation-link href="#" title="Users"> Users
<ul .navigation-list.float-right>
<li .navigation-item>
<a .navigation-link href=@{ProfileR}> Profile
<li .navigation-item>
<a .navigation-link href=@{SigninR LogoutR}> Logout
<.container>
<h4>
<a href=@{HomeR}> Index
<span> »
<a href=@{AdmR}> Management
$maybe route <- mcurrentroute
<span> »
<a href=@{route}> #{adminRouteToText route}
$nothing
<.row>
<.column.column-20>
<table>
<tr>
<thead> <h5> Moderation
<tr>
<td> <a href=@{AdmR}> Index
<tr>
<td> <a href="#"}> Users
<tr>
<td> <a href=@{AdmBanR}> Bans
<tr>
<td> <a href="#"}> Reports
<span>
<span>
$case group
$of Administrator
<table>
<tr>
<thead> <h5> Admin Menu
<tr>
<td> <a href=@{AdmCategoryR}> Categories
<tr>
<td> <a href=@{AdmForumR}> Forums
$of _
<.column.column-75.column-offset-5>
$maybe message <- mmessage
#{message}
$nothing
^{widget}
\ No newline at end of file
<.row>
<.column>
<p> Username:
<.column.column-75>
<p> #{usersUsername user}
<.row>
<.column>
<p> Email:
<.column.column-75>
<p> #{usersEmail user}
<.row>
<.column>
<p> Join Date:
<.column.column-75>
<p> #{show $ utcToLocalTime timeZone $ usersJoinTime user}
<.row>
<.column>
<p> Topic Started:
<.column.column-75>
<a href="#"> <p> #{usersTopicsStarted user}
<.row>
<.column>
<p> Reply Posted:
<.column.column-75>
<a href="#"> <p> #{usersRepliesPosted user}
<.row>
<.column>
<p> Username:
<.column.column-75>
<p> #{usersUsername user}
<.row>
<.column>
<p> Email:
<.column.column-75>
<p> #{usersEmail user}
<.row>
<.column>
<p> Join Date:
<.column.column-75>
<p> #{show $ utcToLocalTime timeZone $ usersJoinTime user}
<.row>
<.column>
<p> Topics Started:
<.column.column-75>
<p> #{usersTopicsStarted user}
<.row>
<.column>
<p> Replies Posted:
<.column.column-75>
<p> #{usersRepliesPosted user}
<nav .navigation>
<section .container>
<ul .navigation-list.float-left>
<li .navigation-item>
<a .navigation-link href=@{HomeR}> Index
$case group
$of Administrator
<li .navigation-item>
<a .navigation-link href=@{AdmR} title="Management"> Management
<li .navigation-item>
<a .navigation-link href="#" title="Users"> Users
$of Moderator
<li .navigation-item>
<a .navigation-link href=@{AdmR} title="Management"> Management
<li .navigation-item>
<a .navigation-link href="#" title="Users"> Users
$of Member
<li .navigation-item>
<a .navigation-link href="#" title="Users"> Users
$of Banned
<ul .navigation-list.float-right>
<li .navigation-item>
<a .navigation-link href=@{ProfileR}> Profile
<li .navigation-item>
<a .navigation-link href=@{SigninR LogoutR}> Logout
<.container>
$case group
$of Banned
<h2 .banned> You're banned.
$of _
<h4>
<a href="#"> Users
<span> »
<a href="#"> #{usersUsername $ entityVal user}
$maybe route <- mcurrentroute
<span> »
<a href=@{route}> #{profileRouteToText route}
$nothing
<.row>
$if allowededit
<.column.column-20>
<table>
<tr>
<thead> <h5> Profile Menu
<tr>
<td> <a href="#"> Edit Essentials
$case group
$of Administrator
<tr>
<td> <a href="#"> Administration
$of Moderator
<tr>
<td> <a href="#"> Administration
$of _
<.column.column-75.column-offset-5>
$maybe message <- mmessage
#{message}
$nothing
^{widget}
$else
<.column.column-100>
$maybe message <- mmessage
#{message}
$nothing
^{widget}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment