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