markup 4.0.4 → 4.1.0
raw patch · 3 files changed
+133/−59 lines, 3 filesdep +pathdep ~path-extradep ~urlpath
Dependencies added: path
Dependency ranges changed: path-extra, urlpath
Files
- README.md +72/−0
- markup.cabal +55/−54
- src/Data/Markup/Library.hs +6/−5
+ README.md view
@@ -0,0 +1,72 @@+[](https://tldrlegal.com/license/mit-license)+[](https://hackage.haskell.org/package/markup)+[](https://waffle.io/athanclark/markup)++markup+======++> **WARNING**: This project is in it's infancy, please don't expect it to work. +> Thank you :)++A generic interface to chunks of markup.++In this library, we try to ambiguate _types_ of markup via data types, namely +`Image` and `JavaScript` as examples. From here, we can issue a call to +`renderMarkup` on these abstract labels, which will return some markup wrapped +in a monad - in our case, we've made a few monad readers to represent the +different ways a single idea can be deployed as markup.++We have three different deployment schemes - inline, hosted, and local. Inline +markup simply tries to take the information in question and insert it inside the +markup. Hosted markup simply takes the idea and expects it to be somewhere else, +possibly hosted in a CDN. Local markup tries to utilize +[urlpath](https://github.com/athanclark/urlpath) as the means of representing a +local link (absolute, relative, and grounded methods are in another monad - +inside the `HtmlT m ()` of lucid, in this case. Urlpath isn't supported for +Blaze-html.)++## Installation++```bash+cabal install markup+```++## Usage++It's a little awkward at the moment:++```haskell+image' = renderMarkup Image :: Monad m => HostedMarkupT m T.Text (Html ())++image = runHostedMarkupT image' "foo.png"++λ> renderText image++<img src="foo.png">+```++We could also overload the `run*` monad transformer actions of each deployment +scheme, allowing for the decision to be made just with a type coersion. Maybe in +v0.0.2 :)++Here is the same example, going relative instead:++```haskell+image' = renderMarkup Image :: (Monad m, Url UrlString AbsoluteUrl) => LocalMarkupT UrlString m (HtmlT AbsoluteUrl ())++λ> (runUrlReader $ renderTextT $ runIdentity $ runLocalMarkupT image' $+ "foo.png" <?> ("key","bar")+ ) "example.com"++"<img src=\"example.com/foo.png?key=bar\">"+```++## How to run tests++```+cabal configure --enable-tests && cabal build && cabal test+```++## Contributing++Fork, PR, repeat.
markup.cabal view
@@ -1,57 +1,58 @@-Name: markup-Version: 4.0.4-Author: Athan Clark <athan.clark@gmail.com>-Maintainer: Athan Clark <athan.clark@gmail.com>-License: MIT-License-File: LICENSE-Category: Data, Web-Synopsis: Abstraction for HTML-embedded content-Description:- This library tries to simplify deployment of common HTML constructs, for different- HTML engines.- .- Deployment, from this library's perspective, means /how/ something can be- rendered to markup, yet still achieve the same "result" to the end user (namely- the DOM). For instance, we could use a @<link>@ tag to reference external Css,- or we might insert the Css code /inline/ a @<style>@ tag.- .- We use simple tags to infer the deployment mechanism for a context of- markup. The three deployment mechanisms provided include- .- * /inline/ - the asset inserted between markup tags- .- * /local/ - assets on the current server- .- * /remote/ - assets referenced with a complete URI+-- This file has been generated from package.yaml by hpack version 0.21.2.+--+-- see: https://github.com/sol/hpack+--+-- hash: 45b0f98e3a9331ec8258b012b71e0b2cbf744c7de6dca7b6af520a07502f401e -Cabal-Version: >= 1.10-Build-Type: Simple+name: markup+version: 4.1.0+synopsis: Abstraction for HTML-embedded content+description: Please see the README on Github at <https://github.com/githubuser/markup#readme>+category: Data, Web+homepage: https://github.com/athanclark/markup#readme+bug-reports: https://github.com/athanclark/markup/issues+author: Athan Clark+maintainer: athan.clark@localcooking.com+copyright: Copyright (c) 2018 Athan Clark+license: BSD3+license-file: LICENSE+build-type: Simple+cabal-version: >= 1.10 -Library- Default-Language: Haskell2010- HS-Source-Dirs: src- GHC-Options: -Wall- Exposed-Modules: Data.Markup- Data.Markup.Types- Data.Markup.Class- Data.Markup.Library- Build-Depends: base >= 4.8 && < 5- , attoparsec-uri >= 0.0.4- , blaze-html- , blaze-markup- , comonad- , clay- , lucid >= 2.5- , mmorph- , monad-control- , monad-logger- , mtl- , path-extra >= 0.0.6- , resourcet- , text- , transformers-base- , urlpath >= 7.1.0+extra-source-files:+ README.md -Source-Repository head- Type: git- Location: https://github.com/athanclark/markup.git+source-repository head+ type: git+ location: https://github.com/athanclark/markup++library+ exposed-modules:+ Data.Markup+ Data.Markup.Class+ Data.Markup.Library+ Data.Markup.Types+ other-modules:+ Paths_markup+ hs-source-dirs:+ src+ ghc-options: -Wall+ build-depends:+ attoparsec-uri >=0.0.4+ , base >=4.8 && <5+ , blaze-html+ , blaze-markup+ , clay+ , comonad+ , lucid >=2.5+ , mmorph+ , monad-control+ , monad-logger+ , mtl+ , path+ , path-extra >=0.1.2+ , resourcet+ , text+ , transformers-base+ , urlpath >=8.2.0+ default-language: Haskell2010
src/Data/Markup/Library.hs view
@@ -21,12 +21,13 @@ module Data.Markup.Library where -import Data.Markup.Class-import Data.Markup.Types+import Data.Markup.Class (Deploy (deploy))+import Data.Markup.Types (Inline (..), Remote (..), Locally (..)) -import Data.Url+import Data.Url (MonadUrl (locUrl, pathUrl), RelativeUrlT, GroundedUrlT, AbsoluteUrlT) import Data.URI (printURI)-import Path.Extended+import Path (Path, Abs, Rel)+import Path.Extended (Location) import qualified Lucid as L import qualified Text.Blaze.Html5 as H@@ -36,7 +37,7 @@ import qualified Data.Text as T import qualified Data.Text.Lazy as LT-import Control.Monad.Trans+import Control.Monad.Trans (MonadTrans (lift)) data Image = Image deriving (Show, Eq)