|
1 | 1 | {-# Language ScopedTypeVariables #-}
|
2 | 2 | {-# Language OverloadedStrings #-}
|
3 | 3 | {-# Language ViewPatterns #-}
|
| 4 | +{-# Language BangPatterns #-} |
4 | 5 |
|
5 | 6 | import Hakyll
|
6 | 7 | import Data.List (sortOn)
|
7 | 8 | import Control.Monad (filterM)
|
8 | 9 | import Control.Monad.ListM (sortByM)
|
9 | 10 | import Hakyll.Web.Template (loadAndApplyTemplate)
|
| 11 | +import System.IO (SeekMode(RelativeSeek)) |
| 12 | +import Hakyll.Web.Html.RelativizeUrls (relativizeUrls) |
| 13 | +import Hakyll.Web.Template.Context (defaultContext) |
| 14 | +import Data.Maybe (isJust) |
10 | 15 |
|
11 | 16 | --------------------------------------------------------------------------------------------------------
|
12 | 17 | -- MAIN GENERATION -------------------------------------------------------------------------------------
|
@@ -111,6 +116,30 @@ main = hakyll $ do
|
111 | 116 | >>= loadAndApplyTemplate "templates/boilerplate.html" sponsors
|
112 | 117 | >>= relativizeUrls
|
113 | 118 |
|
| 119 | +-- who we are ------------------------------------------------------------------------------------------ |
| 120 | + match "who-we-are/people/*.markdown" $ compile pandocCompiler |
| 121 | + create ["who-we-are/index.html"] $ do |
| 122 | + route idRoute |
| 123 | + compile $ do |
| 124 | + sponsors <- buildSponsorsCtx |
| 125 | + ctx <- whoWeAreCtx <$> loadAll "who-we-are/people/*.markdown" |
| 126 | + |
| 127 | + makeItem "" |
| 128 | + >>= loadAndApplyTemplate "templates/who-we-are/exec-and-board.html" ctx |
| 129 | + >>= loadAndApplyTemplate "templates/boilerplate.html" sponsors |
| 130 | + >>= relativizeUrls |
| 131 | + |
| 132 | + create ["who-we-are/past-boards/index.html"] $ do |
| 133 | + route idRoute |
| 134 | + compile $ do |
| 135 | + sponsors <- buildSponsorsCtx |
| 136 | + ctx <- whoWeAreCtx <$> loadAll "who-we-are/people/*.markdown" |
| 137 | + |
| 138 | + makeItem "" |
| 139 | + >>= loadAndApplyTemplate "templates/who-we-are/past-board.html" ctx |
| 140 | + >>= loadAndApplyTemplate "templates/boilerplate.html" sponsors |
| 141 | + >>= relativizeUrls |
| 142 | + |
114 | 143 | -- general 'static' pages ------------------------------------------------------------------------------
|
115 | 144 | match ("index.html" .||. "**/index.html") $ do
|
116 | 145 | route idRoute
|
@@ -212,6 +241,27 @@ faqCtx entries =
|
212 | 241 | listField "faq_entries" defaultContext (sortFromMetadataField "order" entries) <>
|
213 | 242 | defaultContext
|
214 | 243 |
|
| 244 | +-- who we are ------------------------------------------------------------------------------------------ |
| 245 | +whoWeAreCtx :: [Item String] -> Context String |
| 246 | +whoWeAreCtx people = |
| 247 | + listField "currentexecutiveteam" defaultContext (ofMetadataFieldCurrent True "executiveTeam" "True" people) <> |
| 248 | + listField "currentboard" defaultContext (ofMetadataFieldCurrent True "executiveTeam" "False" people) <> |
| 249 | + listField "pastexecutiveteam" defaultContext (ofMetadataFieldCurrent False "executiveTeam" "True" people) <> |
| 250 | + listField "pastboard" defaultContext (ofMetadataFieldCurrent False "executiveTeam" "False" people) <> |
| 251 | + listField "interimboard" defaultContext (ofMetadataField "interimBoard" "True" people) <> |
| 252 | + defaultContext |
| 253 | + where |
| 254 | + ofMetadataFieldCurrent :: Bool -> String -> String -> [Item String] -> Compiler [Item String] |
| 255 | + ofMetadataFieldCurrent cur field value items = do |
| 256 | + items' <- ofMetadataField field value items |
| 257 | + filterM (\item -> do |
| 258 | + mbTenureStart <- getMetadataField (itemIdentifier item) "tenureStart" |
| 259 | + mbTenureStop <- getMetadataField (itemIdentifier item) "tenureEnd" |
| 260 | + pure $ case mbTenureStop of |
| 261 | + Nothing -> cur && isJust mbTenureStart |
| 262 | + Just date -> not cur |
| 263 | + ) items' |
| 264 | + |
215 | 265 | --------------------------------------------------------------------------------------------------------
|
216 | 266 | -- UTILS -----------------------------------------------------------------------------------------------
|
217 | 267 | --------------------------------------------------------------------------------------------------------
|
|
0 commit comments