Hello,

I am working on a website in erlang-web, and here are two problems I stumbled 
upon that
required modification or erlang-web source code.

First, password fields in form with confirmation would alway return an error 
saying 
the password didn't match. It was caused by wtype_password:validate who would
feed ["password", "password"] to utf8_api:ustring. The result is one string: 
"passwordpassword" instead of ["password", "password"].

Here is the change I made to correct this:
--- a/lib/wparts-1.4/src/wtype_password.erl     Tue Jan 19 10:58:02 2010 +0100
+++ b/lib/wparts-1.4/src/wtype_password.erl     Thu Feb 18 18:09:11 2010 +0100
@@ -45,8 +45,13 @@
             end
     end;

+validate({Types, [RawString1, RawString2]}) when is_list(RawString1) and 
is_list(RawString2) ->
+  validate2({Types, [utf8_api:ustring(RawString1), 
utf8_api:ustring(RawString2)]});
+
 validate({Types, RawString}) when is_list(RawString) ->
-    String = utf8_api:ustring(RawString),
+  validate2({Types, utf8_api:ustring(RawString)}).
+
+validate2({Types, String}) when is_list(String) ->
     case wpart_valid:is_private(Types) of
        true ->
            {ok, String};

My second problem was with DTL templates. While wpart template's parent include 
mecanism works well with templates sepparated in subdirectories, DTL caused 
problems.

Here is an exemple of the directory structure that cause problem:
- templates
  - base
    - base.html
    - half.html
    - frontpage.html
  - article
    - article.html

while an extends "half.html" works well in frontpage.html , it does not in 
article.html.
And if you do an extends "base/base.html" in it, erlydtl tries to load 
article/base/base.html
Trying to do extends "../base/half.html" doesn't fix the problem as it then 
tries to load
article/base.html inside half.html

In order to make DTL have the same behavior, I give DTL the template directory 
throught its doc_root option.

--- a/lib/eptic-1.4/src/e_cache_ets.erl Tue Jan 19 10:58:02 2010 +0100
+++ b/lib/eptic-1.4/src/e_cache_ets.erl Thu Feb 18 18:09:11 2010 +0100
@@ -93,7 +93,7 @@
     XML;
 cache(File, erlydtl_expander) ->
     Mod = list_to_atom(string:join(string:tokens(File, "/.-"), "")),
-    case erlydtl:compile(File, Mod) of
+    case erlydtl:compile(File, Mod, [{doc_root, e_conf:template_root()}]) of
         ok ->
             ets:insert(?MODULE, {File, {date(), time()}, Mod}),
             Mod;



Erlang-web is otherwise quite nice to work with. Thanks for the good work.

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Erlangweb-users mailing list
Erlangweb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlangweb-users
http://www.erlang-web.org/

Reply via email to