New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Sitelet embedding combinator #307

Closed
Tarmil opened this Issue Dec 9, 2014 · 5 comments

Comments

Projects
None yet
2 participants
@Tarmil
Member

Tarmil commented Dec 9, 2014

Add a combinator to embed a Sitelet in another, more general type, for example if we have:

type EmbeddedAction =
    | // ...

type RootAction =
    | // ...
    | Embed of EmbeddedAction

then we want a combinator that allows to easily create a Sitelet<RootAction> given a Sitelet<EmbeddedAction>, which respects the original routing.

@Tarmil Tarmil self-assigned this Dec 9, 2014

@Tarmil Tarmil added this to the 3.0 milestone Dec 9, 2014

@endeavour

This comment has been minimized.

Show comment
Hide comment
@Tarmil

This comment has been minimized.

Show comment
Hide comment
@Tarmil

Tarmil Dec 9, 2014

Member

This is what I currently have in mind: https://gist.github.com/Tarmil/42d211300e09fde95b3b (example use and implementation)

Member

Tarmil commented Dec 9, 2014

This is what I currently have in mind: https://gist.github.com/Tarmil/42d211300e09fde95b3b (example use and implementation)

@endeavour

This comment has been minimized.

Show comment
Hide comment
@endeavour

endeavour Dec 9, 2014

I'm not sure this is sufficient because you can't, for example, link back to the homepage from the embedded site.

i.e. You can't do this: inside Action1:
A [HRef (ctx.Link Home)] -< [Text "Go home"]

It would also be nice to use the parent templates in the child.

I found my original request for this feature (and your comments) here: http://fpish.net/topic/Some/0/76197

I'm not sure this is sufficient because you can't, for example, link back to the homepage from the embedded site.

i.e. You can't do this: inside Action1:
A [HRef (ctx.Link Home)] -< [Text "Go home"]

It would also be nice to use the parent templates in the child.

I found my original request for this feature (and your comments) here: http://fpish.net/topic/Some/0/76197

@Tarmil

This comment has been minimized.

Show comment
Hide comment
@Tarmil

Tarmil Dec 13, 2014

Member

I think there is a use case for both:

  • Embed can wrap an existing sitelet into a wider action type, where the existing sitelet doesn't need to know that it's going to be embedded.
  • Your case, which I have just committed as InferPartial, where we want an inferred sitelet on a subset of the actions and the content function is aware of it.

With InferPartial your original request would be implemented as:

module NestedSite =
    let content templateWrapper = function
        | Foo -> templateWrapper <| fun ctx ->
            [
                Div [Text "Foo page"]
            ]
        | Bar x -> templateWrapper <| fun ctx ->
            [
                Div [Text "Bar page"]
            ]
        | Upload -> UploadHandler.UploadContentFactory "file" (fun _ -> "/success") (fun file -> () (*Save to disk etc here...*))

let Main =
    Sitelet.Sum [
        Sitelet.Content "/" Home HomePage
        Sitelet.Content "/About" About AboutPage
        Sitelet.InferPartialInUnion <@ Nested @> (NestedSite.content (Skin.WithTemplate "Home"))
    ]
Member

Tarmil commented Dec 13, 2014

I think there is a use case for both:

  • Embed can wrap an existing sitelet into a wider action type, where the existing sitelet doesn't need to know that it's going to be embedded.
  • Your case, which I have just committed as InferPartial, where we want an inferred sitelet on a subset of the actions and the content function is aware of it.

With InferPartial your original request would be implemented as:

module NestedSite =
    let content templateWrapper = function
        | Foo -> templateWrapper <| fun ctx ->
            [
                Div [Text "Foo page"]
            ]
        | Bar x -> templateWrapper <| fun ctx ->
            [
                Div [Text "Bar page"]
            ]
        | Upload -> UploadHandler.UploadContentFactory "file" (fun _ -> "/success") (fun file -> () (*Save to disk etc here...*))

let Main =
    Sitelet.Sum [
        Sitelet.Content "/" Home HomePage
        Sitelet.Content "/About" About AboutPage
        Sitelet.InferPartialInUnion <@ Nested @> (NestedSite.content (Skin.WithTemplate "Home"))
    ]
@endeavour

This comment has been minimized.

Show comment
Hide comment
@endeavour

endeavour Dec 13, 2014

Great stuff :) Thanks.

Great stuff :) Thanks.

@Tarmil Tarmil closed this Jan 8, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment