Skip to content

Commit

Permalink
Change Tag internal representation to FilePath
Browse files Browse the repository at this point in the history
  • Loading branch information
felko committed Apr 19, 2020
1 parent 13eb406 commit 8cc0f64
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/Neuron/Web/View.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import Neuron.Zettelkasten.Link.View (neuronLinkExt, renderZettelLink)
import Neuron.Zettelkasten.Markdown (neuronMMarkExts)
import Neuron.Zettelkasten.Query
import Neuron.Zettelkasten.Store
import Neuron.Zettelkasten.Tag (Tag (..))
import Neuron.Zettelkasten.Tag
import Neuron.Zettelkasten.Zettel
import Relude
import qualified Rib
Expand Down Expand Up @@ -189,16 +189,16 @@ renderBrandFooter withVersion =

renderTags :: Monad m => [Tag] -> HtmlT m ()
renderTags tags = do
forM_ tags $ \tag -> do
forM_ tags $ \(tagToText -> tag) -> do
-- TODO: Ideally this should be at the top, not bottom. But putting it at
-- the top pushes the zettel content down, introducing unnecessary white
-- space below the title. So we put it at the bottom for now.
span_ [class_ "ui black right ribbon label", title_ "Tag"] $ do
a_
[ href_ $ routeUrlRelWithQuery Route_Search [queryKey|tag|] (unTag tag),
title_ ("See all zettels tagged '" <> unTag tag <> "'")
[ href_ $ routeUrlRelWithQuery Route_Search [queryKey|tag|] tag,
title_ ("See all zettels tagged '" <> tag <> "'")
]
$ toHtml (unTag tag)
$ toHtml tag
p_ mempty

-- | Font awesome element
Expand Down
4 changes: 2 additions & 2 deletions src/Neuron/Zettelkasten/Link/View.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import Neuron.Zettelkasten.Link.Theme (LinkTheme (..))
import Neuron.Zettelkasten.Markdown (MarkdownLink (..))
import Neuron.Zettelkasten.Query
import Neuron.Zettelkasten.Store
import Neuron.Zettelkasten.Tag (Tag (unTag))
import Neuron.Zettelkasten.Tag (tagToText)
import Neuron.Zettelkasten.Zettel
import Relude
import qualified Rib
Expand Down Expand Up @@ -68,7 +68,7 @@ renderNeuronLink store = \case
toHtml $ Some q
let tags = runQuery store q
ul_ $ do
forM_ tags $ \(unTag -> tag) -> do
forM_ tags $ \(tagToText -> tag) -> do
let tagUrl = routeUrlRelWithQuery Route_Search [queryKey|tag|] tag
li_ $ a_ [href_ tagUrl] $ toHtml tag

Expand Down
10 changes: 9 additions & 1 deletion src/Neuron/Zettelkasten/Tag.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

module Neuron.Zettelkasten.Tag
( Tag (..),
mkTag,
tagToText,
TagPattern (unTagPattern),
mkTagPattern,
tagMatch,
Expand All @@ -15,9 +17,15 @@ import Data.Aeson
import Relude
import System.FilePattern

newtype Tag = Tag {unTag :: Text}
newtype Tag = Tag {unTag :: FilePath}
deriving (Eq, Ord, Show, ToJSON, FromJSON)

mkTag :: Text -> Tag
mkTag = Tag . toString

tagToText :: Tag -> Text
tagToText = toText . unTag

newtype TagPattern = TagPattern {unTagPattern :: FilePattern}
deriving (Eq, Show)

Expand Down

0 comments on commit 8cc0f64

Please sign in to comment.