diff --git a/.dockerignore b/.dockerignore index 5619214..e44af6a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,3 +3,4 @@ Dockerfile docker-compose.yml flake.nix flake.lock +static/style.css diff --git a/.gitignore b/.gitignore index 214f149..67d449f 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ cabal.sandbox.config *.dump-hi .direnv/ .envrc +static/style.css dist-newstyle/ result/ logs/ diff --git a/Dockerfile b/Dockerfile index 60552cd..e7b0cf6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,25 @@ -FROM haskell:9.6.6 as BIN -WORKDIR /app/user -COPY *.cabal ./ +from haskell:9.6.6 as bin +workdir /app/user +copy *.cabal ./ -RUN cabal v2-update && \ +run cabal v2-update && \ cabal v2-build --dependencies-only -COPY . . -RUN cabal v2-install --install-method copy --installdir . --overwrite-policy=always +copy . . -FROM debian:12.5-slim -RUN apt-get update && apt-get install --no-install-recommends -y ca-certificates \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* -COPY --from=BIN /app/user/mat-chalmers /bin/mat-chalmers -ENV LANG C.UTF-8 -CMD /bin/mat-chalmers -EXPOSE 5007 +run curl -sLO https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64 && \ + mv tailwindcss-linux-x64 tailwindcss && \ + chmod +x tailwindcss && \ + ./tailwindcss --content src/View.hs --output static/style.css --minify + +run cabal v2-install --install-method copy --installdir . --overwrite-policy=always + + +from debian:12.5-slim +run apt-get update && apt-get install --no-install-recommends -y ca-certificates \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* +copy --from=bin /app/user/mat-chalmers /bin/mat-chalmers +env LANG C.UTF-8 +cmd /bin/mat-chalmers +expose 5007 diff --git a/README.md b/README.md index 1316cde..4e4f7e9 100644 --- a/README.md +++ b/README.md @@ -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 css, you can use the [Tailwinds cli](https://tailwindcss.com/blog/standalone-cli) program to generate the new css by running `tailwindcss --content src/View.hs --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 `just up` that fixes the css file and then runs the program. +When running `docker compose up --build`, the css file will be generated by it self. + ## Credits Favicon made by Freepik from Html () renderView View {..} = doctypehtml_ $ do sitehead - body_ $ div_ [class_ "container-fluid main"] $ do - h1_ $ do + body_ [class_ "bg-[#e9e7e7] font-sans"] $ 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_ $ uncurry - mappend - ( splitAt 4 (map renderRest restaurants) - & both - %~ (div_ [class_ "row"] . mconcat) - ) - + else div_ [class_ "grid grid-cols-1 lg:grid-cols-4 gap-5 justify-evenly"] $ foldMap renderRest restaurants 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) + Right menus -> foldMap 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"] " " - toHtml spec + h3_ [class_ "inline font-bold text-orange-500 me-2"] (toHtml lunch) + span_ (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_ @@ -71,24 +56,18 @@ sitehead = head_ 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") diff --git a/static/fonts/AnonymousPro-Bold.ttf b/static/fonts/AnonymousPro-Bold.ttf deleted file mode 100644 index f14c18c..0000000 Binary files a/static/fonts/AnonymousPro-Bold.ttf and /dev/null differ diff --git a/static/fonts/AnonymousPro-BoldItalic.ttf b/static/fonts/AnonymousPro-BoldItalic.ttf deleted file mode 100644 index cd7c30a..0000000 Binary files a/static/fonts/AnonymousPro-BoldItalic.ttf and /dev/null differ diff --git a/static/fonts/AnonymousPro-Italic.ttf b/static/fonts/AnonymousPro-Italic.ttf deleted file mode 100644 index 87b1786..0000000 Binary files a/static/fonts/AnonymousPro-Italic.ttf and /dev/null differ diff --git a/static/fonts/AnonymousPro-Regular.ttf b/static/fonts/AnonymousPro-Regular.ttf deleted file mode 100644 index a98da85..0000000 Binary files a/static/fonts/AnonymousPro-Regular.ttf and /dev/null differ diff --git a/static/fonts/OFL.txt b/static/fonts/OFL.txt deleted file mode 100644 index 68d1d00..0000000 --- a/static/fonts/OFL.txt +++ /dev/null @@ -1,94 +0,0 @@ -Copyright (c) 2009, Mark Simonson (http://www.ms-studio.com, mark@marksimonson.com), -with Reserved Font Name Anonymous Pro. - -This Font Software is licensed under the SIL Open Font License, Version 1.1. -This license is copied below, and is also available with a FAQ at: -http://scripts.sil.org/OFL - - ------------------------------------------------------------ -SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 ------------------------------------------------------------ - -PREAMBLE -The goals of the Open Font License (OFL) are to stimulate worldwide -development of collaborative font projects, to support the font creation -efforts of academic and linguistic communities, and to provide a free and -open framework in which fonts may be shared and improved in partnership -with others. - -The OFL allows the licensed fonts to be used, studied, modified and -redistributed freely as long as they are not sold by themselves. The -fonts, including any derivative works, can be bundled, embedded, -redistributed and/or sold with any software provided that any reserved -names are not used by derivative works. The fonts and derivatives, -however, cannot be released under any other type of license. The -requirement for fonts to remain under this license does not apply -to any document created using the fonts or their derivatives. - -DEFINITIONS -"Font Software" refers to the set of files released by the Copyright -Holder(s) under this license and clearly marked as such. This may -include source files, build scripts and documentation. - -"Reserved Font Name" refers to any names specified as such after the -copyright statement(s). - -"Original Version" refers to the collection of Font Software components as -distributed by the Copyright Holder(s). - -"Modified Version" refers to any derivative made by adding to, deleting, -or substituting -- in part or in whole -- any of the components of the -Original Version, by changing formats or by porting the Font Software to a -new environment. - -"Author" refers to any designer, engineer, programmer, technical -writer or other person who contributed to the Font Software. - -PERMISSION & CONDITIONS -Permission is hereby granted, free of charge, to any person obtaining -a copy of the Font Software, to use, study, copy, merge, embed, modify, -redistribute, and sell modified and unmodified copies of the Font -Software, subject to the following conditions: - -1) Neither the Font Software nor any of its individual components, -in Original or Modified Versions, may be sold by itself. - -2) Original or Modified Versions of the Font Software may be bundled, -redistributed and/or sold with any software, provided that each copy -contains the above copyright notice and this license. These can be -included either as stand-alone text files, human-readable headers or -in the appropriate machine-readable metadata fields within text or -binary files as long as those fields can be easily viewed by the user. - -3) No Modified Version of the Font Software may use the Reserved Font -Name(s) unless explicit written permission is granted by the corresponding -Copyright Holder. This restriction only applies to the primary font name as -presented to the users. - -4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font -Software shall not be used to promote, endorse or advertise any -Modified Version, except to acknowledge the contribution(s) of the -Copyright Holder(s) and the Author(s) or with their explicit written -permission. - -5) The Font Software, modified or unmodified, in part or in whole, -must be distributed entirely under this license, and must not be -distributed under any other license. The requirement for fonts to -remain under this license does not apply to any document created -using the Font Software. - -TERMINATION -This license becomes null and void if any of the above conditions are -not met. - -DISCLAIMER -THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE -COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL -DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM -OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/static/style.css b/static/style.css deleted file mode 100644 index 792671e..0000000 --- a/static/style.css +++ /dev/null @@ -1,122 +0,0 @@ -@font-face { - font-family: "Anonymous Pro"; - src: url("fonts/AnonymousPro-Regular.ttf"); - font-weight: 400; -} -@font-face { - font-family: "Anonymous Pro"; - src: url("fonts/AnonymousPro-Bold.ttf"); - font-weight: 700; -} -* { - box-sizing: border-box; -} -html { - font-size: 10px; -} -body { - font-family: "Anonymous Pro"; - font-size: 14px; - line-height: 1.42857143; - background: #fdf7e2; - color: #333; - margin: 0; -} -h1, -h2, -h3 { - line-height: 1.1; - font-weight: 500; - margin: 0; - margin-bottom: 10px; -} -h1 { - padding-left: 15px; - font-size: 36px; - margin-top: 20px; -} -h2 { - font-size: 140%; - font-weight: bold; -} -h3 { - margin-right: 10px; - margin-bottom: 0; - display: inline-block; - font-size: 100%; - font-weight: bold; - color: #bd3613; -} -.invisible-space { - width: 0px; - font-size: 0px; -} -p { - font-size: 10vh; -} -a { - color: #428bca; - text-decoration: none; -} -ul { - padding: 0; - list-style-type: none; - margin-top: 0; - margin-bottom: 10px; -} -li { - width: 100%; - font-weight: 400; - padding-bottom: 5px; -} -.food { - position: relative; - margin-top: 20px; -} -.row { - display: flex; - flex-wrap: wrap; -} -footer { - font-size: 0.9em; - margin-top: 20px; -} -/* Emulate Bootstrap Grid layout */ -.container-fluid { - padding-left: 15px; - padding-right: 15px; - margin-left: auto; - margin-right: auto; -} -.row { - margin-left: -15px; - margin-right: -15px; -} -.col-xs-12, -.col-sm-12, -.col-md-12, -.col-sm-6, -.col-md-3 { - padding-left: 15px; - padding-right: 15px; - position: relative; -} -.col-xs-12 { - width: 100%; -} -@media (min-width: 768px) { - .col-sm-12 { - width: 100%; - } - .col-sm-6 { - width: 50%; - } -} -@media (min-width: 992px) { - .col-md-3 { - width: 25%; - } - .col-md-12 { - width: 100%; - } -} diff --git a/tailwind.config.js b/tailwind.config.js new file mode 100644 index 0000000..e200e96 --- /dev/null +++ b/tailwind.config.js @@ -0,0 +1,10 @@ +/** @type {import('tailwindcss').Config} */ +module.exports = { + content: [], + theme: { + extend: {}, + }, + plugins: [ + ], +} +