synrc / nitro Goto Github PK
View Code? Open in Web Editor NEW๐ฅ NITRO: Nitrogen Web Framework RFC 6455
Home Page: https://nitro.n2o.dev
License: Other
๐ฅ NITRO: Nitrogen Web Framework RFC 6455
Home Page: https://nitro.n2o.dev
License: Other
For nitro:q
you have
Lines 8 to 10 in 14c7cae
I suspect what you want is:
q(Key) -> get(Key, []).
q(Key, Default) ->
case get(Key) of
undefined -> Default;
Value -> Value
end.
I have a strange problem when trying to add any new records and I don't know how to handle this.
These work fine:
-record(svglink,?DEFAULT_BASE).
-record(svglink,{?ELEMENT_BASE(element_svglink)}).
This cause error with any record name and additional elements:
-record(svglink,{?ELEMENT_BASE(element_svglink), something_else})
{[{reason,{badrecord,svglink}},
{mfa,{n2o_cowboy,handle,2}},
{stacktrace,
[{element_svglink,render_element,1,
[{file,
"/data/Erlang/test-n2o-nitro/samples/deps/nitro/src/elements/element_svglink.erl"},
{line,6}]},
{wf_render_elements,render_element,1,
[{file,
"/data/Erlang/test-n2o-nitro/samples/deps/nitro/src/render/wf_render_elements.erl"},
{line,26}]},
{wf_render,'-render/1-lc$^0/1-0-',1,
[{file,
"/data/Erlang/test-n2o-nitro/samples/deps/nitro/src/render/wf_render.erl"},
{line,10}]},
{wf_render,'-render/1-lc$^0/1-0-',1,
[{file,
"/data/Erlang/test-n2o-nitro/samples/deps/nitro/src/render/wf_render.erl"},
{line,10}]},
{element_svg,render_element,1,
[{file,
"/data/Erlang/test-n2o-nitro/samples/deps/nitro/src/elements/element_svg.erl"},
{line,7}]},
{wf_render_elements,render_element,1,
[{file,
"/data/Erlang/test-n2o-nitro/samples/deps/nitro/src/render/wf_render_elements.erl"},
{line,26}]},
{wf_render,'-render/1-lc$^0/1-0-',1,
[{file,
"/data/Erlang/test-n2o-nitro/samples/deps/nitro/src/render/wf_render.erl"},
{line,10}]},
{wf_render,'-render/1-lc$^0/1-0-',1,
[{file,
"/data/Erlang/test-n2o-nitro/samples/deps/nitro/src/render/wf_render.erl"},
{line,10}]}]},
{req,
[{socket,#Port<0.52776>},
{transport,ranch_tcp},
{connection,keepalive},
{pid,<0.1510.0>},
{method,<<"GET">>},
{version,'HTTP/1.1'},
{peer,{{127,0,0,1},43904}},
{host,<<"localhost">>},
{host_info,undefined},
{port,8000},
{path,<<"/">>},
{path_info,undefined},
{qs,<<>>},
{qs_vals,undefined},
{bindings,[]},
{headers,
[{<<"host">>,<<"localhost:8000">>},
{<<"user-agent">>,
<<"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:34.0) Gecko/20100101 Firefox/34.0">>},
{<<"accept">>,
<<"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8">>},
{<<"accept-language">>,<<"ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3">>},
{<<"accept-encoding">>,<<"gzip, deflate">>},
{<<"cookie">>,
<<"BX_USER_ID=b6ea441ad6bca38509e78fbb6854a4c2; site-sid=c292b3a17b2e289493b95bc69c5cceb9; z_ua=c%3Ddesktop%26u%3D1%26t%3D1%26w%3D1920%26h%3D1080; __utma=111872281.763977304.1443060238.1443060238.1443064762.2; __utmz=111872281.1443060238.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); _ga=GA1.1.763977304.1443060238; z_sid=GvPucYDUgQS1cozWHLov0DveX76PNSMm; __utmc=111872281; activity=8|40">>},
{<<"connection">>,<<"keep-alive">>},
{<<"cache-control">>,<<"max-age=0">>}]},
{p_headers,[{<<"connection">>,[<<"keep-alive">>]}]},
{cookies,undefined},
{meta,[]},
{body_state,waiting},
{buffer,<<>>},
{multipart,undefined},
{resp_compress,false},
{resp_state,waiting},
{resp_headers,[]},
{resp_body,<<>>},
{onresponse,undefined}]},
{state,{state,undefined,undefined}}],
[{cowboy_protocol,execute,4,
[{file,
"/data/Erlang/test-n2o/samples/deps/cowboy/src/cowboy_protocol.erl"},
{line,442}]}]}
Unless I missed something in N2O/NITRO, I need a interface or way to Get/Set Browser Cookies, so requesting it:
nitro:cookie(Key) -> Binary
nitro:cookie(Key, Value, Path, MinutesToLive)
I tried to work around this, it is possible to set browser cookie like this:
nitro:wire(nitro:f("document.cookie=\"~s=~s\"",["user","Joe"])),
But unable to read cookies since it seems #api erlang callback does not work:
nitro:wire(#api{name ="getCookies",delegate=index}),
But browser console reports:
SyntaxError: Unexpected identifier 'getCookies'
Otherwise I could maybe have retrieved it by this in erlang callback nitro:wire(<<"document.getCookies('document.cookie');">>),
https://github.com/synrc/nitro/blob/master/man/nitro_n2o.htm#L68-L70
Those 3 lines contains 3 different names for message:
Pickle message - singular without 'ed'
Those messages - plural
Pickled messaged - singular with too many 'ed'.
Some normalization needed.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.