Skip to content

Commit

Permalink
Merge pull request #50 from duplode/develop
Browse files Browse the repository at this point in the history
Enable resource file embedding. #27
  • Loading branch information
HeinrichApfelmus committed Sep 7, 2013
2 parents 4de034c + 5f62273 commit 9bc7993
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/Graphics/UI/Threepenny/Internal/Include.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE TemplateHaskell, CPP #-}
module Graphics.UI.Threepenny.Internal.Include (include) where

import Data.Functor
Expand Down
45 changes: 24 additions & 21 deletions src/Graphics/UI/Threepenny/Internal/Resources.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,29 @@ module Graphics.UI.Threepenny.Internal.Resources where

import Data.Text (Text)
import qualified Data.Text as Text
import Graphics.UI.Threepenny.Internal.Include


jsDriverCode :: Text
cssDriverCode :: Text
defaultHtmlFile :: Text


jsDriverCode = Text.unlines $ map Text.pack
[ [include|Graphics/UI/jquery.js|]
, [include|Graphics/UI/jquery-cookie.js|]
, [include|Graphics/UI/driver.js|]
]

cssDriverCode = Text.pack [include|Graphics/UI/driver.css|]

defaultHtmlFile = Text.pack [include|Graphics/UI/index.html|]


{-
-- Disabled code:
-- Do not embed files with executables.
import qualified Data.Text.IO as Text
import System.FilePath
import System.IO.Unsafe
Expand All @@ -16,11 +39,6 @@ getDataDir = return $ "Graphics" </> "UI"
#endif
jsDriverCode :: Text
cssDriverCode :: Text
defaultHtmlFile :: Text


jsDriverCode = unsafePerformIO $
readFiles $ words "jquery.js jquery-cookie.js driver.js"
Expand All @@ -36,19 +54,4 @@ readFiles files = do
getDataFile x = unsafePerformIO $ fmap (</> x) getDataDir

{-
-- Temporarily disabled code.
-- Use quasiquotation to bundle resource files with executable.
jsDriverCode = Text.unlines $ map Text.pack
[ [include|Graphics/UI/jquery.js|]
, [include|Graphics/UI/jquery-cookie.js|]
, [include|Graphics/UI/driver.js|]
]
cssDriverCode = Text.pack [include|Graphics/UI/driver.css|]
defaultHtmlFile = Text.pack [include|Graphics/UI/index.html|]
-}
-}
8 changes: 4 additions & 4 deletions threepenny-gui.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@ Cabal-version: >=1.8

Extra-Source-Files: src/Graphics/UI/*.html
,src/Graphics/UI/*.js
,src/Graphics/UI/*.css

Data-dir: .
Data-files: src/Graphics/UI/*.js
,src/Graphics/UI/*.html
,src/Graphics/UI/*.css
,wwwroot/css/*.css
Data-files: wwwroot/css/*.css
,wwwroot/css/*.png
,wwwroot/*.html
,wwwroot/*.txt
Expand Down Expand Up @@ -78,6 +76,7 @@ Library
,Control.Concurrent.Delay
,Graphics.UI.Threepenny.Internal.Core
,Graphics.UI.Threepenny.Internal.Resources
,Graphics.UI.Threepenny.Internal.Include
,Graphics.UI.Threepenny.Internal.Types
,Reactive.Threepenny.PulseLatch
,Reactive.Threepenny.Memo
Expand All @@ -101,6 +100,7 @@ Library
,network
,filepath
,data-default
,template-haskell
,transformers
,stm
,attoparsec-enumerator
Expand Down

0 comments on commit 9bc7993

Please sign in to comment.