summaryrefslogtreecommitdiff
path: root/src/Hakyll/Web/Page
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2012-11-10 18:11:46 +0100
committerJasper Van der Jeugt <m@jaspervdj.be>2012-11-10 18:11:46 +0100
commit141e761ce11d4d4ae9e9b86201249dbd549e2924 (patch)
tree0d0ba398331bceb9326c58392680fb81361fb6c3 /src/Hakyll/Web/Page
parent260e4e2e8936f756d2f3a2e6e788f05ca28e4324 (diff)
downloadhakyll-141e761ce11d4d4ae9e9b86201249dbd549e2924.tar.gz
Deprecate things, basics now work
Diffstat (limited to 'src/Hakyll/Web/Page')
-rw-r--r--src/Hakyll/Web/Page/Internal.hs50
-rw-r--r--src/Hakyll/Web/Page/List.hs1
-rw-r--r--src/Hakyll/Web/Page/Metadata.hs10
-rw-r--r--src/Hakyll/Web/Page/Read.hs61
4 files changed, 12 insertions, 110 deletions
diff --git a/src/Hakyll/Web/Page/Internal.hs b/src/Hakyll/Web/Page/Internal.hs
index 55067ed..04cf08a 100644
--- a/src/Hakyll/Web/Page/Internal.hs
+++ b/src/Hakyll/Web/Page/Internal.hs
@@ -1,50 +1,8 @@
--- | Internal representation of the page datatype
---
-{-# LANGUAGE DeriveDataTypeable #-}
+--------------------------------------------------------------------------------
module Hakyll.Web.Page.Internal
- ( Page (..)
- , fromMap
- , toMap
+ ( Page
) where
-import Control.Applicative ((<$>), (<*>))
-import Data.Monoid (Monoid, mempty, mappend)
-import Data.Map (Map)
-import Data.Binary (Binary, get, put)
-import Data.Typeable (Typeable)
-import qualified Data.Map as M
-
-import Hakyll.Core.Writable
-
--- | Type used to represent pages
---
-data Page a = Page
- { pageMetadata :: Map String String
- , pageBody :: a
- } deriving (Eq, Show, Typeable)
-
-instance Monoid a => Monoid (Page a) where
- mempty = Page M.empty mempty
- mappend (Page m1 b1) (Page m2 b2) =
- Page (M.union m1 m2) (mappend b1 b2)
-
-instance Functor Page where
- fmap f (Page m b) = Page m (f b)
-
-instance Binary a => Binary (Page a) where
- put (Page m b) = put m >> put b
- get = Page <$> get <*> get
-
-instance Writable a => Writable (Page a) where
- write p (Page _ b) = write p b
-
--- | Create a metadata page, without a body
---
-fromMap :: Monoid a => Map String String -> Page a
-fromMap m = Page m mempty
-
--- | Convert a page to a map. The body will be placed in the @body@ key.
---
-toMap :: Page String -> Map String String
-toMap (Page m b) = M.insert "body" b m
+--------------------------------------------------------------------------------
+type Page = String
diff --git a/src/Hakyll/Web/Page/List.hs b/src/Hakyll/Web/Page/List.hs
index 24721e7..20c178c 100644
--- a/src/Hakyll/Web/Page/List.hs
+++ b/src/Hakyll/Web/Page/List.hs
@@ -1,3 +1,4 @@
+-- TODO: Port
-- | Provides an easy way to combine several pages in a list. The applications
-- are obvious:
--
diff --git a/src/Hakyll/Web/Page/Metadata.hs b/src/Hakyll/Web/Page/Metadata.hs
index 8605aea..d9f330e 100644
--- a/src/Hakyll/Web/Page/Metadata.hs
+++ b/src/Hakyll/Web/Page/Metadata.hs
@@ -1,7 +1,8 @@
-- | Provides various functions to manipulate the metadata fields of a page
---
+-- TODO: PORT
module Hakyll.Web.Page.Metadata
- ( getField
+ (
+ {- getField
, getFieldMaybe
, setField
, trySetField
@@ -17,8 +18,10 @@ module Hakyll.Web.Page.Metadata
, copyBodyToField
, copyBodyFromField
, comparePagesByDate
+ -}
) where
+{-
import Control.Arrow (Arrow, arr, (>>>), (***), (&&&))
import Control.Category (id)
import Control.Monad (msum)
@@ -209,7 +212,7 @@ renderModificationTimeWith :: TimeLocale
-> Compiler (Page String) (Page String)
-- ^ Resulting compiler
renderModificationTimeWith locale key format =
- id &&& (getResourceWith resourceModificationTime) >>>
+ id &&& (getResourceWith $ const resourceModificationTime) >>>
setFieldA key (arr (formatTime locale format))
-- | Copy the body of a page to a metadata field
@@ -233,3 +236,4 @@ comparePagesByDate :: Page a -> Page a -> Ordering
comparePagesByDate = comparing $ fromMaybe zero . getUTCMaybe defaultTimeLocale
where
zero = UTCTime (ModifiedJulianDay 0) 0
+-}
diff --git a/src/Hakyll/Web/Page/Read.hs b/src/Hakyll/Web/Page/Read.hs
deleted file mode 100644
index 40a4cd5..0000000
--- a/src/Hakyll/Web/Page/Read.hs
+++ /dev/null
@@ -1,61 +0,0 @@
--- | Module providing a function to parse a page from a file
---
-module Hakyll.Web.Page.Read
- ( readPage
- ) where
-
-import Control.Applicative ((<$>), (<*>), (<*), (<|>))
-import qualified Data.Map as M
-
-import Text.Parsec.Char (alphaNum, anyChar, char, oneOf, string)
-import Text.Parsec.Combinator (choice, many1, manyTill, option, skipMany1)
-import Text.Parsec.Prim (many, parse, skipMany, (<?>))
-import Text.Parsec.String (Parser)
-
-import Hakyll.Core.Util.String
-import Hakyll.Web.Page.Internal
-
--- | Space or tab, no newline
-inlineSpace :: Parser Char
-inlineSpace = oneOf ['\t', ' '] <?> "space"
-
--- | Parse Windows newlines as well (i.e. "\n" or "\r\n")
-newline :: Parser String
-newline = string "\n" -- Unix
- <|> string "\r\n" -- DOS
-
--- | Parse a single metadata field
---
-metadataField :: Parser (String, String)
-metadataField = do
- key <- manyTill alphaNum $ char ':'
- skipMany1 inlineSpace <?> "space followed by metadata for: " ++ key
- value <- manyTill anyChar newline
- trailing' <- many trailing
- return (key, trim $ value ++ concat trailing')
- where
- trailing = (++) <$> many1 inlineSpace <*> manyTill anyChar newline
-
--- | Parse a metadata block, including delimiters and trailing newlines
---
-metadata :: Parser [(String, String)]
-metadata = do
- open <- many1 (char '-') <* many inlineSpace <* newline
- metadata' <- many metadataField
- _ <- choice $ map (string . replicate (length open)) ['-', '.']
- skipMany inlineSpace
- skipMany1 newline
- return metadata'
-
--- | Parse a Hakyll page
---
-page :: Parser ([(String, String)], String)
-page = do
- metadata' <- option [] metadata
- body <- many anyChar
- return (metadata', body)
-
-readPage :: String -> Page String
-readPage input = case parse page "page" input of
- Left err -> error (show err)
- Right (md, b) -> Page (M.fromList md) b