Skip to content

Commit 8635296

Browse files
committed
fix: hamonize and simplify generation and context management
1 parent cc97ff9 commit 8635296

File tree

4 files changed

+110
-133
lines changed

4 files changed

+110
-133
lines changed

affiliates/index.html

Lines changed: 0 additions & 71 deletions
This file was deleted.

site.hs

Lines changed: 42 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ import Control.Monad (filterM)
77
import Data.List (sortOn)
88
import Data.Ord (comparing)
99

10-
main :: IO ()
11-
main = hakyll $ do
12-
1310
--------------------------------------------------------------------------------------------------------
14-
-- STATICS ---------------------------------------------------------------------------------------------
11+
-- MAIN GENERATION -------------------------------------------------------------------------------------
1512
--------------------------------------------------------------------------------------------------------
16-
13+
main :: IO ()
14+
main = hakyll $ do
15+
-- statics ---------------------------------------------------------------------------------------------
1716
match "assets/css/main.css" $ do
1817
route idRoute
1918
compile compressCssCompiler
@@ -22,74 +21,54 @@ main = hakyll $ do
2221
route idRoute
2322
compile copyFileCompiler
2423

25-
--------------------------------------------------------------------------------------------------------
26-
-- HOME ------------------------------------------------------------------------------------------------
27-
--------------------------------------------------------------------------------------------------------
28-
24+
-- home ------------------------------------------------------------------------------------------------
2925
match "index.html" $ do
3026
route idRoute
3127
compile $ do
32-
sponsors <- sponsorsCtx defaultContext . sortOn itemIdentifier <$> loadAll "donations/sponsors/*.markdown"
28+
sponsors <- sponsorsCtx . sortOn itemIdentifier <$> loadAll "donations/sponsors/*.markdown"
3329
getResourceBody
3430
>>= applyAsTemplate sponsors
3531
>>= loadAndApplyTemplate "templates/boilerplate.html" sponsors
3632
>>= relativizeUrls
3733

34+
-- sponsors --------------------------------------------------------------------------------------------
3835
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-
--------------------------------------------------------------------------------------------------------
5136

37+
-- affiliates ------------------------------------------------------------------------------------------
5238
match "affiliates/*.markdown" $ compile pandocCompiler
53-
match "affiliates/index.html" $ do
39+
create ["affiliates/index.html"] $ do
5440
route idRoute
5541
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"
5844

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
6248
>>= relativizeUrls
6349

64-
--------------------------------------------------------------------------------------------------------
65-
-- PROJECTS --------------------------------------------------------------------------------------------
66-
--------------------------------------------------------------------------------------------------------
67-
50+
-- projects --------------------------------------------------------------------------------------------
6851
match "projects/*.markdown" $ compile pandocCompiler
69-
7052
create ["projects/index.html"] $ do
7153
route idRoute
7254
compile $ do
55+
sponsors <- sponsorsCtx . sortOn itemIdentifier <$> loadAll "donations/sponsors/*.markdown"
7356
ctx <- projectsCtx . sortOn itemIdentifier <$> loadAll "projects/*.markdown"
74-
sponsors <- sponsorsCtx ctx . sortOn itemIdentifier <$> loadAll "donations/sponsors/*.markdown"
7557

7658
makeItem ""
77-
>>= loadAndApplyTemplate "templates/projects/list.html" sponsors
59+
>>= loadAndApplyTemplate "templates/projects/list.html" ctx
7860
>>= loadAndApplyTemplate "templates/boilerplate.html" sponsors
7961
>>= relativizeUrls
8062

63+
-- news ------------------------------------------------------------------------------------------------
8164
match "news/**.markdown" $ compile pandocCompiler
8265
categories <- buildCategories "news/**.markdown" (fromCapture "news/categories/**.html")
8366

84-
--------------------------------------------------------------------------------------------------------
85-
-- NEWS ------------------------------------------------------------------------------------------------
86-
--------------------------------------------------------------------------------------------------------
87-
8867
tagsRules categories $ \category catId -> compile $ do
8968
news <- recentFirst =<< loadAll catId
9069
let ctx =
9170
listField "news" (newsWithCategoriesCtx categories) (pure news) <>
92-
constField "category" category <>
71+
constField "category" category <>
9372
defaultContext
9473

9574
makeItem ""
@@ -99,8 +78,9 @@ main = hakyll $ do
9978
create ["news/index.html"] $ do
10079
route idRoute
10180
compile $ do
102-
sponsors <- sponsorsCtx defaultContext . sortOn itemIdentifier <$> loadAll "donations/sponsors/*.markdown"
81+
sponsors <- sponsorsCtx . sortOn itemIdentifier <$> loadAll "donations/sponsors/*.markdown"
10382
newsWithCategories <- recentFirst =<< loadAll "news/categories/**.html"
83+
10484
let ctx =
10585
listField "categories" defaultContext (return newsWithCategories) <>
10686
defaultContext
@@ -110,27 +90,37 @@ main = hakyll $ do
11090
>>= loadAndApplyTemplate "templates/boilerplate.html" sponsors
11191
>>= relativizeUrls
11292

113-
--------------------------------------------------------------------------------------------------------
114-
-- TEMPLATES -------------------------------------------------------------------------------------------
115-
--------------------------------------------------------------------------------------------------------
116-
93+
-- templates -------------------------------------------------------------------------------------------
11794
match "templates/*" $ compile templateBodyCompiler
11895
match "templates/**" $ compile templateBodyCompiler
11996

