{-# LANGUAGE DeriveGeneric, OverloadedStrings #-}
module Rules.DisneyExperienceSummary (rules) where

import           Control.Monad.Reader  (asks)
import           Control.Monad.Trans   (MonadTrans (..))
import           Data.List             (nub, sortBy)
import qualified Data.Map              as M
import           Data.Ord              (comparing)
import           Data.String           (IsString (..))
import           Dhall                 (FromDhall, Generic, auto, input)
import           Hakyll
import           System.FilePath       (joinPath, (</>))
import           System.FilePath.Posix (takeBaseName)

import           Config                (contentsRoot, readerOptions)
import           Contexts              (siteCtx)
import           Media.SVG             (mermaidTransform)
import           Rules.PageType
import           Text.Pandoc.Walk      (walkM)
import           Utils                 (mconcatM, modifyExternalLinkAttr)
import qualified Vendor.FontAwesome    as FA

data Favorite = Favorite {
    Favorite -> String
text     :: String
  , Favorite -> String
category :: String
  , Favorite -> Maybe String
link     :: Maybe String
  } deriving ((forall x. Favorite -> Rep Favorite x)
-> (forall x. Rep Favorite x -> Favorite) -> Generic Favorite
forall x. Rep Favorite x -> Favorite
forall x. Favorite -> Rep Favorite x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Favorite -> Rep Favorite x
from :: forall x. Favorite -> Rep Favorite x
$cto :: forall x. Rep Favorite x -> Favorite
to :: forall x. Rep Favorite x -> Favorite
Generic, Int -> Favorite -> ShowS
[Favorite] -> ShowS
Favorite -> String
(Int -> Favorite -> ShowS)
-> (Favorite -> String) -> ([Favorite] -> ShowS) -> Show Favorite
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Favorite -> ShowS
showsPrec :: Int -> Favorite -> ShowS
$cshow :: Favorite -> String
show :: Favorite -> String
$cshowList :: [Favorite] -> ShowS
showList :: [Favorite] -> ShowS
Show)

instance FromDhall Favorite

-- タグ設定のデータ構造
data TagConfig = TagConfig {
    TagConfig -> String
mapKey   :: String
  , TagConfig -> TagInfo
mapValue :: TagInfo
  } deriving ((forall x. TagConfig -> Rep TagConfig x)
-> (forall x. Rep TagConfig x -> TagConfig) -> Generic TagConfig
forall x. Rep TagConfig x -> TagConfig
forall x. TagConfig -> Rep TagConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. TagConfig -> Rep TagConfig x
from :: forall x. TagConfig -> Rep TagConfig x
$cto :: forall x. Rep TagConfig x -> TagConfig
to :: forall x. Rep TagConfig x -> TagConfig
Generic, Int -> TagConfig -> ShowS
[TagConfig] -> ShowS
TagConfig -> String
(Int -> TagConfig -> ShowS)
-> (TagConfig -> String)
-> ([TagConfig] -> ShowS)
-> Show TagConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TagConfig -> ShowS
showsPrec :: Int -> TagConfig -> ShowS
$cshow :: TagConfig -> String
show :: TagConfig -> String
$cshowList :: [TagConfig] -> ShowS
showList :: [TagConfig] -> ShowS
Show)

data TagInfo = TagInfo {
    TagInfo -> String
color :: String
  , TagInfo -> String
url   :: String
  } deriving ((forall x. TagInfo -> Rep TagInfo x)
-> (forall x. Rep TagInfo x -> TagInfo) -> Generic TagInfo
forall x. Rep TagInfo x -> TagInfo
forall x. TagInfo -> Rep TagInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. TagInfo -> Rep TagInfo x
from :: forall x. TagInfo -> Rep TagInfo x
$cto :: forall x. Rep TagInfo x -> TagInfo
to :: forall x. Rep TagInfo x -> TagInfo
Generic, Int -> TagInfo -> ShowS
[TagInfo] -> ShowS
TagInfo -> String
(Int -> TagInfo -> ShowS)
-> (TagInfo -> String) -> ([TagInfo] -> ShowS) -> Show TagInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TagInfo -> ShowS
showsPrec :: Int -> TagInfo -> ShowS
$cshow :: TagInfo -> String
show :: TagInfo -> String
$cshowList :: [TagInfo] -> ShowS
showList :: [TagInfo] -> ShowS
Show)

instance FromDhall TagConfig
instance FromDhall TagInfo

-- Dhallファイルからタグ設定を読み込み
loadDisneyTags :: IO [TagConfig]
loadDisneyTags :: IO [TagConfig]
loadDisneyTags = Decoder [TagConfig] -> Text -> IO [TagConfig]
forall a. Decoder a -> Text -> IO a
input Decoder [TagConfig]
forall a. FromDhall a => Decoder a
auto Text
"./contents/config/disney/Tags.dhall"

-- タグ設定をMapに変換
tagConfigMap :: IO (M.Map String (String, String))
tagConfigMap :: IO (Map String (String, String))
tagConfigMap = do
    [TagConfig]
tags <- IO [TagConfig]
loadDisneyTags
    Map String (String, String) -> IO (Map String (String, String))
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Map String (String, String) -> IO (Map String (String, String)))
-> Map String (String, String) -> IO (Map String (String, String))
forall a b. (a -> b) -> a -> b
$ [(String, (String, String))] -> Map String (String, String)
forall k a. Ord k => [(k, a)] -> Map k a
M.fromList ([(String, (String, String))] -> Map String (String, String))
-> [(String, (String, String))] -> Map String (String, String)
forall a b. (a -> b) -> a -> b
$ (TagConfig -> (String, (String, String)))
-> [TagConfig] -> [(String, (String, String))]
forall a b. (a -> b) -> [a] -> [b]
map (\TagConfig
tag -> (TagConfig -> String
mapKey TagConfig
tag, (TagInfo -> String
color (TagInfo -> String) -> TagInfo -> String
forall a b. (a -> b) -> a -> b
$ TagConfig -> TagInfo
mapValue TagConfig
tag, TagInfo -> String
url (TagInfo -> String) -> TagInfo -> String
forall a b. (a -> b) -> a -> b
$ TagConfig -> TagInfo
mapValue TagConfig
tag))) [TagConfig]
tags

