lucid-extras 0.2.1 → 0.2.2
raw patch · 3 files changed
+53/−12 lines, 3 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Lucid.Leaflet: data TileLayerProperties
- Lucid.Leaflet: mapElementToJS :: LMapElement -> Text
+ Lucid.Leaflet: instance GHC.Classes.Eq Lucid.Leaflet.LMap
+ Lucid.Leaflet: instance GHC.Classes.Eq Lucid.Leaflet.LMapElement
+ Lucid.Leaflet: instance GHC.Classes.Eq Lucid.Leaflet.TileLayerProperties
+ Lucid.Leaflet: instance GHC.Show.Show Lucid.Leaflet.LMap
+ Lucid.Leaflet: instance GHC.Show.Show Lucid.Leaflet.LMapElement
+ Lucid.Leaflet: instance GHC.Show.Show Lucid.Leaflet.TileLayerProperties
+ Lucid.Leaflet: newtype TileLayerProperties
Files
- lib/Lucid/Leaflet.hs +30/−6
- lib/Lucid/VegaLite.hs +19/−2
- lucid-extras.cabal +4/−4
lib/Lucid/Leaflet.hs view
@@ -1,7 +1,26 @@-{-# LANGUAGE OverloadedStrings, StandaloneDeriving, DeriveGeneric #-}+{-# LANGUAGE OverloadedStrings, DeriveGeneric #-}+{-|+Module : Lucid.Leaflet+Description : LeafletJS bindings+Copyright : (c) Tom Nielsen, Marco Zocca, 2019+License : GPL-3+Maintainer : ocramz fripost org+Stability : experimental+Portability : POSIX -module Lucid.Leaflet where+Bindings to the LeafletJS map API. +See https://leafletjs.com/ for usage details+-}+module Lucid.Leaflet (+ -- * CDN declarations+ leafletCDN, leafletCssCDN,+ -- * Utilities+ leafletMap, osmTileLayer,+ -- * Types+ LMap(..), LMapElement(..), TileLayerProperties(..)+ ) where+ import qualified Data.Aeson as Aeson import qualified Data.ByteString.Lazy as BSL import Lucid@@ -11,17 +30,20 @@ import Data.Monoid import GHC.Generics +++-- | Statement for embedding the LeafletJS javascript blob. leafletCDN :: Monad m => HtmlT m () leafletCDN = scriptSrc "https://unpkg.com/leaflet@1.2.0/dist/leaflet.js" -data LMap = LMap T.Text | SetView (Double, Double) Double LMap+data LMap = LMap T.Text | SetView (Double, Double) Double LMap deriving (Eq, Show) data LMapElement = TileLayer T.Text TileLayerProperties | Marker (Double, Double)- | BindPopup T.Text LMapElement + | BindPopup T.Text LMapElement deriving (Eq, Show) -data TileLayerProperties = TileLayerProperties { attribution :: T.Text } deriving (Generic)+newtype TileLayerProperties = TileLayerProperties { attribution :: T.Text } deriving (Eq, Show, Generic) instance Aeson.ToJSON TileLayerProperties mapElementToJS :: LMapElement -> T.Text@@ -33,17 +55,19 @@ g = T.decodeUtf8 . BSL.toStrict . Aeson.encode -+-- | OpenStreetMap tile layer osmTileLayer :: LMapElement osmTileLayer = TileLayer "http://{s}.tile.osm.org/{z}/{x}/{y}.png" $ TileLayerProperties "© <a href=\"http://osm.org/copyright\">OpenStreetMap</a> contributors" +-- | Statement for embedding the LeafletJS CSS stylesheet. leafletCssCDN :: Monad m => HtmlT m () leafletCssCDN = link_ [rel_ "stylesheet", href_ "https://unpkg.com/leaflet@1.2.0/dist/leaflet.css"] +-- | @\<SCRIPT\>@ section that declares a LeafletJS map leafletMap :: Monad m => LMap -> [LMapElement] -> HtmlT m () leafletMap mp elms = script_ $ writeMap mp <> writeElems elms where writeMap m = "\nvar lmap = " <> writeMap' m <> ";"
lib/Lucid/VegaLite.hs view
@@ -1,6 +1,23 @@ {-# language OverloadedStrings, ExtendedDefaultRules #-}-module Lucid.VegaLite (vegaEmbedHead, vegaEmbedBodyScript, mkVegaHtml) where+{-|+Module : Lucid.VegaLite+Description : Vega-lite bindings+Copyright : (c) Tom Nielsen, Marco Zocca, 2019+License : GPL-3+Maintainer : ocramz fripost org+Stability : experimental+Portability : POSIX +Bindings to the vega-lite visualization and infographics API.++See https://vega.github.io/ for usage details+-}+module Lucid.VegaLite (+ -- * Standalone+ mkVegaHtml+ -- * Utilities+ , vegaEmbedHead, vegaEmbedBodyScript) where+ import Lucid import Lucid.PreEscaped (scriptSrc) @@ -18,7 +35,7 @@ vegaLiteCDN = scriptSrc "https://cdn.jsdelivr.net/npm/vega-lite@2.5.0" vegaEmbedCDN = scriptSrc "https://cdn.jsdelivr.net/npm/vega-embed@3" --- | Construct a HTML page that can render a vega-lite plot. The plot will be rendered by the vega-embed library.+-- | Construct a standalone HTML page that can render a vega-lite plot. The plot will be rendered by the vega-embed library. -- -- NB: the 'A.Value' parameter must contain a vega-lite JSON payload mkVegaHtml :: A.Value -> Html ()
lucid-extras.cabal view
@@ -1,6 +1,6 @@ cabal-version: >=1.10 name: lucid-extras-version: 0.2.1+version: 0.2.2 license: MIT license-file: LICENSE maintainer: Marco Zocca <ocramz fripost org>@@ -8,10 +8,10 @@ tested-with: ghc ==7.10.2 ghc ==7.10.3 ghc ==8.0.1 ghc ==8.0.2 homepage: https://github.com/diffusionkinetics/open/lucid-extras bug-reports: https://github.com/diffusionkinetics/open/issues-synopsis: Generate more HTML with Lucid+synopsis: Generate more HTML with Lucid - Bootstrap, Rdash, Vega-Lite, Leaflet JS, Email. description:- Generate more HTML with Lucid - Bootstrap, Rdash, Vega-Lite, Email.-category: Web+ Generate more HTML with Lucid - Bootstrap, Rdash, Vega-Lite, Leaflet JS, Email. Provides functions to generate rich web page elements for infographics, geographical maps, and more.+category: Web, Graphics build-type: Simple extra-source-files: changelog.md