Erlang/OTP Forums

Author Message

<  Erlyweb mailing list  ~  Making a blog with ErlyWeb

Guest
Posted: Fri Dec 14, 2007 6:55 am Reply with quote
Guest
Hi,

> A note on the blog: It probably makes more work right now to rewrite
> what I
Guest
Posted: Fri Dec 14, 2007 10:16 am Reply with quote
Guest
Gotta go to sleep -- I'll answer tomorrow Smile

Yariv

On Dec 13, 2007 10:54 PM, maddiin <maddiin@googlemail.com> wrote:
>
> Hi,
>
> > A note on the blog: It probably makes more work right now to rewrite
> > what I
ketralnis
Posted: Fri Dec 14, 2007 5:23 pm Reply with quote
User Joined: 20 Jul 2007 Posts: 151 Location: San Francisco, CA
> 1. Website root:
> I didn
View user's profile Send private message AIM Address
dmitriid
Posted: Sat Dec 15, 2007 9:20 am Reply with quote
User Joined: 17 Aug 2006 Posts: 213
Quote:
Quote:
3. Template inheritance: Using the html_container_controller.erl/html_container_view.et as the root-template, how do I reuse header, main-content, sidebar and footer from other components? I only found out how to have a static sidebar and I would like that to be dynamic, for example showing blogrolls related to a category or leaving out latest_entries from an entry detail page. [/code]
Use the component system. See my example code on the FOREACH thread, or here <http://forum.trapexit.org/viewtopic.php?t=11291&sid=bd4ecf2f0188639e9da9efc6aa1c12d4 > (although trapexit loses all of my intentation). To summarise, you want a controller function like this: foo(A, Args) -> [{ewc,sidebar,[A]}, {data,whatever_data(Args)}].[/code]

Does this mean that I will need to return {ewc,sidebar,[A]} from every function of every controller?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post recived from mailinglist
View user's profile Send private message
ketralnis
Posted: Sat Dec 15, 2007 5:54 pm Reply with quote
User Joined: 20 Jul 2007 Posts: 151 Location: San Francisco, CA
>> Use the component system. See my example code on the FOREACH thread,
>> or here <http://forum.trapexit.org/viewtopic.php?t=11291&sid=bd4ecf2f0188639e9da9efc6aa1c12d4
>> > (although trapexit loses all of my intentation).
>>
>> To summarise, you want a controller function like this:
>>
>> foo(A, Args) ->
>> [{ewc,sidebar,[A]},
>> {data,whatever_data(Args)}].
> Does this mean that I will need to return {ewc,sidebar,[A]} from
> every function of every controller?

No. You chopped off the important bit of his question:

> 3. Template inheritance:
> Using the html_container_controller.erl/html_container_view.et as the
> root-template, how do I reuse header, main-content, sidebar and footer
> from other components?

I read that to mean, "I am using the html_container controller and
view to have a sidebar. But in some places I want to use those
components in some other way". Maybe I read it wrong Smile

If you just put it in your html_container, you don't need to do it
anywhere else.

Is anyone interested in a fully working erlyweb reference app? Would
that help? I have a tictactoe server that I wrote ages ago as an
example for someone that doesn't use erlydb, but it does use erlyweb

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post recived from mailinglist
View user's profile Send private message AIM Address
Guest
Posted: Sat Dec 15, 2007 6:53 pm Reply with quote
Guest
> Is anyone interested in a fully working erlyweb reference app? Would
> that help? I have a tictactoe server that I wrote ages ago as an
> example for someone that doesn't use erlydb, but it does use erlyweb

I'm interested... It isn't helping that erlyweb is my first MVC experience.

I always learn better by browsing working source code than by reading
chunks of code presented outside of the working tree.

Shaun

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post recived from mailinglist
ketralnis
Posted: Sat Dec 15, 2007 8:16 pm Reply with quote
User Joined: 20 Jul 2007 Posts: 151 Location: San Francisco, CA
>> Is anyone interested in a fully working erlyweb reference app? Would
>> that help? I have a tictactoe server that I wrote ages ago as an
>> example for someone that doesn't use erlydb, but it does use erlyweb
> I'm interested... It isn't helping that erlyweb is my first MVC
> experience.
> I always learn better by browsing working source code than by reading
> chunks of code presented outside of the working tree.

Alright, I'll clean it up and post it. I can also move a lot of the
state out into mnesia, so that it could use erlydb as well, so that it
serves as a better example.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post recived from mailinglist
View user's profile Send private message AIM Address
Guest
Posted: Sat Dec 15, 2007 8:25 pm Reply with quote
Guest
> Alright, I'll clean it up and post it. I can also move a lot of the
> state out into mnesia, so that it could use erlydb as well, so that it
> serves as a better example.

