Used stylish-haskell on all source files
This commit is contained in:
parent
8f1b6b5c4e
commit
9719b5a62d
5 changed files with 125 additions and 105 deletions
41
src/Blog.hs
41
src/Blog.hs
|
@ -1,25 +1,30 @@
|
||||||
{-# LANGUAGE OverloadedStrings, ScopedTypeVariables, DeriveDataTypeable, TemplateHaskell, QuasiQuotes, RecordWildCards #-}
|
{-# LANGUAGE DeriveDataTypeable #-}
|
||||||
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
{-# LANGUAGE QuasiQuotes #-}
|
||||||
|
{-# LANGUAGE RecordWildCards #-}
|
||||||
|
{-# LANGUAGE ScopedTypeVariables #-}
|
||||||
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
|
|
||||||
module Blog where
|
module Blog where
|
||||||
|
|
||||||
import Control.Monad (when, unless)
|
import BlogDB
|
||||||
import Data.Data (Data, Typeable)
|
import Control.Monad (unless, when)
|
||||||
import Data.List (intersperse)
|
import Data.Data (Data, Typeable)
|
||||||
import Data.Maybe (fromJust)
|
import Data.List (intersperse)
|
||||||
import Data.Monoid (mempty)
|
import Data.Maybe (fromJust)
|
||||||
import Data.Text (Text, append, pack, empty)
|
import Data.Monoid (mempty)
|
||||||
import Data.Text.Lazy (fromStrict)
|
import Data.Text (Text, append, empty, pack)
|
||||||
import Data.Time
|
import Data.Text.Lazy (fromStrict)
|
||||||
import Network.Captcha.ReCaptcha
|
import Data.Time
|
||||||
import System.Locale (defaultTimeLocale)
|
import Locales
|
||||||
import Text.Blaze.Html (preEscapedToHtml)
|
import Network.Captcha.ReCaptcha
|
||||||
import Text.Hamlet
|
import System.Locale (defaultTimeLocale)
|
||||||
import Text.Lucius
|
import Text.Blaze.Html (preEscapedToHtml)
|
||||||
import Text.Markdown
|
import Text.Hamlet
|
||||||
import Locales
|
import Text.Lucius
|
||||||
import BlogDB
|
import Text.Markdown
|
||||||
|
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
|
|
||||||
-- custom list functions
|
-- custom list functions
|
||||||
intersperse' :: a -> [a] -> [a]
|
intersperse' :: a -> [a] -> [a]
|
||||||
|
|
|
@ -1,30 +1,36 @@
|
||||||
{-# LANGUAGE DeriveDataTypeable, GeneralizedNewtypeDeriving, RecordWildCards,
|
{-# LANGUAGE DeriveDataTypeable #-}
|
||||||
TemplateHaskell, TypeFamilies, OverloadedStrings, ScopedTypeVariables, BangPatterns #-}
|
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
||||||
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
{-# LANGUAGE RecordWildCards #-}
|
||||||
|
{-# LANGUAGE ScopedTypeVariables #-}
|
||||||
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
|
{-# LANGUAGE TypeFamilies #-}
|
||||||
|
|
||||||
module BlogDB where
|
module BlogDB where
|
||||||
|
|
||||||
import Control.Monad.Reader (ask)
|
import Control.Monad.Reader (ask)
|
||||||
import Control.Monad.State (get, put)
|
import Control.Monad.State (get, put)
|
||||||
import Data.Acid
|
import Data.Acid
|
||||||
import Data.Acid.Advanced
|
import Data.Acid.Advanced
|
||||||
import Data.Acid.Local
|
import Data.Acid.Local
|
||||||
import Data.ByteString (ByteString)
|
import Data.ByteString (ByteString)
|
||||||
import Data.Char (toLower)
|
import Data.Char (toLower)
|
||||||
import Data.Data (Data, Typeable)
|
import Data.Data (Data, Typeable)
|
||||||
import Data.IxSet (Indexable(..), IxSet(..), (@=), Proxy(..), getOne, ixFun, ixSet)
|
import Data.IxSet (Indexable (..), IxSet (..), Proxy (..),
|
||||||
import Data.List (insert)
|
getOne, ixFun, ixSet, (@=))
|
||||||
import Data.SafeCopy (SafeCopy, base, deriveSafeCopy)
|
import Data.List (insert)
|
||||||
import Data.Text (Text, pack)
|
import Data.SafeCopy (SafeCopy, base, deriveSafeCopy)
|
||||||
import Data.Text.Lazy (toStrict)
|
import Data.Text (Text, pack)
|
||||||
import Data.Time
|
import Data.Text.Lazy (toStrict)
|
||||||
import Happstack.Server (FromReqURI(..))
|
import Data.Time
|
||||||
import System.Environment (getEnv)
|
import Happstack.Server (FromReqURI (..))
|
||||||
|
import System.Environment (getEnv)
|
||||||
|
|
||||||
import qualified Crypto.Hash.SHA512 as SHA (hash)
|
import qualified Crypto.Hash.SHA512 as SHA (hash)
|
||||||
import qualified Data.ByteString.Char8 as B
|
|
||||||
import qualified Data.ByteString.Base64 as B64 (encode)
|
import qualified Data.ByteString.Base64 as B64 (encode)
|
||||||
import qualified Data.IxSet as IxSet
|
import qualified Data.ByteString.Char8 as B
|
||||||
import qualified Data.Text as Text
|
import qualified Data.IxSet as IxSet
|
||||||
|
import qualified Data.Text as Text
|
||||||
|
|
||||||
|
|
||||||
newtype EntryId = EntryId { unEntryId :: Integer }
|
newtype EntryId = EntryId { unEntryId :: Integer }
|
||||||
|
@ -58,14 +64,14 @@ data Comment = Comment {
|
||||||
$(deriveSafeCopy 0 'base ''Comment)
|
$(deriveSafeCopy 0 'base ''Comment)
|
||||||
|
|
||||||
data Entry = Entry {
|
data Entry = Entry {
|
||||||
entryId :: EntryId,
|
entryId :: EntryId,
|
||||||
lang :: BlogLang,
|
lang :: BlogLang,
|
||||||
author :: Text,
|
author :: Text,
|
||||||
title :: Text,
|
title :: Text,
|
||||||
btext :: Text,
|
btext :: Text,
|
||||||
mtext :: Text,
|
mtext :: Text,
|
||||||
edate :: UTCTime,
|
edate :: UTCTime,
|
||||||
tags :: [Text],
|
tags :: [Text],
|
||||||
comments :: [Comment]
|
comments :: [Comment]
|
||||||
} deriving (Eq, Ord, Show, Data, Typeable)
|
} deriving (Eq, Ord, Show, Data, Typeable)
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,17 @@
|
||||||
{-# LANGUAGE ScopedTypeVariables, DeriveDataTypeable, OverloadedStrings #-}
|
{-# LANGUAGE DeriveDataTypeable #-}
|
||||||
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
{-# LANGUAGE ScopedTypeVariables #-}
|
||||||
|
|
||||||
module Locales where
|
module Locales where
|
||||||
|
|
||||||
import Data.Data (Data, Typeable)
|
import Data.Data (Data, Typeable)
|
||||||
import Data.Maybe (fromMaybe)
|
import Data.Maybe (fromMaybe)
|
||||||
import Data.Text (Text)
|
import Data.Text (Text)
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import Network.URI
|
import Network.URI
|
||||||
|
|
||||||
|
|
||||||
import BlogDB (BlogLang (..))
|
import BlogDB (BlogLang (..))
|
||||||
|
|
||||||
{- to add a language simply define its abbreviation and Show instance then
|
{- to add a language simply define its abbreviation and Show instance then
|
||||||
- translate the appropriate strings and add CouchDB views in Server.hs -}
|
- translate the appropriate strings and add CouchDB views in Server.hs -}
|
||||||
|
|
49
src/Main.hs
49
src/Main.hs
|
@ -1,36 +1,43 @@
|
||||||
{-# LANGUAGE OverloadedStrings, ScopedTypeVariables, GeneralizedNewtypeDeriving,
|
{-# LANGUAGE DeriveDataTypeable #-}
|
||||||
DeriveDataTypeable, FlexibleContexts, MultiParamTypeClasses, TemplateHaskell,
|
{-# LANGUAGE FlexibleContexts #-}
|
||||||
TypeFamilies, RecordWildCards, BangPatterns #-}
|
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
||||||
|
{-# LANGUAGE MultiParamTypeClasses #-}
|
||||||
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
{-# LANGUAGE RecordWildCards #-}
|
||||||
|
{-# LANGUAGE ScopedTypeVariables #-}
|
||||||
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
|
{-# LANGUAGE TypeFamilies #-}
|
||||||
|
|
||||||
module Main where
|
module Main where
|
||||||
|
|
||||||
import Control.Applicative ((<$>), (<*>), optional, pure)
|
import Control.Applicative (optional, pure, (<$>), (<*>))
|
||||||
import Control.Exception (bracket)
|
import Control.Exception (bracket)
|
||||||
import Control.Monad (msum, mzero, when, unless)
|
import Control.Monad (msum, mzero, unless, when)
|
||||||
import Control.Monad.IO.Class (liftIO)
|
import Control.Monad.IO.Class (liftIO)
|
||||||
import Control.Monad.State (get, put)
|
import Control.Monad.Reader (ask)
|
||||||
import Control.Monad.Reader (ask)
|
import Control.Monad.State (get, put)
|
||||||
import qualified Crypto.Hash.SHA512 as SHA
|
import qualified Crypto.Hash.SHA512 as SHA
|
||||||
import Data.Acid
|
import Data.Acid
|
||||||
import Data.Acid.Advanced
|
import Data.Acid.Advanced
|
||||||
import Data.Acid.Local
|
import Data.Acid.Local
|
||||||
import qualified Data.ByteString.Base64 as B64 (encode)
|
import qualified Data.ByteString.Base64 as B64 (encode)
|
||||||
import Data.ByteString.Char8 (ByteString, pack, unpack)
|
import Data.ByteString.Char8 (ByteString, pack, unpack)
|
||||||
import Data.Data (Data, Typeable)
|
import Data.Data (Data, Typeable)
|
||||||
import Data.Maybe (fromJust)
|
import Data.Maybe (fromJust)
|
||||||
import Data.Monoid (mempty)
|
import Data.Monoid (mempty)
|
||||||
import Data.Text (Text)
|
import Data.SafeCopy (base, deriveSafeCopy)
|
||||||
import qualified Data.Text as T
|
import Data.Text (Text)
|
||||||
|
import qualified Data.Text as T
|
||||||
import Data.Time
|
import Data.Time
|
||||||
import Data.SafeCopy (base, deriveSafeCopy)
|
import Happstack.Server hiding (Session)
|
||||||
import Happstack.Server hiding (Session)
|
|
||||||
import Happstack.Server.Compression
|
import Happstack.Server.Compression
|
||||||
import Network.Captcha.ReCaptcha
|
import Network.Captcha.ReCaptcha
|
||||||
import Options
|
import Options
|
||||||
import System.Locale (defaultTimeLocale)
|
import System.Locale (defaultTimeLocale)
|
||||||
|
|
||||||
import Blog
|
import Blog
|
||||||
import BlogDB hiding (addComment, updateEntry, deleteComment)
|
import BlogDB hiding (addComment, deleteComment,
|
||||||
|
updateEntry)
|
||||||
import Locales
|
import Locales
|
||||||
import RSS
|
import RSS
|
||||||
|
|
||||||
|
|
14
src/RSS.hs
14
src/RSS.hs
|
@ -2,15 +2,15 @@
|
||||||
|
|
||||||
module RSS (renderFeed) where
|
module RSS (renderFeed) where
|
||||||
|
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
|
|
||||||
import Data.Maybe (fromMaybe)
|
import Data.Maybe (fromMaybe)
|
||||||
import Data.Time (getCurrentTime, UTCTime)
|
import Data.Time (UTCTime, getCurrentTime)
|
||||||
import Network.URI
|
import Network.URI
|
||||||
import Text.RSS
|
import Text.RSS
|
||||||
|
|
||||||
import Locales
|
import BlogDB hiding (Title)
|
||||||
import BlogDB hiding (Title)
|
import Locales
|
||||||
|
|
||||||
createChannel :: BlogLang -> UTCTime -> [ChannelElem]
|
createChannel :: BlogLang -> UTCTime -> [ChannelElem]
|
||||||
createChannel l now = [ Language $ show l
|
createChannel l now = [ Language $ show l
|
||||||
|
|
Loading…
Reference in a new issue