yesod-text-markdown (empty) → 0.1.0.0
raw patch · 4 files changed
+123/−0 lines, 4 filesdep +basedep +hamletdep +markdownsetup-changed
Dependencies added: base, hamlet, markdown, persistent, text, yesod-core, yesod-form
Files
- LICENSE +30/−0
- Setup.hs +2/−0
- Yesod/Text/Markdown.hs +42/−0
- yesod-text-markdown.cabal +49/−0
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2012, Arash Rouhani++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of Arash Rouhani nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ Yesod/Text/Markdown.hs view
@@ -0,0 +1,42 @@+{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE MultiParamTypeClasses #-}+module Yesod.Text.Markdown where++import Yesod.Core (RenderMessage)+import Text.Hamlet (hamlet)+import Yesod.Form+import Yesod.Widget (toWidget)+import Data.Text (Text)+import Data.Text.Lazy (toStrict, fromStrict)+import Text.Markdown (Markdown (Markdown))+import Database.Persist ()+import Database.Persist.Store++instance PersistField Markdown where+ toPersistValue (Markdown t) = PersistText $ toStrict t+ fromPersistValue (PersistText t) = Right $ Markdown $ fromStrict t+ fromPersistValue _ = Left "Not a PersistText value"+ sqlType _ = SqlString+ isNullable _ = False++instance ToField Markdown master where+ toField = areq markdownField++instance ToField (Maybe Markdown) master where+ toField = aopt markdownField++markdownField :: RenderMessage master FormMessage => Field sub master Markdown+markdownField = Field+ { fieldParse = parseHelper $ Right . Markdown . fromStrict+ , fieldView = \theId name attrs val _isReq -> toWidget+ [hamlet|$newline never+<textarea id="#{theId}" name="#{name}" *{attrs}>#{either id extractStrict val}+|]+ }+ where+ extractStrict :: Markdown -> Text+ extractStrict (Markdown lt) = toStrict lt+
+ yesod-text-markdown.cabal view
@@ -0,0 +1,49 @@+name: yesod-text-markdown+version: 0.1.0.0+synopsis: Yesod support for Text.Markdown.+description: The contents of this package is t+ use Text.Markdown in a typical yesod project, that is,+ this module also contains instances related to+ persistence, even though it isn't tightly coupled to+ yesod.+ .+ This package is different from the yesod-markdown package+ which uses the pandoc renderer for markdown. The main+ advantages of having Text.Markdown as underlying renderer+ is the much smaller dependencies and the permissiver+ license. See+ <https://github.com/pbrisbin/yesod-markdown> and+ <https://github.com/snoyberg/markdown>.+ .+ 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+license: BSD3+license-file: LICENSE+author: Arash Rouhani+maintainer: miffoljud@gmail.com+-- copyright:+category: Yesod+build-type: Simple+cabal-version: >=1.8++library+ exposed-modules: Yesod.Text.Markdown+ build-depends: base >= 4 && < 5+ , markdown >= 0.1 && < 1.0+ , yesod-core >= 1.1 && < 2.0+ , yesod-form >= 1.1 && < 2.0+ , persistent >= 1.0 && < 2.0+ , text >= 0.11 && < 1.0+ , hamlet >= 1.1 && < 2.0+ ghc-options: -Wall -fno-warn-orphans++source-repository head+ type: git+ location: git://github.com/Tarrasch/yesod-text-markdown.git