module Hakyll.Web.Pandoc.FileType
( FileType (..)
, fileType
, itemFileType
) where
import System.FilePath (splitExtension)
import Hakyll.Core.Identifier
import Hakyll.Core.Item
data FileType
= Binary
| Css
| DocBook
| Html
| LaTeX
| LiterateHaskell FileType
| Markdown
| MediaWiki
| OrgMode
| PlainText
| Rst
| Textile
deriving (FileType -> FileType -> Bool
(FileType -> FileType -> Bool)
-> (FileType -> FileType -> Bool) -> Eq FileType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FileType -> FileType -> Bool
$c/= :: FileType -> FileType -> Bool
== :: FileType -> FileType -> Bool
$c== :: FileType -> FileType -> Bool
Eq, Eq FileType
Eq FileType
-> (FileType -> FileType -> Ordering)
-> (FileType -> FileType -> Bool)
-> (FileType -> FileType -> Bool)
-> (FileType -> FileType -> Bool)
-> (FileType -> FileType -> Bool)
-> (FileType -> FileType -> FileType)
-> (FileType -> FileType -> FileType)
-> Ord FileType
FileType -> FileType -> Bool
FileType -> FileType -> Ordering
FileType -> FileType -> FileType
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: FileType -> FileType -> FileType
$cmin :: FileType -> FileType -> FileType
max :: FileType -> FileType -> FileType
$cmax :: FileType -> FileType -> FileType
>= :: FileType -> FileType -> Bool
$c>= :: FileType -> FileType -> Bool
> :: FileType -> FileType -> Bool
$c> :: FileType -> FileType -> Bool
<= :: FileType -> FileType -> Bool
$c<= :: FileType -> FileType -> Bool
< :: FileType -> FileType -> Bool
$c< :: FileType -> FileType -> Bool
compare :: FileType -> FileType -> Ordering
$ccompare :: FileType -> FileType -> Ordering
$cp1Ord :: Eq FileType
Ord, Int -> FileType -> ShowS
[FileType] -> ShowS
FileType -> String
(Int -> FileType -> ShowS)
-> (FileType -> String) -> ([FileType] -> ShowS) -> Show FileType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FileType] -> ShowS
$cshowList :: [FileType] -> ShowS
show :: FileType -> String
$cshow :: FileType -> String
showsPrec :: Int -> FileType -> ShowS
$cshowsPrec :: Int -> FileType -> ShowS
Show, ReadPrec [FileType]
ReadPrec FileType
Int -> ReadS FileType
ReadS [FileType]
(Int -> ReadS FileType)
-> ReadS [FileType]
-> ReadPrec FileType
-> ReadPrec [FileType]
-> Read FileType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FileType]
$creadListPrec :: ReadPrec [FileType]
readPrec :: ReadPrec FileType
$creadPrec :: ReadPrec FileType
readList :: ReadS [FileType]
$creadList :: ReadS [FileType]
readsPrec :: Int -> ReadS FileType
$creadsPrec :: Int -> ReadS FileType
Read)
fileType :: FilePath -> FileType
fileType :: String -> FileType
fileType = (String -> String -> FileType) -> (String, String) -> FileType
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry String -> String -> FileType
fileType' ((String, String) -> FileType)
-> (String -> (String, String)) -> String -> FileType
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> (String, String)
splitExtension
where
fileType' :: String -> String -> FileType
fileType' String
_ String
".css" = FileType
Css
fileType' String
_ String
".dbk" = FileType
DocBook
fileType' String
_ String
".htm" = FileType
Html
fileType' String
_ String
".html" = FileType
Html
fileType' String
f String
".lhs" = FileType -> FileType
LiterateHaskell (FileType -> FileType) -> FileType -> FileType
forall a b. (a -> b) -> a -> b
$ case String -> FileType
fileType String
f of
FileType
Binary -> FileType
Markdown
FileType
x -> FileType
x
fileType' String
_ String
".markdown" = FileType
Markdown
fileType' String
_ String
".mediawiki" = FileType
MediaWiki
fileType' String
_ String
".md" = FileType
Markdown
fileType' String
_ String
".mdn" = FileType
Markdown
fileType' String
_ String
".mdown" = FileType
Markdown
fileType' String
_ String
".mdwn" = FileType
Markdown
fileType' String
_ String
".mkd" = FileType
Markdown
fileType' String
_ String
".mkdwn" = FileType
Markdown
fileType' String
_ String
".org" = FileType
OrgMode
fileType' String
_ String
".page" = FileType
Markdown
fileType' String
_ String
".rst" = FileType
Rst
fileType' String
_ String
".tex" = FileType
LaTeX
fileType' String
_ String
".text" = FileType
PlainText
fileType' String
_ String
".textile" = FileType
Textile
fileType' String
_ String
".txt" = FileType
PlainText
fileType' String
_ String
".wiki" = FileType
MediaWiki
fileType' String
_ String
_ = FileType
Binary
itemFileType :: Item a -> FileType
itemFileType :: Item a -> FileType
itemFileType = String -> FileType
fileType (String -> FileType) -> (Item a -> String) -> Item a -> FileType
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Identifier -> String
toFilePath (Identifier -> String)
-> (Item a -> Identifier) -> Item a -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Item a -> Identifier
forall a. Item a -> Identifier
itemIdentifier