aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/BlogEntry.purs
diff options
context:
space:
mode:
authorChristine Dodrill <me@christine.website>2016-12-18 07:03:16 -0800
committerChristine Dodrill <me@christine.website>2016-12-18 07:03:16 -0800
commite1a6482dc61afee78ae23d92510db41b703c534f (patch)
treeaf7b79a1336efae0f0e36d3db25573694ce6b3d7 /frontend/src/BlogEntry.purs
parent62ffa5f0089f5f11c069f017b0dc69df6141de34 (diff)
downloadxesite-e1a6482dc61afee78ae23d92510db41b703c534f.tar.xz
xesite-e1a6482dc61afee78ae23d92510db41b703c534f.zip
frontend: make mdify return rendered html
Diffstat (limited to 'frontend/src/BlogEntry.purs')
-rw-r--r--frontend/src/BlogEntry.purs14
1 files changed, 3 insertions, 11 deletions
diff --git a/frontend/src/BlogEntry.purs b/frontend/src/BlogEntry.purs
index 9286619..0a46976 100644
--- a/frontend/src/BlogEntry.purs
+++ b/frontend/src/BlogEntry.purs
@@ -8,18 +8,16 @@ import Data.Either (Either(..), either)
import Data.Maybe (Maybe(..))
import Network.HTTP.Affjax (AJAX, get)
import Prelude (bind, pure, show, ($), (<>), (<<<))
-import Pux (EffModel, noEffects)
+import Pux (noEffects, EffModel)
import Pux.DocumentTitle (documentTitle)
import Pux.Html (Html, div, h1, p, text)
import Pux.Html.Attributes (dangerouslySetInnerHTML, className, id_, title)
data Action = RequestPost
| ReceivePost (Either String Post)
- | RenderPost
type State =
{ status :: String
- , hack :: String
, id :: Maybe Int
, post :: Post
, name :: String }
@@ -40,7 +38,6 @@ instance decodeJsonPost :: DecodeJson Post where
init :: State
init =
{ status: "Loading..."
- , hack: ""
, post: Post
{ title: ""
, body: ""
@@ -51,10 +48,7 @@ init =
update :: Action -> State -> EffModel State Action (ajax :: AJAX, dom :: DOM)
update (ReceivePost (Left err)) state =
noEffects $ state { id = Nothing, status = err }
-update (ReceivePost (Right post)) state =
- { state: state { status = "", id = Just 1, post = post }
- , effects: [ pure $ RenderPost ]
- }
+update (ReceivePost (Right post)) state = noEffects $ state { status = "", id = Just 1, post = post }
update RequestPost state =
{ state: state
, effects: [ do
@@ -64,8 +58,6 @@ update RequestPost state =
pure $ ReceivePost post
]
}
-update RenderPost state =
- noEffects $ state { hack = mdify "blogpost" }
view :: State -> Html Action
view { id: id, status: status, post: (Post post) } =
@@ -76,5 +68,5 @@ view { id: id, status: status, post: (Post post) } =
[ h1 [] [ text status ]
, documentTitle [ title $ post.title <> " - Christine Dodrill" ] []
, div [ className "col s8 offset-s2" ]
- [ p [ id_ "blogpost", dangerouslySetInnerHTML post.body ] [] ]
+ [ p [ id_ "blogpost", dangerouslySetInnerHTML $ mdify post.body ] [] ]
]