erlangweb-users Mailing List for Erlang Web (Page 2)
Brought to you by:
etcerlangweb,
paulgray
You can subscribe to this list here.
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
(2) |
Aug
(1) |
Sep
(1) |
Oct
|
Nov
(40) |
Dec
(25) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2009 |
Jan
(7) |
Feb
(17) |
Mar
(10) |
Apr
(3) |
May
(10) |
Jun
(2) |
Jul
(2) |
Aug
(3) |
Sep
(12) |
Oct
(9) |
Nov
(11) |
Dec
(7) |
| 2010 |
Jan
(3) |
Feb
(10) |
Mar
(18) |
Apr
(20) |
May
(1) |
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
(8) |
May
|
Jun
|
Jul
|
Aug
(6) |
Sep
(1) |
Oct
|
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
|
From: Jeff <je...@gh...> - 2010-04-29 06:08:58
|
On 29/04/10 3:57 PM, Sergey Yelin wrote: > Hi, > > which parts of my project should I add to the source control? Are > there any best practices for that? > > Tastes vary, but I just add mine to version control this morning. I included everything including erlang-web but excluded the .beam files and the text editor back ups. Jeff. |
|
From: Sergey Y. <el...@gm...> - 2010-04-29 05:57:31
|
Hi, which parts of my project should I add to the source control? Are there any best practices for that? |
|
From: jm <je...@gh...> - 2010-04-19 12:40:13
|
Just a quick reply. I'll have to look at that page tomorrow obviously
missed it in my search. I found the tuples in the source code by
grepping for "{template" after I sent the email and saw the {custom,
Val} option, but figured that there must be another option that I was
missing. As elrlangweb supports different web servers including those
that support ewgi I thought that there might be a server independent
manner in which to do things. Is such a thing planned?
As I said above just a quick reply hope it makes sense.
Jeff.
Michal Zajda wrote:
> Hi Jeffm,
>
> Here is the link to controller return-tuples doc: http://wiki.erlang-web.org/Eptic/ServerTuples.
>
> There is one called {custom, Val} and using it lets you return anything accepted by the server (Val will go directly to HTTP server).
>
> However, once I migrated old system (written in yaws) to ErlangWeb, and there was already yaws module for streaming, so I simply check authorization and set a session on ErlangWeb side and then redirected to yaws module (to do it you need also another appmod defined for this module).
>
>
>
>
|
|
From: Michal Z. <mic...@er...> - 2010-04-19 07:24:06
|
Hi Jeffm, Here is the link to controller return-tuples doc: http://wiki.erlang-web.org/Eptic/ServerTuples. There is one called {custom, Val} and using it lets you return anything accepted by the server (Val will go directly to HTTP server). However, once I migrated old system (written in yaws) to ErlangWeb, and there was already yaws module for streaming, so I simply check authorization and set a session on ErlangWeb side and then redirected to yaws module (to do it you need also another appmod defined for this module). ----- "Jeffm" <je...@gh...> wrote: > Is it possible to stream data from, or to trigger streaming from a > controller model in erlang-web? The motivation behind this is that in > a > test project I'm playing around with I have large (static) files which > > should only be accessible once you authenticate as a user which is > allowed access to these files. Standard stuff really. Copying these > large files into memory in one block to send to the browser is > wasteful > of memory. A quick inspection of the doco for both inets and yaws says > > that they support this feature, but I can't find the doco on the > allowed > return values for the controller modules. If I've missed it please > point > me to it. > > Jeff. > > > ------------------------------------------------------------------------------ > 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 > Erl...@li... > https://lists.sourceforge.net/lists/listinfo/erlangweb-users > http://www.erlang-web.org/ -- Michal Zajda Erlang Solutions Ltd. http://www.erlang-solutions.com --------------------------------------------------- --------------------------------------------------- WE'VE CHANGED NAMES! Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. www.erlang-solutions.com |
|
From: Jeffm <je...@gh...> - 2010-04-19 03:16:48
|
Is it possible to stream data from, or to trigger streaming from a controller model in erlang-web? The motivation behind this is that in a test project I'm playing around with I have large (static) files which should only be accessible once you authenticate as a user which is allowed access to these files. Standard stuff really. Copying these large files into memory in one block to send to the browser is wasteful of memory. A quick inspection of the doco for both inets and yaws says that they support this feature, but I can't find the doco on the allowed return values for the controller modules. If I've missed it please point me to it. Jeff. |
|
From: Jeffm <je...@gh...> - 2010-04-14 06:43:21
|
You'll be glad to know that this is the short version of the email I was about to write. I manage to work out how to get forms to behave the way I wanted. Anyway... Is there an example of how to handle a file upload? and while I'm asking questions, are there any ajax or jquery examples/etc floating around? |
|
From: Michal P. <mic...@er...> - 2010-04-13 08:54:22
|
Hi,
----- "AndyChow" <diu...@16...> wrote:
> hi,
>
> when i set tpl variable tag in tpl file like this:
>
> <a wpart:href="/language/en/{reload_url}">English</a>
The wpart above will be expanded to
"/language/en/"reload_url""
In order to skip "" inside of the attributes values, use:
<a wpart:href="/language/en/{[string]reload_url}">English</a>
>
> And i add some code add my erl file, like this:
>
> show_item(Args) ->
> %% put the show_item function body here
> N = list_to_integer(proplists:get_value(id, Args)),
> Item = wtype_item:read(N),
> RUrl = wpart:fget("__path"),
> wpart:fset("item", wtype_item:format(Item)),
> wpart:fset("reload_url", RUrl),
> wpart_lang:get_translation("login_name"),
> {template, "item/show.html"}.
>
> when i recompile and restart service, i browse the app url, find tpl
> tag is replace like:
>
>
> <a href="/language/en/"item/show/15"">English</a>
> reload_url tag is replaced and some special characters not i wished..
>
>
> please give me a hand, thanks! :)
>
> _______________________________________________
> Erlangweb-users mailing list
> Erl...@li...
> https://lists.sourceforge.net/lists/listinfo/erlangweb-users
> http://www.erlang-web.org/
Best regards,
Michal Ptaszek
---------------------------------------------------
---------------------------------------------------
WE'VE CHANGED NAMES!
Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD.
www.erlang-solutions.com
|
|
From: AndyChow <diu...@16...> - 2010-04-13 07:38:20
|
hi,
when i set tpl variable tag in tpl file like this:
<a wpart:href="/language/en/{reload_url}">English</a>
And i add some code add my erl file, like this:
show_item(Args) ->
%% put the show_item function body here
N = list_to_integer(proplists:get_value(id, Args)),
Item = wtype_item:read(N),
RUrl = wpart:fget("__path"),
wpart:fset("item", wtype_item:format(Item)),
wpart:fset("reload_url", RUrl),
wpart_lang:get_translation("login_name"),
{template, "item/show.html"}.
when i recompile and restart service, i browse the app url, find tpl tag is replace like:
<a href="/language/en/"item/show/15"">English</a>
reload_url tag is replaced and some special characters not i wished..
please give me a hand, thanks! :)
|
|
From: Gilbert R. <erl...@la...> - 2010-04-09 22:11:19
|
Hello,
I found a few bugs concerning utf8 handling in dtl templates and in forms.
Value stored in database are stored with large integer value of characters and those
would end up into the template result and make xmerl complain and bug.
I modified erlydtl_compiler:format to correct this:
diff -r old/lib/erlydtl-0.5.3/src/erlydtl/erlydtl_compiler.erl new/lib/erlydtl-0.5.3/src/erlydtl/erlydtl_compiler.erl
548c548,552
< auto_escape(format_number_ast(Ast), Context).
---
> Tmp = format_number_ast(Ast),
> %% Value is a list of Unicode codepoints. We need to convert that
> %% to UTF-8.
> Tmp2 = erl_syntax:application(erl_syntax:atom(erlydtl_filters), erl_syntax:atom(utf32_to_utf8), [Tmp]),
> auto_escape(Tmp2, Context).
the "utf32_to_utf8" function I put in erlydtl_filters ; but I'm sure there
must be a more appropriate place for it. It was a quick hack.
diff -r old/lib/erlydtl-0.5.3/src/erlydtl/erlydtl_filters.erl new/lib/erlydtl-0.5.3/src/erlydtl/erlydtl_filters.erl
192a193,199
> utf32_to_utf8(Input) when is_list(Input) ->
> % Convert utf32 strings into utf8
> {ok, UTF8} = utf8:to_binary(Input),
> binary_to_list(UTF8);
> utf32_to_utf8(Input) ->
> Input.
>
I also found another problem with forms. wpart forms would retrieve the large integer
character and bug.
Here's what I did to fix it:
diff -r old/lib/wparts-1.4/src/wpart_derived.erl new/lib/wparts-1.4/src/wpart_derived.erl
135c135
< Input = Module:build_html_tag(LName, Params, find(LName, Defaults)),
---
> Input = Module:build_html_tag(LName, Params, erlydtl_filters:utf32_to_utf8(find(LName, Defaults))),
I hope it'll helps.
Regards.
|
|
From: Magnus H. <ma...@er...> - 2010-04-09 15:42:52
|
AndyChow <diu...@16...> writes:
> <a wpart:href="/item/show/{[integer]item:id}"><wpart:lookup key="item:name" /></a>
Right, that's the critical line. <wpart:lookup/> doesn't handle Unicode
correctly, so you need the wpart_lookup_unbreak module in the link I
posted.
--
Magnus Henoch, ma...@er...
Erlang Solutions
http://www.erlang-solutions.com/
|
|
From: AndyChow <diu...@16...> - 2010-04-09 15:21:10
|
hi,
the following tpl is my simple app for show data list, include chinese unicode.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Erlang Web Shop - All Items</title>
</head>
<body>
<h1>All items that are stored in the shop:</h1>
<a href="/item/admin/add">Add Item</a>
<ul>
<wpart:list select="map" list="items" as="item">
<li>
<wpart:choose>
<wpart:when test="not {item:available}">
NOT AVAILABLE
</wpart:when>
</wpart:choose>
<a wpart:href="/item/show/{[integer]item:id}"><wpart:lookup key="item:name" /></a>
<a wpart:href="/item/admin/edit/{[integer]item:id}">Edit</a>
<a wpart:href="/item/admin/delete/{[integer]item:id}">Delete</a>
</li>
</wpart:list>
</ul>
</body>
</html>
AndyChow <diu...@16...> writes:
> when i input some chinese characters and submit to app, the chinese
> string can not show correctly. my page unicode is utf8.
>
> please give me hande, how to resolve this problem. :P
My crystal ball tells me that you need wpart_lookup_unbreak:
http://permalink.gmane.org/gmane.comp.lang.erlang.erlangweb.general/10
It might be wrong, though. Could you show the part of the template that
outputs the Chinese text?
|
|
From: Magnus H. <ma...@er...> - 2010-04-09 11:00:17
|
AndyChow <diu...@16...> writes: > when i input some chinese characters and submit to app, the chinese > string can not show correctly. my page unicode is utf8. > > please give me hande, how to resolve this problem. :P My crystal ball tells me that you need wpart_lookup_unbreak: http://permalink.gmane.org/gmane.comp.lang.erlang.erlangweb.general/10 It might be wrong, though. Could you show the part of the template that outputs the Chinese text? -- Magnus Henoch, ma...@er... Erlang Solutions http://www.erlang-solutions.com/ |
|
From: AndyChow <diu...@16...> - 2010-04-09 08:57:00
|
hi, when i input some chinese characters and submit to app, the chinese string can not show correctly. my page unicode is utf8. please give me hande, how to resolve this problem. :P |
|
From: Michał P. <pau...@gm...> - 2010-04-03 19:10:22
|
Hi,
Wiadomość napisana w dniu 2010-03-31, o godz. 13:14, przez Roberto Aloi:
> Hi all,
>
>> (<0.3201.0>) call wtype_date:validate({[{description,"Start date
>> (YYYYMMDD)"},
>> {format,"YYYYMMDD"},
>> {optional,{2010,3,29}}],
>> []})
>
> The validate function here is called with [] since the user didn't set
> any value in the form.
> In wtype_date.erl, the validate function is expecting the atom
> "undefined" instead, to trigger the search of the optional value.
>
> validate({Types, undefined}) ->
> case wpart_valid:is_private(Types) of
> true ->
> {ok, undefined};
> false ->
> case lists:keysearch(optional, 1, Types) of
> {value, {optional, Default}} ->
> {ok, Default};
> _ ->
> {error, {empty_input, undefined}}
> end
> end;
>
> The wype_date.erl should match:
>
> validate({Types, []}) ->
>
> Or am I missing something?
Well, it depends on what would you like to achieve.
In Erlang Web "optional" attribute is activated only when there is no
corresponding field on the form (HTML), thus no value is passed/sent
to the server. When no value is entered into the form, the field is
set to "" and the first validate function clause does not match.
The more I think about it, the more I am convinced to your way of
thinking (or just to keep both behaviours).
>
> Roberto Aloi
> --
> University of Kent - Erlang Solutions Ltd.
> Twitter: @prof3ta
> Blog: http://aloiroberto.wordpress.com
> ---------------------------------------------------
>
> ---------------------------------------------------
>
> WE'VE CHANGED NAMES!
>
> Since January 1st 2010 Erlang Training and Consulting Ltd. has
> become ERLANG SOLUTIONS LTD.
>
> www.erlang-solutions.com
Cheers,
Michal Ptaszek |
|
From: Roberto A. <rob...@er...> - 2010-03-31 11:14:52
|
Hi all,
> (<0.3201.0>) call wtype_date:validate({[{description,"Start date (YYYYMMDD)"},
> {format,"YYYYMMDD"},
> {optional,{2010,3,29}}],
> []})
The validate function here is called with [] since the user didn't set
any value in the form.
In wtype_date.erl, the validate function is expecting the atom
"undefined" instead, to trigger the search of the optional value.
validate({Types, undefined}) ->
case wpart_valid:is_private(Types) of
true ->
{ok, undefined};
false ->
case lists:keysearch(optional, 1, Types) of
{value, {optional, Default}} ->
{ok, Default};
_ ->
{error, {empty_input, undefined}}
end
end;
The wype_date.erl should match:
validate({Types, []}) ->
Or am I missing something?
Roberto Aloi
--
University of Kent - Erlang Solutions Ltd.
Twitter: @prof3ta
Blog: http://aloiroberto.wordpress.com
---------------------------------------------------
---------------------------------------------------
WE'VE CHANGED NAMES!
Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD.
www.erlang-solutions.com
|
|
From: Anders K. <and...@er...> - 2010-03-31 10:41:38
|
Hi, I'm trying to use the date type(http://wiki.erlang-web.org/Wparts/BasicTypes/date) with an optional value for one of my input fields, but if I leave the field that has an optional value empty my validation fails. As long as I put a date in all fields the validation works! from my tracing: (<0.3201.0>) call admin_utils:set_active(not_used,user_admin,admin_reports,[[]]) (<0.3201.0>) returned from admin_utils:set_active/4 -> {proceed,[[]]} (<0.3201.0>) call admin_utils:validate({admin_report,create},user_admin,admin_reports,[[]]) (<0.3201.0>) call wtype_date:validate({[{description,"End date (YYYYMMDD)"},{format,"YYYYMMDD"}],"20100330"}) (<0.3201.0>) call wtype_date:convert_input("YYYYMMDD","20100330",[]) (<0.3201.0>) call wtype_date:convert_input("MMDD","0330",[{year,2010}]) (<0.3201.0>) call wtype_date:convert_input("DD","30",[{month,3},{year,2010}]) (<0.3201.0>) call wtype_date:convert_input([],[],[{day,30},{month,3},{year,2010}]) (<0.3201.0>) returned from wtype_date:convert_input/3 -> {2010,3,30} (<0.3201.0>) returned from wtype_date:convert_input/3 -> {2010,3,30} (<0.3201.0>) returned from wtype_date:convert_input/3 -> {2010,3,30} (<0.3201.0>) returned from wtype_date:convert_input/3 -> {2010,3,30} (<0.3201.0>) call wtype_date:check_min([{description,"End date (YYYYMMDD)"},{format,"YYYYMMDD"}],{2010,3,30}) (<0.3201.0>) returned from wtype_date:check_min/2 -> {ok,{2010,3,30}} (<0.3201.0>) call wtype_date:check_max([{description,"End date (YYYYMMDD)"},{format,"YYYYMMDD"}],{2010,3,30}) (<0.3201.0>) returned from wtype_date:check_max/2 -> {ok,{2010,3,30}} (<0.3201.0>) returned from wtype_date:validate/1 -> {ok,{2010,3,30}} (<0.3201.0>) call wtype_date:validate({[{description,"Start date (YYYYMMDD)"}, {format,"YYYYMMDD"}, {optional,{2010,3,29}}], []}) (<0.3201.0>) call wtype_date:convert_input("YYYYMMDD",[],[]) (<0.3201.0>) returned from wtype_date:convert_input/3 -> {error,bad_format} (<0.3201.0>) returned from wtype_date:validate/1 -> {error, {bad_date_format,[]}} (<0.3201.0>) returned from admin_utils:validate/4 -> {error, {user_admin, validate_error, [admin_reports]}} (<0.3201.0>) call wtype_date:get_date("YYYY-MM-DD","20100330") (<0.3201.0>) returned from wtype_date:get_date/2 -> "20100330" and my admin_report.hrl -record(admin_report, { start_date, start_time, end_date, end_time}). -record(admin_report_types, { start_date = {date, [ {description, "Start date (YYYYMMDD)"} , {format, "YYYYMMDD"} , {optional, {2010,03,29}} ]} , start_time = {time, [ {description, "Start time (HHMMSS)"} , {format, "HHMMSS"} ]} , end_date = {date, [ {description, "End date (YYYYMMDD)"} , {format, "YYYYMMDD"} ]} , end_time = {time, [ {description, "End time (HHMMSS)"} , {format, "HHMMSS"} ]}}). any ideas? Cheers, Anders Karlsson --------------------------------------------------- --------------------------------------------------- WE'VE CHANGED NAMES! Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD. www.erlang-solutions.com |
|
From: Graeme D. <gra...@gm...> - 2010-03-23 12:36:44
|
Roberto,
I am not sure whether Erlang Web supports this, but one option would
be to add the current page to the language-setting URL, and then
retrieve it in the controller. i.e.something like
<li><a href="/session/language/en?/the/current/page.html">English</a></li>
(suitable escaped, of course) and then pick it out again for the redirect.
Make any sense?
graeme
_______________________________________
On 23 March 2010 02:13, Roberto Aloi <rob...@er...> wrote:
> Hi all,
>
> I'm trying to add international support for a website based on the
> Erlang Web 1.4.
>
> I would like to have a couple of links on every page (the notorious
> Country flags) that allow the user to set his language session variable.
>
> What I have right now is a link like:
>
> <li><a href="/session/language/en">English</a></li>
>
> Where, in the session controller I do:
>
> language(Args) ->
> LanguageId = proplists:get_value(id, Args),
> case language_is_supported(LanguageId) of
> false ->
> ok;
> true ->
> wpart:fset("session:lang", LanguageId)
> end,
> {redirect, "/"}.
>
> The problem is that, after setting the preferred language, I would like
> the user to be redirected to the page he was visiting before changing
> the language. In this case the "__path" variable doesn't help because it
> contains the language request and not the "previous" one.
>
> How could I resolve this situation?
> I'm probably using the wrong approach but I cannot thing to anything
> else right now.
>
> Cheers,
>
> Roberto Aloi
> --
> University of Kent - Erlang Solutions Ltd.
> Twitter: @prof3ta
> Blog: http://aloiroberto.wordpress.com
> ---------------------------------------------------
>
> ---------------------------------------------------
>
> WE'VE CHANGED NAMES!
>
> Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD.
>
> www.erlang-solutions.com
>
>
> ------------------------------------------------------------------------------
> 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
> Erl...@li...
> https://lists.sourceforge.net/lists/listinfo/erlangweb-users
> http://www.erlang-web.org/
>
|
|
From: Michal Z. <mic...@er...> - 2010-03-22 23:26:18
|
Hi Roberto,
the first thing which comes to me, is to have link to 'session handler' (/session/language/en) dynamic. Every time you load some page, you can rebuild it.
So, for example, if you are on startpage.html, link could look like /sesssion/en/startpage.html.
Another solution, would be to encode the link in GET variable. The link would look like /session/language/en?current_address=startpage.html.
Finally, it would be possible to make it in more RESTful way and keep in every link to content, on your page, language code (/en/startpage.html), but this is not too good for search engines and indexing (I guess?).
br
Michał Zajda
----- "Roberto Aloi" <rob...@er...> wrote:
> Hi all,
>
> I'm trying to add international support for a website based on the
> Erlang Web 1.4.
>
> I would like to have a couple of links on every page (the notorious
> Country flags) that allow the user to set his language session
> variable.
>
> What I have right now is a link like:
>
> <li><a href="/session/language/en">English</a></li>
>
> Where, in the session controller I do:
>
> language(Args) ->
> LanguageId = proplists:get_value(id, Args),
> case language_is_supported(LanguageId) of
> false ->
> ok;
> true ->
> wpart:fset("session:lang", LanguageId)
> end,
> {redirect, "/"}.
>
> The problem is that, after setting the preferred language, I would
> like
> the user to be redirected to the page he was visiting before changing
> the language. In this case the "__path" variable doesn't help because
> it
> contains the language request and not the "previous" one.
>
> How could I resolve this situation?
> I'm probably using the wrong approach but I cannot thing to anything
> else right now.
>
> Cheers,
>
> Roberto Aloi
> --
> University of Kent - Erlang Solutions Ltd.
> Twitter: @prof3ta
> Blog: http://aloiroberto.wordpress.com
> ---------------------------------------------------
>
> ---------------------------------------------------
>
> WE'VE CHANGED NAMES!
>
> Since January 1st 2010 Erlang Training and Consulting Ltd. has become
> ERLANG SOLUTIONS LTD.
>
> www.erlang-solutions.com
>
>
> ------------------------------------------------------------------------------
> 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
> Erl...@li...
> https://lists.sourceforge.net/lists/listinfo/erlangweb-users
> http://www.erlang-web.org/
> ---------------------------------------------------
>
> ---------------------------------------------------
>
> WE'VE CHANGED NAMES!
>
> Since January 1st 2010 Erlang Training and Consulting Ltd. has become
> ERLANG SOLUTIONS LTD.
>
> www.erlang-solutions.com
--
Michal Zajda
Erlang Solutions Ltd.
http://www.erlang-solutions.com
---------------------------------------------------
---------------------------------------------------
WE'VE CHANGED NAMES!
Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD.
www.erlang-solutions.com
|
|
From: Roberto A. <rob...@er...> - 2010-03-22 18:14:14
|
Hi all,
I'm trying to add international support for a website based on the
Erlang Web 1.4.
I would like to have a couple of links on every page (the notorious
Country flags) that allow the user to set his language session variable.
What I have right now is a link like:
<li><a href="/session/language/en">English</a></li>
Where, in the session controller I do:
language(Args) ->
LanguageId = proplists:get_value(id, Args),
case language_is_supported(LanguageId) of
false ->
ok;
true ->
wpart:fset("session:lang", LanguageId)
end,
{redirect, "/"}.
The problem is that, after setting the preferred language, I would like
the user to be redirected to the page he was visiting before changing
the language. In this case the "__path" variable doesn't help because it
contains the language request and not the "previous" one.
How could I resolve this situation?
I'm probably using the wrong approach but I cannot thing to anything
else right now.
Cheers,
Roberto Aloi
--
University of Kent - Erlang Solutions Ltd.
Twitter: @prof3ta
Blog: http://aloiroberto.wordpress.com
---------------------------------------------------
---------------------------------------------------
WE'VE CHANGED NAMES!
Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD.
www.erlang-solutions.com
|
|
From: Magnus H. <ma...@er...> - 2010-03-22 12:31:41
|
Graeme Defty <gra...@gm...> writes:
> My _types record contains this:
>
> dob = {date,[{format, "YYYY-MM-DD"},
> {description, "Date of Birth"}]}
>
> and my html looks thusly:
>
> <p>date of birth: <wpart:lookup key="player:dob" format="date" /></p>
These two places have no connection with eachother; the wpart:lookup
can't get the format from your wtype. Try something like:
<wpart:lookup key="player:dob" format="date(YYYY-MM-DD)" />
--
Magnus Henoch, ma...@er...
Erlang Solutions
http://www.erlang-solutions.com/
---------------------------------------------------
---------------------------------------------------
WE'VE CHANGED NAMES!
Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD.
www.erlang-solutions.com
|
|
From: Michal Z. <mic...@er...> - 2010-03-22 09:28:00
|
Hi,
You are right, there should be no leading slash.
Lack of leading slash emphasis that it is not absolute path to templates.
The path in return tuple (like {template, ..path..}) is trailing part of final path, which is build basing on root_template environment variable (by default it is "/<server_path>/templates").
To see how it is used and how to modify defaults see eptic/src/e_conf.erl (line 366).
Michal Zajda
----- "jm" <je...@gh...> wrote:
> I notice that the following code causes a 501 error,
>
> do_add(_Args) ->
> case validate_tool:validate_cu(item, create) of
> {ok, Item} ->
> wtype_item:create(Item),
> {redirect, "/item/all"};
> {error, _Reason} ->
> wpart:fset("__edit", wtype_item:prepare_validated()),
> {template, "/item/add.html"}
> end.
>
> but changing the template line to, note lack of leading slash,
>
> {template, "item/add.html"}
>
> fixes the problem. This appear to be what it should be as the matching
>
> instructed entry for dispatch.conf is
>
> {static, "^/item/add$", "item/add.html"}.
>
>
> Jeff.
>
>
> ------------------------------------------------------------------------------
> 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
> Erl...@li...
> https://lists.sourceforge.net/lists/listinfo/erlangweb-users
> http://www.erlang-web.org/
--
Michal Zajda
Erlang Solutions Ltd.
http://www.erlang-solutions.com
---------------------------------------------------
---------------------------------------------------
WE'VE CHANGED NAMES!
Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD.
www.erlang-solutions.com
|
|
From: jm <je...@gh...> - 2010-03-22 08:25:48
|
I notice that the following code causes a 501 error,
do_add(_Args) ->
case validate_tool:validate_cu(item, create) of
{ok, Item} ->
wtype_item:create(Item),
{redirect, "/item/all"};
{error, _Reason} ->
wpart:fset("__edit", wtype_item:prepare_validated()),
{template, "/item/add.html"}
end.
but changing the template line to, note lack of leading slash,
{template, "item/add.html"}
fixes the problem. This appear to be what it should be as the matching
instructed entry for dispatch.conf is
{static, "^/item/add$", "item/add.html"}.
Jeff.
|
|
From: Graeme D. <gra...@gm...> - 2010-03-21 01:24:48
|
On 20 March 2010 16:24, alexander barakin <ale...@gm...> wrote:
> On Sat, Mar 20, 2010 at 11:25, Graeme Defty <gra...@gm...> wrote:
>> On 20 March 2010 15:07, alexander barakin <ale...@gm...> wrote:
>>> On Sat, Mar 20, 2010 at 06:37, Graeme Defty <gra...@gm...> wrote:
>>>> Hi,
>>>>
>>>> I am sure everyone else is displaying dates fine, so it must be me,
>>>> but I have tried all the combinations i can think of.
>>>>
>>>> The data in my database looks good (as io:format-ed after reading) but
>>>> displays as an integer.
>>>>
>>>> My _types record contains this:
>>>>
>>>> dob = {date,[{format, "YYYY-MM-DD"},
>>>> {description, "Date of Birth"}]}
>>>>
>>>> and my html looks thusly:
>>>>
>>>> <p>date of birth: <wpart:lookup key="player:dob" format="date" /></p>
>>>>
>>>> but the display is just a number :
>>>>
>>>> date of birth: 61661174400
>>>>
>>>> i.e. the date in seconds.
>>>
>>> because 61661174400 is in far future? (:
>>> $ date -d @61661174400
>>> Thu Dec 20 03:00:00 MSK 3923
>>>
>>> --
>>> wbr, alexander barakin aka sash-kan.
>>>
>>
>> I don't think so.
>>
>> 61661174400 is 1953-12-17 in seconds.
>>
>> 1953-12-17 is what i put in the database and what i see read out of it
>> again, as I mentioned.
>
> 1953 — date before unix epoch, which starts at 1970-01-01:
> $ date -d '1953-12-17' +'%s'
> -506228400
>
> --
> wbr, alexander barakin aka sash-kan.
>
Erlang does not store dates in Unix format, but in a tuple of
{YYYY,MM,DD}. Unix epoch is irelevant.
In any case, even non-erlang programs are capable of displaying dates
before 1970.
So how is it done in ErlangWeb?
|
|
From: alexander b. <ale...@gm...> - 2010-03-20 09:24:31
|
On Sat, Mar 20, 2010 at 11:25, Graeme Defty <gra...@gm...> wrote:
> On 20 March 2010 15:07, alexander barakin <ale...@gm...> wrote:
>> On Sat, Mar 20, 2010 at 06:37, Graeme Defty <gra...@gm...> wrote:
>>> Hi,
>>>
>>> I am sure everyone else is displaying dates fine, so it must be me,
>>> but I have tried all the combinations i can think of.
>>>
>>> The data in my database looks good (as io:format-ed after reading) but
>>> displays as an integer.
>>>
>>> My _types record contains this:
>>>
>>> dob = {date,[{format, "YYYY-MM-DD"},
>>> {description, "Date of Birth"}]}
>>>
>>> and my html looks thusly:
>>>
>>> <p>date of birth: <wpart:lookup key="player:dob" format="date" /></p>
>>>
>>> but the display is just a number :
>>>
>>> date of birth: 61661174400
>>>
>>> i.e. the date in seconds.
>>
>> because 61661174400 is in far future? (:
>> $ date -d @61661174400
>> Thu Dec 20 03:00:00 MSK 3923
>>
>> --
>> wbr, alexander barakin aka sash-kan.
>>
>
> I don't think so.
>
> 61661174400 is 1953-12-17 in seconds.
>
> 1953-12-17 is what i put in the database and what i see read out of it
> again, as I mentioned.
1953 — date before unix epoch, which starts at 1970-01-01:
$ date -d '1953-12-17' +'%s'
-506228400
--
wbr, alexander barakin aka sash-kan.
|
|
From: Graeme D. <gra...@gm...> - 2010-03-20 08:25:37
|
On 20 March 2010 15:07, alexander barakin <ale...@gm...> wrote:
> On Sat, Mar 20, 2010 at 06:37, Graeme Defty <gra...@gm...> wrote:
>> Hi,
>>
>> I am sure everyone else is displaying dates fine, so it must be me,
>> but I have tried all the combinations i can think of.
>>
>> The data in my database looks good (as io:format-ed after reading) but
>> displays as an integer.
>>
>> My _types record contains this:
>>
>> dob = {date,[{format, "YYYY-MM-DD"},
>> {description, "Date of Birth"}]}
>>
>> and my html looks thusly:
>>
>> <p>date of birth: <wpart:lookup key="player:dob" format="date" /></p>
>>
>> but the display is just a number :
>>
>> date of birth: 61661174400
>>
>> i.e. the date in seconds.
>
> because 61661174400 is in far future? (:
> $ date -d @61661174400
> Thu Dec 20 03:00:00 MSK 3923
>
> --
> wbr, alexander barakin aka sash-kan.
>
I don't think so.
61661174400 is 1953-12-17 in seconds.
1953-12-17 is what i put in the database and what i see read out of it
again, as I mentioned.
g
|