From e5148fbccec6a91d33bd76e0a43e1c3283f6aebd Mon Sep 17 00:00:00 2001 From: shivaraj-bh Date: Tue, 19 Dec 2023 11:05:44 +0530 Subject: [PATCH 1/6] flake.lock: update nixpkgs --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index 23c17815a..1b3c6c0d5 100644 --- a/flake.lock +++ b/flake.lock @@ -99,11 +99,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1693626178, - "narHash": "sha256-Rpiy6lIOu4zny8tfGuIeN1ji9eSz9nPmm9yBhh/4IOM=", + "lastModified": 1702900294, + "narHash": "sha256-pt7sSoJYNw3n8YtXw0Z/Nnr6/PfY2YrjDvqboErXnRM=", "owner": "nixos", "repo": "nixpkgs", - "rev": "bfb7dfec93f3b5d7274db109f2990bc889861caf", + "rev": "886c9aee6ca9324e127f9c2c4e6f68c2641c8256", "type": "github" }, "original": { From 9c4b36bed9a155b121c4f65ac2215b4fea9dd0da Mon Sep 17 00:00:00 2001 From: shivaraj-bh Date: Tue, 19 Dec 2023 11:05:17 +0530 Subject: [PATCH 2/6] unmark broken heist; pandac_3_1_6 is no longer in nixpkgs --- flake.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 510cb8524..1e430c259 100644 --- a/flake.nix +++ b/flake.nix @@ -71,6 +71,7 @@ settings = { # TODO: Eliminate these after new emanote gets upstreamed to nixpkgs fsnotify.check = false; + heist.broken = false; ixset-typed.broken = false; ixset-typed.jailbreak = true; ema.jailbreak = true; @@ -90,7 +91,7 @@ justStaticExecutables = true; removeReferencesTo = [ self.pandoc - self.pandoc_3_1_6 + self.pandoc_3_1_9 self.pandoc-types self.warp ]; From 4c7e108add8d13c84836106f0773852700d6f7fe Mon Sep 17 00:00:00 2001 From: shivaraj-bh Date: Tue, 19 Dec 2023 11:04:39 +0530 Subject: [PATCH 3/6] hlint: use mapM --- emanote/src/Emanote/Pandoc/Renderer/Url.hs | 32 ++++++++++++---------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/emanote/src/Emanote/Pandoc/Renderer/Url.hs b/emanote/src/Emanote/Pandoc/Renderer/Url.hs index 9e291b83d..f07457425 100644 --- a/emanote/src/Emanote/Pandoc/Renderer/Url.hs +++ b/emanote/src/Emanote/Pandoc/Renderer/Url.hs @@ -91,20 +91,24 @@ renderSomeInlineRefWith getSr (is, (url, tit)) rRel model (ctxSansCustomSplicing pure $ do raw <- HP.rpInline ctx (tooltip "Link is ambiguous" [B.Strikeout $ one $ B.Str $ Link.unParseLink origInl, B.Str "❗"]) candidates <- - fmap mconcat . sequence $ - toList srs - <&> \(getSr -> sr) -> do - let (rp, _) = M.withoutRoutePrism model - srRoute = toText $ review rp sr - (_newIs, (newUrl, isNotEmaLink)) = replaceLinkNodeWithRoute model sr (is, srRoute) - linkAttr = [openInNewTabAttr | M.inLiveServer model && isNotEmaLink] - newIs = one $ B.Str $ show sr - HP.rpInline ctx $ - B.Span ("", ["emanote:error:aside"], []) $ - one $ - tooltip (show sr <> " -> " <> srRoute) $ - one $ - B.Link ("", mempty, linkAttr) newIs (newUrl, tit) + fmap + mconcat + ( mapM + ( \(getSr -> sr) -> do + let (rp, _) = M.withoutRoutePrism model + srRoute = toText $ review rp sr + (_newIs, (newUrl, isNotEmaLink)) = replaceLinkNodeWithRoute model sr (is, srRoute) + linkAttr = [openInNewTabAttr | M.inLiveServer model && isNotEmaLink] + newIs = one $ B.Str $ show sr + HP.rpInline ctx + $ B.Span ("", ["emanote:error:aside"], []) + $ one + $ tooltip (show sr <> " -> " <> srRoute) + $ one + $ B.Link ("", mempty, linkAttr) newIs (newUrl, tit) + ) + (toList srs) + ) if M.inLiveServer model then pure $ raw <> candidates else pure raw From f9218f76b42bb8370ce303407ee0a2a5d0469450 Mon Sep 17 00:00:00 2001 From: shivaraj-bh Date: Tue, 19 Dec 2023 11:03:32 +0530 Subject: [PATCH 4/6] hlint: use last --- emanote/src/Emanote/Route/R.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emanote/src/Emanote/Route/R.hs b/emanote/src/Emanote/Route/R.hs index 4c67820ac..b5b4b6f33 100644 --- a/emanote/src/Emanote/Route/R.hs +++ b/emanote/src/Emanote/Route/R.hs @@ -52,7 +52,7 @@ routeSlugWithPrefix prefix r = do -- | The base name of the route without its parent path. routeBaseName :: R ext -> Text routeBaseName = - Slug.unSlug . head . NE.reverse . unRoute + Slug.unSlug . last . unRoute routeParent :: R ext -> Maybe (R 'Folder) routeParent = From a600ec461c0f9cc0782e3936c03ae174122bda3d Mon Sep 17 00:00:00 2001 From: shivaraj-bh Date: Tue, 19 Dec 2023 11:02:14 +0530 Subject: [PATCH 5/6] hlint: use concatMap --- emanote/src/Emanote/Route/SiteRoute/Class.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/emanote/src/Emanote/Route/SiteRoute/Class.hs b/emanote/src/Emanote/Route/SiteRoute/Class.hs index f15ba39b8..d5361f20f 100644 --- a/emanote/src/Emanote/Route/SiteRoute/Class.hs +++ b/emanote/src/Emanote/Route/SiteRoute/Class.hs @@ -59,11 +59,13 @@ emanoteGeneratableRoutes model = virtualRoutes :: [VirtualRoute] = let tags = fst <$> M.modelTags model tagPaths = - Set.fromList $ - ([] :) $ -- [] Triggers generation of main tag index. - concat $ - tags <&> \(HT.deconstructTag -> tagPath) -> + Set.fromList + $ ([] :) + $ concatMap -- [] Triggers generation of main tag index. + ( \(HT.deconstructTag -> tagPath) -> NE.filter (not . null) $ NE.inits tagPath + ) + tags in VirtualRoute_Index : VirtualRoute_Export : VirtualRoute_StorkIndex From 826ce3d4775b0388d510636efbc839ba713952c5 Mon Sep 17 00:00:00 2001 From: shivaraj-bh Date: Tue, 19 Dec 2023 11:01:07 +0530 Subject: [PATCH 6/6] fmt --- emanote/emanote.cabal | 4 +- emanote/src/Emanote.hs | 27 ++--- emanote/src/Emanote/CLI.hs | 4 +- emanote/src/Emanote/Model/Calendar.hs | 9 +- emanote/src/Emanote/Model/Graph.hs | 9 +- emanote/src/Emanote/Model/Link/Rel.hs | 9 +- emanote/src/Emanote/Model/Link/Resolve.hs | 4 +- emanote/src/Emanote/Model/Note.hs | 99 ++++++++++--------- emanote/src/Emanote/Model/Query.hs | 12 +-- emanote/src/Emanote/Model/StaticFile.hs | 24 ++--- emanote/src/Emanote/Model/Stork/Index.hs | 18 ++-- emanote/src/Emanote/Model/Task.hs | 5 +- emanote/src/Emanote/Model/Type.hs | 56 ++++++----- emanote/src/Emanote/Pandoc/BuiltinFilters.hs | 8 +- emanote/src/Emanote/Pandoc/Markdown/Parser.hs | 17 ++-- emanote/src/Emanote/Pandoc/Renderer.hs | 10 +- emanote/src/Emanote/Pandoc/Renderer/Embed.hs | 8 +- emanote/src/Emanote/Pandoc/Renderer/Url.hs | 22 +++-- emanote/src/Emanote/Route/R.hs | 6 +- emanote/src/Emanote/Route/SiteRoute/Class.hs | 25 ++--- emanote/src/Emanote/Source/Loc.hs | 5 +- emanote/src/Emanote/Source/Patch.hs | 6 +- emanote/src/Emanote/Source/Pattern.hs | 12 +-- emanote/src/Emanote/View/Common.hs | 24 ++--- emanote/src/Emanote/View/Export.hs | 5 +- emanote/src/Emanote/View/TagIndex.hs | 12 +-- emanote/src/Emanote/View/TaskIndex.hs | 15 +-- emanote/src/Emanote/View/Template.hs | 38 +++---- 28 files changed, 267 insertions(+), 226 deletions(-) diff --git a/emanote/emanote.cabal b/emanote/emanote.cabal index 2408dad7c..98f72896b 100644 --- a/emanote/emanote.cabal +++ b/emanote/emanote.cabal @@ -43,8 +43,6 @@ common haskell-common -fprint-explicit-foralls -fprint-explicit-kinds default-extensions: - NoImplicitPrelude - NoStarIsType BangPatterns ConstraintKinds DataKinds @@ -70,6 +68,8 @@ common haskell-common LambdaCase MultiParamTypeClasses MultiWayIf + NoImplicitPrelude + NoStarIsType NumericUnderscores OverloadedStrings PolyKinds diff --git a/emanote/src/Emanote.hs b/emanote/src/Emanote.hs index cb4245729..f091ef4bf 100644 --- a/emanote/src/Emanote.hs +++ b/emanote/src/Emanote.hs @@ -67,8 +67,8 @@ run cfg@EmanoteConfig {..} = do >>= postRun cfg CLI.Cmd_Export -> do Dynamic (unModelEma -> model0, _) <- - flip runLoggerLoggingT oneOffLogger $ - siteInput @SiteRoute (Ema.CLI.action def) cfg + flip runLoggerLoggingT oneOffLogger + $ siteInput @SiteRoute (Ema.CLI.action def) cfg putLBSLn $ Export.renderJSONExport model0 where -- A logger suited for running one-off commands. @@ -84,8 +84,8 @@ run cfg@EmanoteConfig {..} = do postRun :: EmanoteConfig -> (Model.ModelEma, (FilePath, [FilePath])) -> IO () postRun EmanoteConfig {..} (unModelEma -> model0, (outPath, genPaths)) = do - when (model0 ^. modelCompileTailwind) $ - compileTailwindCss (outPath generatedCssFile) genPaths + when (model0 ^. modelCompileTailwind) + $ compileTailwindCss (outPath generatedCssFile) genPaths checkBrokenLinks _emanoteConfigCli $ Export.modelRels model0 checkBadMarkdownFiles $ Model.modelNoteErrors model0 @@ -104,8 +104,9 @@ checkBadMarkdownFiles noteErrs = runStderrLoggingT $ do checkBrokenLinks :: CLI.Cli -> Map LMLRoute [Export.Link] -> IO () checkBrokenLinks cli modelRels = runStderrLoggingT $ do - ((), res :: Sum Int) <- runWriterT $ - forM_ (Map.toList modelRels) $ \(noteRoute, rels) -> + ((), res :: Sum Int) <- runWriterT + $ forM_ (Map.toList modelRels) + $ \(noteRoute, rels) -> forM_ (sortNub rels) $ \(Export.Link urt rrt) -> case rrt of RRTFound _ -> pass @@ -127,11 +128,15 @@ compileTailwindCss :: (MonadUnliftIO m) => FilePath -> [FilePath] -> m () compileTailwindCss cssPath genPaths = do runStdoutLoggingT $ do log $ "Running Tailwind CSS v3 compiler to generate: " <> toText cssPath - Tailwind.runTailwind $ - def - & Tailwind.tailwindConfig % Tailwind.tailwindConfigContent .~ genPaths - & Tailwind.tailwindOutput .~ cssPath - & Tailwind.tailwindMode .~ Tailwind.Production + Tailwind.runTailwind + $ def + & Tailwind.tailwindConfig + % Tailwind.tailwindConfigContent + .~ genPaths + & Tailwind.tailwindOutput + .~ cssPath + & Tailwind.tailwindMode + .~ Tailwind.Production defaultEmanotePandocRenderers :: EmanotePandocRenderers Model.Model LMLRoute defaultEmanotePandocRenderers = diff --git a/emanote/src/Emanote/CLI.hs b/emanote/src/Emanote/CLI.hs index f6575cb81..9eee61c4e 100644 --- a/emanote/src/Emanote/CLI.hs +++ b/emanote/src/Emanote/CLI.hs @@ -36,8 +36,8 @@ cliParser cwd = do pure Cli {..} where pathList defaultPath = do - option pathListReader $ - mconcat + option pathListReader + $ mconcat [ long "layers" , short 'L' , metavar "LAYERS" diff --git a/emanote/src/Emanote/Model/Calendar.hs b/emanote/src/Emanote/Model/Calendar.hs index 2a520d385..2988bbfde 100644 --- a/emanote/src/Emanote/Model/Calendar.hs +++ b/emanote/src/Emanote/Model/Calendar.hs @@ -44,9 +44,10 @@ parseRouteDay = -- Day day <- asInt =<< replicateM 2 M.digitChar -- Optional suffix (ignored) - void $ - optional $ do + void + $ optional + $ do void $ M.oneOf ['-', '_', ' '] void M.takeRest - maybe (fail "Not a date") pure $ - fromGregorianValid year (fromInteger month) (fromInteger day) + maybe (fail "Not a date") pure + $ fromGregorianValid year (fromInteger month) (fromInteger day) diff --git a/emanote/src/Emanote/Model/Graph.hs b/emanote/src/Emanote/Model/Graph.hs index efa6a30b4..a78850d87 100644 --- a/emanote/src/Emanote/Model/Graph.hs +++ b/emanote/src/Emanote/Model/Graph.hs @@ -115,10 +115,11 @@ lookupNoteByWikiLink model wl = do modelLookupBacklinks :: R.LMLRoute -> Model -> [(R.LMLRoute, NonEmpty [B.Block])] modelLookupBacklinks r model = - sortOn (Calendar.backlinkSortKey model . fst) $ - groupNE $ - backlinkRels r model <&> \rel -> - (rel ^. Rel.relFrom, rel ^. Rel.relCtx) + sortOn (Calendar.backlinkSortKey model . fst) + $ groupNE + $ backlinkRels r model + <&> \rel -> + (rel ^. Rel.relFrom, rel ^. Rel.relCtx) where groupNE :: forall a b. (Ord a) => [(a, b)] -> [(a, NonEmpty b)] groupNE = diff --git a/emanote/src/Emanote/Model/Link/Rel.hs b/emanote/src/Emanote/Model/Link/Rel.hs index d469c8ebf..a660a2f51 100644 --- a/emanote/src/Emanote/Model/Link/Rel.hs +++ b/emanote/src/Emanote/Model/Link/Rel.hs @@ -67,8 +67,9 @@ noteRels note = where extractLinks :: Map Text (NonEmpty ([(Text, Text)], [B.Block])) -> IxRel extractLinks m = - Ix.fromList $ - flip concatMap (Map.toList m) $ \(url, instances) -> do + Ix.fromList + $ flip concatMap (Map.toList m) + $ \(url, instances) -> do flip mapMaybe (toList instances) $ \(attrs, ctx) -> do let parentR = R.withLmlRoute R.routeParent $ note ^. noteRoute (target, _manchor) <- parseUnresolvedRelTarget parentR attrs url @@ -103,8 +104,8 @@ parseUnresolvedRelTarget baseDir attrs url = do relocateRelUrlUnder :: Maybe FilePath -> FilePath -> FilePath relocateRelUrlUnder mbase fp = - normalizeIgnoringSymlinks $ - case mbase of + normalizeIgnoringSymlinks + $ case mbase of Nothing -> fp Just x -> x fp diff --git a/emanote/src/Emanote/Model/Link/Resolve.hs b/emanote/src/Emanote/Model/Link/Resolve.hs index 9dd39ca5c..f973354ee 100644 --- a/emanote/src/Emanote/Model/Link/Resolve.hs +++ b/emanote/src/Emanote/Model/Link/Resolve.hs @@ -22,8 +22,8 @@ resolveUnresolvedRelTarget model = \case resolveModelRoute model r <&> resourceSiteRoute Rel.URTVirtual virtualRoute -> do - Rel.RRTFound $ - SR.SiteRoute_VirtualRoute + Rel.RRTFound + $ SR.SiteRoute_VirtualRoute virtualRoute resolveWikiLinkMustExist :: diff --git a/emanote/src/Emanote/Model/Note.hs b/emanote/src/Emanote/Model/Note.hs index 120c5b1f1..cc4ea9846 100644 --- a/emanote/src/Emanote/Model/Note.hs +++ b/emanote/src/Emanote/Model/Note.hs @@ -149,8 +149,9 @@ queryNoteTitle r doc meta = getPandocTitle doc R.LMLRoute_Org _ -> getPandocMetaTitle doc - in fromMaybe (doc, fileNameTitle) $ - fmap (doc,) yamlNoteTitle <|> fmap (withoutH1 doc,) notePandocTitle + in fromMaybe (doc, fileNameTitle) + $ fmap (doc,) yamlNoteTitle + <|> fmap (withoutH1 doc,) notePandocTitle where getPandocTitle :: Pandoc -> Maybe Tit.Title getPandocTitle = @@ -208,15 +209,17 @@ ancestorPlaceholderNote r = [ folderListingQuery , -- TODO: Ideally, we should use semantic tags, like