diff --git a/config/routes b/config/routes index df56ea4..403163f 100644 --- a/config/routes +++ b/config/routes @@ -1,5 +1,5 @@ /static StaticR Static appStatic -/theme ThemeR GET +/theme.css ThemeR GET / HomeR GET /reload ReloadR GET /downloads DownloadsR GET diff --git a/hl.cabal b/hl.cabal index 34dd936..ca2c15e 100644 --- a/hl.cabal +++ b/hl.cabal @@ -27,4 +27,5 @@ executable hl base >= 4 && < 5, foreign-store == 0.0, blaze == 0.0.2, - css == 0.1 + css == 0.1, + directory == 1.1.0.2 diff --git a/scripts/deploy b/scripts/deploy new file mode 100755 index 0000000..5dd4286 --- /dev/null +++ b/scripts/deploy @@ -0,0 +1,6 @@ +#!/bin/bash -ex +cabal build +strip dist/build/hl/hl +tar czf hl.tar.gz dist/build/hl/hl scripts/restart static/ +scp hl.tar.gz herz: +ssh herz 'mkdir -p hl && cd hl && tar xf ../hl.tar.gz && killall hl -w && rm ../hl.tar.gz' diff --git a/scripts/restart b/scripts/restart new file mode 100644 index 0000000..0e770cc --- /dev/null +++ b/scripts/restart @@ -0,0 +1 @@ +dist/build/hl/hl diff --git a/src/HL/Controller/Reload.hs b/src/HL/Controller/Reload.hs index 7bd7a31..ad2032b 100644 --- a/src/HL/Controller/Reload.hs +++ b/src/HL/Controller/Reload.hs @@ -3,7 +3,6 @@ module HL.Controller.Reload where import HL.Foundation -import HL.View.Home import Control.Concurrent.Chan.Lifted diff --git a/src/HL/Controller/Theme.hs b/src/HL/Controller/Theme.hs index 65841b7..eefb64d 100644 --- a/src/HL/Controller/Theme.hs +++ b/src/HL/Controller/Theme.hs @@ -7,13 +7,13 @@ module HL.Controller.Theme where import HL.Foundation import HL.View.Theme -import Data.Conduit -import Data.Conduit.List as CL import Data.Text.Lazy (Text) import Language.CSS -- | Generate CSS from Clay theme. getThemeR :: Handler TypedContent getThemeR = - respondSource "text/css" - (sendChunk (renderCSS (runCSS theme))) + respondSource "text/css" (sendChunk themeCss) + +themeCss :: Text +themeCss = renderCSS (runCSS theme) diff --git a/src/HL/Foundation.hs b/src/HL/Foundation.hs index 648e6b6..c0fcda2 100644 --- a/src/HL/Foundation.hs +++ b/src/HL/Foundation.hs @@ -1,5 +1,6 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE OverloadedStrings #-} {-# OPTIONS -fno-warn-name-shadowing #-} -- | Yesod foundation. @@ -35,7 +36,8 @@ mkYesodData "App" $(parseRoutesFile "config/routes") -- | Don't log anything to stdout. instance Yesod App where - makeLogger _ = do set <- newFileLoggerSet 1000 "/dev/null" - (date,_) <- clockDateCacher - return (Logger {loggerSet = set - ,loggerDate = date}) + makeLogger _ = + do set <- newFileLoggerSet 1000 "/dev/null" + (date,_) <- clockDateCacher + return (Logger {loggerSet = set + ,loggerDate = date}) diff --git a/src/HL/View/Template.hs b/src/HL/View/Template.hs index 1b22776..2b11ac1 100644 --- a/src/HL/View/Template.hs +++ b/src/HL/View/Template.hs @@ -8,11 +8,9 @@ module HL.View.Template where import HL.Foundation import Blaze (AttributeValue) -import qualified Blaze.Attributes as A import Blaze.Bootstrap import qualified Blaze.Elements as E import Blaze.Prelude -import Blaze.Senza import Control.Monad import Data.Text (Text) diff --git a/src/HL/View/Theme.hs b/src/HL/View/Theme.hs index d6e1acc..4ee0fba 100644 --- a/src/HL/View/Theme.hs +++ b/src/HL/View/Theme.hs @@ -1,5 +1,6 @@ {-# LANGUAGE NoMonomorphismRestriction #-} {-# LANGUAGE OverloadedStrings #-} +{-# OPTIONS -fno-warn-missing-signatures #-} -- | CSS theme. diff --git a/src/Main.hs b/src/Main.hs index af43711..a31f612 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -2,15 +2,23 @@ module Main where -import HL.Foundation -import HL.Dispatch () +import HL.Foundation +import HL.Dispatch () +import HL.Controller.Theme -import Control.Concurrent.Chan -import Yesod.Static +import Control.Concurrent.Chan +import qualified Data.Text.Lazy.IO as L +import System.Directory +import Yesod.Static -- | Main entry point. main :: IO () main = do s <- static "static" c <- newChan - warp 1990 (App s c) + setupCache + warp 2001 (App s c) + +setupCache = + do createDirectoryIfMissing True "cache/" + L.writeFile "cache/theme.css" (themeCss)