Skip to content

Commit fa42e84

Browse files
Undo head/CSS branching
1 parent d2125f1 commit fa42e84

File tree

1 file changed

+22
-39
lines changed

1 file changed

+22
-39
lines changed

examples/Example/App.hs

+22-39
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ import Foreign.Store (Store (..), lookupStore, readStore, storeAction, withStore
6262
import GHC.Generics (Generic)
6363
import GHC.Word (Word32)
6464
import Network.HTTP.Types (Header, Method, QueryItem, hCacheControl, methodPost, status200, status404)
65-
import Network.Wai (pathInfo)
6665
import Network.Wai qualified as Wai
6766
import Network.Wai.Handler.Warp qualified as Warp
6867
import Network.Wai.Middleware.Static as Static (CacheContainer, CachingStrategy (..), Options (..), addBase)
@@ -91,46 +90,13 @@ run = do
9190
cache <- clientCache
9291
Warp.run port $
9392
Static.staticPolicyWithOptions cache (addBase "client/dist") $
94-
Static.staticPolicy (addBase "examples/static") $ \req -> do
95-
let doc = case pathInfo req of
96-
"todoscss" : _ -> toDocumentTodosCSS
97-
_ -> toDocument
98-
(app doc users count) req
99-
100-
-- Use the embedded version for real applications (see basicDocument).
101-
-- The link to /hyperbole.js here is just to make local development easier
102-
toDocument :: BL.ByteString -> BL.ByteString
103-
toDocument cnt =
104-
[i|<html>
105-
<head>
106-
<title>Hyperbole Examples</title>
107-
<meta httpEquiv="Content-Type" content="text/html" charset="UTF-8">
108-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
109-
<script type="text/javascript" src="/hyperbole.js"></script>
110-
<script type="text/javascript" src="/custom.js"></script>
111-
<style type="text/css">#{cssResetEmbed}</style>
112-
<style type="text/css">body { background-color: \#d3dceb }</style>
113-
</head>
114-
<body>#{cnt}</body>
115-
</html>|]
116-
117-
toDocumentTodosCSS :: BL.ByteString -> BL.ByteString
118-
toDocumentTodosCSS cnt =
119-
[i|<html>
120-
<head>
121-
<title>Todo MVC</title>
122-
<script type="text/javascript">#{scriptEmbed}</script>
123-
124-
<link href="https://cdn.jsdelivr.net/npm/[email protected]/index.min.css"
125-
rel="stylesheet">
126-
</head>
127-
<body>#{cnt}</body>
128-
</html>|]
93+
Static.staticPolicy (addBase "examples/static") $
94+
app users count
12995

130-
app :: (BL.ByteString -> BL.ByteString) -> UserStore -> TVar Int -> Application
131-
app doc users count = do
96+
app :: UserStore -> TVar Int -> Application
97+
app users count = do
13298
liveApp
133-
doc
99+
toDocument
134100
(runApp . routeRequest $ router)
135101
where
136102
runApp :: (Hyperbole :> es, IOE :> es) => Eff (GenRandom : Concurrent : Debug : Users : Todos : es) a -> Eff es a
@@ -178,6 +144,23 @@ app doc users count = do
178144
hello Redirected = do
179145
pure $ exampleLayout RedirectNow $ el (pad 10) "You were redirected"
180146

147+
-- Use the embedded version for real applications (see basicDocument).
148+
-- The link to /hyperbole.js here is just to make local development easier
149+
toDocument :: BL.ByteString -> BL.ByteString
150+
toDocument cnt =
151+
[i|<html>
152+
<head>
153+
<title>Hyperbole Examples</title>
154+
<meta httpEquiv="Content-Type" content="text/html" charset="UTF-8">
155+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
156+
<script type="text/javascript" src="/hyperbole.js"></script>
157+
<script type="text/javascript" src="/custom.js"></script>
158+
<style type="text/css">#{cssResetEmbed}</style>
159+
<style type="text/css">body { background-color: \#d3dceb }</style>
160+
</head>
161+
<body>#{cnt}</body>
162+
</html>|]
163+
181164
{- | Made for local development
182165
-
183166
- ghcid --setup=Main.update --command="cabal repl exe:examples lib:hyperbole test" --run=Main.update --warnings

0 commit comments

Comments
 (0)