|
@@ -11,21 +11,6 @@ atom(List) when erlang:is_list(List) ->
|
|
|
string:join([ nitro:to_list(L) || L <- List], "_");
|
|
|
atom(Scalar) -> nitro:to_list(Scalar).
|
|
|
|
|
|
-q(Key) -> q(Key, []).
|
|
|
-
|
|
|
-q(Key, Def) ->
|
|
|
- case erlang:get(Key) of
|
|
|
- undefined -> Def;
|
|
|
- Val -> Val
|
|
|
- end.
|
|
|
-
|
|
|
-qc(Key) ->
|
|
|
- CX = erlang:get(context),
|
|
|
- qc(Key,CX#cx.req).
|
|
|
-
|
|
|
-qc(Key, Req) ->
|
|
|
- proplists:get_value(nitro:to_binary(Key), cowboy_req:parse_qs(Req)).
|
|
|
-
|
|
|
|
|
|
% Convert and Utils API
|
|
|
|
|
@@ -124,13 +109,6 @@ os_env(Key, Default) ->
|
|
|
end.
|
|
|
|
|
|
|
|
|
--ifndef(PICKLER).
|
|
|
--define(PICKLER, (application:get_env(n2z, pickler, nitro_conv))).
|
|
|
--endif.
|
|
|
-
|
|
|
-pickle(Data) -> ?PICKLER:pickle(Data).
|
|
|
-depickle(SerializedData) -> ?PICKLER:depickle(SerializedData).
|
|
|
-
|
|
|
prolongate() ->
|
|
|
case application:get_env(n2z, session) of
|
|
|
{ok, M} -> M:prolongate();
|
|
@@ -147,11 +125,6 @@ render(X) -> wf_render:render(X).
|
|
|
|
|
|
wire(Actions) -> action_wire:wire(Actions).
|
|
|
|
|
|
-unique_integer() -> erlang:unique_integer().
|
|
|
-
|
|
|
-temp_id() ->
|
|
|
- "auto" ++ integer_to_list(unique_integer() rem 1000000).
|
|
|
-
|
|
|
|
|
|
% Fast HEX
|
|
|
|
|
@@ -428,21 +401,3 @@ num(S) -> case rev(S) of
|
|
|
[$T|T] -> erlang:list_to_integer(rev(T)) * 1000 * 1000 * 1000 * 1000
|
|
|
end.
|
|
|
|
|
|
-cookie_expire(SecondsToLive) ->
|
|
|
- Seconds = calendar:datetime_to_gregorian_seconds(calendar:local_time()),
|
|
|
- DateTime = calendar:gregorian_seconds_to_datetime(Seconds + SecondsToLive),
|
|
|
- cow_date:rfc2109(DateTime).
|
|
|
-
|
|
|
-cookie(Id, Value) -> cookie(Id, Value, 2147483647). % expire never
|
|
|
-cookie(Id, Value, Expire) ->
|
|
|
- Format = "document.cookie='~s=~s; path=/; expires=~s';",
|
|
|
- nitro:wire(nitro:f(Format, [nitro:to_list(Id), nitro:to_list(Value), cookie_expire(Expire)])).
|
|
|
-
|
|
|
-cookies() ->
|
|
|
- cowboy_req:parse_cookies((erlang:get(context))#cx.req).
|
|
|
-cookie(Key) ->
|
|
|
- case lists:keyfind(Key, 1, cowboy_req:parse_cookies((erlang:get(context))#cx.req)) of
|
|
|
- false -> undefined;
|
|
|
- {_, Value} -> Value
|
|
|
- end.
|
|
|
-
|