packages feed

hakyll-elm (empty) → 0.1

raw patch · 4 files changed

+124/−0 lines, 4 filesdep +Elmdep +basedep +blaze-htmlsetup-changed

Dependencies added: Elm, base, blaze-html, blaze-markup, hakyll, mtl

Files

+ Hakyll/Web/Elm.hs view
@@ -0,0 +1,47 @@+{-# LANGUAGE OverloadedStrings #-}+module Hakyll.Web.Elm (elmStandaloneCompiler)+       where++import Data.Monoid         ((<>), mempty)+import Data.String         (fromString)+import Data.Traversable    (traverse)+import Control.Applicative ((<$>))+import Control.Monad.Error (throwError)++import qualified Language.Elm      as Elm+import Hakyll+import Text.Blaze                  (preEscapedToMarkup)+import Text.Blaze.Html5            ((!))+import Text.Blaze.Html.Renderer.String (renderHtml)+import qualified Text.Blaze.Html5  as H+import qualified Text.Blaze.Html5.Attributes as Attr++{-| Compiles an elm file to a div and inline Javascript.+    +    Expects elm-runtime.js to have already been loaded on the page.++    Works for files that only import from modules in the elm runtime.+-}+elmStandaloneCompiler :: Compiler (Item String)+elmStandaloneCompiler = do+  it <- getResourceBody+  case traverse compileModule it of+    Left  err -> throwError [err]+    Right out -> return out++compileModule :: String -> Either String String+compileModule bod = html modul <$> js+  where modul = maybe "Main" id . Elm.moduleName $ bod+        js    = Elm.compile bod++html :: String -- ^ Module Name+        -> String -- ^ Generated Javascript+        -> String -- ^ HTML & JS+html modul genJS = renderHtml $ node <> instantiate+  where node = H.div ! Attr.id (fromString modul) $ mempty+        instantiate = (H.script ! Attr.type_ "text/javascript")+                      . preEscapedToMarkup . unlines $+                      [ genJS+                      , "var div = document.getElementById('" <> modul <> "', div);"+                      , "Elm.embed(Elm." <> modul <> ", div);"+                      ]
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2013, Max New++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 Max New 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,3 @@+import Distribution.Simple++main = defaultMain
+ hakyll-elm.cabal view
@@ -0,0 +1,44 @@+name:                hakyll-elm+version:             0.1+synopsis:            Hakyll wrapper for the Elm compiler.+description:         A wrapper for compiling+                     Elm (<http://elm-lang.org>) programs to+                     html/javascript in a Hakyll project.+                     .+                     Currently supports single-module programs that+                     only import from an Elm runtime that's manually+                     included.++homepage:            https://github.com/maxsnew/hakyll-elm+license:             BSD3+license-file:        LICENSE+copyright:           Copyright: (c) 2013 Max New+author:              Max New+maintainer:          maxsnew@gmail.com+category:            Web+build-type:          Simple+cabal-version:       >=1.10++source-repository head+  type:     git+  location: git://github.com/maxsnew/hakyll-elm.git+  branch:   develop++source-repository this+  type:     git+  location: git://github.com/maxsnew/hakyll-elm.git+  branch:   master+  tag:      0.1.0++library+  -- Modules exported by the library.+  exposed-modules:     Hakyll.Web.Elm+  build-depends:       base         >= 4.6 && < 4.7,+                       hakyll       >= 4.0 && < 4.5,+                       Elm          >= 0.9 && < 0.11,+                       mtl          >= 1.0 && < 3.0,+                       blaze-html   >= 0.4 && < 0.7,+                       blaze-markup >= 0.5 && < 0.6+  -- Base language which the package is written in.+  default-language:    Haskell2010+  ghc-options:         -Wall