From e03ff22a299afa3b9963029b40214ee2675f69a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20van=20Br=C3=BCgge?= Date: Thu, 25 Apr 2024 17:43:21 +0100 Subject: [PATCH 1/4] Do not repeat introduction text in article itself --- articles/2020/open-source-journey.md | 5 +---- articles/2020/redesigning-a-framework.md | 2 -- src/Main.hs | 1 + templates/post.html | 6 ++++++ 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/articles/2020/open-source-journey.md b/articles/2020/open-source-journey.md index 9a3e361..7383121 100644 --- a/articles/2020/open-source-journey.md +++ b/articles/2020/open-source-journey.md @@ -3,13 +3,10 @@ title: My Open Source Journey author: Jan van Brügge date: 2020-10-28 tags: [open-source] +published_on: the [Futurice Blog](https://futurice.com/blog/my-open-source-journey) description: It's October again, Hacktoberfest time. Also time for me to reminisce about my personal learning journey that was so heavily influenced by open source. --- -*This post was first published on the [Futurice Blog](https://futurice.com/blog/my-open-source-journey).* - -It's October again, Hacktoberfest time. Also time for me to reminisce about my personal learning journey that was so heavily influenced by open source. - ## The Beginning My interest in computers and coding started rather early, so when I was 14 years old, I went to the local library, got myself a book about programming ("From Zero to Hero: Java") and started on this wonderful path that is now not only my job, but also my passion. diff --git a/articles/2020/redesigning-a-framework.md b/articles/2020/redesigning-a-framework.md index be08b3d..fbeb1d5 100644 --- a/articles/2020/redesigning-a-framework.md +++ b/articles/2020/redesigning-a-framework.md @@ -6,8 +6,6 @@ tags: [typescript, open-source] description: For the last few years, the core team of Cycle.js ([André](https://twitter.com/andrestaltz) and me) has been redesigning the architecture and the developer experience of the framework. This February we finally found a solution to our problems that still stays true to the core ideas of the framework. --- -For the last few years, the core team of Cycle.js ([André](https://twitter.com/andrestaltz) and me) has been redesigning the architecture and the developer experience of the framework. This February we finally found a solution to our problems that still stays true to the core ideas of the framework. - This blog post marks the first in a series that will cover the new design and its development. In this installment, I want to bring everyone onto the same page. _What_ where the problems I described earlier and _how_ does the new design solve them. In the later articles I will cover the new `run` function (the core of the framework) and the new HTTP driver and especially the issues I encountered while implementing those. _\*cough\*_ race conditions _\*cough\*_. ## The status quo diff --git a/src/Main.hs b/src/Main.hs index f919a8f..38b8d71 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -29,6 +29,7 @@ data Post = MkPost { title :: String , author :: String , description :: String + , published_on :: Maybe String , content :: String , url :: String , date :: String diff --git a/templates/post.html b/templates/post.html index d0f4187..a82c095 100644 --- a/templates/post.html +++ b/templates/post.html @@ -1,4 +1,10 @@
{{> templates/postHeader.html}} + {{#published_on}} +

This post was first published on {{{.}}}.

+ {{/published_on}} +

+ {{{description}}} +

{{{content}}}
From 9d17dbf83cdaea9a5efb8b53852b60a0f2870a88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20van=20Br=C3=BCgge?= Date: Thu, 25 Apr 2024 17:46:52 +0100 Subject: [PATCH 2/4] Run CI also on PRs (but keep deployment for master) --- .github/workflows/deploy.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 61d452f..887d148 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,5 +1,6 @@ name: Deploy on: + pull_request: push: branches: - master @@ -35,6 +36,7 @@ jobs: run: cabal run blog - name: Upload artifact + if: github.ref == 'refs/heads/master' uses: actions/upload-pages-artifact@v3 with: path: ./build @@ -42,6 +44,7 @@ jobs: deploy: needs: build runs-on: ubuntu-latest + if: github.ref == 'refs/heads/master' permissions: pages: write From b1a8dad1c08b6ea987b572178531d86d152042ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20van=20Br=C3=BCgge?= Date: Fri, 26 Apr 2024 11:31:44 +0100 Subject: [PATCH 3/4] Add table of contents to articles --- blog.cabal | 1 + src/Main.hs | 38 ++++++++++++++++++++++++++------------ templates/postList.html | 2 +- templates/shell.html | 1 + 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/blog.cabal b/blog.cabal index 428bc3d..0b23045 100644 --- a/blog.cabal +++ b/blog.cabal @@ -23,6 +23,7 @@ executable blog build-depends: base ^>=4.18.0.0 , containers , aeson + , pandoc , slick , shake , text diff --git a/src/Main.hs b/src/Main.hs index 38b8d71..dcc2947 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -3,28 +3,42 @@ module Main where -import Development.Shake (ShakeOptions(..), shakeOptions, Verbosity (..), Action, forP, getDirectoryFiles, readFile', writeFile', copyFileChanged) -import Development.Shake.Forward (forwardOptions, shakeArgsForward, cacheAction) -import GHC.Generics (Generic) -import Development.Shake.Classes (Binary) +import Control.Monad (foldM) +import Control.Monad.IO.Class (liftIO) import Data.Aeson (FromJSON, ToJSON) -import Data.Aeson.Types qualified as A -import Data.Text qualified as T -import Slick (markdownToHTML, compileTemplate', substitute) -import Slick.Utils (convert) +import Data.Aeson.Key (fromText) import Data.Aeson.KeyMap qualified as KM -import Development.Shake.FilePath (dropDirectory1, (), dropExtension) +import Data.Aeson.Types qualified as A import Data.Functor (void) -import Data.Maybe (fromMaybe) -import Control.Monad (foldM) -import Data.Aeson.Key (fromText) import Data.List (sortOn) +import Data.Maybe (fromMaybe) import Data.Ord (Down(..)) import Data.Set qualified as Set +import Data.Text qualified as T +import Development.Shake (ShakeOptions(..), shakeOptions, Verbosity (..), Action, forP, getDirectoryFiles, readFile', writeFile', copyFileChanged) +import Development.Shake.Classes (Binary) +import Development.Shake.FilePath (dropDirectory1, (), dropExtension) +import Development.Shake.Forward (forwardOptions, shakeArgsForward, cacheAction) +import GHC.Generics (Generic) +import Slick (compileTemplate', substitute) +import Slick.Pandoc (loadUsingMeta, defaultHtml5Options, defaultMarkdownOptions) +import Slick.Utils (convert) +import Text.Pandoc.Options (writerTableOfContents, writerTemplate) +import Text.Pandoc.Readers (readMarkdown) +import Text.Pandoc.Templates (compileTemplate) +import Text.Pandoc.Writers (writeHtml5String) outputFolder :: FilePath outputFolder = "build/" +markdownToHTML :: T.Text -> Action A.Value +markdownToHTML txt = do + Right x <- liftIO $ compileTemplate "" "

Table of Contents

\n$toc$\n$body$" + loadUsingMeta (readMarkdown defaultMarkdownOptions) + (writeHtml5String (defaultHtml5Options { writerTableOfContents = True, writerTemplate = Just x })) + (writeHtml5String defaultHtml5Options) + txt + data Post = MkPost { title :: String , author :: String diff --git a/templates/postList.html b/templates/postList.html index 68c4761..253a058 100644 --- a/templates/postList.html +++ b/templates/postList.html @@ -5,6 +5,6 @@ {{/posts}} diff --git a/templates/shell.html b/templates/shell.html index 62bf5ee..633f083 100644 --- a/templates/shell.html +++ b/templates/shell.html @@ -23,6 +23,7 @@ © 2020-2024, Jan van Brügge. Opinions are my own. All articles licensed under CC BY-SA 4.0 Feeds are available via Atom + Site generated by Haskell with Slick From d07bbf84b9f274561861f20370fb1133535b3eca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20van=20Br=C3=BCgge?= Date: Fri, 26 Apr 2024 11:36:25 +0100 Subject: [PATCH 4/4] Add more details about the site to footer --- templates/shell.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/shell.html b/templates/shell.html index 633f083..a2c6b72 100644 --- a/templates/shell.html +++ b/templates/shell.html @@ -23,7 +23,7 @@ © 2020-2024, Jan van Brügge. Opinions are my own. All articles licensed under CC BY-SA 4.0 Feeds are available via Atom - Site generated by Haskell with Slick + Site generated with Haskell and Slick. See the source on GitHub.