Skip to content

Commit

Permalink
Fix homepage blog link
Browse files Browse the repository at this point in the history
  • Loading branch information
snoyberg committed Jan 31, 2014
1 parent d41db07 commit df51499
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
6 changes: 0 additions & 6 deletions Handler/Blog.hs
Expand Up @@ -23,16 +23,10 @@ import Data.Digest.Pure.MD5 (md5)
import qualified Data.ByteString.Lazy.Char8 as L8
import Data.Time (utctDay, toGregorian)
import qualified Data.Foldable as Fo
import Data.Time (getCurrentTime)

getBlogR :: Handler ()
getBlogR = getNewestBlog >>= redirect . fst

getBlog :: Handler Blog
getBlog = do
now <- liftIO getCurrentTime
(ywBlog <$> getYesod) >>= fmap (filterBlog now) . liftIO . readIORef

getOldBlogPostR :: Slug -> Handler ()
getOldBlogPostR s = do
Blog blog <- getBlog
Expand Down
9 changes: 7 additions & 2 deletions Import.hs
Expand Up @@ -13,6 +13,7 @@ module Import
, loadBook
, loadBlog
, loadAuthors
, getBlog
) where

import Prelude hiding (writeFile, readFile)
Expand Down Expand Up @@ -53,10 +54,14 @@ getBlogList = do
(s, p) <- ps
return (BlogPostR y m s, p)

getBlog :: Handler Blog
getBlog = do
now <- liftIO getCurrentTime
(ywBlog <$> getYesod) >>= fmap (filterBlog now) . liftIO . readIORef

getNewestBlog :: Handler (Route YesodWeb, Post)
getNewestBlog = do
iblog <- ywBlog <$> getYesod
Blog blog <- liftIO $ readIORef iblog
Blog blog <- getBlog
maybe notFound return $ listToMaybe $ do
(year, x) <- take 1 $ reverse $ sortBy (comparing fst) $ Map.toList blog
(month, y) <- take 1 $ reverse $ sortBy (comparing fst) $ Map.toList x
Expand Down

0 comments on commit df51499

Please sign in to comment.