Skip to content

Commit

Permalink
Cursed be it here
Browse files Browse the repository at this point in the history
  • Loading branch information
The1Penguin committed Oct 24, 2024
1 parent 683ab60 commit 5b00272
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 164 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ cabal.sandbox.config
dist-newstyle/
result/
logs/
demo_files/
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ cachix use jassob # Only needed once
cachix use pingu # Probably more up to date as of 5/6-24
```

### Updating the view?
Currently, the css framework used is [TailwindCSS](https://tailwindcss.com).
To generate the css file, visit the website, wait until menus have loaded, and then save the html to `demo.html`.
Then use [Tailwinds cli](https://tailwindcss.com/blog/standalone-cli) program to generate the new css by running `tailwindcss --content demo.html --output static/style.css --minify`.

Worth noting is that the css is embedded in the binary, and changes to it aren't well captured by cabal, so `cabal clean && cabal run` or `docker compose up --build` might be needed to see the updated styling.

## Credits

Favicon made by Freepik from <a href="http://www.flaticon.com"
Expand Down
3 changes: 3 additions & 0 deletions demo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="icon" type="image/png" href="http://localhost:5007/icon.png"><link rel="stylesheet" href="demo_files/style.css"><title>Lunch at Chalmers</title></head><body class="bg-[#e9e7e7]" br-mode="off" style="--fixation-edge-opacity: 80%; --br-line-height: 1; --br-boldness: 600;" saccades-color="" fixation-strength="2" saccades-interval="0"><div class="px-4 py-4 mx-auto"><h1 class="text-4xl">Today / 2024-10-24</h1><div class="grid grid-cols-1 md:grid-cols-4"><div class="relative mt-5"><h2 class="text-2xl text-orange-500">Kårrestaurangen&nbsp;<a href="https://plateimpact-screen.azurewebsites.net/menu/week/karrestaurangen/21f31565-5c2b-4b47-d2a1-08d558129279"></a></h2><ul class="food-menu"><li class="text-lg"><h3 class="inline-block font-bold text-orange-500">Greens</h3><span class="invisible"> </span>Tofu kung pao, salladslök, paprika, basmatiris, koriander, lime</li><li class="text-lg"><h3 class="inline-block font-bold text-orange-500">Street food</h3><span class="invisible"> </span>Bakad fisk,tikka masala ,koriander, basmatiris &amp; yoghurt</li><li class="text-lg"><h3 class="inline-block font-bold text-orange-500">Nordic</h3><span class="invisible"> </span>Fläsk karré, bakad potatis, rödvinssås &amp; örtsmör</li></ul></div><div class="relative mt-5"><h2 class="text-2xl text-orange-500">S.M.A.K.&nbsp;<a href="https://plateimpact-screen.azurewebsites.net/menu/week/smak/3ac68e11-bcee-425e-d2a8-08d558129279"></a></h2><ul class="food-menu"><li class="text-lg"><h3 class="inline-block font-bold text-orange-500">Dagens</h3><span class="invisible"> </span>Pumpacurry, kikärtor &amp; bönor, koriander, chili &amp; ris</li></ul></div><div class="relative mt-5"><h2 class="text-2xl text-orange-500">L's Kitchen&nbsp;<a href="https://plateimpact-screen.azurewebsites.net/menu/week/ls-kitchen/c74da2cf-aa1a-4d3a-9ba6-08d5569587a1"></a></h2><ul class="food-menu"><li class="text-lg"><h3 class="inline-block font-bold text-orange-500">Kött</h3><span class="invisible"> </span>Fläskfärsbiff, grön curry, ingefära, nudlar, soja, misokräm &amp; koriander</li><li class="text-lg"><h3 class="inline-block font-bold text-orange-500">Fisk</h3><span class="invisible"> </span>Ångad fisk, musselsås, potatismos, gröna ärtor, haricot verts &amp; citron</li><li class="text-lg"><h3 class="inline-block font-bold text-orange-500">Vegan</h3><span class="invisible"> </span>Falafel, couscoussallad, "vegansk raita, koriander</li><li class="text-lg"><h3 class="inline-block font-bold text-orange-500">Sallad</h3><span class="invisible"> </span>Bulgur, kokt ägg, räkor, dillkräm, rädisor</li><li class="text-lg"><h3 class="inline-block font-bold text-orange-500">Sallad</h3><span class="invisible"> </span>Caesarsallad; kyckling, grana padano, bacon, krutonger</li></ul></div><div class="relative mt-5"><h2 class="text-2xl text-orange-500">Wijkanders&nbsp;<a href="https://www.wijkanders.se/restaurangen"></a></h2><ul class="food-menu"><li class="text-lg"><h3 class="inline-block font-bold text-orange-500">Veg</h3><span class="invisible"> </span>Pasta med grönkålspesto, bakade tomater, grana padano &amp; ruccola </li><li class="text-lg"><h3 class="inline-block font-bold text-orange-500">Fisk</h3><span class="invisible"> </span>Mandelbakad fisk, brynt smör, blomkålspuré &amp; svamp</li><li class="text-lg"><h3 class="inline-block font-bold text-orange-500">Kött</h3><span class="invisible"> </span>Nattbakad fläskkarrè, chimichurri, rostad sötpotatis &amp; mojo rojo</li></ul></div><div class="relative mt-5"><h2 class="text-2xl text-orange-500">Café Linsen&nbsp;<a href="https://cafe-linsen.se/#menu"></a></h2><ul class="food-menu"><li class="text-lg"><h3 class="inline-block font-bold text-orange-500">Högrevsburgare.</h3><span class="invisible"> </span>Bacon Chutney, Picklad Gurka/Sallad, Brioche, Ost, Friterad Klyftpotatis.</li><li class="text-lg"><h3 class="inline-block font-bold text-orange-500">Italiensk fisksoppa.</h3><span class="invisible"> </span>Räkor, Musslor, Tomat, Grönsaker, Krutonger, Potatis.</li><li class="text-lg"><h3 class="inline-block font-bold text-orange-500">Grillost Burgare.</h3><span class="invisible"> </span>Svamp Chutney, Picklad Gurka , Sallad, Brioche, Fritera Klyftpotatis.</li></ul></div></div><footer class="py-6 relative justify-self-end">Eat at your own risk :) // Problems? <a href="https://github.com/dtekcth/mat-chalmers/issues/new" class="text-orange-500 visited:text-orange-800">File an issue!</a> // <a href="https://kortladdning3.chalmerskonferens.se/" class="text-orange-500 visited:text-orange-800">Top-up your card</a></footer></div></body><div style="position: absolute; bottom: 0px; left: 0px; height: 0px; z-index: 5;"></div></html>
7 changes: 4 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@
packages = p: [ self.packages.${system}.mat ];
withHoogle = true;
buildInputs =
[
pkgs.zlib
] ++
(with pkgs; [
zlib
tailwindcss
]) ++
(with haskellPackages; [
haskell-language-server
cabal-install
Expand Down
60 changes: 21 additions & 39 deletions src/View.hs
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
{-# LANGUAGE OverloadedStrings, TemplateHaskell, RecordWildCards #-}
{-# LANGUAGE OverloadedStrings, RecordWildCards #-}

module View
( View(..)
, render
)
where

import Data.FileEmbed
import qualified Data.Text.Lazy as T
import qualified Data.Text.Lazy.Builder as T
import Data.Thyme ( defaultTimeLocale
, formatTime )
import Lens.Micro.Platform ( (&)
, (%~)
, both
)
import Lucid
import qualified Text.CSS.Parse as CSS
import qualified Text.CSS.Render as CSS

import Model
import Model.Types ( NoMenu(..) )
Expand All @@ -28,67 +20,57 @@ render v = renderText (renderView v)
renderView :: View -> Html ()
renderView View {..} = doctypehtml_ $ do
sitehead
body_ $ div_ [class_ "container-fluid main"] $ do
h1_ $ do
toHtml day
" / "
toHtml (formatTime defaultTimeLocale "%F" date)
if null restaurants
then div_ . box_ . h3_ $ ("No lunches " >> toHtml day)
else div_ $ uncurry
mappend
( splitAt 4 (map renderRest restaurants)
& both
%~ (div_ [class_ "row"] . mconcat)
)
body_ [class_ "bg-[#e9e7e7]"] $ do
div_ [class_ "px-4 py-4 mx-auto"] $ do
h1_ [class_ "text-4xl"] $ do
toHtml day
" / "
toHtml (formatTime defaultTimeLocale "%F" date)
if null restaurants
then div_ . box_ . h3_ $ ("No lunches " >> toHtml day)
else div_ [class_ "grid grid-cols-1 md:grid-cols-4"] . mconcat $ map renderRest restaurants

sitefooter
sitefooter

renderRest :: Restaurant -> Html ()
renderRest Restaurant {..} = box_ $ do
h2_ (toHtml name >> " " >> a_ [href_ (T.toStrict url)] "")
h2_ [class_ "text-2xl text-orange-500"] (toHtml name >> " " >> a_ [href_ (T.toStrict url)] "")
ul_ [class_ "food-menu"] $ case menu of
Left NoLunch -> li_ "No lunch this day!"
Left _ -> li_ "Something went wrong, " <> a_
[href_ $ T.toStrict "https://github.com/dtekcth/mat-chalmers/issues/new"]
[href_ "https://github.com/dtekcth/mat-chalmers/issues/new", class_ "text-orange-500 visited:text-orange-800"]
"please file an issue."
Right menus -> mconcat (map renderMenu menus)

renderMenu :: Menu -> Html ()
renderMenu (Menu lunch spec) = li_
renderMenu (Menu lunch spec) = li_ [class_ "text-lg"]
(do
h3_ (toHtml lunch)
span_ [class_ "invisible-space"] " "
h3_ [class_ "inline-block font-bold text-orange-500"](toHtml lunch)
span_ [class_ "invisible"] " "
toHtml spec
)

box_ :: Html () -> Html ()
box_ = div_ [class_ "col-xs-12 col-sm-6 col-md-3 food"]
box_ = div_ [class_ "relative mt-5"]

sitehead :: Html ()
sitehead = head_
(do
meta_ [charset_ "utf-8"]
meta_ [name_ "viewport", content_ "width=device-width, initial-scale=1"]
link_ [rel_ "icon", type_ "image/png", href_ "icon.png"]
style_ [] css
link_ [rel_ "stylesheet", href_ "style.css"]
title_ "Lunch at Chalmers"
)

sitefooter :: Html ()
sitefooter = footer_
[class_ "col-xs-12 col-sm-12 col-md-12"]
[class_ "py-6 relative justify-self-end"]
(do
"Eat at your own risk :) // "
"Problems? "
a_ [href_ "https://github.com/dtekcth/mat-chalmers/issues/new"]
a_ [href_ "https://github.com/dtekcth/mat-chalmers/issues/new", class_ "text-orange-500 visited:text-orange-800"]
"File an issue!"
" // "
a_ [href_ "https://kortladdning3.chalmerskonferens.se/"] "Top-up your card"
a_ [href_ "https://kortladdning3.chalmerskonferens.se/", class_ "text-orange-500 visited:text-orange-800"] "Top-up your card"
)

-- brittany-disable-next-binding
css :: T.Text
css =
(either error (T.toLazyText . CSS.renderNestedBlocks) . CSS.parseNestedBlocks)
$(embedStringFile "static/style.css")
123 changes: 1 addition & 122 deletions static/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [],
theme: {
extend: {},
},
plugins: [
require('@tailwindcss/typography'),
],
}

0 comments on commit 5b00272

Please sign in to comment.