@@ -1,5 +1,5 @@
# Used by "mix format"
[
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"],
- line_length: 133
+ line_length: 80
]
@@ -1,7 +1,8 @@
defmodule NITRO do
require Record
- Enum.each(Record.extract_all(from_lib: "nitro/include/nitro.hrl"), fn {name, definition} ->
+ Enum.each(Record.extract_all(from_lib: "nitro/include/nitro.hrl"), fn {name,
+ definition} ->
Record.defrecord(name, definition)
end)
end
@@ -2,7 +2,13 @@ defmodule NITRO.Mixfile do
use Mix.Project
def project do
- [app: :nitro, version: "4.7.2", description: "NITRO Web Framework and HTML5 DSL", package: package(), deps: deps()]
+ [
+ app: :nitro,
+ version: "4.7.3",
+ description: "NITRO Web Framework",
+ package: package(),
+ deps: deps()
+ ]
def application do
@@ -1,6 +1,6 @@
{application, nitro, [
- {description, "NITRO Web Framework and HTML5 DSL"},
- {vsn, "4.7.2"},
+ {description, "NITRO Web Framework"},
+ {vsn, "4.7.3"},
{applications, [kernel, stdlib]},
{modules, []},
{registered, []},
@@ -205,3 +205,13 @@ num(S) -> case rev(S) of
[$M|M] -> list_to_integer(rev(M)) * 1000 * 1000;
[$G|G] -> list_to_integer(rev(G)) * 1000 * 1000 * 1000;
[$T|T] -> 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)])).