diff --git a/lucid-colonnade/LICENSE b/lucid-colonnade/LICENSE new file mode 100644 index 0000000..9beb3f9 --- /dev/null +++ b/lucid-colonnade/LICENSE @@ -0,0 +1,30 @@ +Copyright Andrew Martin (c) 2016 + +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 Andrew Martin 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. \ No newline at end of file diff --git a/lucid-colonnade/Setup.hs b/lucid-colonnade/Setup.hs new file mode 100644 index 0000000..9a994af --- /dev/null +++ b/lucid-colonnade/Setup.hs @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain diff --git a/lucid-colonnade/lucid-colonnade.cabal b/lucid-colonnade/lucid-colonnade.cabal new file mode 100644 index 0000000..39bb4e4 --- /dev/null +++ b/lucid-colonnade/lucid-colonnade.cabal @@ -0,0 +1,28 @@ +name: lucid-colonnade +version: 1.0 +synopsis: Helper functions for using lucid with colonnade +description: Lucid and colonnade +homepage: https://github.com/andrewthad/colonnade#readme +license: BSD3 +license-file: LICENSE +author: Andrew Martin +maintainer: andrew.thaddeus@gmail.com +copyright: 2017 Andrew Martin +category: web +build-type: Simple +cabal-version: >=1.10 + +library + hs-source-dirs: src + exposed-modules: + Lucid.Colonnade + build-depends: + base >= 4.7 && < 5 + , colonnade >= 1.1 && < 1.3 + , lucid >= 2.9 && < 3.0 + , text >= 1.0 && < 1.3 + default-language: Haskell2010 + +source-repository head + type: git + location: https://github.com/andrewthad/colonnade diff --git a/lucid-colonnade/src/Lucid/Colonnade.hs b/lucid-colonnade/src/Lucid/Colonnade.hs new file mode 100644 index 0000000..600b99e --- /dev/null +++ b/lucid-colonnade/src/Lucid/Colonnade.hs @@ -0,0 +1,193 @@ +{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeFamilies #-} + +-- | Build HTML tables using @lucid@ and @colonnade@. It is +-- recommended that users read the documentation for @colonnade@ first, +-- since this library builds on the abstractions introduced there. +-- Also, look at the docs for @blaze-colonnade@. These two +-- libraries are similar, but blaze offers an HTML pretty printer +-- which makes it possible to doctest examples. Since lucid +-- does not offer such facilities, examples are omitted here. +module Lucid.Colonnade + ( -- * Apply + encodeHtmlTable + , encodeCellTable + , encodeTable + -- * Cell + -- $build + , Cell(..) + , htmlCell + , stringCell + , textCell + , lazyTextCell + , builderCell + , htmlFromCell + -- * Discussion + -- $discussion + ) where + +import Colonnade (Colonnade,Headed,Headless,Fascia,Cornice) +import Data.Text (Text) +import Control.Monad +import Data.Monoid +import Data.Foldable +import Data.String (IsString(..)) +import Data.Maybe (listToMaybe) +import Data.Char (isSpace) +import Control.Applicative (liftA2) +import Lucid +import qualified Data.List as List +import qualified Colonnade.Encode as E +import qualified Data.Text as Text +import qualified Data.Text.Lazy as LText +import qualified Data.Text.Lazy.Builder as TBuilder + +-- $build +-- +-- The 'Cell' type is used to build a 'Colonnade' that +-- has 'Html' content inside table cells and may optionally +-- have attributes added to the @\
| @ and the row +-- content the child of a @\ | @. However, it is not possible +-- to add attributes to these parent elements. To accomodate this +-- situation, it is necessary to introduce 'Cell', which includes +-- the possibility of attributes on the parent node. + + diff --git a/stack.yaml b/stack.yaml index a8113eb..e9b0485 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,44 +1,9 @@ -# This file was automatically generated by 'stack init' -# -# Some commonly used options have been documented as comments in this file. -# For advanced use and comprehensive documentation of the format, please see: -# http://docs.haskellstack.org/en/stable/yaml_configuration/ - -# Resolver to choose a 'specific' stackage snapshot or a compiler version. -# A snapshot resolver dictates the compiler version and the set of packages -# to be used for project dependencies. For example: -# -# resolver: lts-3.5 -# resolver: nightly-2015-09-21 -# resolver: ghc-7.10.2 -# resolver: ghcjs-0.1.0_ghc-7.10.2 -# resolver: -# name: custom-snapshot -# location: "./custom-snapshot.yaml" resolver: lts-8.0 - -# User packages to be built. -# Various formats can be used as shown in the example below. -# -# packages: -# - some-directory -# - https://example.com/foo/bar/baz-0.0.2.tar.gz -# - location: -# git: https://github.com/commercialhaskell/stack.git -# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a -# - location: https://github.com/commercialhaskell/stack/commit/e7b331f14bcffb8367cd58fbfc8b40ec7642100a -# extra-dep: true -# subdirs: -# - auto-update -# - wai -# -# A package marked 'extra-dep: true' will only be built if demanded by a -# non-dependency (i.e. a user package), and its test suites and benchmarks -# will not be run. This is useful for tweaking upstream packages. packages: - 'colonnade' - 'yesod-colonnade' - 'blaze-colonnade' +- 'lucid-colonnade' - 'siphon' # - 'geolite-csv' # Dependency packages to be pulled from upstream that are not in the resolver |
|---|