1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
|
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
module Main where
import Data.ByteString.Lazy (ByteString)
import Data.Text.Lazy (Text)
import Data.Text.Lazy.Encoding (encodeUtf8)
import Text.Blaze (Markup)
import Text.Blaze.Html (Html)
import Text.Blaze.Html.Renderer.Text (renderHtml)
import Text.Hamlet (shamlet)
import Text.Lucius (lucius, renderCss)
import Web.Scotty (ActionM, scotty, get, html, raw, setHeader)
render :: Html -> ActionM ()
render = html . renderHtml
css :: ByteString -> ActionM ()
css src = setHeader "content-type" "text/css" >> raw src
main :: IO ()
main = scotty 3000 $ do
get "/" $ render homepage
get "/custom.css" $ css stylesheet
data Person = Person
{ _name :: Text
, _pic :: Text
, _twitter :: Text
, _website :: Text
, _books :: [Book]
}
data Book = Book
{ _title :: Text
, _author :: Text
, _amznref :: Text
}
allPeople :: [Person]
allPeople =
[ Person { _name = "Joe Rogan"
, _pic = "https://pbs.twimg.com/profile_images/552307347851210752/vrXDcTFC_400x400.jpeg"
, _twitter = "joerogan"
, _website = "http://joerogan.com"
, _books = [ Book {_title = "Food of the Gods"
, _author = "Terence McKenna"
, _amznref = "0553371304"
}
, Book { _title = "The War of Art"
, _author ="Steven Pressfield"
, _amznref ="B007A4SDCG"
}
]
}
, Person { _name = "Beyoncé"
, _pic = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTxT84sF19lxdnSiblIXAp-Y4wAigpQn8sZ2GtAerIR_ApiiEJfFQ"
, _twitter = "Beyonce"
, _website = "http://beyonce.com"
, _books = [ Book { _title = "What Will It Take To Make A Woman President?"
, _author = "Marianne Schnall"
, _amznref = "B00E257Y7G"}
]
}
, Person { _name = "Barrack Obama"
, _pic = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQeLzftR36p0hYI-EKNa5fm7CYDuN-vyz23_R48ocqa8X1nPr6C"
, _twitter = "BarackObama"
, _website = "http://barackobama.com"
, _books = [ Book { _title = "An American Marriage"
, _author = "Tayari Jones"
, _amznref = "B01NCUXEFR"}
, Book { _title = "Americanah"
, _author = "Chimamanda Ngozi Adichie"
, _amznref = "B00A9ET4MC"}
]
}
, Person { _name = "Warren Buffet"
, _pic = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQQbmnUykS6zqgzaf44tsq1RAsnHe6H7fapEoSqUwAoJGSFKbAPSw"
, _twitter = "WarrenBuffett"
, _website = "http://berkshirehathaway.com"
, _books = [ Book { _title = "The Intelligent Investor"
, _author = "Benjamin Graham"
, _amznref = "B000FC12C8"}
, Book { _title = "Security Analysis"
, _author = "Benjamin Graham"
, _amznref = "B0037JO5J8"}
]
}
, Person { _name = "Bill Gates"
, _pic = "https://pbs.twimg.com/profile_images/988775660163252226/XpgonN0X_400x400.jpg"
, _twitter = "BillGates"
, _website = "https://www.gatesnotes.com"
, _books = [ Book { _title = "Leonardo da Vinci"
, _author = "Walter Isaacson"
, _amznref = "1501139169"
}
, Book { _title = "Educated"
, _author = "Tara Wetsover"
, _amznref = "B072BLVM83"
}
]
}
, Person { _name = "Stephen King"
, _pic = "https://pbs.twimg.com/profile_images/378800000836981162/b683f7509ec792c3e481ead332940cdc_400x400.jpeg"
, _twitter = "StephenKing"
, _website = "https://stephenking.com/"
, _books = [ Book { _title = "Red Moon"
, _author = "Benjamin Percy"
, _amznref = "B008TU2592"
}
, Book { _title = "The Marauders"
, _author = "Tom Cooper"
, _amznref = "B00MKZBVTM"
}
]
}
, Person { _name = "Tobi Lütke"
, _pic = "https://pbs.twimg.com/profile_images/551403375141457920/28EOlhnM_400x400.jpeg"
, _twitter = "tobi"
, _website = "https://www.shopify.com"
, _books = [ Book { _title = "Influence"
, _author ="Robert B. Cialdini"
, _amznref = "006124189X"
}
, Book { _title = "High Output Management"
, _author ="Andrew S. Grove"
, _amznref = "B015VACHOK"
}
]
}
, Person { _name = "Susan Cain"
, _pic = "https://pbs.twimg.com/profile_images/1474290079/SusanCain5smaller-1_400x400.jpg"
, _twitter = "susancain"
, _website = "https://www.quietrev.com"
, _books = [ Book { _title = "Bird by Bird"
, _author ="Anne Lamott"
, _amznref = "0385480016"
}
, Book { _title = "Waking Up"
, _author ="Sam Harris"
, _amznref = "1451636024"
}
]
}
, Person { _name = "Oprah Winfrey"
, _pic = "https://pbs.twimg.com/profile_images/1013835283698049025/q5ZN4yv3_400x400.jpg"
, _twitter = "Oprah"
, _website = "http://www.oprah.com/index.html"
, _books = [ Book { _title = "A New Earth"
, _author ="Eckhart Tolle"
, _amznref = "B000PC0S5K"
}
, Book { _title = "The Poisonwood Bible"
, _author ="Barbara Kingsolver"
, _amznref = "B000QTE9WU"
}
]
}
, Person { _name = "Patrick Collison"
, _pic = "https://pbs.twimg.com/profile_images/825622525342199809/_iAaSUQf_400x400.jpg"
, _twitter = "patrickc"
, _website = "https://patrickcollison.com"
, _books = [ Book { _title = "How Judges Think"
, _author ="Richard A. Posner"
, _amznref = "0674048067"
}
, Book { _title = "Programmers at Work"
, _author ="Susan Lammers"
, _amznref = "1556152116"
}
]
}
, Person { _name = "Luis Von Ahn"
, _pic = "https://pbs.twimg.com/profile_images/1020343581087678464/NIXD5MdC_400x400.jpg"
, _twitter = "LuisvonAhn"
, _website = "https://www.duolingo.com/"
, _books = [ Book { _title = "Zero to One"
, _author ="Peter Thiel"
, _amznref = "B00J6YBOFQ"
}
, Book { _title = "The Hard Thing About Hard Things"
, _author ="Ben Horowitz"
, _amznref = "B00DQ845EA"
}
]
}
, Person { _name = "Bryan Johnson"
, _pic = "https://pbs.twimg.com/profile_images/1055165076372475904/vNp60sSl_400x400.jpg"
, _twitter = "bryan_johnson"
, _website = "https://bryanjohnson.co"
, _books = [ Book { _title = "A Good Man"
, _author ="Mark Shriver"
, _amznref = "B007CLBH0M"
}
, Book { _title = "Shackleton"
, _author ="Nick Bertozzi"
, _amznref = "1596434511"
}
]
}
, Person { _name = "Peter Thiel"
, _pic = "https://pbs.twimg.com/profile_images/1121220551/Peter_Thiel_400x400.jpg"
, _twitter = "peterthiel"
, _website = "http://zerotoonebook.com"
, _books = [ Book { _title = "Deceit, Desire, and the Novel"
, _author ="René Girard"
, _amznref = "0801818303"
}
, Book { _title = "Violence and the Sacred"
, _author ="René Girard"
, _amznref = "0801822181"
}
]
}
, Person { _name = "Tim Ferris"
, _pic = "https://pbs.twimg.com/profile_images/49918572/half-face-ice_400x400.jpg"
, _twitter = "tferriss"
, _website = "http://tim.blog"
, _books = [ Book { _title = "10% Happier"
, _author ="Dan Harris"
, _amznref = "0062265431"
}
, Book { _title = "A Guide to the Good Life"
, _author ="William Irvine"
, _amznref = "B0040JHNQG"
}
]
}
, Person { _name = "Allen Walton"
, _pic = "https://pbs.twimg.com/profile_images/1038905908678545409/yUbF9Ruc_400x400.jpg"
, _twitter = "allenthird"
, _website = "https://www.allenwalton.com"
, _books = [ Book { _title = "4 Hour Work Week"
, _author ="Tim Ferris"
, _amznref = "B002WE46UW"
}
, Book { _title = "Choose Yourself"
, _author ="James Altucher"
, _amznref = "B00CO8D3G4"
}
]
}
, Person { _name = "Peter Mallouk"
, _pic = "https://pbs.twimg.com/profile_images/713172266968715264/KsyDYghf_400x400.jpg"
, _twitter = "PeterMallouk"
, _website = "https://creativeplanning.com"
, _books = [ Book { _title = "Awareness"
, _author ="Anthony de Mello SJ"
, _amznref = "B005GFBP6W"
}
, Book { _title = "The Prophet"
, _author ="Kahlil Gibran"
, _amznref = "B07NDJ3LMW"
}
]
}
, Person { _name = "Adam Robinson"
, _pic = "https://pbs.twimg.com/profile_images/822708907051077632/y5KyboMV_400x400.jpg"
, _twitter = "IAmAdamRobinson"
, _website = "http://robinsonglobalstrategies.com"
, _books = [ Book { _title = "Wishcraft"
, _author ="Barbara Sher"
, _amznref = "0345465180"
}
, Book { _title = "You Can Be a Stock Market Genius"
, _author ="Joel Greenblatt"
, _amznref = "0684832135"
}
]
}
, Person { _name = "Anrew Weil"
, _pic = "https://pbs.twimg.com/profile_images/987461787422359553/mpoZAmPH_400x400.jpg"
, _twitter = "DrWeil"
, _website = "https://www.drweil.com"
, _books = [ Book { _title = "The Way Of Life According To Lao Tzu"
, _author = "Witter Byner"
, _amznref = "0399512985"
}
, Book { _title = "The Psychology of Romantic Love"
, _author ="Nathaniel Branden"
, _amznref = "B0012RMVJI"
}
]
}
, Person { _name = "Hubert Joly"
, _pic = "https://scontent-ort2-2.xx.fbcdn.net/v/t1.0-1/c1.0.193.193a/38444401_2156120597936470_9028564067043770368_n.jpg?_nc_cat=104&_nc_ht=scontent-ort2-2.xx&oh=162142edb167f389a5b585a329e4993a&oe=5CE1D578"
, _twitter = "BBYCEO"
, _website = "https://www.bestbuy.com"
, _books = [ Book { _title = "Who Says Elephants Can't Dance"
, _author = "Louis. V. Gerstner"
, _amznref = "0060523808"
}
, Book { _title = "Onward"
, _author ="Howard Schultz"
, _amznref = "1609613821"
}
]
}
, Person { _name = "Esther Perel"
, _pic = "https://pbs.twimg.com/profile_images/1091062675151319040/MzxCcgdU_400x400.jpg"
, _twitter = "EstherPerel"
, _website = "https://www.estherperel.com"
, _books = [ Book { _title = "Crime And Punishment"
, _author = "Fyodor Dostoyevsky"
, _amznref = "B07NL94DFD"
}
, Book { _title = "If This Is a Man and The Truce"
, _author ="Primo Levi"
, _amznref = "0349100136"
}
]
}
, Person { _name ="Neil deGrasse Tyson"
, _pic = "https://pbs.twimg.com/profile_images/74188698/NeilTysonOriginsA-Crop_400x400.jpg"
, _twitter = "neiltyson"
, _website = "https://www.haydenplanetarium.org/tyson/"
, _books = [ Book { _title = "The Prince"
, _author = "Machiavelli"
, _amznref = "B07ND3CM16"
}
, Book { _title = "The Art of War"
, _author ="Sun Tzu"
, _amznref = "1545211957"
}
]
}
]
displayPerson :: Person -> Markup
displayPerson person = [shamlet|
<div .card .mx-3 .my-5 .w-25 .h-25>
<img .card-img .img-fluid src=#{_pic person}>
<div .card-body>
<h4 .card-title>
#{_name person}
<h6>
<a target=_blank href="https://twitter.com/#{_twitter person}" class="fab fa-twitter">
<a target=_blank href=#{_website person} class="fas fa-globe">
<p .card-text>
<ul>
$forall book <- (_books person)
<li>
<a target=_blank .text-dark href="https://www.amazon.com/dp/#{_amznref book}">
#{_title book}
|]
title, subtitle :: Text
title = "Influenced by books"
subtitle = "Influential people and the books that made them."
homepage :: Markup
homepage = [shamlet|
<!doctype html>
<head>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS"
crossorigin="anonymous">
<link rel="stylesheet"
href="https://use.fontawesome.com/releases/v5.7.1/css/all.css"
integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr"
crossorigin="anonymous">
<link href="/custom.css" rel="stylesheet">
<title>#{title} | #{subtitle}
<body>
<div .container.mt-5>
<div .jumbotron>
<h1 .display-4>
#{title}
<p .lead>
#{subtitle}
<div .d-flex .flex-wrap .justify-content-around>
$forall person <- allPeople
#{displayPerson person}
|]
stylesheet :: ByteString
stylesheet = encodeUtf8 . renderCss $ [lucius|
.jumbotron
{ background: #fff
; text-align: center
}
|] undefined
|