From 3a7772bbdd24486faf6d37eb3e558578987b5cd0 Mon Sep 17 00:00:00 2001 From: David Vollbracht Date: Sun, 12 Nov 2023 15:39:31 -0600 Subject: [PATCH] Fill out documentation sections with possible topics --- orville-docsite/site-builder/css/default.css | 4 +- .../explanations/building-sql-expressions.md | 6 ++ .../fighting-n-plus-one-queries-with-plans.md | 6 ++ .../the-monad-orville-typeclass.md | 6 ++ ...o-add-orville-to-your-application-monad.md | 6 ++ .../how-tos/how-to-execute-raw-sql.md | 6 ++ .../how-to-marshall-a-haskell-record.md | 6 ++ ...o-set-up-an-auto-incrementing-id-column.md | 6 ++ orville-docsite/site-builder/site.hs | 60 ++++++++++++------- .../site-builder/templates/default.html | 15 ++++- 10 files changed, 98 insertions(+), 23 deletions(-) create mode 100644 orville-docsite/site-builder/explanations/building-sql-expressions.md create mode 100644 orville-docsite/site-builder/explanations/fighting-n-plus-one-queries-with-plans.md create mode 100644 orville-docsite/site-builder/explanations/the-monad-orville-typeclass.md create mode 100644 orville-docsite/site-builder/how-tos/how-to-add-orville-to-your-application-monad.md create mode 100644 orville-docsite/site-builder/how-tos/how-to-execute-raw-sql.md create mode 100644 orville-docsite/site-builder/how-tos/how-to-marshall-a-haskell-record.md create mode 100644 orville-docsite/site-builder/how-tos/how-to-set-up-an-auto-incrementing-id-column.md diff --git a/orville-docsite/site-builder/css/default.css b/orville-docsite/site-builder/css/default.css index 74d6c8f..063ebee 100644 --- a/orville-docsite/site-builder/css/default.css +++ b/orville-docsite/site-builder/css/default.css @@ -33,7 +33,9 @@ main { } nav a { - display: block; + display: block; + margin-top: 8px; + margin-bottom: 8px; } a { diff --git a/orville-docsite/site-builder/explanations/building-sql-expressions.md b/orville-docsite/site-builder/explanations/building-sql-expressions.md new file mode 100644 index 0000000..ae6500c --- /dev/null +++ b/orville-docsite/site-builder/explanations/building-sql-expressions.md @@ -0,0 +1,6 @@ +--- +title: Building SQL Expressions (Upcoming) +navOrder: 2 +--- + +Coming Soon diff --git a/orville-docsite/site-builder/explanations/fighting-n-plus-one-queries-with-plans.md b/orville-docsite/site-builder/explanations/fighting-n-plus-one-queries-with-plans.md new file mode 100644 index 0000000..97e534c --- /dev/null +++ b/orville-docsite/site-builder/explanations/fighting-n-plus-one-queries-with-plans.md @@ -0,0 +1,6 @@ +--- +title: Fighting N+1 Queries with Plans (Upcoming) +navOrder: 3 +--- + +Coming Soon diff --git a/orville-docsite/site-builder/explanations/the-monad-orville-typeclass.md b/orville-docsite/site-builder/explanations/the-monad-orville-typeclass.md new file mode 100644 index 0000000..be71f44 --- /dev/null +++ b/orville-docsite/site-builder/explanations/the-monad-orville-typeclass.md @@ -0,0 +1,6 @@ +--- +title: The MonadOrville Typeclass (Upcoming) +navOrder: 1 +--- + +Coming Soon diff --git a/orville-docsite/site-builder/how-tos/how-to-add-orville-to-your-application-monad.md b/orville-docsite/site-builder/how-tos/how-to-add-orville-to-your-application-monad.md new file mode 100644 index 0000000..9d055e2 --- /dev/null +++ b/orville-docsite/site-builder/how-tos/how-to-add-orville-to-your-application-monad.md @@ -0,0 +1,6 @@ +--- +title: How To Add Orville to Your Application Monad (Upcoming) +navOrder: 1 +--- + +Coming Soon diff --git a/orville-docsite/site-builder/how-tos/how-to-execute-raw-sql.md b/orville-docsite/site-builder/how-tos/how-to-execute-raw-sql.md new file mode 100644 index 0000000..8aed817 --- /dev/null +++ b/orville-docsite/site-builder/how-tos/how-to-execute-raw-sql.md @@ -0,0 +1,6 @@ +--- +title: How To Execute Raw SQL (Upcoming) +navOrder: 4 +--- + +Coming Soon diff --git a/orville-docsite/site-builder/how-tos/how-to-marshall-a-haskell-record.md b/orville-docsite/site-builder/how-tos/how-to-marshall-a-haskell-record.md new file mode 100644 index 0000000..e368108 --- /dev/null +++ b/orville-docsite/site-builder/how-tos/how-to-marshall-a-haskell-record.md @@ -0,0 +1,6 @@ +--- +title: How To Marshall a Haskell Record (Upcoming) +navOrder: 2 +--- + +Coming Soon diff --git a/orville-docsite/site-builder/how-tos/how-to-set-up-an-auto-incrementing-id-column.md b/orville-docsite/site-builder/how-tos/how-to-set-up-an-auto-incrementing-id-column.md new file mode 100644 index 0000000..8a0eb4e --- /dev/null +++ b/orville-docsite/site-builder/how-tos/how-to-set-up-an-auto-incrementing-id-column.md @@ -0,0 +1,6 @@ +--- +title: How To Set Up An Auto-incrementing Id Column (Upcoming) +navOrder: 3 +--- + +Coming Soon diff --git a/orville-docsite/site-builder/site.hs b/orville-docsite/site-builder/site.hs index 14172ee..ad60a06 100644 --- a/orville-docsite/site-builder/site.hs +++ b/orville-docsite/site-builder/site.hs @@ -45,10 +45,29 @@ renderPandocInStyle = { writerHighlightStyle = Just pandocCodeStyle }) +data Section = + Section + { sectionName :: String + , sectionPattern :: Pattern + } + +sections :: [Section] +sections = + [ Section "tutorials" "tutorials/**" + , Section "how-tos" "how-tos/**" + , Section "explanations" "explanations/**" + ] + +sectionFiles :: Pattern +sectionFiles = + foldr (.||.) (complement mempty) (map sectionPattern sections) + main :: IO () main = do hakyllWith config $ do snippetCache <- preprocess newSnippetCache + let + navContext = mkNavContext snippetCache match "images/*" $ do route idRoute @@ -65,34 +84,27 @@ main = do match "contact.md" $ do route $ setExtension "html" compile $ pandocCompiler - >>= applyDefaultLayout snippetCache defaultContext + >>= applyDefaultLayout navContext defaultContext >>= relativizeUrls - let - tutorialsRoute = - composeRoutes - (gsubRoute "tutorials/" (const "")) - (setExtension "html") - - match "tutorials/**" $ do - route tutorialsRoute + match sectionFiles $ do + route (setExtension "html") compile $ getResourceBody >>= applyAsTemplate (pageCtx snippetCache) >>= renderPandocInStyle >>= loadAndApplyTemplate "templates/post.html" (pageCtx snippetCache) >>= saveSnapshot navLinksSnapshot - >>= applyDefaultLayout snippetCache (pageCtx snippetCache) + >>= applyDefaultLayout navContext (pageCtx snippetCache) >>= relativizeUrls match "index.md" $ do route $ setExtension "html" compile $ do - navContext <- loadNavContex snippetCache getResourceBody >>= applyAsTemplate (mconcat [navContext, pageCtx snippetCache]) >>= renderPandocInStyle - >>= applyDefaultLayout snippetCache defaultContext + >>= applyDefaultLayout navContext defaultContext >>= relativizeUrls match "templates/*" $ compile templateBodyCompiler @@ -110,15 +122,14 @@ main = do -------------------------------------------------------------------------------- applyDefaultLayout :: - SnippetCache -> + Context a -> Context a -> Item a -> Compiler (Item String) -applyDefaultLayout snippetCache itemContext item = do - navContext <- loadNavContex snippetCache +applyDefaultLayout navContext itemContext item = do loadAndApplyTemplate "templates/default.html" - (mappend navContext itemContext) + (navContext <> itemContext) item {- | @@ -130,11 +141,18 @@ navLinksSnapshot :: String navLinksSnapshot = "navLinks" -loadNavContex :: SnippetCache -> Compiler (Context a) -loadNavContex snippetCache = do - tutorials <- inNavOrder =<< loadAllSnapshots "tutorials/*" navLinksSnapshot - pure $ - listField "tutorials" (pageCtx snippetCache) (return tutorials) +mkNavContext :: SnippetCache -> Context a +mkNavContext snippetCache = do + foldMap (sectionContext snippetCache) sections + +sectionContext :: SnippetCache -> Section -> Context a +sectionContext snippetCache section = + listField (sectionName section) (pageCtx snippetCache) $ + inNavOrder =<< + loadAllSnapshots + (sectionPattern section) + navLinksSnapshot + inNavOrder :: (MonadMetadata m, MonadFail m) => [Item a] -> m [Item a] inNavOrder = diff --git a/orville-docsite/site-builder/templates/default.html b/orville-docsite/site-builder/templates/default.html index 2181ffd..10f5c5a 100644 --- a/orville-docsite/site-builder/templates/default.html +++ b/orville-docsite/site-builder/templates/default.html @@ -13,7 +13,7 @@

- Orville Logo + Orville Logo

@@ -26,6 +26,19 @@ $title$ $endfor$ +

How-To Guides

+ $for(how-tos)$ + $title$ + $endfor$ + +

Futher Explanation

+ $for(explanations)$ + $title$ + $endfor$ + +

API Reference

+ See Hackage +

Other Links

Contact