lucid-xstatic (empty) → 0.1.0
raw patch · 4 files changed
+107/−0 lines, 4 filesdep +basedep +luciddep +text
Dependencies added: base, lucid, text, xstatic
Files
- CHANGELOG.md +5/−0
- LICENSE +29/−0
- lucid-xstatic.cabal +39/−0
- src/Lucid/XStatic.hs +34/−0
+ CHANGELOG.md view
@@ -0,0 +1,5 @@+# Changelog++## 0.1.0++- Initial release
+ LICENSE view
@@ -0,0 +1,29 @@+BSD 3-Clause License++Copyright (c) 2022, Tristan de Cacqueray+All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++1. Redistributions of source code must retain the above copyright notice, this+ list of conditions and the following disclaimer.++2. 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.++3. Neither the name of the copyright holder nor the names of its+ 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 HOLDER 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.
+ lucid-xstatic.cabal view
@@ -0,0 +1,39 @@+cabal-version: 1.12++-- This file has been generated from package.yaml by hpack version 0.35.0.+--+-- see: https://github.com/sol/hpack++name: lucid-xstatic+version: 0.1.0+synopsis: Lucid helper for XStatic+description: Use this library to add XStaticFile to your Html.+category: JavaScript+homepage: https://github.com/TristanCacqueray/haskell-xstatic#readme+bug-reports: https://github.com/TristanCacqueray/haskell-xstatic/issues+author: Tristan Cacqueray+maintainer: tdecacqu@redhat.com+license: BSD3+license-file: LICENSE+build-type: Simple+extra-source-files:+ CHANGELOG.md++source-repository head+ type: git+ location: https://github.com/TristanCacqueray/haskell-xstatic++library+ exposed-modules:+ Lucid.XStatic+ other-modules:+ Paths_lucid_xstatic+ hs-source-dirs:+ src/+ ghc-options: -Weverything -Wno-implicit-prelude -Wno-missing-import-lists -Wno-missing-safe-haskell-mode -Wno-unsafe+ build-depends:+ base <5+ , lucid+ , text+ , xstatic+ default-language: Haskell2010
+ src/Lucid/XStatic.hs view
@@ -0,0 +1,34 @@+{-# LANGUAGE OverloadedStrings #-}++{- | Add XStaticFile to Html document.++@+indexHtml :: Html ()+indexHtml = do+ doctypehtml_ do+ head_ do+ meta_ [charset_ "utf-8"]+ meta_ [name_ "viewport", content_ "width=device-width, initial-scale=1.0"]+ xstaticScripts xfiles+ where+ xfiles = XStatic.htmx : XStatic.xterm+@+-}+module Lucid.XStatic (xstaticScripts) where++import Data.Foldable (traverse_)+import Data.Text.Encoding+import Lucid+import XStatic++-- | Adds 'script_' and 'link_' for javascript and css files.+xstaticScripts :: [XStaticFile] -> Html ()+xstaticScripts = traverse_ xrender+ where+ xrender :: XStaticFile -> Html ()+ xrender xf =+ let src = "/xstatic" <> decodeUtf8 (xfPath xf)+ in case xfType xf of+ "application/javascript" -> with (script_ mempty) [src_ src]+ "text/css" -> link_ [href_ src, rel_ "stylesheet"]+ _ -> pure ()