120-
--------------------------------------------------------------------------------------------------------
121-
--------------------------------------------------------------------------------------------------------
12297

12398
--------------------------------------------------------------------------------------------------------
12499
-- CONTEXT ---------------------------------------------------------------------------------------------
125100
--------------------------------------------------------------------------------------------------------
126101

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 ------------------------------------------------------------------------------------------
127116
-- | Partition affiliates into affiliates and pending
128117
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) <>
132121
defaultContext
133122

123+
-- projects --------------------------------------------------------------------------------------------
134124
-- | Partition projects into : Ideation | Proposed | In Progress | Completed
135125
projectsCtx :: [Item String] -> Context String
136126
projectsCtx projects =
@@ -140,18 +130,7 @@ projectsCtx projects =
140130
listField "completed" defaultContext (ofMetadataField "status" "completed" projects) <>
141131
defaultContext
142132

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 ------------------------------------------------------------------------------------------------
155134
buildNewsCtx :: Tags -> Context String
156135
buildNewsCtx categories =
157136
tagsField "categories" categories <>
@@ -182,6 +161,7 @@ newsWithCategoriesCtx categories =
182161
newsCtx :: Context String
183162
newsCtx = newsWithCategoriesCtx categories
184163

164+
185165
--------------------------------------------------------------------------------------------------------
186166
-- UTILS -----------------------------------------------------------------------------------------------
187167
--------------------------------------------------------------------------------------------------------

templates/affiliates/list.html

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
title: Affiliates
3+
---
4+
<div class="xl:max-w-screen-xl mx-auto md:px-12 lg:px-16">
5+
<div class="bg-gray-800 shadow-lg shadow-xl shadow-md shadow-sm px-6 sm:px-12 md:px-12 lg:px-16 py-16 md:py-20">
6+
<div class="grid gap-8 lg:grid-cols-2 lg:gap-16 lg:text-xl text-gray-300 leading-relaxed">
7+
<div>
8+
We invite existing Haskell projects, committees and communities to explicitly affiliate and align themselves
9+
with the Haskell Foundation. Affiliation means that the group supports the goals of the Haskell Foundation, and
10+
that the Haskell Foundation in turn supports this group.
11+
</div>
12+
<div>
13+
We require affiliated groups to adhere to guidelines around transparency, being open to new members, and follow
14+
the <a href="/guidelines-for-respectful-communication" target="_blank">Haskell committee guidelines for
15+
respectful communication</a>. We believe that this will help us grow towards being a more open and welcoming
16+
community.
17+
</div>
18+
</div>
19+
</div>
20+
</div>
21+
<div class="max-w-screen-xl mx-auto">
22+
<div class="mt-16 md:mt-24 px-4 sm:px-12 md:px-12 lg:px-16">
23+
<div class="flex items-center space-x-4">
24+
<div>
25+
<img class="h-10 md:h-16 lg:h-20" src="/assets/images/affiliated.svg" alt="">
26+
</div>
27+
<h2 class="text-2xl font-normal">Affiliated</h2>
28+
</div>
29+
<div
30+
class="border-l-3 border-gray-300 ml-5 md:ml-8 lg:ml-10 pl-4 md:pl-8 lg:pl-14 pr-4 my-6 md:my-8 lg:my-10 grid lg:grid-cols-2 py-4 md:py-8 gap-4 md:gap-8">
31+
$for(affiliated)$
32+
$partial("templates/affiliates/tile.html")$
33+
$endfor$
34+
</div>
35+
<div class="flex items-center space-x-4">
36+
<div>
37+
<img class="h-10 md:h-16 lg:h-20" src="/assets/images/pending.svg" alt="">
38+
</div>
39+
<h2 class="text-2xl font-normal">Pending Affiliations</h2>
40+
</div>
41+
<div
42+
class="border-l-3 border-gray-300 ml-5 md:ml-8 lg:ml-10 pl-4 md:pl-8 lg:pl-14 pr-4 my-6 md:my-8 lg:my-10 grid lg:grid-cols-2 py-4 md:py-8 gap-4 md:gap-8">
43+
$for(pending)$
44+
$partial("templates/affiliates/tile.html")$
45+
$endfor$
46+
</div>
47+
<div class="flex items-center space-x-4">
48+
<div>
49+
<img class="h-10 md:h-16 lg:h-20" src="/assets/images/join.svg" alt="">
50+
</div>
51+
<h2 class="text-2xl font-normal">Join Affiliations!</h2>
52+
</div>
53+
<div class="ml-14 md:ml-20 lg:ml-24 mt-4 max-w-xl">
54+
<p>
55+
This is not a closed list! We very much want the Haskell Foundation to be something by all of us. Please contact
56+
us if you are interested in joining us in our quest to make Haskell better for everyone.
57+
</p>
58+
<div class="mt-4">
59+
<a class="arrow-link" href="/contact/">>> Contact Us</a>
60+
</div>
61+
</div>
62+
</div>
63+
</div>

templates/affiliates/tile.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<a class="block border-l-3 border-purple-700 hover:bg-gray-50 shadow-lg px-4 py-2 md:py-4" href="$externalUrl$"
2+
target="_blank">
3+
<div class="font-medium">$title$</div>
4+
<div class="text-gray-600 break-all">$externalUrl$</div>
5+
</a>

0 commit comments

Comments
 (0)