Browse files

use happstack-yui

  • Loading branch information...
1 parent 10bada2 commit 57b3df6dd30c02152e00eb2138c66d56e4e4d8bb @dag committed May 26, 2012
Showing with 25 additions and 255 deletions.
  1. +0 −25 assets/yui.css
  2. +0 −216 assets/yui.js
  3. +10 −4 bin/happaste.hs
  4. +1 −0 happaste.cabal
  5. +14 −10 src/Happaste/HTML.hs
View
25 assets/yui.css
@@ -1,25 +0,0 @@
-/*
-YUI 3.5.0pre5 (build 5015)
-Copyright 2012 Yahoo! Inc. All rights reserved.
-Licensed under the BSD License.
-http://yuilibrary.com/license/
-*/
-html{color:#000;background:#FFF}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td{margin:0;padding:0}table{border-collapse:collapse;border-spacing:0}fieldset,img{border:0}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal}ol,ul{list-style:none}caption,th{text-align:left}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal}q:before,q:after{content:''}abbr,acronym{border:0;font-variant:normal}sup{vertical-align:text-top}sub{vertical-align:text-bottom}input,textarea,select{font-family:inherit;font-size:inherit;font-weight:inherit}input,textarea,select{*font-size:100%}legend{color:#000}#yui3-css-stamp.cssreset{display:none}/*
-YUI 3.5.0pre5 (build 5015)
-Copyright 2012 Yahoo! Inc. All rights reserved.
-Licensed under the BSD License.
-http://yuilibrary.com/license/
-*/
-body{font:13px/1.231 arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small}select,input,button,textarea{font:99% arial,helvetica,clean,sans-serif}table{font-size:inherit;font:100%}pre,code,kbd,samp,tt{font-family:monospace;*font-size:108%;line-height:100%}#yui3-css-stamp.cssfonts{display:none}/*
-YUI 3.5.0pre5 (build 5015)
-Copyright 2012 Yahoo! Inc. All rights reserved.
-Licensed under the BSD License.
-http://yuilibrary.com/license/
-*/
-.yui3-g{letter-spacing:-0.31em;*letter-spacing:normal;word-spacing:-0.43em}.yui3-u{display:inline-block;zoom:1;*display:inline;letter-spacing:normal;word-spacing:normal;vertical-align:top}.yui3-u-1,.yui3-u-1-2,.yui3-u-1-3,.yui3-u-2-3,.yui3-u-1-4,.yui3-u-3-4,.yui3-u-1-5,.yui3-u-2-5,.yui3-u-3-5,.yui3-u-4-5,.yui3-u-1-6,.yui3-u-5-6,.yui3-u-1-8,.yui3-u-3-8,.yui3-u-5-8,.yui3-u-7-8,.yui3-u-1-12,.yui3-u-5-12,.yui3-u-7-12,.yui3-u-11-12,.yui3-u-1-24,.yui3-u-5-24,.yui3-u-7-24,.yui3-u-11-24,.yui3-u-13-24,.yui3-u-17-24,.yui3-u-19-24,.yui3-u-23-24{display:inline-block;zoom:1;*display:inline;letter-spacing:normal;word-spacing:normal;vertical-align:top}.yui3-u-1{display:block}.yui3-u-1-2{width:50%}.yui3-u-1-3{width:33.33333%}.yui3-u-2-3{width:66.66666%}.yui3-u-1-4{width:25%}.yui3-u-3-4{width:75%}.yui3-u-1-5{width:20%}.yui3-u-2-5{width:40%}.yui3-u-3-5{width:60%}.yui3-u-4-5{width:80%}.yui3-u-1-6{width:16.656%}.yui3-u-5-6{width:83.33%}.yui3-u-1-8{width:12.5%}.yui3-u-3-8{width:37.5%}.yui3-u-5-8{width:62.5%}.yui3-u-7-8{width:87.5%}.yui3-u-1-12{width:8.3333%}.yui3-u-5-12{width:41.6666%}.yui3-u-7-12{width:58.3333%}.yui3-u-11-12{width:91.6666%}.yui3-u-1-24{width:4.1666%}.yui3-u-5-24{width:20.8333%}.yui3-u-7-24{width:29.1666%}.yui3-u-11-24{width:45.8333%}.yui3-u-13-24{width:54.1666%}.yui3-u-17-24{width:70.8333%}.yui3-u-19-24{width:79.1666%}.yui3-u-23-24{width:95.8333%}#yui3-css-stamp.cssgrids{display:none}/*
-YUI 3.5.0pre5 (build 5015)
-Copyright 2012 Yahoo! Inc. All rights reserved.
-Licensed under the BSD License.
-http://yuilibrary.com/license/
-*/
-h1{font-size:138.5%}h2{font-size:123.1%}h3{font-size:108%}h1,h2,h3{margin:1em 0}h1,h2,h3,h4,h5,h6,strong{font-weight:bold}abbr,acronym{border-bottom:1px dotted #000;cursor:help}em{font-style:italic}blockquote,ul,ol,dl{margin:1em}ol,ul,dl{margin-left:2em}ol{list-style:decimal outside}ul{list-style:disc outside}dl dd{margin-left:1em}th,td{border:1px solid #000;padding:.5em}th{font-weight:bold;text-align:center}caption{margin-bottom:.5em;text-align:center}p,fieldset,table,pre{margin-bottom:1em}input[type=text],input[type=password],textarea{width:12.25em;*width:11.9em}#yui3-css-stamp.cssbase{display:none}
View
216 assets/yui.js
0 additions, 216 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
14 bin/happaste.hs
@@ -1,26 +1,32 @@
+{-# LANGUAGE OverloadedStrings #-}
+
module Main where
import qualified Data.Text as T
import Control.Exception (bracket)
+import Control.Monad (msum)
import Control.Monad.Reader (runReaderT)
import Control.Monad.State (evalStateT)
import Data.Acid (AcidState, IsAcidic, openLocalState)
import Data.Acid.Local (createCheckpointAndClose)
import Data.Default (Default(def))
import Data.Typeable (Typeable)
import Happstack.Server (mapServerPartT, simpleHTTP, nullConf, decodeBody, defaultBodyPolicy)
+import Happstack.Server.YUI (implYUISite)
import System.Log.Logger (updateGlobalLogger, rootLoggerName, setLevel, Priority(DEBUG))
import Web.Routes.Happstack (implSite)
import Happaste.HTTP
import Happaste.Types
server :: AcidState PasteState -> AcidState HighlighterState -> IO ()
-server ps hs = simpleHTTP nullConf $ do
- decodeBody $ defaultBodyPolicy "/tmp/" 0 40960 40960
- implSite (T.pack "http://localhost:8000") T.empty $
- fmap (mapServerPartT ((`evalStateT` 0) . (`runReaderT` st))) site
+server ps hs = simpleHTTP nullConf $
+ msum [ implYUISite "http://localhost:8000" "/yui"
+ , do decodeBody $ defaultBodyPolicy "/tmp/" 0 40960 40960
+ implSite "http://localhost:8000" T.empty $
+ fmap (mapServerPartT ((`evalStateT` 0) . (`runReaderT` st))) site
+ ]
where
st = States ps hs
View
1 happaste.cabal
@@ -46,6 +46,7 @@ Executable happaste
happstack-hsp == 7.1.*,
happstack-jmacro == 7.0.*,
happstack-server == 7.0.1,
+ happstack-yui == 7351.3.*,
haskell-src-exts == 1.13.* && >= 1.13.1,
haskell-src-meta == 0.5.* && >= 0.5.1.2,
highlighter == 0.2.*,
View
24 src/Happaste/HTML.hs
@@ -6,9 +6,10 @@ import Prelude hiding (head)
import Control.Monad (liftM)
import Data.Lens ((^.))
-import Data.Text (Text, unpack)
+import Data.Text (Text, pack, unpack)
import Happstack.Server (Response, ToMessage, getHeaderM, toResponse)
import Happstack.Server.HSP.HTML (EmbedAsChild(asChild), EmbedAsAttr, genElement, asAttr, Attr((:=)), unXMLGenT, genEElement, cdata)
+import Happstack.Server.YUI (gridUnit)
import Web.Routes.XMLGenT ()
import Happaste.CSS (css)
@@ -30,7 +31,7 @@ appTemplate body = do
<body>
<% header %>
<div id="content"><% grid body %></div>
- <script src=(AssetURL "yui.js")/>
+ <script src="/yui/3.5.1"/>
<% pjax %>
</body>
</html>
@@ -43,7 +44,7 @@ head :: Template
head =
<head>
<title>Happaste</title>
- <% stylesheet $ AssetURL "yui.css" %>
+ <% stylesheet "/yui/3.5.1/css?reset&base&fonts&grids" %>
<% stylesheet $ AssetURL "highlighter.css" %>
<% stylesheet "http://fonts.googleapis.com/css?family=Stoke" %>
<% css %>
@@ -52,7 +53,7 @@ head =
header :: Template
header =
<div id="header">
- <% grid $ unit "1"
+ <% grid $ unit 1 1
<h1><a href=CreatePasteURL class="pjax">Happaste</a></h1>
%>
</div>
@@ -65,13 +66,16 @@ grid body =
</div>
</div>
-unit :: EmbedAsChild Server c => String -> c -> Template
-unit size body =
- <div class=("yui3-u-" ++ size)>
+unit :: EmbedAsChild Server c => Integer -> Integer -> c -> Template
+unit n d body =
+ <div class=(gridUnit' n d)>
<div class="unit">
<% body %>
</div>
</div>
+ where
+ gridUnit' 1 1 = pack "yui3-u-1"
+ gridUnit' a b = gridUnit a b
recentPastesList :: Template
recentPastesList = do
@@ -86,13 +90,13 @@ createPastePage :: [Template] -> Server Response
createPastePage f =
appTemplate
<%>
- <% unit "17-24" f %>
- <% unit "7-24" recentPastesList %>
+ <% unit 17 24 f %>
+ <% unit 7 24 recentPastesList %>
</%>
getPastePage :: Paste -> Text -> Server Response
getPastePage p h =
- appTemplate $ unit "1"
+ appTemplate $ unit 1 1
<%>
<h2><% p ^. fileName %></h2>
<% cdata . unpack $ h %>

0 comments on commit 57b3df6

Please sign in to comment.