aboutsummaryrefslogtreecommitdiff
path: root/frontend/src
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
parent62ffa5f0089f5f11c069f017b0dc69df6141de34 (diff)
downloadxesite-e1a6482dc61afee78ae23d92510db41b703c534f.tar.xz
xesite-e1a6482dc61afee78ae23d92510db41b703c534f.zip
frontend: make mdify return rendered html
Diffstat (limited to 'frontend/src')
-rw-r--r--frontend/src/BlogEntry.purs14
-rw-r--r--frontend/src/Utils.js7
2 files changed, 5 insertions, 16 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 ] [] ]
]
diff --git a/frontend/src/Utils.js b/frontend/src/Utils.js
index f464cf2..942f75c 100644
--- a/frontend/src/Utils.js
+++ b/frontend/src/Utils.js
@@ -1,9 +1,6 @@
// Module App.BlogEntry
-exports.mdify = function(id) {
+exports.mdify = function(corpus) {
var converter = new showdown.Converter()
- elem = document.getElementById(id);
- md = elem.innerHTML;
- elem.innerHTML = converter.makeHtml(md);
- return "done :)";
+ return converter.makeHtml(corpus);
}