For what it's worth, leaving it the way it is without using erlydb
would be very helpful. If you convert it to mnesia would you be
willing to publish both?

Shaun

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post recived from mailinglist
Guest
Posted: Sat Dec 15, 2007 8:25 pm Reply with quote
Guest
On Dec 14, 2007 9:20 AM, David King <dking@ketralnis.com> wrote:
>
> > 1. Website root:
> > I didn
ketralnis
Posted: Sun Dec 16, 2007 1:59 am Reply with quote
User Joined: 20 Jul 2007 Posts: 151 Location: San Francisco, CA
>> Alright, I'll clean it up and post it. I can also move a lot of the
>> state out into mnesia, so that it could use erlydb as well, so that
>> it
>> serves as a better example.
> For what it's worth, leaving it the way it is without using erlydb
> would be very helpful. If you convert it to mnesia would you be
> willing to publish both?

I'm not sure it would be that useful; about half the code right now is
the "board_server", which is basically just a state server that
contains the boards and reaps expired ones. Pushing that out to a
database means less business logic (so it makes a better example
application), and Mnesia is a good choice because it ships with Erlang
already.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post recived from mailinglist
View user's profile Send private message AIM Address
dmitriid
Posted: Mon Dec 17, 2007 8:44 am Reply with quote
User Joined: 17 Aug 2006 Posts: 213
>
> Is anyone interested in a fully working erlyweb reference app? Would
> that help?
Definitely. I'm still trying to wrap my head around all this phased stuff Smile

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post recived from mailinglist
View user's profile Send private message
Guest
Posted: Tue Dec 18, 2007 6:02 am Reply with quote
Guest
Hi,

thanks for the answers, it was quite helpful. Most important: I found
out how to make use of the component system and was able to put all
logic in controllers.

Following the checklist:

1. I copied David
Guest
Posted: Wed Dec 19, 2007 12:19 am Reply with quote
Guest
On Dec 17, 2007 10:01 PM, maddiin <maddiin@googlemail.com> wrote:
>
> Hi,
>
> thanks for the answers, it was quite helpful. Most important: I found
> out how to make use of the component system and was able to put all
> logic in controllers.
>
> Following the checklist:
>
> 1. I copied David
ketralnis
Posted: Fri Dec 21, 2007 4:59 pm Reply with quote
User Joined: 20 Jul 2007 Posts: 151 Location: San Francisco, CA
> I also find it useful at the beginning of the hook function to ensure
> that the arg's appmoddata field is always preceded by a forward slash
> (i.e. add it if it's not there).

IMO that's something erlyweb should be doing long before the app sees
it.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post recived from mailinglist
View user's profile Send private message AIM Address
Guest
Posted: Sat Dec 22, 2007 12:09 pm Reply with quote
Guest
I want to have different sidebars, sorry for the confusing
explanation.

Using your hook/1, this is the setup I have now for a sidebar that is
always the same:

html_container_controller.erl:

index(A, Ewc) ->
Ewc.

html_container_view.et:

<%@ index(Data) %>
<html>
<head>
</head>
<body>
<div id="header">
header
</div>

<div id="content">
<% Data %>
</div>

<div id="footer">
footer
</div>
</body>
</html>


main_layout_controller.erl:

index(A, Ewc) ->
[Ewc, {ewc, sidebar, [A]}].

main_layout_view.et:

<%@ index([Data, Sidebar]) %>
<div id="main">
<% Data %>
</div>
<div id="sidebar">
<% Sidebar %>
</div>

For a different sidebar on each page, does it mean to get rid of the
main_layout_controller/view and put the stuff in entry_controller/view
and so on?

e.g.:

entry_controller.erl:

index(A) ->
Entries = entry:find_with({order_by, [{id, desc}]}),
[[{ewc, entry, entry, [A, Entry]} || Entry <- Entries], {ewc,
sidebar, entry_index, [A]}].

entry_view.et:

<%@ index([Entry, Sidebar]) %>
<div id="main">
<h1>Entries</h1>
<% Entry %>
</div>
<div id="sidebar">
<% Sidebar %>
</div>

<%@ entry(...) %>
...

This would mean to repeat the #main and #sidebar divs in every view,
so it doesn

Display posts from previous:  

All times are GMT
Page 1 of 2
Goto page 1, 2  Next
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum