added main page pagination
This commit is contained in:
parent
11a37855c5
commit
1dd08f9f59
4 changed files with 45 additions and 0 deletions
|
@ -18,11 +18,24 @@
|
|||
module Handler.Home where
|
||||
|
||||
import Import
|
||||
import qualified Data.Text as T
|
||||
|
||||
getHomeR :: Handler Html
|
||||
getHomeR = do
|
||||
recentMedia <- runDB $ selectList [] [Desc MediumTime, LimitTo 30]
|
||||
nextMediaQuery <- runDB $ selectList [] [Desc MediumTime, LimitTo 1, OffsetBy 30]
|
||||
nextMedia <- return $ not $ null nextMediaQuery
|
||||
widgetLayout <- return $ widgetFile "default-widget"
|
||||
defaultLayout $ do
|
||||
setTitle "Eidolon :: Home"
|
||||
$(widgetFile "home")
|
||||
|
||||
getPageR :: Int -> Handler Html
|
||||
getPageR page = do
|
||||
pageMedia <- runDB $ selectList [] [Desc MediumTime, LimitTo 30, OffsetBy (page*30)]
|
||||
nextMediaQuery <- runDB $ selectList [] [Desc MediumTime, LimitTo 1, OffsetBy ((page + 1) * 30)]
|
||||
nextMedia <- return $ not $ null nextMediaQuery
|
||||
widgetLayout <- return $ widgetFile "default-widget"
|
||||
defaultLayout $ do
|
||||
setTitle $ toHtml ("Eidolon :: Page " `T.append` (T.pack $ show page))
|
||||
$(widgetFile "page")
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
/robots.txt RobotsR GET
|
||||
|
||||
/ HomeR GET
|
||||
/page/#Int PageR GET
|
||||
/signup SignupR GET POST
|
||||
/login LoginR GET POST
|
||||
/logout LogoutR GET
|
||||
|
|
|
@ -10,3 +10,9 @@ $forall (Entity mediumId medium) <- recentMedia
|
|||
<figure>
|
||||
<img src=#{mediumThumb medium}>
|
||||
<figcaption>#{mediumTitle medium}
|
||||
$if nextMedia
|
||||
<div id="header" class="item" data-width="400">
|
||||
<div class="inner">
|
||||
<p>
|
||||
<a href=@{PageR 1}>
|
||||
older
|
||||
|
|
25
templates/page.hamlet
Normal file
25
templates/page.hamlet
Normal file
|
@ -0,0 +1,25 @@
|
|||
$doctype 5
|
||||
$if page == 1
|
||||
<div id="header" class="item" data-width="400">
|
||||
<div class="inner">
|
||||
<p>
|
||||
<a href=@{HomeR}>
|
||||
newer
|
||||
$else
|
||||
<div id="header" class="item" data-width="400">
|
||||
<div class="inner">
|
||||
<p>
|
||||
<a href=@{PageR (page - 1)}>
|
||||
newer
|
||||
$forall (Entity mediumId medium) <- pageMedia
|
||||
<article class="item" data-width=#{mediumThumbWidth medium}>
|
||||
<a href=@{MediumR mediumId}>
|
||||
<figure>
|
||||
<img src=#{mediumThumb medium}>
|
||||
<figcaption>#{mediumTitle medium}
|
||||
$if nextMedia
|
||||
<div id="header" class="item" data-width="400">
|
||||
<div class="inner">
|
||||
<p>
|
||||
<a href=@{PageR (page + 1)}>
|
||||
older
|
Loading…
Reference in a new issue