now serving static files more gracefully via StaticR
This commit is contained in:
parent
ee8b46b26b
commit
2c5a546122
16 changed files with 23 additions and 15 deletions
|
@ -21,6 +21,7 @@ import Handler.Commons
|
|||
import System.FilePath
|
||||
import System.Directory
|
||||
import Data.List (tail)
|
||||
import qualified Data.Text as T
|
||||
|
||||
getAdminMediaR :: Handler Html
|
||||
getAdminMediaR = do
|
||||
|
|
|
@ -18,6 +18,7 @@ module Handler.Album where
|
|||
|
||||
import Import
|
||||
import qualified Data.Text as T
|
||||
import System.FilePath
|
||||
|
||||
getAlbumR :: AlbumId -> Handler Html
|
||||
getAlbumR albumId = do
|
||||
|
|
|
@ -19,12 +19,14 @@ module Handler.Home where
|
|||
|
||||
import Import
|
||||
import qualified Data.Text as T
|
||||
import Data.List as L
|
||||
import System.FilePath
|
||||
|
||||
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
|
||||
nextMedia <- return $ not $ L.null nextMediaQuery
|
||||
widgetLayout <- return $ widgetFile "default-widget"
|
||||
defaultLayout $ do
|
||||
setTitle "Eidolon :: Home"
|
||||
|
@ -34,7 +36,7 @@ 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
|
||||
nextMedia <- return $ not $ L.null nextMediaQuery
|
||||
widgetLayout <- return $ widgetFile "default-widget"
|
||||
defaultLayout $ do
|
||||
setTitle $ toHtml ("Eidolon :: Page " `T.append` (T.pack $ show page))
|
||||
|
|
|
@ -21,6 +21,7 @@ import Data.Time
|
|||
import Data.Maybe
|
||||
import qualified Data.Text as T
|
||||
import System.Locale
|
||||
import System.FilePath
|
||||
import Yesod.Markdown
|
||||
|
||||
getMediumR :: MediumId -> Handler Html
|
||||
|
|
|
@ -19,6 +19,7 @@ module Handler.Profile where
|
|||
import Import
|
||||
import Data.Maybe
|
||||
import qualified Data.Text as T
|
||||
import System.FilePath
|
||||
|
||||
getProfileR :: UserId -> Handler Html
|
||||
getProfileR ownerId = do
|
||||
|
|
|
@ -18,6 +18,7 @@ module Handler.Tag where
|
|||
|
||||
import Import
|
||||
import qualified Data.Text as T
|
||||
import System.FilePath
|
||||
|
||||
getTagR :: Text -> Handler Html
|
||||
getTagR tag = do
|
||||
|
|
|
@ -21,6 +21,7 @@ module Import
|
|||
import Prelude as Import hiding (head, init, last,
|
||||
readFile, tail, writeFile)
|
||||
import Yesod as Import hiding (Route (..))
|
||||
import Yesod.Static as Import
|
||||
|
||||
import Control.Applicative as Import (pure, (<$>), (<*>))
|
||||
import Data.Text as Import (Text)
|
||||
|
|
|
@ -9,5 +9,5 @@ $forall (Entity mId m) <- media
|
|||
<article class="item" data-width=#{mediumThumbWidth m}>
|
||||
<a href=@{AdminMediumSettingsR mId}>
|
||||
<figure class="thumbnail">
|
||||
<img src=#{mediumThumb m}>
|
||||
<img src=@{StaticR $ StaticRoute (drop 2 $ map T.pack $ splitDirectories $ mediumThumb m) []}>
|
||||
<figcaption>#{mediumTitle m}
|
||||
|
|
|
@ -9,5 +9,5 @@ $forall (Entity mId m) <- media
|
|||
<article class="item" data-width=#{mediumThumbWidth m}>
|
||||
<a href=@{AdminMediumSettingsR mId}>#{mediumTitle m}
|
||||
<figure class="thumbnail">
|
||||
<img src=#{mediumThumb m}>
|
||||
<img src=@{StaticR $ StaticRoute (drop 2 $ map T.pack $ splitDirectories $ mediumThumb m) []}>
|
||||
<figcaption>#{mediumTitle m}
|
||||
|
|
|
@ -10,5 +10,5 @@ $forall (Entity mId m) <- media
|
|||
<article class="item" data-width=#{mediumThumbWidth m}>
|
||||
<a href=@{AdminMediumSettingsR mId}>#{mediumTitle m}
|
||||
<figure class="thumbnail">
|
||||
<img src=#{mediumThumb m}>
|
||||
<img src=@{StaticR $ StaticRoute (drop 2 $ map T.pack $ splitDirectories $ mediumThumb m) []}>
|
||||
<figcaption>#{mediumTitle m}
|
||||
|
|
|
@ -18,7 +18,7 @@ $else
|
|||
<article class="item" data-width=#{mediumThumbWidth medium}>
|
||||
<a href=@{MediumR mediumId}>
|
||||
<figure class="thumbnail">
|
||||
<img src=#{mediumThumb medium}>
|
||||
<img src=@{StaticR $ StaticRoute (drop 2 $ map T.pack $ splitDirectories $ mediumThumb medium) []}>
|
||||
<figcaption>#{mediumTitle medium}
|
||||
|
||||
<div id="footer">
|
||||
|
|
|
@ -8,7 +8,7 @@ $forall (Entity mediumId medium) <- recentMedia
|
|||
<article class="item" data-width=#{mediumThumbWidth medium}>
|
||||
<a href=@{MediumR mediumId}>
|
||||
<figure>
|
||||
<img src=#{mediumThumb medium}>
|
||||
<img src=@{StaticR $ StaticRoute (drop 2 $ map T.pack $ splitDirectories $ mediumThumb medium) []}>
|
||||
<figcaption>#{mediumTitle medium}
|
||||
$if nextMedia
|
||||
<div id="header" class="item" data-width="400">
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
by <a href=@{UserR ownerName}>#{ownerName}</a> from album <a href=@{AlbumR albumId}>#{albumTitle album}</a>
|
||||
<div id="header" class="item image" data-width=#{dataWidth}>
|
||||
<div class="inner">
|
||||
<img src=#{mediumPath medium}>
|
||||
<img src=@{StaticR $ StaticRoute (drop 2 $ map T.pack $ splitDirectories $ mediumPath medium) []}>
|
||||
|
||||
<div id="header" class="item" data-width="400">
|
||||
<div class="inner">
|
||||
|
|
|
@ -15,7 +15,7 @@ $forall (Entity mediumId medium) <- pageMedia
|
|||
<article class="item" data-width=#{mediumThumbWidth medium}>
|
||||
<a href=@{MediumR mediumId}>
|
||||
<figure>
|
||||
<img src=#{mediumThumb medium}>
|
||||
<img src=@{StaticR $ StaticRoute (drop 2 $ map T.pack $ splitDirectories $ mediumThumb medium) []}>
|
||||
<figcaption>#{mediumTitle medium}
|
||||
$if nextMedia
|
||||
<div id="header" class="item" data-width="400">
|
||||
|
|
|
@ -18,9 +18,9 @@ $forall (Entity albumId album) <- userAlbs
|
|||
<a href=@{AlbumR albumId}>
|
||||
<figure class="thumbnail">
|
||||
$if (albumSamplePic album) == Nothing
|
||||
<img src="/static/img/album.jpg">
|
||||
<img src=@{StaticR img_album_jpg}>
|
||||
$else
|
||||
<img src=#{T.pack $ fromJust $ albumSamplePic album}>
|
||||
<img src=@{StaticR $ StaticRoute (drop 2 $ map T.pack $ splitDirectories $ fromJust $ albumSamplePic album) []}>
|
||||
<figcaption>#{albumTitle album}
|
||||
|
||||
$if null sharedAlbs
|
||||
|
@ -34,9 +34,9 @@ $else
|
|||
<a href=@{AlbumR albumId}>
|
||||
<figure class="thumbnail">
|
||||
$if (albumSamplePic album) == Nothing
|
||||
<img src="/static/img/album.jpg">
|
||||
<img src=@{StaticR img_album_jpg}>
|
||||
$else
|
||||
<img src=#{T.pack $ fromJust $ albumSamplePic album}>
|
||||
<img src=@{StaticR $ StaticRoute (drop 2 $ map T.pack $ splitDirectories $ fromJust $ albumSamplePic album) []}>
|
||||
<figcaption>#{albumTitle album}
|
||||
|
||||
$if null recentMedia
|
||||
|
@ -49,7 +49,7 @@ $else
|
|||
<article class="recent item" data-width=#{mediumThumbWidth medium}>
|
||||
<a href=@{MediumR mediumId}>
|
||||
<figure class="thumbnail">
|
||||
<img src=#{mediumThumb medium}>
|
||||
<img src=@{StaticR $ StaticRoute (drop 2 $ map T.pack $ splitDirectories $ mediumThumb medium) []}>
|
||||
<figcaption>#{mediumTitle medium}
|
||||
|
||||
<div id="footer">
|
||||
|
|
|
@ -9,5 +9,5 @@ $forall Just (Entity mId m) <- media
|
|||
<article class="item" data-width=#{mediumThumbWidth m}>
|
||||
<a href=@{MediumR mId}>
|
||||
<figure class="thumbnail">
|
||||
<img src=#{mediumThumb m}>
|
||||
<img src=@{StaticR $ StaticRoute (drop 2 $ map T.pack $ splitDirectories $ mediumThumb m) []}>
|
||||
<figcapion>#{mediumTitle m}
|
||||
|
|
Loading…
Reference in a new issue