shakebook 0.7.1.0 → 0.7.2.0
raw patch · 5 files changed
+34/−31 lines, 5 filesdep ~aeson-with
Dependency ranges changed: aeson-with
Files
- ChangeLog.md +4/−0
- shakebook.cabal +4/−4
- src/Shakebook/Conventions.hs +15/−16
- src/Shakebook/Pandoc.hs +6/−6
- test/Spec.hs +5/−5
ChangeLog.md view
@@ -1,5 +1,9 @@ # Changelog for Shakebook +## (v0.7.2.0)++* Upgrade to [aeson-with](https://hackage.haskell.org/package/aeson-with) v0.1.1.0.+ ## (v0.7.1.0) * Upgrade to [zipper-extra](https://hackage.haskell.org/package/zipper-extra) v0.1.3.0.
shakebook.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 3fd5dfe9c0ad89666b06e7a79e4f378fa824b3670c6416345ba0f3af5518c5cc+-- hash: 0ed9b385c04cfae22cd6f8586c6fd4b3659a7a6697ffaba9679d0823ca37c3a9 name: shakebook-version: 0.7.1.0+version: 0.7.2.0 synopsis: Shake-based technical documentation generator; HTML & PDF description: Shakebook is a documentation generator aimed at covering all the bases for mathematical, technical and scientific diagrams and typesetting. Shakebook provides combinators for taking markdown files and combining them into documents, but allowing the user to control how. Shakebook provides general combinators for templating single pages, cofree comonads for representing tables of contents, and zipper comonads for representing pagers. category: Web@@ -37,7 +37,7 @@ ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints build-depends: aeson >=1.5.2.0- , aeson-with >=0.1.0.0+ , aeson-with >=0.1.1.0 , base >=4.7 && <5 , comonad , comonad-extras@@ -70,7 +70,7 @@ ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N build-depends: aeson >=1.5.2.0- , aeson-with >=0.1.0.0+ , aeson-with >=0.1.1.0 , base >=4.7 && <5 , comonad , comonad-extras
src/Shakebook/Conventions.hs view
@@ -6,7 +6,6 @@ viewImage , viewPostTime , viewPostTimeRaw-, viewSrcPath , viewTags , viewTitle , viewAllPostTags@@ -78,31 +77,31 @@ import Text.Pandoc.Highlighting -- | View the "image" field of a JSON value.-viewImage :: Value -> Text-viewImage = view (key "image" . _String)+viewImage :: ToJSON a => a -> Text+viewImage = view' (key "image" . _String) -- | View the "date" field of a JSON Value as a UTCTime.-viewPostTime :: Value -> UTCTime-viewPostTime = parseISODateTime . view (key "date" . _String)+viewPostTime :: ToJSON a => a -> UTCTime+viewPostTime = parseISODateTime . view' (key "date" . _String) -- | View the "date" field of a JSON Value as Text.-viewPostTimeRaw :: Value -> Text-viewPostTimeRaw = view (key "date" . _String)+viewPostTimeRaw :: ToJSON a => a -> Text+viewPostTimeRaw = view' (key "date" . _String) -- | View the "tags" field of a JSON Value as a list.-viewTags :: Value -> [Text]-viewTags = toListOf (key "tags" . values . _String)+viewTags :: ToJSON a => a -> [Text]+viewTags = toListOf' (key "tags" . values . _String) -- | View the "title" field of a JSON Value.-viewTitle :: Value -> Text-viewTitle = view (key "title" . _String)+viewTitle :: ToJSON a => a -> Text+viewTitle = view' (key "title" . _String) -- | View all post tags for a list of posts.-viewAllPostTags :: [Value] -> [Text]+viewAllPostTags :: ToJSON a => [a] -> [Text] viewAllPostTags = (>>= viewTags) -- | View all posts times for a list of posts.-viewAllPostTimes :: [Value] -> [UTCTime]+viewAllPostTimes :: ToJSON a => [a] -> [UTCTime] viewAllPostTimes = fmap viewPostTime -- | Add "base-url" field from input Text.@@ -264,14 +263,14 @@ object ["toc1" A..= [_Object . at "toc2" ?~ Array (V.fromList $ map toc2 xs) $ x]] where toc2 (y :< ys) = (_Object . at "toc3" ?~ Array (V.fromList $ map extract ys)) y -genPageData :: Text -> (Text -> Text) -> Zipper [] [Value] -> Value+genPageData :: ToJSON a => Text -> (Text -> Text) -> Zipper [] [a] -> Value genPageData t f xs = let x = T.pack . show $ pos xs + 1 in withTitle t . withJSON (genLinkData x (f x)) . withPosts (extract xs) $ Object mempty -genIndexPageData :: MonadThrow m- => [Value]+genIndexPageData :: (MonadThrow m, ToJSON a)+ => [a] -> Text -> (Text -> Text) -> Int
src/Shakebook/Pandoc.hs view
@@ -109,24 +109,24 @@ flattenMeta opts meta = liftAction $ Slick.Pandoc.flattenMeta opts meta -- | View the "content" field of a JSON value.-viewContent :: Value -> Text-viewContent = view (key "content" . _String)+viewContent :: ToJSON a => a -> Text+viewContent = view' (key "content" . _String) -- | Add "content" field from input Text. withContent :: Text -> Value -> Value withContent = withStringField "content" -- | View the "src-path" field of a JSON Value.-viewSrcPath :: Value -> Text-viewSrcPath = view (key "src-path" . _String)+viewSrcPath :: ToJSON a => a -> Text+viewSrcPath = view' (key "src-path" . _String) -- | Add "src-path" field based on input Text. withSrcPath :: Text -> Value -> Value withSrcPath = withStringField "src-path" -- | View the "url" field of a JSON Value.-viewUrl :: Value -> Text-viewUrl = view (key "url" . _String)+viewUrl :: ToJSON a => a -> Text+viewUrl = view' (key "url" . _String) -- | Add "url" field from input Text. withUrl :: Text -> Value -> Value
test/Spec.hs view
@@ -64,12 +64,12 @@ blogIndexPageData <- newCache $ \fp -> do xs <- postsIx fp- genIndexPageData (unPost <$> Ix.toList xs) "Posts" ("/posts/pages/" <>) postsPerPage+ genIndexPageData (Ix.toList xs) "Posts" ("/posts/pages/" <>) postsPerPage blogTagIndexPageData <- newCache $ \fp -> do xs <- postsIx fp k <- forM (Ix.groupDescBy xs) $ \(Tag t, ys) -> do- z <- genIndexPageData (unPost <$> ys) ("Posts tagged " <> t) (("/posts/tags/" <> t <> "/pages/") <>) postsPerPage+ z <- genIndexPageData ys ("Posts tagged " <> t) (("/posts/tags/" <> t <> "/pages/") <>) postsPerPage return (t, z) return $ HM.fromList k @@ -77,7 +77,7 @@ xs <- postsIx fp k <- forM (Ix.groupDescBy xs) $ \(YearMonth (y,m), ys) -> do let t' = UTCTime (fromGregorian y m 1) 0- z <- genIndexPageData (unPost <$> ys)+ z <- genIndexPageData ys (("Posts from " <>) . defaultPrettyMonthFormat $ t') (("/posts/months/" <> defaultMonthUrlFormat t' <> "/pages/") <>) postsPerPage@@ -113,8 +113,8 @@ o' "posts/*.html" %^> \out -> do src <- blinkAndMapM sourceFolder withMdExtension out xs <- postsZ myPosts- xs' <- seekOnThrow (viewSrcPath . unPost) (T.pack . toFilePath . extract $ src) xs- myBuildBlogPage $(mkRelFile "templates/post.html") (extract (unPost <$> xs')) out+ xs' <- seekOnThrow viewSrcPath (T.pack . toFilePath . extract $ src) xs+ myBuildBlogPage $(mkRelFile "templates/post.html") (toJSON $ extract xs') out toc' <- mapM (mapM withHtmlExtension) $ fmap o' tableOfContents void . sequence . flip extend toc' $ \xs -> (toFilePath <$> extract xs) %^> \out -> do