Skip to content

Commit

Permalink
Merge pull request #32 from koterpillar/fix-asset-rendering
Browse files Browse the repository at this point in the history
Fix asset rendering
  • Loading branch information
koterpillar authored Dec 26, 2018
2 parents 4c1eefd + bbf6cc6 commit cc0937e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/Render.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

module Render where

import qualified Data.ByteString as B

import Data.Text (Text)
import qualified Data.Text as Text
import Data.Text.Encoding (encodeUtf8)
Expand All @@ -29,16 +27,16 @@ withContentType :: ContentType -> Response -> Response
withContentType ct = setHeaderBS "Content-Type" (encodeUtf8 ct)

newtype Stylesheet =
Stylesheet TL.Text
Stylesheet { unStylesheet :: TL.Text }

instance ToMessage Stylesheet where
toResponse = withContentType css . toResponse
toResponse = withContentType css . toResponse . unStylesheet

newtype JavaScript =
JavaScript TL.Text
JavaScript { unJavaScript :: TL.Text }

instance ToMessage JavaScript where
toResponse = withContentType javaScript . toResponse
toResponse = withContentType javaScript . toResponse . unJavaScript

data Export content = Export
{ exContent :: content
Expand Down
10 changes: 10 additions & 0 deletions testsuite/Integration/TestHome.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,13 @@ test_home_next_page = do
assertTextContains "Very early article" home
assertTextContains "Previous page" home
assertTextNotContains "Next page" home

test_css :: IO ()
test_css = do
css <- makeRequestText $ simpleRequest "/code.css"
assertTextContains "color" css

test_js :: IO ()
test_js = do
js <- makeRequestText $ simpleRequest "/site.js"
assertTextContains "function" js

0 comments on commit cc0937e

Please sign in to comment.