On Monday, January 9, 2017 at 11:24:57 AM UTC, Rupert Smith wrote:
>
> In my case, I am using server side rendering just for (relatively) static 
> content, so there is practically no application state. I am pretty much 
> there with this simple application model as far as being isomorphic goes.
>

So I have client and server side renderings of the site now fully working 
and looking identical.

Server rendered content is under /content/slug but client rendered is under 
/editor/#slug. For that reason, I have to pass down a function that is used 
to create links from slugs, into the view:

type alias LinkBuilder msg =
    String -> Html.Attribute msg

view : LinkBuilder msg -> Model.Content -> Html msg

Interestingly, as the server side can only render Html Never, I was able to 
constrain it to doing just that and have the type checker ensure it is 
enforceable:

Html.map never <| ContentView.view contentLinker content

This binds the type parameter 'msg' to Never, ensuring it has not been 
bound to some Msg type. This will be a useful check, because the next step 
is to pass some kind of editing function into the view too, which will 
render content in such a way that it does generate events but I need to 
make sure I don't accidentally introduce some code that will prevent the 
server side rendering from working.

The principal content type I am using is markdown, and this is rendered 
with Markdown.toHtml. So I need a function that gives me Markdwon.toHtml 
for server mode, and one that gives me that or a textbox for client mode.

I'd like if the mouse hovers over an editable item for a while or the user 
clicks on one, that some kind of box appears around it with a toolbar at 
the top. Not sure yet if this will work best outwith the normal page flow, 
stacked above it, or sit within it. I'll try stacking it above it first, 
and using the techniques described here to get the size and position of the 
content being worked with:

https://medium.com/@debois/elm-the-dom-8c9883190d20#.xwek1w608

That is a rough outline of the editing function and how it will be injected 
into the view logic that is otherwise fully shared between client and 
server.

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to