Having fun with yesod, and a few questions came up.

I'm playing with yesod http://docs.yesodweb.com/yesod/, and I have a few questions: Here's an excerpt from yesod/tutorial/i18n.lhs **NOTE: This tutorial requires the development version of Yesod (version 0.4.0). The [tutorial main page]($root/yesod/tutorial/) has instructions on setting up your environment.** Where is $root? I thought it was where yesod-examples-0.4.0 was installed. But if this is the case, I'm not finding these instructions. This makes me think I am confused about the directory $root represents. I was playing around with the code and made some changes. Here is the line in question, with the complete code below for context.
instance Yesod I18N where approot _ = ""
This does what I expect it to do, it runs the program when I open up http://my.blog.server/ however, I wanted to see what would happen if I played around with it a little bit. I want the same program to run when I point my browser to http://my.blog.server/blog so I made this change
approot _ = "/blog"
but now when I point my browser to http://my.blog.server/blog it gets re-written to http:/my.blog.server/blog/blog and then this error message Not Found /blog/blog Not sure what is going on here, could someone enlighten me? --- title: Multi-lingual -- Tutorials -- Yesod --- **NOTE: This tutorial requires the development version of Yesod (version 0.4.0). The [tutorial main page]($root/yesod/tutorial/) has instructions on setting up your environment.**
{-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeFamilies #-}
import Yesod import Data.Monoid (mempty)
data I18N = I18N
mkYesod "I18N" [$parseRoutes| / HomepageR GET /set/#String SetLangR GET |]
instance Yesod I18N where approot _ = "/blog"
getHomepageR :: Handler I18N RepHtml getHomepageR = do ls <- languages let hello = chooseHello ls let choices = [ ("en", "English") , ("es", "Spanish") , ("he", "Hebrew") ] applyLayout "I18N Homepage" mempty [$hamlet| %h1 $hello$ %p In other languages: %ul $forall choices choice %li %a!href=@SetLangR.fst.choice@ $snd.choice$ |]
chooseHello :: [String] -> String chooseHello [] = "Hello" chooseHello ("he":_) = "ש×~\×~U×~]" chooseHello ("es":_) = "Hola" chooseHello (_:rest) = chooseHello rest
getSetLangR :: String -> Handler I18N () getSetLangR lang = do setLanguage lang redirect RedirectTemporary HomepageR
main :: IO () main = basicHandler 3000 I18N

On Thu, Jul 15, 2010 at 6:57 PM, Michael Litchard
I'm playing with yesod http://docs.yesodweb.com/yesod/, and I have a few questions:
Here's an excerpt from yesod/tutorial/i18n.lhs
**NOTE: This tutorial requires the development version of Yesod (version 0.4.0). The [tutorial main page]($root/yesod/tutorial/) has instructions on setting up your environment.**
Where is $root? I thought it was where yesod-examples-0.4.0 was installed. But if this is the case, I'm not finding these instructions. This makes me think I am confused about the directory $root represents.
Sorry about the $root stuff, it's an artifact from the web site. I use the same code base for the yesod-examples package and the tutorials on the site to make sure everything compiles properly. In any event, the line in question is out-of-date and needs to be removed: 0.4.0 has been officially released, so you just need a cabal install yesod to get started.
line in question, with the complete code below for context.
instance Yesod I18N where approot _ = ""
This does what I expect it to do, it runs the program when I open up http://my.blog.server/
however, I wanted to see what would happen if I played around with it a little bit. I want the same program to run when I point my browser to http://my.blog.server/blog
so I made this change
approot _ = "/blog"
but now when I point my browser to http://my.blog.server/blog it gets re-written to http:/my.blog.server/blog/blog and then this error message Not Found /blog/blog
Not sure what is going on here, could someone enlighten me?
The approot function is used for *rendering* routes. This has no affect on where Yesod *listens* to requests. For example, you could put approot _ = " http://haskell.org", but you wouldn't be able to respond to requests for
I was playing around with the code and made some changes. Here is the that domain. Nonetheless, URLs generated by Yesod would then point to haskell.org. Basically, the only time to get fancy with approot is when you're doing URL rewriting for (Fast)CGI hosted applications. When you use a standalone server, you'll always* be serving from the root of the domain, and so the value of approot should just be that domain name. * Of course, there's always exceptions. You might look at the documentation[1] where it explains when it's permissible to use an empty string for the value of approot. Michael [1] http://docs.yesodweb.com/haddock/yesod/Yesod-Yesod.html#v%3Aapproot

Okay this is what I have so far, concerning what I need to do on the Haskell end of things to get it working with lighttpd. As an example, I will use blog.lhs from the yesod tutorial All that's left now is the main function. Yesod is built on top of WAI, so you can use any WAI handler you wish. For the tutorials, we'll use the basicHandler that comes built-in with Yesod: it serves content via CGI if the appropriate environment variables are available, otherwise with simpleserver.
main :: IO () main = do entries <- loadEntries basicHandler 3000 $ Blog entries
This brings into sharp relief my ignorance on how to use hackage. I
tried to investigate hackage looking for some WAI handler that would
get me what I want. Namely, turning this example into a fastCGI
application that lighttpd could use.
So this generates two questions. How would one use hackage to find a
WAI handler to use for fastCGI?
What would be an example of a WAI handler I could use with yesod?
Thanks for making it possible for guys like me to do this.
On Thu, Jul 15, 2010 at 9:33 AM, Michael Snoyman
On Thu, Jul 15, 2010 at 6:57 PM, Michael Litchard
wrote: I'm playing with yesod http://docs.yesodweb.com/yesod/, and I have a few questions:
Here's an excerpt from yesod/tutorial/i18n.lhs
**NOTE: This tutorial requires the development version of Yesod (version 0.4.0). The [tutorial main page]($root/yesod/tutorial/) has instructions on setting up your environment.**
Where is $root? I thought it was where yesod-examples-0.4.0 was installed. But if this is the case, I'm not finding these instructions. This makes me think I am confused about the directory $root represents.
Sorry about the $root stuff, it's an artifact from the web site. I use the same code base for the yesod-examples package and the tutorials on the site to make sure everything compiles properly. In any event, the line in question is out-of-date and needs to be removed: 0.4.0 has been officially released, so you just need a cabal install yesod to get started.
I was playing around with the code and made some changes. Here is the line in question, with the complete code below for context.
instance Yesod I18N where approot _ = ""
This does what I expect it to do, it runs the program when I open up http://my.blog.server/
however, I wanted to see what would happen if I played around with it a little bit. I want the same program to run when I point my browser to http://my.blog.server/blog
so I made this change
approot _ = "/blog"
but now when I point my browser to http://my.blog.server/blog it gets re-written to http:/my.blog.server/blog/blog and then this error message Not Found /blog/blog
Not sure what is going on here, could someone enlighten me?
The approot function is used for *rendering* routes. This has no affect on where Yesod *listens* to requests. For example, you could put approot _ = "http://haskell.org", but you wouldn't be able to respond to requests for that domain. Nonetheless, URLs generated by Yesod would then point to haskell.org. Basically, the only time to get fancy with approot is when you're doing URL rewriting for (Fast)CGI hosted applications. When you use a standalone server, you'll always* be serving from the root of the domain, and so the value of approot should just be that domain name. * Of course, there's always exceptions. You might look at the documentation[1] where it explains when it's permissible to use an empty string for the value of approot. Michael [1] http://docs.yesodweb.com/haddock/yesod/Yesod-Yesod.html#v%3Aapproot

Regarding the incompleteness of fastcgi tutorial: I'm not quite sure what
you mean. The deploying section[1] gives information on how to configure
lighttpd to run a compiled Yesod application, *not* on how to write that
application. The tutorials show you how to write a Yesod application
The only thing missing now is your other question: which handler to use. The
answer to wai-handler-fastcgi[2]. It's built on top of the libfcgi C
library, so you'll need to make sure you have that installed. A previous
version was built on the direct-fastcgi[3] package, but I found that to have
considerably lower performance. If people are interested in a
wai-handler-direct-fastcgi, let me know, I'll release it.
Anyway, the function you're probably looking for in Yesod is toWaiApp[4],
which produces an Application. You can then pass that Application to the
wai-handler-fastcgi run function, and you'll have a fastcgi executable.
If you think it will be useful, I can package up a sample application with a
lighttpd config file. And if anyone out there knows how to write config
files for other servers, that would be a nice addition as well.
Michael
[1] http://docs.yesodweb.com/yesod/deploying.html
http://docs.yesodweb.com/yesod/deploying.html[2]
http://hackage.haskell.org/package/wai-handler-fastcgi
[3] http://hackage.haskell.org/package/direct-fastcgi
[4] http://docs.yesodweb.com/haddock/yesod/Yesod-Dispatch.html#v%3AtoWaiApp
On Thu, Jul 15, 2010 at 8:39 PM, Michael Litchard
Okay this is what I have so far, concerning what I need to do on the Haskell end of things to get it working with lighttpd.
As an example, I will use blog.lhs from the yesod tutorial
All that's left now is the main function. Yesod is built on top of WAI, so you can use any WAI handler you wish. For the tutorials, we'll use the basicHandler that comes built-in with Yesod: it serves content via CGI if the appropriate environment variables are available, otherwise with simpleserver.
main :: IO () main = do entries <- loadEntries basicHandler 3000 $ Blog entries
This brings into sharp relief my ignorance on how to use hackage. I tried to investigate hackage looking for some WAI handler that would get me what I want. Namely, turning this example into a fastCGI application that lighttpd could use.
So this generates two questions. How would one use hackage to find a WAI handler to use for fastCGI? What would be an example of a WAI handler I could use with yesod?
Thanks for making it possible for guys like me to do this.
On Thu, Jul 15, 2010 at 9:33 AM, Michael Snoyman
wrote: On Thu, Jul 15, 2010 at 6:57 PM, Michael Litchard
wrote: I'm playing with yesod http://docs.yesodweb.com/yesod/, and I have a few questions:
Here's an excerpt from yesod/tutorial/i18n.lhs
**NOTE: This tutorial requires the development version of Yesod (version 0.4.0). The [tutorial main page]($root/yesod/tutorial/) has instructions on setting up your environment.**
Where is $root? I thought it was where yesod-examples-0.4.0 was installed. But if this is the case, I'm not finding these instructions. This makes me think I am confused about the directory $root represents.
Sorry about the $root stuff, it's an artifact from the web site. I use
the
same code base for the yesod-examples package and the tutorials on the site to make sure everything compiles properly. In any event, the line in question is out-of-date and needs to be removed: 0.4.0 has been officially released, so you just need a cabal install yesod to get started.
I was playing around with the code and made some changes. Here is the line in question, with the complete code below for context.
instance Yesod I18N where approot _ = ""
This does what I expect it to do, it runs the program when I open up http://my.blog.server/
however, I wanted to see what would happen if I played around with it a little bit. I want the same program to run when I point my browser to http://my.blog.server/blog
so I made this change
approot _ = "/blog"
but now when I point my browser to http://my.blog.server/blog it gets re-written to http:/my.blog.server/blog/blog and then this error message Not Found /blog/blog
Not sure what is going on here, could someone enlighten me?
The approot function is used for *rendering* routes. This has no affect on where Yesod *listens* to requests. For example, you could put approot _ = "http://haskell.org", but you wouldn't be able to respond to requests for that domain. Nonetheless, URLs generated by Yesod would then point to haskell.org. Basically, the only time to get fancy with approot is when you're doing URL rewriting for (Fast)CGI hosted applications. When you use a standalone server, you'll always* be serving from the root of the domain, and so the value of approot should just be that domain name. * Of course, there's always exceptions. You might look at the documentation[1] where it explains when it's permissible to use an empty string for the value of approot. Michael [1] http://docs.yesodweb.com/haddock/yesod/Yesod-Yesod.html#v%3Aapproot
Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

Yes, thank you. It would be useful for you to package up a sample
application with a lighttpd config file. I would appreciate that.
On Thu, Jul 15, 2010 at 11:06 AM, Michael Snoyman
Regarding the incompleteness of fastcgi tutorial: I'm not quite sure what you mean. The deploying section[1] gives information on how to configure lighttpd to run a compiled Yesod application, *not* on how to write that application. The tutorials show you how to write a Yesod application The only thing missing now is your other question: which handler to use. The answer to wai-handler-fastcgi[2]. It's built on top of the libfcgi C library, so you'll need to make sure you have that installed. A previous version was built on the direct-fastcgi[3] package, but I found that to have considerably lower performance. If people are interested in a wai-handler-direct-fastcgi, let me know, I'll release it. Anyway, the function you're probably looking for in Yesod is toWaiApp[4], which produces an Application. You can then pass that Application to the wai-handler-fastcgi run function, and you'll have a fastcgi executable. If you think it will be useful, I can package up a sample application with a lighttpd config file. And if anyone out there knows how to write config files for other servers, that would be a nice addition as well. Michael
[1] http://docs.yesodweb.com/yesod/deploying.html [2] http://hackage.haskell.org/package/wai-handler-fastcgi [3] http://hackage.haskell.org/package/direct-fastcgi [4] http://docs.yesodweb.com/haddock/yesod/Yesod-Dispatch.html#v%3AtoWaiApp
On Thu, Jul 15, 2010 at 8:39 PM, Michael Litchard
wrote: Okay this is what I have so far, concerning what I need to do on the Haskell end of things to get it working with lighttpd.
As an example, I will use blog.lhs from the yesod tutorial
All that's left now is the main function. Yesod is built on top of WAI, so you can use any WAI handler you wish. For the tutorials, we'll use the basicHandler that comes built-in with Yesod: it serves content via CGI if the appropriate environment variables are available, otherwise with simpleserver.
main :: IO () main = do entries <- loadEntries basicHandler 3000 $ Blog entries
This brings into sharp relief my ignorance on how to use hackage. I tried to investigate hackage looking for some WAI handler that would get me what I want. Namely, turning this example into a fastCGI application that lighttpd could use.
So this generates two questions. How would one use hackage to find a WAI handler to use for fastCGI? What would be an example of a WAI handler I could use with yesod?
Thanks for making it possible for guys like me to do this.
On Thu, Jul 15, 2010 at 9:33 AM, Michael Snoyman
wrote: On Thu, Jul 15, 2010 at 6:57 PM, Michael Litchard
wrote: I'm playing with yesod http://docs.yesodweb.com/yesod/, and I have a few questions:
Here's an excerpt from yesod/tutorial/i18n.lhs
**NOTE: This tutorial requires the development version of Yesod (version 0.4.0). The [tutorial main page]($root/yesod/tutorial/) has instructions on setting up your environment.**
Where is $root? I thought it was where yesod-examples-0.4.0 was installed. But if this is the case, I'm not finding these instructions. This makes me think I am confused about the directory $root represents.
Sorry about the $root stuff, it's an artifact from the web site. I use the same code base for the yesod-examples package and the tutorials on the site to make sure everything compiles properly. In any event, the line in question is out-of-date and needs to be removed: 0.4.0 has been officially released, so you just need a cabal install yesod to get started.
I was playing around with the code and made some changes. Here is the line in question, with the complete code below for context.
instance Yesod I18N where approot _ = ""
This does what I expect it to do, it runs the program when I open up http://my.blog.server/
however, I wanted to see what would happen if I played around with it a little bit. I want the same program to run when I point my browser to http://my.blog.server/blog
so I made this change
approot _ = "/blog"
but now when I point my browser to http://my.blog.server/blog it gets re-written to http:/my.blog.server/blog/blog and then this error message Not Found /blog/blog
Not sure what is going on here, could someone enlighten me?
The approot function is used for *rendering* routes. This has no affect on where Yesod *listens* to requests. For example, you could put approot _ = "http://haskell.org", but you wouldn't be able to respond to requests for that domain. Nonetheless, URLs generated by Yesod would then point to haskell.org. Basically, the only time to get fancy with approot is when you're doing URL rewriting for (Fast)CGI hosted applications. When you use a standalone server, you'll always* be serving from the root of the domain, and so the value of approot should just be that domain name. * Of course, there's always exceptions. You might look at the documentation[1] where it explains when it's permissible to use an empty string for the value of approot. Michael [1] http://docs.yesodweb.com/haddock/yesod/Yesod-Yesod.html#v%3Aapproot
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

On Thu, 15 Jul 2010 11:18:39 -0700
"Michael" == Michael Litchard
wrote:
Michael> Yes, thank you. It would be useful for you to package up a Michael> sample application with a lighttpd config file. I would Michael> appreciate that. +1 for cherokee config ;) Sincerely, Gour -- Gour | Hlapicina, Croatia | GPG key: F96FF5F6 ----------------------------------------------------------------

I've put together a repository on github[1] that has examples of hosting a
simple Yesod application. The nonroot variants show you how to host your
application at some place other than the domain root.
I've only included lighttpd config files, since that's all I use on a
regular basis. I'm happy to take patches from anyone having experience with
other servers.
Michael
[1] http://github.com/snoyberg/yesod-hello
On Thu, Jul 15, 2010 at 11:09 PM, Gour
On Thu, 15 Jul 2010 11:18:39 -0700
> "Michael" == Michael Litchard
wrote: Michael> Yes, thank you. It would be useful for you to package up a Michael> sample application with a lighttpd config file. I would Michael> appreciate that.
+1 for cherokee config ;)
Sincerely, Gour
--
Gour | Hlapicina, Croatia | GPG key: F96FF5F6 ----------------------------------------------------------------
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

