@@ -7,13 +7,12 @@ import Control.Monad (filterM)
7
7
import Data.List (sortOn )
8
8
import Data.Ord (comparing )
9
9
10
- main :: IO ()
11
- main = hakyll $ do
12
-
13
10
--------------------------------------------------------------------------------------------------------
14
- -- STATICS -------- -------------------------------------------------------------------------------------
11
+ -- MAIN GENERATION -------------------------------------------------------------------------------------
15
12
--------------------------------------------------------------------------------------------------------
16
-
13
+ main :: IO ()
14
+ main = hakyll $ do
15
+ -- statics ---------------------------------------------------------------------------------------------
17
16
match " assets/css/main.css" $ do
18
17
route idRoute
19
18
compile compressCssCompiler
@@ -22,74 +21,54 @@ main = hakyll $ do
22
21
route idRoute
23
22
compile copyFileCompiler
24
23
25
- --------------------------------------------------------------------------------------------------------
26
- -- HOME ------------------------------------------------------------------------------------------------
27
- --------------------------------------------------------------------------------------------------------
28
-
24
+ -- home ------------------------------------------------------------------------------------------------
29
25
match " index.html" $ do
30
26
route idRoute
31
27
compile $ do
32
- sponsors <- sponsorsCtx defaultContext . sortOn itemIdentifier <$> loadAll " donations/sponsors/*.markdown"
28
+ sponsors <- sponsorsCtx . sortOn itemIdentifier <$> loadAll " donations/sponsors/*.markdown"
33
29
getResourceBody
34
30
>>= applyAsTemplate sponsors
35
31
>>= loadAndApplyTemplate " templates/boilerplate.html" sponsors
36
32
>>= relativizeUrls
37
33
34
+ -- sponsors --------------------------------------------------------------------------------------------
38
35
match " donations/sponsors/*.markdown" $ compile pandocCompiler
39
- match " **/index.html" $ do
40
- route idRoute
41
- compile $ do
42
- sponsors <- sponsorsCtx defaultContext . sortOn itemIdentifier <$> loadAll " donations/sponsors/*.markdown"
43
- getResourceBody
44
- >>= applyAsTemplate sponsors
45
- >>= loadAndApplyTemplate " templates/boilerplate.html" sponsors
46
- >>= relativizeUrls
47
-
48
- --------------------------------------------------------------------------------------------------------
49
- -- AFFILIATES ------------------------------------------------------------------------------------------
50
- --------------------------------------------------------------------------------------------------------
51
36
37
+ -- affiliates ------------------------------------------------------------------------------------------
52
38
match " affiliates/*.markdown" $ compile pandocCompiler
53
- match " affiliates/index.html" $ do
39
+ create [ " affiliates/index.html" ] $ do
54
40
route idRoute
55
41
compile $ do
56
- affils <- affiliatesCtx . sortOn itemIdentifier <$> loadAll " affiliates /*.markdown"
57
- sponsors <- sponsorsCtx affils . sortOn itemIdentifier <$> loadAll " donations/sponsors /*.markdown"
42
+ sponsors <- sponsorsCtx . sortOn itemIdentifier <$> loadAll " donations/sponsors /*.markdown"
43
+ ctx <- affiliatesCtx . sortOn itemIdentifier <$> loadAll " affiliates /*.markdown"
58
44
59
- getResourceBody
60
- >>= applyAsTemplate sponsors
61
- >>= loadAndApplyTemplate " templates/boilerplate.html" sponsors
45
+ makeItem " "
46
+ >>= loadAndApplyTemplate " templates/affiliates/list.html " ctx
47
+ >>= loadAndApplyTemplate " templates/boilerplate.html" sponsors
62
48
>>= relativizeUrls
63
49
64
- --------------------------------------------------------------------------------------------------------
65
- -- PROJECTS --------------------------------------------------------------------------------------------
66
- --------------------------------------------------------------------------------------------------------
67
-
50
+ -- projects --------------------------------------------------------------------------------------------
68
51
match " projects/*.markdown" $ compile pandocCompiler
69
-
70
52
create [" projects/index.html" ] $ do
71
53
route idRoute
72
54
compile $ do
55
+ sponsors <- sponsorsCtx . sortOn itemIdentifier <$> loadAll " donations/sponsors/*.markdown"
73
56
ctx <- projectsCtx . sortOn itemIdentifier <$> loadAll " projects/*.markdown"
74
- sponsors <- sponsorsCtx ctx . sortOn itemIdentifier <$> loadAll " donations/sponsors/*.markdown"
75
57
76
58
makeItem " "
77
- >>= loadAndApplyTemplate " templates/projects/list.html" sponsors
59
+ >>= loadAndApplyTemplate " templates/projects/list.html" ctx
78
60
>>= loadAndApplyTemplate " templates/boilerplate.html" sponsors
79
61
>>= relativizeUrls
80
62
63
+ -- news ------------------------------------------------------------------------------------------------
81
64
match " news/**.markdown" $ compile pandocCompiler
82
65
categories <- buildCategories " news/**.markdown" (fromCapture " news/categories/**.html" )
83
66
84
- --------------------------------------------------------------------------------------------------------
85
- -- NEWS ------------------------------------------------------------------------------------------------
86
- --------------------------------------------------------------------------------------------------------
87
-
88
67
tagsRules categories $ \ category catId -> compile $ do
89
68
news <- recentFirst =<< loadAll catId
90
69
let ctx =
91
70
listField " news" (newsWithCategoriesCtx categories) (pure news) <>
92
- constField " category" category <>
71
+ constField " category" category <>
93
72
defaultContext
94
73
95
74
makeItem " "
@@ -99,8 +78,9 @@ main = hakyll $ do
99
78
create [" news/index.html" ] $ do
100
79
route idRoute
101
80
compile $ do
102
- sponsors <- sponsorsCtx defaultContext . sortOn itemIdentifier <$> loadAll " donations/sponsors/*.markdown"
81
+ sponsors <- sponsorsCtx . sortOn itemIdentifier <$> loadAll " donations/sponsors/*.markdown"
103
82
newsWithCategories <- recentFirst =<< loadAll " news/categories/**.html"
83
+
104
84
let ctx =
105
85
listField " categories" defaultContext (return newsWithCategories) <>
106
86
defaultContext
@@ -110,27 +90,37 @@ main = hakyll $ do
110
90
>>= loadAndApplyTemplate " templates/boilerplate.html" sponsors
111
91
>>= relativizeUrls
112
92
113
- --------------------------------------------------------------------------------------------------------
114
- -- TEMPLATES -------------------------------------------------------------------------------------------
115
- --------------------------------------------------------------------------------------------------------
116
-
93
+ -- templates -------------------------------------------------------------------------------------------
117
94
match " templates/*" $ compile templateBodyCompiler
118
95
match " templates/**" $ compile templateBodyCompiler
119
96
120
- --------------------------------------------------------------------------------------------------------
121
- --------------------------------------------------------------------------------------------------------
122
97
123
98
--------------------------------------------------------------------------------------------------------
124
99
-- CONTEXT ---------------------------------------------------------------------------------------------
125
100
--------------------------------------------------------------------------------------------------------
126
101
102
+ -- sponsors --------------------------------------------------------------------------------------------
103
+ -- | Partition sponsors into by level: monad, applicative, and functor
104
+ -- Sponsors are listed in the footer template, which means we need this
105
+ -- context for most pages. The first argument is another context so
106
+ -- we can compose them together, and the usage site can pass in the
107
+ -- context it is in.
108
+ sponsorsCtx :: [Item String ] -> Context String
109
+ sponsorsCtx sponsors =
110
+ listField " monads" defaultContext (ofMetadataField " level" " Monad" sponsors) <>
111
+ listField " applicatives" defaultContext (ofMetadataField " level" " Applicative" sponsors) <>
112
+ listField " functors" defaultContext (ofMetadataField " level" " Functor" sponsors) <>
113
+ defaultContext
114
+
115
+ -- affiliates ------------------------------------------------------------------------------------------
127
116
-- | Partition affiliates into affiliates and pending
128
117
affiliatesCtx :: [Item String ] -> Context String
129
- affiliatesCtx tuts =
130
- listField " affiliated" defaultContext (ofMetadataField " status" " affiliated" tuts ) <>
131
- listField " pending" defaultContext (ofMetadataField " status" " pending" tuts ) <>
118
+ affiliatesCtx affiliates =
119
+ listField " affiliated" defaultContext (ofMetadataField " status" " affiliated" affiliates ) <>
120
+ listField " pending" defaultContext (ofMetadataField " status" " pending" affiliates ) <>
132
121
defaultContext
133
122
123
+ -- projects --------------------------------------------------------------------------------------------
134
124
-- | Partition projects into : Ideation | Proposed | In Progress | Completed
135
125
projectsCtx :: [Item String ] -> Context String
136
126
projectsCtx projects =
@@ -140,18 +130,7 @@ projectsCtx projects =
140
130
listField " completed" defaultContext (ofMetadataField " status" " completed" projects) <>
141
131
defaultContext
142
132
143
- -- | Partition sponsors into by level: monad, applicative, and functor
144
- -- Sponsors are listed in the footer template, which means we need this
145
- -- context for most pages. The first argument is another context so
146
- -- we can compose them together, and the usage site can pass in the
147
- -- context it is in.
148
- sponsorsCtx :: Context String -> [Item String ] -> Context String
149
- sponsorsCtx ctx sponsors =
150
- listField " monads" defaultContext (ofMetadataField " level" " Monad" sponsors) <>
151
- listField " applicatives" defaultContext (ofMetadataField " level" " Applicative" sponsors) <>
152
- listField " functors" defaultContext (ofMetadataField " level" " Functor" sponsors) <>
153
- ctx
154
-
133
+ -- news ------------------------------------------------------------------------------------------------
155
134
buildNewsCtx :: Tags -> Context String
156
135
buildNewsCtx categories =
157
136
tagsField " categories" categories <>
@@ -182,6 +161,7 @@ newsWithCategoriesCtx categories =
182
161
newsCtx :: Context String
183
162
newsCtx = newsWithCategoriesCtx categories
184
163
164
+
185
165
--------------------------------------------------------------------------------------------------------
186
166
-- UTILS -----------------------------------------------------------------------------------------------
187
167
--------------------------------------------------------------------------------------------------------
0 commit comments