Skip to content

Commit

Permalink
Fix #138 (#139)
Browse files Browse the repository at this point in the history
* live server: fix AssetStatic redirection

* Refactor: reorganize

* Changelog and version

Co-authored-by: Sridhar Ratnakumar <[email protected]>
  • Loading branch information
Lucas and srid authored Aug 28, 2022
1 parent 25f3bd6 commit 3a25c9c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Revision history for ema

## Unreleased

- Bug fixes
- Fix live server redirecting static assets to wrong links [\#138](https://github.com/EmaApps/ema/issues/138)

## 0.8.0.0 (2022-08-19)

This releases brings a significant rewrite of Ema. If you choose to upgrade your apps from 0.6, see https://ema.srid.ca/start/upgrade for guidance.
Expand Down
2 changes: 1 addition & 1 deletion ema.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 2.4
name: ema
version: 0.8.0.0
version: 0.8.1.0
license: AGPL-3.0-only
copyright: 2021 Sridhar Ratnakumar
maintainer: [email protected]
Expand Down
10 changes: 4 additions & 6 deletions src/Ema/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,13 @@ runServerWithWebSocketHotReload host mport model = do
liftIO $ WS.sendTextData conn $ emaErrorHtmlResponse decodeRouteNothingMsg
Right (Just r) -> do
renderCatchingErrors s r >>= \case
AssetStatic staticPath ->
-- HACK: Websocket client should check for REDIRECT prefix.
-- Not bothering with JSON to avoid having to JSON parse every HTML dump.
liftIO $ WS.sendTextData conn $ "REDIRECT " <> toText staticPath
AssetGenerated Html html ->
liftIO $ WS.sendTextData conn $ html <> toLazy wsClientHtml
-- HACK: We expect the websocket client should check for REDIRECT prefix.
-- Not bothering with JSON response to avoid having to JSON parse every HTML dump.
AssetStatic _staticPath ->
liftIO $ WS.sendTextData conn $ "REDIRECT " <> toText (review (fromPrism_ $ enc s) r)
AssetGenerated Other _s ->
-- HACK: Websocket client should check for REDIRECT prefix.
-- Not bothering with JSON to avoid having to JSON parse every HTML dump.
liftIO $ WS.sendTextData conn $ "REDIRECT " <> toText (review (fromPrism_ $ enc s) r)
log LevelDebug $ " ~~> " <> show r
loop = flip runLoggingT logger $ do
Expand Down

0 comments on commit 3a25c9c

Please sign in to comment.