Multiple static pages

26 views
Skip to first unread message

Bulat Ziganshin

unread,
May 30, 2012, 1:33:55 AM5/30/12
to Yesod Web Framework
i'm trying to use Yesod to reimplement my http://freearc.org site. it
consists of static pages, so handlers for all the pages should be the
same - approach not directly supported by Yesod. ATM i got with the
following decision:

routes:
/ HomeR GET
/Download DownloadR GET

Handler\Home.hs: http://hpaste.org/69235

it would be great to replace this part:

getHomeR, getDownloadR :: Handler RepHtml
[getHomeR, getDownloadR] = map page table

with TH call of sort:

$(makeGetRs table pageRoute page)

Ideally, it should be possible to declare routes+metainfo in the same
place, may be directly in page file templates, as it was done in
https://github.com/yesodweb/yesodweb.com-content/blob/master/blog/posts.yaml
or https://github.com/yesodweb/yesodweb.com-content/blob/master/page/about.html
;)

Bulat Ziganshin

unread,
May 30, 2012, 3:25:11 AM5/30/12
to Yesod Web Framework
Hello Bulat,

Wednesday, May 30, 2012, 9:33:55 AM, you wrote:

> it would be great to replace this part:
> with TH call of sort:

i've added TH generation of page handlers, although it's a bit
specific to my code and can't be directly propagated to the library:

http://hpaste.org/69245


--
Best regards,
Bulat mailto:Bulat.Z...@gmail.com

Michael Snoyman

unread,
May 30, 2012, 5:10:57 AM5/30/12
to yeso...@googlegroups.com
That approach works, and might be the best solution for you. Without
knowing more about your use case (what's in the hamlet files, what all
of the routes look like, etc) I can't really give any advice. Let me
ask a different question: why isn't the approach taken by yesodweb.com
(in the folder you linked to[1]) a sufficient solution?

Michael

[1] https://github.com/yesodweb/yesodweb.com-content/tree/master/page

Bulat Ziganshin

unread,
May 30, 2012, 6:35:16 AM5/30/12
to Michael Snoyman, yeso...@googlegroups.com
Hello Michael,

Wednesday, May 30, 2012, 1:10:57 PM, you wrote:

> That approach works, and might be the best solution for you. Without
> knowing more about your use case (what's in the hamlet files, what all
> of the routes look like, etc) I can't really give any advice. Let me
> ask a different question: why isn't the approach taken by yesodweb.com
> (in the folder you linked to[1]) a sufficient solution?

1) because it isn't part of Yeasod, meaning that i would need to
copy-paste your code

2) because "yesod-contents" may only include plain HTML, omitting
support for hamlet features like @{route} and %{var}

your solution is great for dynamic content. what i need is a sort of
compile-time CMS, with a key CMS feature - page metainformation
that i need to automatically build menus on each page

Kirill Zaborsky

unread,
May 30, 2012, 6:39:46 AM5/30/12
to yeso...@googlegroups.com, Michael Snoyman
Bulat, why don't you use Hakyll[1] for that?


Kind regards,
Kirill Zaborsky

2012/5/30 Bulat Ziganshin <bulat.z...@gmail.com>

Michael Snoyman

unread,
May 30, 2012, 9:43:15 AM5/30/12
to yeso...@googlegroups.com
In that case, I think for now your TH solution is probably the best
thing to stick with. I don't know that this is a general enough
problem that we can offer a built-in solution for it (though if people
have ideas, feel free to bring them up).

Michael

Bulat Ziganshin

unread,
Jun 1, 2012, 8:34:48 AM6/1/12
to Kirill Zaborsky, yeso...@googlegroups.com, Michael Snoyman
Hello Kirill,

Wednesday, May 30, 2012, 2:39:46 PM, you wrote:

> Bulat, why don't you use Hakyll[1] for that?

thank you for suggestion. those static pages were only the first step,
i'm already adding some intelligence to them. so i'm searching for
application server like node.js

yesod looks the best choice for me - because i already know haskell,
and because it promises great performance and scalability. now i
use nginx for reverse proxying and static files, plus apache for
ssi/fcgi and hope to replace them all with yesod-based app server
Reply all
Reply to author
Forward
0 new messages