packages feed

moe 2010.9.29 → 2010.9.29.1

raw patch · 10 files changed

+414/−1 lines, 10 files

Files

moe.cabal view
@@ -1,5 +1,5 @@ Name:                 moe-Version:              2010.9.29+Version:              2010.9.29.1 Build-type:           Simple Synopsis:             html with style Description:@@ -30,5 +30,15 @@                       Text.HTML.Moe.Type                       Text.HTML.Moe.Utils                       Text.HTML.Moe.Backend.ByteString+                      +                      Text.HTML.Moe2   +                      Text.HTML.Moe2.Attribute+                      Text.HTML.Moe2.Element+                      Text.HTML.Moe2.DSL.Markdown+                      Text.HTML.Moe2.DSL.Kawaii+                      Text.HTML.Moe2.DSL.HTML5+                      Text.HTML.Moe2.Type+                      Text.HTML.Moe2.Utils+                         other-modules:                       Text.HTML.Moe.Backend.DList
src/Text/HTML/Moe.hs view
@@ -96,3 +96,6 @@ render_attribute x =    [x.key, pack "=", pack "\"", x.T.value, pack "\""].concat ++(/) :: MoeUnit+(/) = return ()
+ src/Text/HTML/Moe2.hs view
@@ -0,0 +1,21 @@+module Text.HTML.Moe2++(+  module Text.HTML.Moe2.Element+, module Text.HTML.Moe2.Attribute+, module Text.HTML.Moe2.Renderer+, module Text.HTML.Moe2.DSL.HTML+, module Text.HTML.Moe2.DSL.HTML5+, module Text.HTML.Moe2.DSL.Kawaii+, module Text.HTML.Moe2.Utils+)++where++import Text.HTML.Moe2.Element+import Text.HTML.Moe2.Attribute+import Text.HTML.Moe2.Renderer+import Text.HTML.Moe2.DSL.HTML+import Text.HTML.Moe2.DSL.HTML5+import Text.HTML.Moe2.DSL.Kawaii+import Text.HTML.Moe2.Utils ((/))
+ src/Text/HTML/Moe2/Attribute.hs view
@@ -0,0 +1,86 @@+module Text.HTML.Moe2.Attribute where++import Text.HTML.Moe2.Type+import Text.HTML.Moe2.Utils+import Prelude hiding (id, (-))+import MPS.Light ((-))+import Text.HTML.Moe2.Utils++attr :: String -> String -> Attribute+attr x y = Attribute (pack x) (pack - escape - y)++_class      :: String -> Attribute+_data       :: String -> Attribute+_span       :: String -> Attribute+_style      :: String -> Attribute+_title      :: String -> Attribute+_type       :: String -> Attribute+action      :: String -> Attribute+align       :: String -> Attribute+alt         :: String -> Attribute+bgcolor     :: String -> Attribute+border      :: String -> Attribute+classid     :: String -> Attribute+colspan     :: String -> Attribute+cols        :: String -> Attribute+content     :: String -> Attribute+height      :: String -> Attribute+href        :: String -> Attribute+http_equiv  :: String -> Attribute+id          :: String -> Attribute+lang        :: String -> Attribute+language    :: String -> Attribute+media       :: String -> Attribute+method      :: String -> Attribute+name        :: String -> Attribute+quality     :: String -> Attribute+rel         :: String -> Attribute+rowspan     :: String -> Attribute+rows        :: String -> Attribute+selected    :: String -> Attribute+src         :: String -> Attribute+size        :: String -> Attribute+target      :: String -> Attribute+valign      :: String -> Attribute+value       :: String -> Attribute+width       :: String -> Attribute+xml_lang    :: String -> Attribute+xmlns       :: String -> Attribute++_class      = attr "class"+_data       = attr "data"+_span       = attr "span"+_style      = attr "style"+_title      = attr "title"+_type       = attr "type"+action      = attr "action"+align       = attr "align"+alt         = attr "alt"+bgcolor     = attr "bgcolor"+border      = attr "border"+classid     = attr "classid"+colspan     = attr "colspan"+cols        = attr "cols"+content     = attr "content"+height      = attr "height"+href        = attr "href"+http_equiv  = attr "http-equiv"+id          = attr "id"+lang        = attr "lang"+language    = attr "language"+media       = attr "media"+method      = attr "method"+name        = attr "name"+quality     = attr "quality"+rel         = attr "rel"+rowspan     = attr "rowspan"+rows        = attr "rows"+selected    = attr "selected"+src         = attr "src"+size        = attr "size"+target      = attr "target"+valign      = attr "valign"+value       = attr "value"+width       = attr "width"+xml_lang    = attr "xml:lang"+xmlns       = attr "xmlns"
+ src/Text/HTML/Moe2/DSL/HTML5.hs view
@@ -0,0 +1,57 @@+module Text.HTML.Moe2.DSL.HTML5 where++import Text.HTML.Moe2.Element+import Text.HTML.Moe2.Type++article       :: MoeCombinator +aside         :: MoeCombinator +audio         :: MoeCombinator +canvas        :: MoeCombinator +command       :: MoeCombinator +datagrid      :: MoeCombinator +datalist      :: MoeCombinator +datatemplate  :: MoeCombinator +details       :: MoeCombinator +dialog        :: MoeCombinator +event_source  :: MoeCombinator +figure        :: MoeCombinator +footer        :: MoeCombinator +header        :: MoeCombinator +mark          :: MoeCombinator +meter         :: MoeCombinator +nav           :: MoeCombinator +nest          :: MoeCombinator +output        :: MoeCombinator +progress      :: MoeCombinator +rule          :: MoeCombinator +section       :: MoeCombinator +source        :: MoeCombinator +time          :: MoeCombinator +video         :: MoeCombinator+++article       = element "article"+aside         = element "aside"+audio         = element "audio"+canvas        = element "canvas"+command       = element "command"+datagrid      = element "datagrid"+datalist      = element "datalist"+datatemplate  = element "datatemplate"+details       = element "details"+dialog        = element "dialog"+event_source  = element "event_source"+figure        = element "figure"+footer        = element "footer"+header        = element "header"+mark          = element "mark"+meter         = element "meter"+nav           = element "nav"+nest          = element "nest"+output        = element "output"+progress      = element "progress"+rule          = element "rule"+section       = element "section"+source        = element "source"+time          = element "time"+video         = element "video"
+ src/Text/HTML/Moe2/DSL/Kawaii.hs view
@@ -0,0 +1,23 @@+module Text.HTML.Moe2.DSL.Kawaii where+++import Text.HTML.Moe2.Element+import Text.HTML.Moe2.Type (MoeUnit)+import Text.HTML.Moe2.DSL.Markdown+import Text.HTML.Moe2.Attribute+import Text.HTML.Moe2.DSL.HTML+import Text.HTML.Moe2.Utils+import MPS.Env ((-))+import Prelude hiding ((-), (/), div)++c :: String -> MoeUnit -> MoeUnit+c x = div ! [_class x]++css :: String -> MoeUnit+css x = link ! [rel "stylesheet", _type "text/css", href x] - (/)++js :: String -> MoeUnit+js x = script ! [_type "text/javascript", src x] - (/)++(~>) :: String -> String -> MoeUnit+(~>) = (<>)
+ src/Text/HTML/Moe2/DSL/Markdown.hs view
@@ -0,0 +1,63 @@+module Text.HTML.Moe2.DSL.Markdown+(+  (#)+, (##)+, (###)+, (####)+, (#####)+, (######)+, (>>)+, (*)+, (***)+-- , _+-- , __+, (!)+, (<>)+, o+, block+) where++import Text.HTML.Moe2.Type+import Text.HTML.Moe2.Element+import Text.HTML.Moe2.Attribute+import Text.HTML.Moe2.DSL.HTML++import MPS.Light ((-))+import Prelude hiding ((-), (/), (>>), (*))++single_line, r :: (MoeUnit -> MoeUnit) -> String -> MoeUnit+single_line f = f . str+r = single_line++(#)       :: String -> MoeUnit+(##)      :: String -> MoeUnit+(###)     :: String -> MoeUnit+(####)    :: String -> MoeUnit+(#####)   :: String -> MoeUnit+(######)  :: String -> MoeUnit+(>>)      :: String -> MoeUnit+(*)       :: String -> MoeUnit+-- _         :: String -> MoeUnit+-- __        :: String -> MoeUnit+o         :: String -> MoeUnit+block     :: String -> MoeUnit+(***)     :: MoeUnit+(!!)       :: String -> String -> MoeUnit+(<>)      :: String -> String -> MoeUnit+++(#)       = r h1+(##)      = r h2+(###)     = r h3+(####)    = r h4+(#####)   = r h5+(######)  = r h6+(>>)      = r blockquote+(*)       = r ul+-- _         = r em'+-- __        = r strong'+o         = r li+block     = pre . code . _pre+(***)     = hr (return ())+(!!) x y   = img ! [src y, alt x] - (return ())+(<>) x y  = a ! [href y] - str x
+ src/Text/HTML/Moe2/Element.hs view
@@ -0,0 +1,69 @@+module Text.HTML.Moe2.Element where++import Text.HTML.Moe2.Type+import Text.HTML.Moe2.Utils+import Data.Default+import Control.Monad.Writer+import Prelude hiding (id, span, div, head, (>), (.), (-))+import MPS.Light ((-), first)+import Data.DList (singleton, toList)++element :: String -> MoeCombinator+element x u = tell - singleton - +  def+    {+      name       = pack - escape x+    , elements   = toList - execWriter - u+    }++(!) :: (MoeUnit -> MoeUnit) -> [Attribute] -> (MoeUnit -> MoeUnit)+(!) = add_attributes++infixl 1 !++add_attributes :: (MoeUnit -> MoeUnit) -> [Attribute] -> (MoeUnit -> MoeUnit)+add_attributes f xs = \u -> +  let r = f u+  in+  +  tell - singleton - Attributes xs - first - toList - execWriter - r+++e :: String -> MoeCombinator+e = element++++no_indent_element :: String -> MoeCombinator+no_indent_element x u = tell - singleton -+  def+    {+      name       = pack - x+    , elements   = toList - execWriter u+    , indent     = False+    }++ne :: String -> MoeCombinator+ne = no_indent_element++self_close_element :: String -> LightCombinator+self_close_element x _ = tell - singleton - +  def+    {+      name       = pack - escape x+    , self_close = True+    }++sc :: String -> LightCombinator+sc = self_close_element+++str, raw, _pre, prim :: String -> MoeUnit++str x   = tell - singleton - Data (pack - escape x)+raw x   = tell - singleton - Raw  (pack x)+_pre x  = tell - singleton - Pre  (pack - escape x)+prim x  = tell - singleton - Prim (pack x)++raw_bytestring x   = tell - singleton - Raw  x+prim_bytestring x  = tell - singleton - Prim x
+ src/Text/HTML/Moe2/Type.hs view
@@ -0,0 +1,49 @@+module Text.HTML.Moe2.Type where++import Data.Default+import Control.Monad.Writer+import Text.HTML.Moe.Utils+import Data.DList (DList)++data Element = +    Element+      {+        name :: Internal+      , elements :: [Element]+      , attributes :: [Attribute]+      , indent :: Bool+      , self_close :: Bool+      }+  | Raw Internal  -- no escape, no indent+  | Pre Internal  -- escape, no indent+  | Data Internal -- escape, indent+  | Prim Internal -- no escape, indent+  | Attributes [Attribute] Element+  deriving (Show)++instance Default Element where+  def = Element +    {+      name = none+    , elements = def+    , attributes = def+    , indent = True+    , self_close = False+    }++data Attribute = Attribute+  {+    key :: Internal+  , value :: Internal+  }+  deriving (Show)++instance Default Attribute where+  def = Attribute none none++type MoeUnitT a = Writer (DList Element) a+type MoeUnit = MoeUnitT ()++type MoeCombinator = MoeUnit -> MoeUnit++type LightCombinator = MoeCombinator
+ src/Text/HTML/Moe2/Utils.hs view
@@ -0,0 +1,32 @@+module Text.HTML.Moe2.Utils +( escape+, (+)+, module Text.HTML.Moe.Backend.ByteString+, (/)+) where++import Data.Monoid+import Text.HTML.Moe.Backend.ByteString+import Text.HTML.Moe2.Type+import Prelude hiding ((/), (+))++escape :: String -> String+escape = escape_html++escape_html :: String -> String+escape_html = concatMap fixChar+  where+    fixChar '&'  = "&amp;"+    fixChar '<'  = "&lt;"+    fixChar '>'  = "&gt;"+    fixChar '\'' = "&#39;"+    fixChar '"'  = "&quot;"+    fixChar x    = [x]+++(/) :: MoeUnit+(/) = return ()++(+) :: (Monoid a) => a -> a -> a+(+) = mappend+infixl 5 +