On Sun, Jun 28, 2015 at 10:18 AM, Njagi Mwaniki
<mwanikibusiness(a)gmail.com> wrote:
> Another question for you. How can I or recreate the results of functions
> like widgetFile in yesod? I want to use julius, lucius and hamlet in my
> wai-routes app.
You don't need a widgetFile function to use Julius and Lucius in
wai-routes. Take a look at this small example -
https://github.com/ajnsit/wai-routes/blob/master/examples/Hamlet.hs -
on how to render Cassius from an external file. The process for
including Julius or Lucius should be fairly similar to Cassius.
Note that Wai-routes 0.7.1 includes a function called `showRouteQuery`
(http://hackage.haskell.org/package/wai-routes-0.7.1/docs/Network-Wai-Middle…)
which is a route renderer in the format that Shakespearean templates
expect.
-- Anupam
Hi all,
I have just released v0.7 of wai-routes, the typesafe urls framework
for wai. After letting the code rot for several months, I finally
managed to carve out some time to do a bit of housekeeping. The code
now compiles with ghc 7.8 and 7.10, and is compatible with wai-3.0.
The dependency on yesod-routes has also been removed, as that package
was deprecated, and its code has been folded into wai-routes.
I also took the opportunity to add a few long pending features -
1. Subsites! Simpler than the corresponding concept in Yesod, though
probably less powerful as well. This is still an evolving experimental
feature.
2. Ability to get information about the currently executing route,
including the Route Attributes (which is exactly the same thing as in
Yesod).
Get it at -
[http://hackage.haskell.org/package/wai-routes]
[https://github.com/ajnsit/wai-routes]
Feedback would be greatly appreciated, especially from people using
wai-routes in their projects!
-- Anupam
Glad you figured it out! The html function accepts Bytestring instead
of Text to be compatible with blaze-html. I will probably add a
htmlText function which supports Text instead and works seamlessly
with Hamlet et all.
One minor thing I notices in your code - it converts from Lazy Text ->
Strict Text -> Strict ByteString -> Lazy ByteString
If you use encodeUtf8 from Data.Text.Lazy.Encoding, you can go
directly from Lazy ByteString -> Lazy Text.
-- Anupam
On Fri, Jun 12, 2015 at 5:16 PM, Njagi Mwaniki
<mwanikibusiness(a)gmail.com> wrote:
> Never mind. I found a way to make it work here:
> https://github.com/urbanslug/cats/blob/master/Handler/Home.hs
>
>
> On Friday, 12 June 2015 12:08:44 UTC+3, Njagi Mwaniki wrote:
>>
>> Hey, I am trying to use shakesperean templates with this. I just can't get
>> it to work. Even in a quasiqote widget kind of way. What am I doing wrong?
>> or is this not supported at all. I would like to finally use external files
>> for hamlet lucius and julius. I could show you my code but it's just a ball
>> of wool so I won't even bother.
>>
>> On Wednesday, 10 June 2015 22:19:06 UTC+3, Anupam wrote:
>>>
>>> You are right. The example in the README is meant to be more of a
>>> template which gives you a flavor of what the code looks like. It also
>>> has chunks of code missing (and with ellipses in its place) that would
>>> need to be filled in before it would compile. The code in the
>>> examples/ directory on github has working code examples with cabal
>>> files
>>> (https://github.com/ajnsit/wai-routes/blob/master/examples/Subsites.hs)
>>> I am working on improving the documentation, and adding more examples.
>>>
>>> To answer your other questions -
>>>
>>> 1. I just released v0.7 today. Docs on Hackage are built periodically,
>>> and we should have proper documentation generated soon.
>>>
>>> 2. The TH code generates a "resource" for your route which is like an
>>> abstract representation of your route declaration. It can be reused in
>>> other parts of the code. Notably it is useful when you want to
>>> separate the declaration for the Route datatype and the dispatching
>>> code. In your example, since the resource is created but not used or
>>> exported, it generates a warning. For now you can safely ignore it.
>>>
>>> 3. "HandlerS sub master" is the type of a handler for a Subsite "sub"
>>> running within a master site "master". Unfortunately that type is not
>>> very easy to work with. "HandlerM" is a Monadic type that provides
>>> easy access to all wai-routes functionality, and can then be converted
>>> to a HandlerS using runHandlerM. When you don't have a subsite, the
>>> type is simply "HandlerM sub master", which is aliased to "Handler
>>> master". That's why in your example, the handlers all have the type
>>> "Handler MyRoute".
>>>
>>> 4. "RouteM" is another Monadic type which makes it easy to compose
>>> multiple routes and middleware together to create a final wai
>>> application. This along with "nested routes", and "subsites", helps
>>> you better organise your application.
>>>
>>> HTH
>>>
>>> -- Anupam
>>>
>>>
>>>
>>> On Wed, Jun 10, 2015 at 8:38 PM, Njagi Mwaniki
>>> <mwaniki...(a)gmail.com> wrote:
>>> > It could be just me but the example in your README is totally broken.
>>> > It
>>> > needs at least the extensions like QuasiQotes and TemplateHaskell. Also
>>> > where does DB (used in your example) come from?
>>> >
>>> > Anyway using other examples from your README I got a minimal working
>>> > example
>>> > here: https://gist.github.com/urbanslug/58a584c002f54ad75c02
>>> >
>>> > I have a few questions regarding the types.
>>> >
>>> > * The haddocks on hackage don't work yet, do they?
>>> > * in myRoute L21 I get the warning `Defined but not used:
>>> > ‘resourcesMyRoute’` can you help with that?
>>> > * I'm confused about this type signature "runHandlerM :: HandlerM sub
>>> > master
>>> > () -> HandlerS sub master"
>>> > * What are HandlerM and RouteM and sub and master? They are in many
>>> > type
>>> > signatures and I don't get them.
>>> >
>>> > Thank you.
>>> >
>>> > On Wednesday, 10 June 2015 01:54:33 UTC+3, Anupam wrote:
>>> >>
>>> >> Hi all,
>>> >>
>>> >> I have just released v0.7 of wai-routes, the typesafe urls framework
>>> >> for wai. After letting the code rot for several months, I finally
>>> >> managed to carve out some time to do a bit of housekeeping. The code
>>> >> now compiles with ghc 7.8 and 7.10, and is compatible with wai-3.0.
>>> >> The dependency on yesod-routes has also been removed, as that package
>>> >> was deprecated, and its code has been folded into wai-routes.
>>> >>
>>> >> I also took the opportunity to add a few long pending features -
>>> >> 1. Subsites! Simpler than the corresponding concept in Yesod, though
>>> >> probably less powerful as well. This is still an evolving experimental
>>> >> feature.
>>> >> 2. Ability to get information about the currently executing route,
>>> >> including the Route Attributes (which is exactly the same thing as in
>>> >> Yesod).
>>> >>
>>> >> Get it at -
>>> >> [http://hackage.haskell.org/package/wai-routes]
>>> >> [https://github.com/ajnsit/wai-routes]
>>> >>
>>> >> Feedback would be greatly appreciated, especially from people using
>>> >> wai-routes in their projects!
>>> >>
>>> >> -- Anupam
>>> >
>>> > --
>>> > You received this message because you are subscribed to the Google
>>> > Groups
>>> > "Yesod Web Framework" group.
>>> > To unsubscribe from this group and stop receiving emails from it, send
>>> > an
>>> > email to yesodweb+u...(a)googlegroups.com.
>>> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Yesod Web Framework" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to yesodweb+unsubscribe(a)googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
You are right. The example in the README is meant to be more of a
template which gives you a flavor of what the code looks like. It also
has chunks of code missing (and with ellipses in its place) that would
need to be filled in before it would compile. The code in the
examples/ directory on github has working code examples with cabal
files (https://github.com/ajnsit/wai-routes/blob/master/examples/Subsites.hs)
I am working on improving the documentation, and adding more examples.
To answer your other questions -
1. I just released v0.7 today. Docs on Hackage are built periodically,
and we should have proper documentation generated soon.
2. The TH code generates a "resource" for your route which is like an
abstract representation of your route declaration. It can be reused in
other parts of the code. Notably it is useful when you want to
separate the declaration for the Route datatype and the dispatching
code. In your example, since the resource is created but not used or
exported, it generates a warning. For now you can safely ignore it.
3. "HandlerS sub master" is the type of a handler for a Subsite "sub"
running within a master site "master". Unfortunately that type is not
very easy to work with. "HandlerM" is a Monadic type that provides
easy access to all wai-routes functionality, and can then be converted
to a HandlerS using runHandlerM. When you don't have a subsite, the
type is simply "HandlerM sub master", which is aliased to "Handler
master". That's why in your example, the handlers all have the type
"Handler MyRoute".
4. "RouteM" is another Monadic type which makes it easy to compose
multiple routes and middleware together to create a final wai
application. This along with "nested routes", and "subsites", helps
you better organise your application.
HTH
-- Anupam
On Wed, Jun 10, 2015 at 8:38 PM, Njagi Mwaniki
<mwanikibusiness(a)gmail.com> wrote:
> It could be just me but the example in your README is totally broken. It
> needs at least the extensions like QuasiQotes and TemplateHaskell. Also
> where does DB (used in your example) come from?
>
> Anyway using other examples from your README I got a minimal working example
> here: https://gist.github.com/urbanslug/58a584c002f54ad75c02
>
> I have a few questions regarding the types.
>
> * The haddocks on hackage don't work yet, do they?
> * in myRoute L21 I get the warning `Defined but not used:
> ‘resourcesMyRoute’` can you help with that?
> * I'm confused about this type signature "runHandlerM :: HandlerM sub master
> () -> HandlerS sub master"
> * What are HandlerM and RouteM and sub and master? They are in many type
> signatures and I don't get them.
>
> Thank you.
>
> On Wednesday, 10 June 2015 01:54:33 UTC+3, Anupam wrote:
>>
>> Hi all,
>>
>> I have just released v0.7 of wai-routes, the typesafe urls framework
>> for wai. After letting the code rot for several months, I finally
>> managed to carve out some time to do a bit of housekeeping. The code
>> now compiles with ghc 7.8 and 7.10, and is compatible with wai-3.0.
>> The dependency on yesod-routes has also been removed, as that package
>> was deprecated, and its code has been folded into wai-routes.
>>
>> I also took the opportunity to add a few long pending features -
>> 1. Subsites! Simpler than the corresponding concept in Yesod, though
>> probably less powerful as well. This is still an evolving experimental
>> feature.
>> 2. Ability to get information about the currently executing route,
>> including the Route Attributes (which is exactly the same thing as in
>> Yesod).
>>
>> Get it at -
>> [http://hackage.haskell.org/package/wai-routes]
>> [https://github.com/ajnsit/wai-routes]
>>
>> Feedback would be greatly appreciated, especially from people using
>> wai-routes in their projects!
>>
>> -- Anupam
>
> --
> You received this message because you are subscribed to the Google Groups
> "Yesod Web Framework" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to yesodweb+unsubscribe(a)googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.