-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NO-ISSUE] Enable live reload of pages upon server restart
- Loading branch information
Showing
32 changed files
with
2,210 additions
and
1,937 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
module Data.Text.HTML | ||
( TextHtml | ||
, fromText | ||
, toText | ||
) where | ||
|
||
import Control.DeepSeq | ||
import Data.Aeson | ||
import Data.Text | ||
import Database.PostgreSQL.Simple.FromField (FromField (..)) | ||
import Database.PostgreSQL.Simple.ToField (ToField (..)) | ||
import GHC.Generics | ||
import Lucid | ||
|
||
-- | a wrapper that attaches from and tofield instances | ||
-- for a text db row for LucidHtml | ||
newtype TextHtml = MkTextHtml Text | ||
deriving stock (Show, Generic) | ||
deriving | ||
(Eq, ToHtml) | ||
via Text | ||
|
||
instance ToJSON TextHtml where | ||
toJSON (MkTextHtml a) = String a | ||
|
||
instance FromJSON TextHtml where | ||
parseJSON = withText "TextHtml" (pure . MkTextHtml) | ||
|
||
instance NFData TextHtml where | ||
rnf a = seq a () | ||
|
||
-- | ||
instance FromField TextHtml where | ||
fromField field bs = MkTextHtml <$> fromField field bs | ||
|
||
instance ToField TextHtml where | ||
toField (MkTextHtml x) = toField x | ||
|
||
fromText :: Text -> TextHtml | ||
fromText = MkTextHtml | ||
|
||
toText :: TextHtml -> Text | ||
toText (MkTextHtml t) = t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.