ErlyWeb 0.2.2

0 views
Skip to first unread message

Yariv Sadan

unread,
Nov 6, 2006, 6:16:30 PM11/6/06
to erl...@googlegroups.com
Hi,

I made a few bug fixes and improvements based on user feedback. Here's
what I did:

- In auto-generated files, the link to css files has changed from

<link rel="stylesheet" href="/[appname]/style.css">

to

<link rel="stylesheet" href="/style.css">

(This removes the assumption that your appmod directive in yaws.conf
is 'appmod = <"/[appname]", erlyweb>).

- Navigating to the root path of the erlyweb appmod now makes ErlyWeb
return {page, "/"} instead of {page, "/index.html"}.

- Controllers can now implement the function

use_app_view() -> Val.

where Val is 'true' or 'false'.

If Val is 'false', the output of such components will not be rendered
with the app view. This lets you make components that are AJAX
friendly.

(Note: the app view logic may undergo more refinement at a later
version, but I don't want to make big changes right before I go on
vacation. For now, if you need fine-grained control over how
components are rendered, you can use the 'hook' function in the app
controller to rewrite the Arg or invoke components manually).

- Previously, you could only return from controller functions a single
'data' tuple, a single 'ewc' tuple, or a list of 'ewc' tuples. Now,
you can also return a list of arbitrary 'data' and/or 'ewc' tuples.
For instance, you can implement a component such as:

foo_controller.erl:
-module(foo_controller).
bar(A) ->
[{data, "hello"}, {ewc, sub_component, [A]}].

foo_view.et:
<% Data %>

<%@ bar([Msg, SubComponent]) %>
<% Msg %><br/>
<% SubComponent %>

When ErlyWeb calls foo_view:bar/1, the 'Msg' variable will be "hello",
and SubComponent will be the result of calling the 'index' action in
'sub_component'.


Finally, Klacke made a bug fix in CVS when the appmods = <"/",
erlyweb> directive wasn't handled properly. If you want to use ErlyWeb
as a root appmod, get the latest version of Yaws from CVS.

Cheers,
Yariv

Roberto Saccon

unread,
Nov 6, 2006, 8:19:22 PM11/6/06
to erlyweb
Great news. But yaws from CVS does not work for me (on Ubunutu 6.10 and
with erlyweb SVN trunk), I get:

ERROR erlang code crashed:
File: appmod:0
Reason: {badarg,[{lists,keysearch,["appname",1,<0.103.0>]},
{erlyweb_util,get_appname,1},
{erlyweb,out,1},
{yaws_server,deliver_dyn_part,8},
{yaws_server,aloop,3},
{yaws_server,acceptor0,2},
{proc_lib,init_p,5}]}
Req: {http_request,'GET',{abs_path,"/home"},{1,1}}


I had to switch back to yaws 1.65. Just me messing up something ?

Roberto Saccon

unread,
Nov 6, 2006, 8:48:59 PM11/6/06
to erlyweb
I am trying to add to my controllers the

use_app_view() -> true | false.

But there is a problem. I need to decide dynamically based on a query
variable in A whether I want to set to true or false. How can I do that
? I was expecting "use_app_view" to be somting like this:

use_app_view(A) -> true | false.

Yariv Sadan

unread,
Nov 6, 2006, 9:18:49 PM11/6/06
to erl...@googlegroups.com
Yes... I overlooked this point.

Change line 305 of erlyweb.erl from

M2 = add_func(M1, use_app_view, 0, "use_app_view() -> true."),

to

M2 = add_func(M1, use_app_view, 1, "use_app_view(_A) -> true."),

and line 377 from

case Controller:use_app_view() of

to

case Controller:use_app_view(A) of

I will incorporate this change to the next release.

Yariv

Yariv Sadan

unread,
Nov 6, 2006, 9:25:47 PM11/6/06
to erl...@googlegroups.com
Ok, I checked this change into trunk. You can just do an update and
you'll be all set. Now I'll look at the other issue. What does your
configuration look like?

Yariv

Roberto Saccon

unread,
Nov 6, 2006, 10:15:11 PM11/6/06
to erlyweb
Erlyweb rocks ! Now the use_app_view(A) works perfect for my needs.

Maybe the other hook, the private() function should also accept A, then
it could even be used for fine-granular Access Control. Would that make
sense ?

My configuration (which could have caused malfunctioning with yaws-CVS)
looks something like this:

<server myapp>
port = 3000
listen = 0.0.0.0
docroot = /myapp/www


appmods = <"/", erlyweb>

<opaque>
appname = myapp
mode = development
</opaque>
</server>

yar...@gmail.com

unread,
Nov 6, 2006, 10:19:38 PM11/6/06
to erlyweb

Roberto Saccon wrote:
> Erlyweb rocks ! Now the use_app_view(A) works perfect for my needs.
>
> Maybe the other hook, the private() function should also accept A, then
> it could even be used for fine-granular Access Control. Would that make
> sense ?

If you could show me an example where it would make sense, I'd be happy
to change it. I just can't think of one myself.

>
> My configuration (which could have caused malfunctioning with yaws-CVS)
> looks something like this:
>
> <server myapp>
> port = 3000
> listen = 0.0.0.0
> docroot = /myapp/www
> appmods = <"/", erlyweb>
> <opaque>
> appname = myapp
> mode = development
> </opaque>
> </server>

Weird... this kind of setup works for me. I'll have to poke at it a
little more. It would be interesting to see if other developers
experience the same thing.

Yariv

Roberto Saccon

unread,
Nov 7, 2006, 12:25:09 AM11/7/06
to erlyweb
> > Maybe the other hook, the private() function should also accept A, then
> > it could even be used for fine-granular Access Control. Would that make
> > sense ?If you could show me an example where it would make sense, I'd be happy

> to change it. I just can't think of one myself.
>

I changed my mind and take back the suggestion, because I can't think
of one either ..

ke han

unread,
Nov 7, 2006, 8:01:20 AM11/7/06
to erlyweb
I've tested 0.2.2. All is well except for a minor bug in the magic
view generation for "create new". I've porsted a new thread for this
but google groups does not seem to want to accept my new threads ;-).
thanks for the quick turn around on these bug fixes!!!
ke han

Reply all
Reply to author
Forward
0 new messages