getTag :: String -> M.Map String (String, String) -> (String, String)
getTag :: String -> Map String (String, String) -> (String, String)
getTag = (String, String)
-> String -> Map String (String, String) -> (String, String)
forall k a. Ord k => a -> k -> Map k a -> a
M.findWithDefault (String
"#363636", String
"#")

-- タグの色を取得
getTagColor :: String -> M.Map String (String, String) -> String
getTagColor :: String -> Map String (String, String) -> String
getTagColor = ((String, String) -> String)
-> (Map String (String, String) -> (String, String))
-> Map String (String, String)
-> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
(.) (String, String) -> String
forall a b. (a, b) -> a
fst ((Map String (String, String) -> (String, String))
 -> Map String (String, String) -> String)
-> (String -> Map String (String, String) -> (String, String))
-> String
-> Map String (String, String)
-> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Map String (String, String) -> (String, String)
getTag

-- タグのリンクを取得
getTagLink :: String -> M.Map String (String, String) -> String
getTagLink :: String -> Map String (String, String) -> String
getTagLink = ((String, String) -> String)
-> (Map String (String, String) -> (String, String))
-> Map String (String, String)
-> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
(.) (String, String) -> String
forall a b. (a, b) -> b
snd ((Map String (String, String) -> (String, String))
 -> Map String (String, String) -> String)
-> (String -> Map String (String, String) -> (String, String))
-> String
-> Map String (String, String)
-> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Map String (String, String) -> (String, String)
getTag

-- メタデータ用のトリム関数
trimMeta :: String -> String
trimMeta :: ShowS
trimMeta = ShowS
f ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
f
  where f :: ShowS
f = ShowS
forall a. [a] -> [a]
reverse ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> ShowS
forall a. (a -> Bool) -> [a] -> [a]
dropWhile (Char -> String -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` (String
" \n\r\t" :: String))

-- SNSリンクのメタデータを処理するためのフィールド
snsLinksField :: String -> Context String
snsLinksField :: String -> Context String
snsLinksField String
snsType = String
-> Context String
-> (Item String -> Compiler [Item String])
-> Context String
forall a b.
String -> Context a -> (Item b -> Compiler [Item a]) -> Context b
listFieldWith (String
snsType String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"-links") (String -> (Item String -> Compiler String) -> Context String
forall a. String -> (Item a -> Compiler String) -> Context a
field String
"url" (String -> Compiler String
forall a. a -> Compiler a
forall (m :: * -> *) a. Monad m => a -> m a
return (String -> Compiler String)
-> (Item String -> String) -> Item String -> Compiler String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Item String -> String
forall a. Item a -> a
itemBody)) ((Item String -> Compiler [Item String]) -> Context String)
-> (Item String -> Compiler [Item String]) -> Context String
forall a b. (a -> b) -> a -> b
$ \Item String
item -> do
    Maybe String
mUrls <- Identifier -> String -> Compiler (Maybe String)
forall (m :: * -> *).
MonadMetadata m =>
Identifier -> String -> m (Maybe String)
getMetadataField (Item String -> Identifier
forall a. Item a -> Identifier
itemIdentifier Item String
item) String
snsType
    case Maybe String
mUrls of
        Just String
urlsStr -> [Item String] -> Compiler [Item String]
forall a. a -> Compiler a
forall (m :: * -> *) a. Monad m => a -> m a
return ([Item String] -> Compiler [Item String])
-> [Item String] -> Compiler [Item String]
forall a b. (a -> b) -> a -> b
$ (String -> Item String) -> [String] -> [Item String]
forall a b. (a -> b) -> [a] -> [b]
map (\String
url -> Identifier -> String -> Item String
forall a. Identifier -> a -> Item a
Item (String -> Identifier
forall a. IsString a => String -> a
fromString String
url) (ShowS
trimMeta String
url)) (String -> String -> [String]
splitAll String
"," String
urlsStr)
        Maybe String
Nothing     -> [Item String] -> Compiler [Item String]
forall a. a -> Compiler a
forall (m :: * -> *) a. Monad m => a -> m a
return []

-- タグのメタデータを処理するためのフィールド
disneyTagsField :: M.Map String (String, String) -> Context String
disneyTagsField :: Map String (String, String) -> Context String
disneyTagsField Map String (String, String)
tagConfig = String
-> Context String
-> (Item String -> Compiler [Item String])
-> Context String
forall a b.
String -> Context a -> (Item b -> Compiler [Item a]) -> Context b
listFieldWith String
"disney-tags-list" Context String
tagCtx ((Item String -> Compiler [Item String]) -> Context String)
-> (Item String -> Compiler [Item String]) -> Context String
forall a b. (a -> b) -> a -> b
$ \Item String
item -> do
    Maybe String
mTags <- Identifier -> String -> Compiler (Maybe String)
forall (m :: * -> *).
MonadMetadata m =>
Identifier -> String -> m (Maybe String)
getMetadataField (Item String -> Identifier
forall a. Item a -> Identifier
itemIdentifier Item String
item) String
"disney-tags"
    case Maybe String
mTags of
        Just String
tagsStr -> [Item String] -> Compiler [Item String]
forall a. a -> Compiler a
forall (m :: * -> *) a. Monad m => a -> m a
return ([Item String] -> Compiler [Item String])
-> [Item String] -> Compiler [Item String]
forall a b. (a -> b) -> a -> b
$ (String -> Item String) -> [String] -> [Item String]
forall a b. (a -> b) -> [a] -> [b]
map (\String
tag -> Identifier -> String -> Item String
forall a. Identifier -> a -> Item a
Item (String -> Identifier
forall a. IsString a => String -> a
fromString String
tag) String
tag) ([String] -> [Item String]) -> [String] -> [Item String]
forall a b. (a -> b) -> a -> b
$ (String -> Bool) -> [String] -> [String]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool) -> (String -> Bool) -> String -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null) ([String] -> [String]) -> [String] -> [String]
forall a b. (a -> b) -> a -> b
$ ShowS -> [String] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map ShowS
trimMeta (String -> String -> [String]
splitAll String
"," String
tagsStr)
        Maybe String
Nothing      -> [Item String] -> Compiler [Item String]
forall a. a -> Compiler a
forall (m :: * -> *) a. Monad m => a -> m a
return []
  where
    tagCtx :: Context String
tagCtx = String -> (Item String -> Compiler String) -> Context String
forall a. String -> (Item a -> Compiler String) -> Context a
field String
"name" (String -> Compiler String
forall a. a -> Compiler a
forall (m :: * -> *) a. Monad m => a -> m a
return (String -> Compiler String)
-> (Item String -> String) -> Item String -> Compiler String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Item String -> String
forall a. Item a -> a
itemBody)
          Context String -> Context String -> Context String
forall a. Semigroup a => a -> a -> a
<> String -> (Item String -> Compiler String) -> Context String
forall a. String -> (Item a -> Compiler String) -> Context a
field String
"color" (String -> Compiler String
forall a. a -> Compiler a
forall (m :: * -> *) a. Monad m => a -> m a
return (String -> Compiler String)
-> (Item String -> String) -> Item String -> Compiler String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> Map String (String, String) -> String)
-> Map String (String, String) -> ShowS
forall a b c. (a -> b -> c) -> b -> a -> c
flip String -> Map String (String, String) -> String
getTagColor Map String (String, String)
tagConfig ShowS -> (Item String -> String) -> Item String -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Item String -> String
forall a. Item a -> a
itemBody)
          Context String -> Context String -> Context String
forall a. Semigroup a => a -> a -> a
<> String -> (Item String -> Compiler String) -> Context String
forall a. String -> (Item a -> Compiler String) -> Context a
field String
"link" (String -> Compiler String
forall a. a -> Compiler a
forall (m :: * -> *) a. Monad m => a -> m a
return (String -> Compiler String)
-> (Item String -> String) -> Item String -> Compiler String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> Map String (String, String) -> String)
-> Map String (String, String) -> ShowS
forall a b c. (a -> b -> c) -> b -> a -> c
flip String -> Map String (String, String) -> String
getTagLink Map String (String, String)
tagConfig ShowS -> (Item String -> String) -> Item String -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Item String -> String
forall a. Item a -> a
itemBody)

disneyExperienceSummaryRoot :: FilePath
disneyExperienceSummaryRoot :: String
disneyExperienceSummaryRoot = [String] -> String
joinPath [String
contentsRoot, String
"disney_experience_summary"]

aboutIdent :: Identifier
aboutIdent :: Identifier
aboutIdent = String -> Identifier
forall a. IsString a => String -> a
fromString
    (String -> Identifier) -> String -> Identifier
forall a b. (a -> b) -> a -> b
$ [String] -> String
joinPath [String
disneyExperienceSummaryRoot, String
"about.md"]

disneyLogsPattern :: Pattern
disneyLogsPattern :: Pattern
disneyLogsPattern = String -> Pattern
fromRegex (String -> Pattern) -> String -> Pattern
forall a b. (a -> b) -> a -> b
$ [String] -> String
forall a. Monoid a => [a] -> a
mconcat
    [ String
"(^"
    , [String] -> String
joinPath [String
disneyExperienceSummaryRoot, String
"logs", String
"[0-9]+.md"]
    , String
"$)"
    ]

sortByNum :: [Item a] -> [Item a]
sortByNum :: forall a. [Item a] -> [Item a]
sortByNum = (Item a -> Item a -> Ordering) -> [Item a] -> [Item a]
forall a. (a -> a -> Ordering) -> [a] -> [a]
sortBy
    ((Item a -> Item a -> Ordering) -> [Item a] -> [Item a])
-> (Item a -> Item a -> Ordering) -> [Item a] -> [Item a]
forall a b. (a -> b) -> a -> b
$ (Item a -> Item a -> Ordering) -> Item a -> Item a -> Ordering
forall a b c. (a -> b -> c) -> b -> a -> c
flip
    ((Item a -> Item a -> Ordering) -> Item a -> Item a -> Ordering)
-> (Item a -> Item a -> Ordering) -> Item a -> Item a -> Ordering
forall a b. (a -> b) -> a -> b
$ (Item a -> Int) -> Item a -> Item a -> Ordering
forall a b. Ord a => (b -> a) -> b -> b -> Ordering
comparing
    ((Item a -> Int) -> Item a -> Item a -> Ordering)
-> (Item a -> Int) -> Item a -> Item a -> Ordering
forall a b. (a -> b) -> a -> b
$ (String -> Int
forall a. Read a => String -> a
read :: String -> Int) (String -> Int) -> (Item a -> String) -> Item a -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
takeBaseName ShowS -> (Item a -> String) -> Item a -> String
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

mdRule :: Snapshot
    -> Pattern
    -> PageConfReader Rules ()
mdRule :: String -> Pattern -> PageConfReader Rules ()
mdRule String
ss Pattern
pat = do
    WriterOptions
wOpt <- (PageConf -> WriterOptions) -> ReaderT PageConf Rules WriterOptions
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks PageConf -> WriterOptions
pcWriterOpt
    KaTeXRender
katexRender <- (PageConf -> KaTeXRender) -> ReaderT PageConf Rules KaTeXRender
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks PageConf -> KaTeXRender
pcKaTeXRender
    FontAwesomeIcons
faIcons <- (PageConf -> FontAwesomeIcons)
-> ReaderT PageConf Rules FontAwesomeIcons
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks PageConf -> FontAwesomeIcons
pcFaIcons
    Rules () -> PageConfReader Rules ()
forall (m :: * -> *) a. Monad m => m a -> ReaderT PageConf m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Rules () -> PageConfReader Rules ())
-> Rules () -> PageConfReader Rules ()
forall a b. (a -> b) -> a -> b
$ Pattern -> Rules () -> Rules ()
match Pattern
pat (Rules () -> Rules ()) -> Rules () -> Rules ()
forall a b. (a -> b) -> a -> b
$ Compiler (Item String) -> Rules ()
forall a.
(Binary a, Typeable a, Writable a) =>
Compiler (Item a) -> Rules ()
compile (Compiler (Item String) -> Rules ())
-> Compiler (Item String) -> Rules ()
forall a b. (a -> b) -> a -> b
$ do
        ReaderOptions
-> WriterOptions
-> (Pandoc -> Compiler Pandoc)
-> Compiler (Item String)
pandocCompilerWithTransformM ReaderOptions
readerOptions WriterOptions
wOpt ((Block -> Compiler Block) -> Pandoc -> Compiler Pandoc
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
forall (m :: * -> *).
(Monad m, Applicative m, Functor m) =>
(Block -> m Block) -> Pandoc -> m Pandoc
walkM Block -> Compiler Block
mermaidTransform)
            Compiler (Item String) -> KaTeXRender -> Compiler (Item String)
forall a b. Compiler a -> (a -> Compiler b) -> Compiler b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= KaTeXRender
modifyExternalLinkAttr
            Compiler (Item String) -> KaTeXRender -> Compiler (Item String)
forall a b. Compiler a -> (a -> Compiler b) -> Compiler b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= KaTeXRender
relativizeUrls
            Compiler (Item String) -> KaTeXRender -> Compiler (Item String)
forall a b. Compiler a -> (a -> Compiler b) -> Compiler b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= FontAwesomeIcons -> KaTeXRender
FA.render FontAwesomeIcons
faIcons
            Compiler (Item String) -> KaTeXRender -> Compiler (Item String)
forall a b. Compiler a -> (a -> Compiler b) -> Compiler b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= KaTeXRender
katexRender
            Compiler (Item String) -> KaTeXRender -> Compiler (Item String)
forall a b. Compiler a -> (a -> Compiler b) -> Compiler b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= String -> KaTeXRender
forall a.
(Binary a, Typeable a) =>
String -> Item a -> Compiler (Item a)
saveSnapshot String
ss

loadDisneyFavorites :: IO [Favorite]
loadDisneyFavorites :: IO [Favorite]
loadDisneyFavorites = Decoder [Favorite] -> Text -> IO [Favorite]
forall a. Decoder a -> Text -> IO a
input Decoder [Favorite]
forall a. FromDhall a => Decoder a
auto Text
"./contents/config/disney/Favorites.dhall"

-- ログエントリ用のコンテキストを作成
disneyLogCtx :: M.Map String (String, String) -> Context String
disneyLogCtx :: Map String (String, String) -> Context String
disneyLogCtx Map String (String, String)
tagConfig = [Context String] -> Context String
forall a. Monoid a => [a] -> a
mconcat
    [ Context String
forall a. Context a
metadataField
    , String -> Context String
bodyField String
"log-body"
    , String -> Context String
snsLinksField String
"youtube"
    , String -> Context String
snsLinksField String
"instagram"
    , String -> Context String
snsLinksField String
"x"
    , String -> Context String
snsLinksField String
"note"
    , Map String (String, String) -> Context String
disneyTagsField Map String (String, String)
tagConfig
    ]

rules :: PageConfReader Rules ()
rules :: PageConfReader Rules ()
rules = do
    let items :: [Pattern]
items = Pattern
disneyLogsPattern Pattern -> [Pattern] -> [Pattern]
forall a. a -> [a] -> [a]
: (Identifier -> Pattern) -> [Identifier] -> [Pattern]
forall a b. (a -> b) -> [a] -> [b]
map ([Identifier] -> Pattern
fromList ([Identifier] -> Pattern)
-> (Identifier -> [Identifier]) -> Identifier -> Pattern
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Identifier -> [Identifier] -> [Identifier]
forall a. a -> [a] -> [a]
:[]))
            [ Identifier
aboutIdent
            ]
    (Pattern -> PageConfReader Rules ())
-> [Pattern] -> PageConfReader Rules ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (String -> Pattern -> PageConfReader Rules ()
mdRule String
disneyExperienceSummarySnapshot) [Pattern]
items
    FontAwesomeIcons
faIcons <- (PageConf -> FontAwesomeIcons)
-> ReaderT PageConf Rules FontAwesomeIcons
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks PageConf -> FontAwesomeIcons
pcFaIcons
    Bool
isPreview <- (PageConf -> Bool) -> ReaderT PageConf Rules Bool
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks PageConf -> Bool
pcIsPreview
    [Favorite]
favorites <- Rules [Favorite] -> ReaderT PageConf Rules [Favorite]
forall (m :: * -> *) a. Monad m => m a -> ReaderT PageConf m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Rules [Favorite] -> ReaderT PageConf Rules [Favorite])
-> Rules [Favorite] -> ReaderT PageConf Rules [Favorite]
forall a b. (a -> b) -> a -> b
$ IO [Favorite] -> Rules [Favorite]
forall a. IO a -> Rules a
preprocess IO [Favorite]
loadDisneyFavorites
    Map String (String, String)
tagConfig <- Rules (Map String (String, String))
-> ReaderT PageConf Rules (Map String (String, String))
forall (m :: * -> *) a. Monad m => m a -> ReaderT PageConf m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Rules (Map String (String, String))
 -> ReaderT PageConf Rules (Map String (String, String)))
-> Rules (Map String (String, String))
-> ReaderT PageConf Rules (Map String (String, String))
forall a b. (a -> b) -> a -> b
$ IO (Map String (String, String))
-> Rules (Map String (String, String))
forall a. IO a -> Rules a
preprocess IO (Map String (String, String))
tagConfigMap
    Rules () -> PageConfReader Rules ()
forall (m :: * -> *) a. Monad m => m a -> ReaderT PageConf m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Rules () -> PageConfReader Rules ())
-> Rules () -> PageConfReader Rules ()
forall a b. (a -> b) -> a -> b
$ do
        -- フォントファイルのコピー
        Pattern -> Rules () -> Rules ()
match (String -> Pattern
fromGlob (String -> Pattern) -> String -> Pattern
forall a b. (a -> b) -> a -> b
$ [String] -> String
joinPath [String
contentsRoot, String
"fonts", String
"*.otf"]) (Rules () -> Rules ()) -> Rules () -> Rules ()
forall a b. (a -> b) -> a -> b
$ do
            Routes -> Rules ()
route (Routes -> Rules ()) -> Routes -> Rules ()
forall a b. (a -> b) -> a -> b
$ String -> ShowS -> Routes
gsubRoute String
"contents/" (ShowS -> Routes) -> ShowS -> Routes
forall a b. (a -> b) -> a -> b
$ String -> ShowS
forall a b. a -> b -> a
const String
""
            Compiler (Item CopyFile) -> Rules ()
forall a.
(Binary a, Typeable a, Writable a) =>
Compiler (Item a) -> Rules ()
compile Compiler (Item CopyFile)
copyFileCompiler

        Pattern -> Rules () -> Rules ()
match Pattern
disneyExperienceSummaryJPPath (Rules () -> Rules ()) -> Rules () -> Rules ()
forall a b. (a -> b) -> a -> b
$ do
            Routes -> Rules ()
route (Routes -> Rules ()) -> Routes -> Rules ()
forall a b. (a -> b) -> a -> b
$ String -> ShowS -> Routes
gsubRoute (String
contentsRoot String -> ShowS
</> String
"pages/") (String -> ShowS
forall a b. a -> b -> a
const String
forall a. Monoid a => a
mempty)
            Compiler (Item String) -> Rules ()
forall a.
(Binary a, Typeable a, Writable a) =>
Compiler (Item a) -> Rules ()
compile (Compiler (Item String) -> Rules ())
-> Compiler (Item String) -> Rules ()
forall a b. (a -> b) -> a -> b
$ do
                [Item String]
disneyLogs <- [Item String] -> [Item String]
forall a. [Item a] -> [Item a]
sortByNum ([Item String] -> [Item String])
-> Compiler [Item String] -> Compiler [Item String]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Pattern -> String -> Compiler [Item String]
forall a.
(Binary a, Typeable a) =>
Pattern -> String -> Compiler [Item a]
loadAllSnapshots Pattern
disneyLogsPattern String
disneyExperienceSummarySnapshot
                -- ユニークなタグリストを作成
                [String]
uniqueTags <- do
                    [[String]]
allTags <- [Compiler [String]] -> Compiler [[String]]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
forall (m :: * -> *) a. Monad m => [m a] -> m [a]
sequence ([Compiler [String]] -> Compiler [[String]])
-> [Compiler [String]] -> Compiler [[String]]
forall a b. (a -> b) -> a -> b
$ (Item String -> Compiler [String])
-> [Item String] -> [Compiler [String]]
forall a b. (a -> b) -> [a] -> [b]
map (\Item String
logItem -> do
                        Maybe String
mTags <- Identifier -> String -> Compiler (Maybe String)
forall (m :: * -> *).
MonadMetadata m =>
Identifier -> String -> m (Maybe String)
getMetadataField (Item String -> Identifier
forall a. Item a -> Identifier
itemIdentifier Item String
logItem) String
"disney-tags"
                        case Maybe String
mTags of
                            Just String
tagsStr -> [String] -> Compiler [String]
forall a. a -> Compiler a
forall (m :: * -> *) a. Monad m => a -> m a
return ([String] -> Compiler [String]) -> [String] -> Compiler [String]
forall a b. (a -> b) -> a -> b
$ ShowS -> [String] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map ShowS
trimMeta ([String] -> [String]) -> [String] -> [String]
forall a b. (a -> b) -> a -> b
$ (String -> Bool) -> [String] -> [String]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool) -> (String -> Bool) -> String -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null) ([String] -> [String]) -> [String] -> [String]
forall a b. (a -> b) -> a -> b
$ String -> String -> [String]
splitAll String
"," String
tagsStr
                            Maybe String
Nothing      -> [String] -> Compiler [String]
forall a. a -> Compiler a
forall (m :: * -> *) a. Monad m => a -> m a
return []
                        ) [Item String]
disneyLogs
                    [String] -> Compiler [String]
forall a. a -> Compiler a
forall (m :: * -> *) a. Monad m => a -> m a
return ([String] -> Compiler [String]) -> [String] -> Compiler [String]
forall a b. (a -> b) -> a -> b
$ [String] -> [String]
forall a. Eq a => [a] -> [a]
nub ([String] -> [String]) -> [String] -> [String]
forall a b. (a -> b) -> a -> b
$ [[String]] -> [String]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [[String]]
allTags

                Context String
disneyExperienceSummaryCtx <- [Compiler (Context String)] -> Compiler (Context String)
forall (m :: * -> *) b. (Monad m, Monoid b) => [m b] -> m b
mconcatM [
                    Context String -> Compiler (Context String)
forall a. a -> Compiler a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Context String -> Compiler (Context String))
-> Context String -> Compiler (Context String)
forall a b. (a -> b) -> a -> b
$ String -> String -> Context String
forall a. String -> String -> Context a
constField String
"title" String
"Ponchi's Disney Journey"
                  , Context String -> Compiler (Context String)
forall a. a -> Compiler a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Context String -> Compiler (Context String))
-> Context String -> Compiler (Context String)
forall a b. (a -> b) -> a -> b
$ String -> String -> Context String
forall a. String -> String -> Context a
constField String
"font_path" String
"../fonts/waltograph42.otf"
                  , Context String -> Compiler (Context String)
forall a. a -> Compiler a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Context String -> Compiler (Context String))
-> Context String -> Compiler (Context String)
forall a b. (a -> b) -> a -> b
$ String -> String -> Context String
forall a. String -> String -> Context a
constField String
"is_preview" (Bool -> String
forall a. Show a => a -> String
show Bool
isPreview)
                  , Context String -> Compiler (Context String)
forall a. a -> Compiler a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Context String -> Compiler (Context String))
-> Context String -> Compiler (Context String)
forall a b. (a -> b) -> a -> b
$ String
-> Context String -> Compiler [Item String] -> Context String
forall a b. String -> Context a -> Compiler [Item a] -> Context b
listField String
"additional-css" (String -> (Item String -> Compiler String) -> Context String
forall a. String -> (Item a -> Compiler String) -> Context a
field String
"css" (String -> Compiler String
forall a. a -> Compiler a
forall (m :: * -> *) a. Monad m => a -> m a
return (String -> Compiler String)
-> (Item String -> String) -> Item String -> Compiler String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Item String -> String
forall a. Item a -> a
itemBody)) ([Item String] -> Compiler [Item String]
forall a. a -> Compiler a
forall (m :: * -> *) a. Monad m => a -> m a
return ([Item String] -> Compiler [Item String])
-> [Item String] -> Compiler [Item String]
forall a b. (a -> b) -> a -> b
$ (String -> Item String) -> [String] -> [Item String]
forall a b. (a -> b) -> [a] -> [b]
map (\String
css -> Identifier -> String -> Item String
forall a. Identifier -> a -> Item a
Item (String -> Identifier
forall a. IsString a => String -> a
fromString String
css) String
css) [String
"../style/disney_experience_summary_only.css"])
                  , Context String -> Compiler (Context String)
forall a. a -> Compiler a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Context String -> Compiler (Context String))
-> Context String -> Compiler (Context String)
forall a b. (a -> b) -> a -> b
$ String
-> Context String -> Compiler [Item String] -> Context String
forall a b. String -> Context a -> Compiler [Item a] -> Context b
listField String
"additional-js" (String -> (Item String -> Compiler String) -> Context String
forall a. String -> (Item a -> Compiler String) -> Context a
field String
"js" (String -> Compiler String
forall a. a -> Compiler a
forall (m :: * -> *) a. Monad m => a -> m a
return (String -> Compiler String)
-> (Item String -> String) -> Item String -> Compiler String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Item String -> String
forall a. Item a -> a
itemBody)) ([Item String] -> Compiler [Item String]
forall a. a -> Compiler a
forall (m :: * -> *) a. Monad m => a -> m a
return ([Item String] -> Compiler [Item String])
-> [Item String] -> Compiler [Item String]
forall a b. (a -> b) -> a -> b
$ (String -> Item String) -> [String] -> [Item String]
forall a b. (a -> b) -> [a] -> [b]
map (\String
js -> Identifier -> String -> Item String
forall a. Identifier -> a -> Item a
Item (String -> Identifier
forall a. IsString a => String -> a
fromString String
js) String
js) [String
"../js/disney-tag-filter.js"])
                  , Context String -> Compiler (Context String)
forall a. a -> Compiler a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Context String
siteCtx
                  , Context String -> Compiler (Context String)
forall a. a -> Compiler a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Context String
defaultContext
                  , String -> String -> Context String
forall a. String -> String -> Context a
constField String
"about-body"
                        (String -> Context String)
-> Compiler String -> Compiler (Context String)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Identifier -> String -> Compiler String
forall a.
(Binary a, Typeable a) =>
Identifier -> String -> Compiler a
loadSnapshotBody Identifier
aboutIdent String
disneyExperienceSummarySnapshot
                  , Context String -> Compiler (Context String)
forall a. a -> Compiler a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Context String -> Compiler (Context String))
-> Context String -> Compiler (Context String)
forall a b. (a -> b) -> a -> b
$ String
-> Context String -> Compiler [Item String] -> Context String
forall a b. String -> Context a -> Compiler [Item a] -> Context b
listField String
"disney-logs" (Map String (String, String) -> Context String
disneyLogCtx Map String (String, String)
tagConfig) ([Item String] -> Compiler [Item String]
forall a. a -> Compiler a
forall (m :: * -> *) a. Monad m => a -> m a
return [Item String]
disneyLogs)
                  , Context String -> Compiler (Context String)
forall a. a -> Compiler a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Context String -> Compiler (Context String))
-> Context String -> Compiler (Context String)
forall a b. (a -> b) -> a -> b
$ String
-> Context String -> Compiler [Item String] -> Context String
forall a b. String -> Context a -> Compiler [Item a] -> Context b
listField String
"unique-tags" (String -> (Item String -> Compiler String) -> Context String
forall a. String -> (Item a -> Compiler String) -> Context a
field String
"name" (String -> Compiler String
forall a. a -> Compiler a
forall (m :: * -> *) a. Monad m => a -> m a
return (String -> Compiler String)
-> (Item String -> String) -> Item String -> Compiler String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Item String -> String
forall a. Item a -> a
itemBody) Context String -> Context String -> Context String
forall a. Semigroup a => a -> a -> a
<> String -> (Item String -> Compiler String) -> Context String
forall a. String -> (Item a -> Compiler String) -> Context a
field String
"color" (String -> Compiler String
forall a. a -> Compiler a
forall (m :: * -> *) a. Monad m => a -> m a
return (String -> Compiler String)
-> (Item String -> String) -> Item String -> Compiler String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> Map String (String, String) -> String)
-> Map String (String, String) -> ShowS
forall a b c. (a -> b -> c) -> b -> a -> c
flip String -> Map String (String, String) -> String
getTagColor Map String (String, String)
tagConfig ShowS -> (Item String -> String) -> Item String -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Item String -> String
forall a. Item a -> a
itemBody) Context String -> Context String -> Context String
forall a. Semigroup a => a -> a -> a
<> String -> (Item String -> Compiler String) -> Context String
forall a. String -> (Item a -> Compiler String) -> Context a
field String
"link" (String -> Compiler String
forall a. a -> Compiler a
forall (m :: * -> *) a. Monad m => a -> m a
return (String -> Compiler String)
-> (Item String -> String) -> Item String -> Compiler String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> Map String (String, String) -> String)
-> Map String (String, String) -> ShowS
forall a b c. (a -> b -> c) -> b -> a -> c
flip String -> Map String (String, String) -> String
getTagLink Map String (String, String)
tagConfig ShowS -> (Item String -> String) -> Item String -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Item String -> String
forall a. Item a -> a
itemBody)) ([Item String] -> Compiler [Item String]
forall a. a -> Compiler a
forall (m :: * -> *) a. Monad m => a -> m a
return ([Item String] -> Compiler [Item String])
-> [Item String] -> Compiler [Item String]
forall a b. (a -> b) -> a -> b
$ (String -> Item String) -> [String] -> [Item String]
forall a b. (a -> b) -> [a] -> [b]
map (\String
tag -> Identifier -> String -> Item String
forall a. Identifier -> a -> Item a
Item (String -> Identifier
forall a. IsString a => String -> a
fromString String
tag) String
tag) [String]
uniqueTags)
                  , Context String -> Compiler (Context String)
forall a. a -> Compiler a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Context String -> Compiler (Context String))
-> Context String -> Compiler (Context String)
forall a b. (a -> b) -> a -> b
$ String
-> Context Favorite -> Compiler [Item Favorite] -> Context String
forall a b. String -> Context a -> Compiler [Item a] -> Context b
listField String
"favorite-works" (String -> (Item Favorite -> Compiler String) -> Context Favorite
forall a. String -> (Item a -> Compiler String) -> Context a
field String
"text" (String -> Compiler String
forall a. a -> Compiler a
forall (m :: * -> *) a. Monad m => a -> m a
return (String -> Compiler String)
-> (Item Favorite -> String) -> Item Favorite -> Compiler String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Favorite -> String
text (Favorite -> String)
-> (Item Favorite -> Favorite) -> Item Favorite -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Item Favorite -> Favorite
forall a. Item a -> a
itemBody) Context Favorite -> Context Favorite -> Context Favorite
forall a. Semigroup a => a -> a -> a
<> String -> (Item Favorite -> Compiler String) -> Context Favorite
forall a. String -> (Item a -> Compiler String) -> Context a
field String
"link" (String -> Compiler String
forall a. a -> Compiler a
forall (m :: * -> *) a. Monad m => a -> m a
return (String -> Compiler String)
-> (Item Favorite -> String) -> Item Favorite -> Compiler String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS -> Maybe String -> String
forall b a. b -> (a -> b) -> Maybe a -> b
maybe String
"" ShowS
forall a. a -> a
id (Maybe String -> String)
-> (Item Favorite -> Maybe String) -> Item Favorite -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Favorite -> Maybe String
link (Favorite -> Maybe String)
-> (Item Favorite -> Favorite) -> Item Favorite -> Maybe String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Item Favorite -> Favorite
forall a. Item a -> a
itemBody)) ([Item Favorite] -> Compiler [Item Favorite]
forall a. a -> Compiler a
forall (m :: * -> *) a. Monad m => a -> m a
return ([Item Favorite] -> Compiler [Item Favorite])
-> [Item Favorite] -> Compiler [Item Favorite]
forall a b. (a -> b) -> a -> b
$ (Favorite -> Item Favorite) -> [Favorite] -> [Item Favorite]
forall a b. (a -> b) -> [a] -> [b]
map (\Favorite
f -> Identifier -> Favorite -> Item Favorite
forall a. Identifier -> a -> Item a
Item (String -> Identifier
forall a. IsString a => String -> a
fromString (String -> Identifier) -> String -> Identifier
forall a b. (a -> b) -> a -> b
$ Favorite -> String
text Favorite
f) Favorite
f) ([Favorite] -> [Item Favorite]) -> [Favorite] -> [Item Favorite]
forall a b. (a -> b) -> a -> b
$ (Favorite -> Bool) -> [Favorite] -> [Favorite]
forall a. (a -> Bool) -> [a] -> [a]
filter ((String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== String
"works") (String -> Bool) -> (Favorite -> String) -> Favorite -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Favorite -> String
category) [Favorite]
favorites)
                  , Context String -> Compiler (Context String)
forall a. a -> Compiler a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Context String -> Compiler (Context String))
-> Context String -> Compiler (Context String)
forall a b. (a -> b) -> a -> b
$ String
-> Context Favorite -> Compiler [Item Favorite] -> Context String
forall a b. String -> Context a -> Compiler [Item a] -> Context b
listField String
"favorite-characters" (String -> (Item Favorite -> Compiler String) -> Context Favorite
forall a. String -> (Item a -> Compiler String) -> Context a
field String
"text" (String -> Compiler String
forall a. a -> Compiler a
forall (m :: * -> *) a. Monad m => a -> m a
return (String -> Compiler String)
-> (Item Favorite -> String) -> Item Favorite -> Compiler String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Favorite -> String
text (Favorite -> String)
-> (Item Favorite -> Favorite) -> Item Favorite -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Item Favorite -> Favorite
forall a. Item a -> a
itemBody) Context Favorite -> Context Favorite -> Context Favorite
forall a. Semigroup a => a -> a -> a
<> String -> (Item Favorite -> Compiler String) -> Context Favorite
forall a. String -> (Item a -> Compiler String) -> Context a
field String
"link" (String -> Compiler String
forall a. a -> Compiler a
forall (m :: * -> *) a. Monad m => a -> m a
return (String -> Compiler String)
-> (Item Favorite -> String) -> Item Favorite -> Compiler String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS -> Maybe String -> String
forall b a. b -> (a -> b) -> Maybe a -> b
maybe String
"" ShowS
forall a. a -> a
id (Maybe String -> String)
-> (Item Favorite -> Maybe String) -> Item Favorite -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Favorite -> Maybe String
link (Favorite -> Maybe String)
-> (Item Favorite -> Favorite) -> Item Favorite -> Maybe String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Item Favorite -> Favorite
forall a. Item a -> a
itemBody)) ([Item Favorite] -> Compiler [Item Favorite]
forall a. a -> Compiler a
forall (m :: * -> *) a. Monad m => a -> m a
return ([Item Favorite] -> Compiler [Item Favorite])
-> [Item Favorite] -> Compiler [Item Favorite]
forall a b. (a -> b) -> a -> b
$ (Favorite -> Item Favorite) -> [Favorite] -> [Item Favorite]
forall a b. (a -> b) -> [a] -> [b]
map (\Favorite
f -> Identifier -> Favorite -> Item Favorite
forall a. Identifier -> a -> Item a
Item (String -> Identifier
forall a. IsString a => String -> a
fromString (String -> Identifier) -> String -> Identifier
forall a b. (a -> b) -> a -> b
$ Favorite -> String
text Favorite
f) Favorite
f) ([Favorite] -> [Item Favorite]) -> [Favorite] -> [Item Favorite]
forall a b. (a -> b) -> a -> b
$ (Favorite -> Bool) -> [Favorite] -> [Favorite]
forall a. (a -> Bool) -> [a] -> [a]
filter ((String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== String
"characters") (String -> Bool) -> (Favorite -> String) -> Favorite -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Favorite -> String
category) [Favorite]
favorites)
                  , Context String -> Compiler (Context String)
forall a. a -> Compiler a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Context String -> Compiler (Context String))
-> Context String -> Compiler (Context String)
forall a b. (a -> b) -> a -> b
$ String
-> Context Favorite -> Compiler [Item Favorite] -> Context String
forall a b. String -> Context a -> Compiler [Item a] -> Context b
listField String
"favorite-park-contents" (String -> (Item Favorite -> Compiler String) -> Context Favorite
forall a. String -> (Item a -> Compiler String) -> Context a
field String
"text" (String -> Compiler String
forall a. a -> Compiler a
forall (m :: * -> *) a. Monad m => a -> m a
return (String -> Compiler String)
-> (Item Favorite -> String) -> Item Favorite -> Compiler String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Favorite -> String
text (Favorite -> String)
-> (Item Favorite -> Favorite) -> Item Favorite -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Item Favorite -> Favorite
forall a. Item a -> a
itemBody) Context Favorite -> Context Favorite -> Context Favorite
forall a. Semigroup a => a -> a -> a
<> String -> (Item Favorite -> Compiler String) -> Context Favorite
forall a. String -> (Item a -> Compiler String) -> Context a
field String
"link" (String -> Compiler String
forall a. a -> Compiler a
forall (m :: * -> *) a. Monad m => a -> m a
return (String -> Compiler String)
-> (Item Favorite -> String) -> Item Favorite -> Compiler String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS -> Maybe String -> String
forall b a. b -> (a -> b) -> Maybe a -> b
maybe String
"" ShowS
forall a. a -> a
id (Maybe String -> String)
-> (Item Favorite -> Maybe String) -> Item Favorite -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Favorite -> Maybe String
link (Favorite -> Maybe String)
-> (Item Favorite -> Favorite) -> Item Favorite -> Maybe String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Item Favorite -> Favorite
forall a. Item a -> a
itemBody)) ([Item Favorite] -> Compiler [Item Favorite]
forall a. a -> Compiler a
forall (m :: * -> *) a. Monad m => a -> m a
return ([Item Favorite] -> Compiler [Item Favorite])
-> [Item Favorite] -> Compiler [Item Favorite]
forall a b. (a -> b) -> a -> b
$ (Favorite -> Item Favorite) -> [Favorite] -> [Item Favorite]
forall a b. (a -> b) -> [a] -> [b]
map (\Favorite
f -> Identifier -> Favorite -> Item Favorite
forall a. Identifier -> a -> Item a
Item (String -> Identifier
forall a. IsString a => String -> a
fromString (String -> Identifier) -> String -> Identifier
forall a b. (a -> b) -> a -> b
$ Favorite -> String
text Favorite
f) Favorite
f) ([Favorite] -> [Item Favorite]) -> [Favorite] -> [Item Favorite]
forall a b. (a -> b) -> a -> b
$ (Favorite -> Bool) -> [Favorite] -> [Favorite]
forall a. (a -> Bool) -> [a] -> [a]
filter ((String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== String
"park-contents") (String -> Bool) -> (Favorite -> String) -> Favorite -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Favorite -> String
category) [Favorite]
favorites)
                      ]
                Compiler (Item String)
getResourceBody
                    Compiler (Item String) -> KaTeXRender -> Compiler (Item String)
forall a b. Compiler a -> (a -> Compiler b) -> Compiler b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Context String -> KaTeXRender
applyAsTemplate Context String
disneyExperienceSummaryCtx
                    Compiler (Item String) -> KaTeXRender -> Compiler (Item String)
forall a b. Compiler a -> (a -> Compiler b) -> Compiler b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Identifier -> Context String -> KaTeXRender
forall a.
Identifier -> Context a -> Item a -> Compiler (Item String)
loadAndApplyTemplate Identifier
rootTemplate Context String
disneyExperienceSummaryCtx
                    Compiler (Item String) -> KaTeXRender -> Compiler (Item String)
forall a b. Compiler a -> (a -> Compiler b) -> Compiler b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= KaTeXRender
modifyExternalLinkAttr
                    Compiler (Item String) -> KaTeXRender -> Compiler (Item String)
forall a b. Compiler a -> (a -> Compiler b) -> Compiler b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= KaTeXRender
relativizeUrls
                    Compiler (Item String) -> KaTeXRender -> Compiler (Item String)
forall a b. Compiler a -> (a -> Compiler b) -> Compiler b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= FontAwesomeIcons -> KaTeXRender
FA.render FontAwesomeIcons
faIcons

        [(Identifier, String)] -> Rules ()
createRedirects [
            (String -> Identifier
fromFilePath (String -> Identifier) -> String -> Identifier
forall a b. (a -> b) -> a -> b
$ [String] -> String
joinPath [String
"disney_experience_summary", String
"index.html"], [String] -> String
joinPath [String
"/", String
"disney_experience_summary", String
"jp.html"])
          ]
    where
        disneyExperienceSummarySnapshot :: String
disneyExperienceSummarySnapshot = String
"disneyExperienceSummarySS"
        disneyExperienceSummaryJPPath :: Pattern
disneyExperienceSummaryJPPath = String -> Pattern
fromGlob (String -> Pattern) -> String -> Pattern
forall a b. (a -> b) -> a -> b
$ [String] -> String
joinPath [String
contentsRoot, String
"pages", String
"disney_experience_summary", String
"jp.html"]
        rootTemplate :: Identifier
rootTemplate = String -> Identifier
fromFilePath (String -> Identifier) -> String -> Identifier
forall a b. (a -> b) -> a -> b
$ [String] -> String
joinPath [String
contentsRoot, String
"templates", String
"site", String
"default.html"]