Thank you.
On Fri, Jul 16, 2010 at 12:02 AM, Michael Snoyman
I've put together a repository on github[1] that has examples of hosting a simple Yesod application. The nonroot variants show you how to host your application at some place other than the domain root. I've only included lighttpd config files, since that's all I use on a regular basis. I'm happy to take patches from anyone having experience with other servers.
Michael [1] http://github.com/snoyberg/yesod-hello On Thu, Jul 15, 2010 at 11:09 PM, Gour
wrote: On Thu, 15 Jul 2010 11:18:39 -0700
>> "Michael" == Michael Litchard
wrote: Michael> Yes, thank you. It would be useful for you to package up a Michael> sample application with a lighttpd config file. I would Michael> appreciate that.
+1 for cherokee config ;)
Sincerely, Gour
--
Gour | Hlapicina, Croatia | GPG key: F96FF5F6 ----------------------------------------------------------------
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

ran into this problem
git fetch http://github.com/snoyberg/yesod-hello.git
fatal: Not a git repository
I did that correctly right?
On Fri, Jul 16, 2010 at 12:02 AM, Michael Snoyman
I've put together a repository on github[1] that has examples of hosting a simple Yesod application. The nonroot variants show you how to host your application at some place other than the domain root. I've only included lighttpd config files, since that's all I use on a regular basis. I'm happy to take patches from anyone having experience with other servers.
Michael [1] http://github.com/snoyberg/yesod-hello On Thu, Jul 15, 2010 at 11:09 PM, Gour
wrote: On Thu, 15 Jul 2010 11:18:39 -0700
>> "Michael" == Michael Litchard
wrote: Michael> Yes, thank you. It would be useful for you to package up a Michael> sample application with a lighttpd config file. I would Michael> appreciate that.
+1 for cherokee config ;)
Sincerely, Gour
--
Gour | Hlapicina, Croatia | GPG key: F96FF5F6 ----------------------------------------------------------------
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

On Saturday 17 July 2010 05:22:36, Michael Litchard wrote:
git fetch http://github.com/snoyberg/yesod-hello.git fatal: Not a git repository
I did that correctly right?
I'm not familiar with git, but I think it should be git fetch git://github.com/...

I think you want:
git clone git://....
-deech
On Sat, Jul 17, 2010 at 7:55 AM, Daniel Fischer
On Saturday 17 July 2010 05:22:36, Michael Litchard wrote:
git fetch http://github.com/snoyberg/yesod-hello.git fatal: Not a git repository
I did that correctly right?
I'm not familiar with git, but I think it should be
git fetch git://github.com/...
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
participants (5)
-
aditya siram
-
Daniel Fischer
-
Gour
-
Michael Litchard
-
Michael Snoyman