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
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 ?
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.
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
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>
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
I changed my mind and take back the suggestion, because I can't think
of one either ..