From 370478e7e227c77dc0f58af2730d1daa9e749885 Mon Sep 17 00:00:00 2001 From: clojj Date: Sat, 15 Aug 2020 23:26:47 +0200 Subject: [PATCH 01/16] Ok... new with Day --- neuron/src/app/Neuron/CLI/New.hs | 4 +- neuron/src/app/Neuron/CLI/Types.hs | 4 +- neuron/src/app/Neuron/Reader/Org.hs | 5 +- neuron/src/app/Neuron/Web/View.hs | 2 +- neuron/src/lib/Neuron/Web/Query/View.hs | 2 +- neuron/src/lib/Neuron/Web/Widget.hs | 5 +- neuron/src/lib/Neuron/Web/Zettel/View.hs | 2 +- neuron/src/lib/Neuron/Zettelkasten/Zettel.hs | 6 +-- .../lib/Neuron/Zettelkasten/Zettel/Meta.hs | 47 ++++++++++++++----- .../lib/Neuron/Zettelkasten/Zettel/Parser.hs | 7 +-- 10 files changed, 53 insertions(+), 31 deletions(-) diff --git a/neuron/src/app/Neuron/CLI/New.hs b/neuron/src/app/Neuron/CLI/New.hs index 35e8a365d..4d5157f07 100644 --- a/neuron/src/app/Neuron/CLI/New.hs +++ b/neuron/src/app/Neuron/CLI/New.hs @@ -24,7 +24,7 @@ import Neuron.Web.Generate as Gen import Neuron.Zettelkasten.ID (zettelIDSourceFileName) import qualified Neuron.Zettelkasten.ID.Scheme as IDScheme import Neuron.Zettelkasten.Zettel (zettelID) -import Neuron.Zettelkasten.Zettel.Meta (formatZettelDate) +import Neuron.Zettelkasten.Zettel.Meta (formatZettelDay) import Options.Applicative import Relude import Rib.Shake (ribInputDir) @@ -105,6 +105,6 @@ defaultZettelContent format day mtitle = case format of "\n" ] where - date = formatZettelDate day + date = formatZettelDay day defaultTitleName = "Zettel created on " <> date title = maybe defaultTitleName T.strip mtitle diff --git a/neuron/src/app/Neuron/CLI/Types.hs b/neuron/src/app/Neuron/CLI/Types.hs index 6db648b77..8f9a65184 100644 --- a/neuron/src/app/Neuron/CLI/Types.hs +++ b/neuron/src/app/Neuron/CLI/Types.hs @@ -32,7 +32,7 @@ import qualified Neuron.Zettelkasten.Query.Error as Q import Neuron.Zettelkasten.Query.Graph as Q import qualified Neuron.Zettelkasten.Query.Parser as Q import Neuron.Zettelkasten.Zettel as Q -import Neuron.Zettelkasten.Zettel.Meta (parseZettelDate) +import Neuron.Zettelkasten.Zettel.Meta (parseZettelDay) import Options.Applicative import Relude import qualified Rib.Cli @@ -228,4 +228,4 @@ commandParser defaultNotesDir today = do Left $ displayException e dayReader :: ReadM Day dayReader = - maybeReader (parseZettelDate . toText) + maybeReader (parseZettelDay . toText) diff --git a/neuron/src/app/Neuron/Reader/Org.hs b/neuron/src/app/Neuron/Reader/Org.hs index afbcccf24..3e86a8bb1 100644 --- a/neuron/src/app/Neuron/Reader/Org.hs +++ b/neuron/src/app/Neuron/Reader/Org.hs @@ -16,9 +16,8 @@ import qualified Data.Map as Map import Data.TagTree (Tag (Tag)) import Data.Tagged import Data.Text (toLower) -import Data.Time.Calendar (Day) import Neuron.Reader.Type (ZettelParseError, ZettelReader) -import Neuron.Zettelkasten.Zettel.Meta (Meta (..), parseZettelDate) +import Neuron.Zettelkasten.Zettel.Meta (DateMayTime, Meta (..), parseZettelDate) import Relude import Relude.Extra.Map (lookup) import Text.Pandoc (def, runPure) @@ -44,7 +43,7 @@ extractMetadata doc pure $ Just Meta {..} | otherwise = pure Nothing where - parseDate :: Text -> Either ZettelParseError Day + parseDate :: Text -> Either ZettelParseError DateMayTime parseDate date = maybeToRight (Tagged $ "Invalid date format: " <> date) $ parseZettelDate @Maybe date parseUnlisted :: Text -> Bool diff --git a/neuron/src/app/Neuron/Web/View.hs b/neuron/src/app/Neuron/Web/View.hs index 44d08b3a8..ac82d5b01 100644 --- a/neuron/src/app/Neuron/Web/View.hs +++ b/neuron/src/app/Neuron/Web/View.hs @@ -153,7 +153,7 @@ renderSearch graph script = do [ "id" .= toJSON zettelID, "title" .= zettelTitle, "tags" .= zettelTags, - "day" .= zettelDay + "day" .= zettelDate ] renderBrandFooter :: DomBuilder t m => Maybe Text -> m () diff --git a/neuron/src/lib/Neuron/Web/Query/View.hs b/neuron/src/lib/Neuron/Web/Query/View.hs index 3b1960771..f2edefc4b 100644 --- a/neuron/src/lib/Neuron/Web/Query/View.hs +++ b/neuron/src/lib/Neuron/Web/Query/View.hs @@ -104,7 +104,7 @@ renderZettelLink conn (fromMaybe def -> linkView) Zettel {..} = do LinkView_Default -> Nothing LinkView_ShowDate -> - elTime <$> zettelDay + elTime <$> zettelDate LinkView_ShowID -> Just $ el "tt" $ text $ zettelIDText zettelID classes :: [Text] = catMaybes $ [Just "zettel-link-container"] <> [connClass, rawClass] diff --git a/neuron/src/lib/Neuron/Web/Widget.hs b/neuron/src/lib/Neuron/Web/Widget.hs index a4847c8cd..235525f30 100644 --- a/neuron/src/lib/Neuron/Web/Widget.hs +++ b/neuron/src/lib/Neuron/Web/Widget.hs @@ -5,13 +5,12 @@ module Neuron.Web.Widget where import qualified Data.Text as T -import Data.Time -import Neuron.Zettelkasten.Zettel.Meta (formatZettelDate) +import Neuron.Zettelkasten.Zettel.Meta (DateMayTime, formatZettelDate) import Reflex.Dom.Core import Relude -- |