yesod-text-markdown 0.1.8 → 0.1.10
raw patch · 2 files changed
+15/−20 lines, 2 filesdep ~aesondep ~shakespearenew-uploader
Dependency ranges changed: aeson, shakespeare
Files
- Yesod/Text/Markdown.hs +5/−14
- yesod-text-markdown.cabal +10/−6
Yesod/Text/Markdown.hs view
@@ -1,12 +1,9 @@--- | In addition to the exports here we also export these instances for 'Markdown':------ 'PersistField', 'PersistFieldSql', 'ToJSON', 'FromJSON' {-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-}-module Yesod.Text.Markdown (markdownField) where+module Yesod.Text.Markdown where import Yesod.Core (RenderMessage) import Text.Hamlet (hamlet)@@ -14,23 +11,18 @@ import Yesod.Core (HandlerSite) import Yesod.Core.Widget import Yesod.Persist-import Data.Text (Text)+import Data.Text (Text, pack) import Data.Text.Lazy (toStrict, fromStrict) import Text.Markdown (Markdown (Markdown)) import Database.Persist.Sql import Control.Applicative ((<$>)) import Control.Monad (mzero)-import Data.Aeson (ToJSON(toJSON)- , FromJSON(parseJSON)- , (.=)- , (.:)- , object- , Value(Object))+import Data.Aeson instance PersistField Markdown where toPersistValue (Markdown t) = PersistText $ toStrict t fromPersistValue (PersistText t) = Right $ Markdown $ fromStrict t- fromPersistValue _ = Left "Not a PersistText value"+ fromPersistValue wrongValue = Left $ pack $ "Yesod.Text.Markdown: When attempting to create Markdown from a PersistValue, received " ++ show wrongValue ++ " when a value of type PersistText was expected." instance PersistFieldSql Markdown where sqlType _ = SqlString@@ -42,8 +34,7 @@ parseJSON (Object v) = Markdown <$> v .: "markdown" parseJSON _ = mzero --- | Creates a @\<textarea>@ tag whose returned value is wrapped in a--- 'Markdown' newtype; see 'Markdown' for details.+-- | Creates a @\<textarea>@ tag whose returned value is wrapped in a 'Markdown' newtype; see 'Markdown' for details. markdownField :: (Monad m, RenderMessage (HandlerSite m) FormMessage) => Field m Markdown markdownField = Field { fieldParse = parseHelper $ Right . Markdown . fromStrict
yesod-text-markdown.cabal view
@@ -1,5 +1,5 @@ name: yesod-text-markdown-version: 0.1.8+version: 0.1.10 synopsis: Yesod support for Text.Markdown. description: Use Text.Markdown in a typical yesod project. This module contains instances related to persistence,@@ -16,12 +16,16 @@ This package intentionally tries to be like yesod-markdown, so switching between the markdown backends should be easy.+ .+ If you wonder why the haddocks only show a few exports,+ it's because it doesn't show exporting of instances which+ is most of what this package is about. -bug-reports: https://github.com/Tarrasch/yesod-text-markdown/issues+bug-reports: https://github.com/bsima/yesod-text-markdown/issues license: BSD3 license-file: LICENSE author: Arash Rouhani-maintainer: miffoljud@gmail.com+maintainer: ben@bsima.me -- copyright: category: Yesod build-type: Simple@@ -36,10 +40,10 @@ , yesod-persistent >= 1.2 && < 2.0 , persistent >= 1.2 && < 3.0 , text >= 0.11 && < 2.0- , shakespeare >= 2.0 && < 2.1- , aeson >= 0.7 && < 1.0+ , shakespeare >= 2.0 && < 3.0+ , aeson >= 0.7 && < 2.0 ghc-options: -Wall -fno-warn-orphans source-repository head type: git- location: git://github.com/Tarrasch/yesod-text-markdown.git+ location: git://github.com/bsima/yesod-text-markdown.git