GithubHelp home page GithubHelp logo

synrc / nitro Goto Github PK

View Code? Open in Web Editor NEW
53.0 53.0 33.0 889 KB

๐Ÿ”ฅ NITRO: Nitrogen Web Framework RFC 6455

Home Page: https://nitro.n2o.dev

License: Other

Erlang 66.30% CSS 3.10% JavaScript 20.18% Elixir 7.96% HTML 2.46%
actions css elements html js

nitro's Introduction

NITRO: Nitrogen Web Framework

Actions Status Build Status Hex pm

Features

  • Full HTML5 and SVG Support
  • Support for N2O Erlang WebSocket Application Server
  • Native Erlang way for UI/UX controls as HTML/JS/CSS components
  • Tag Inheritance
  • Polymorphic Tuples
  • Compact size (2500 LOC)
  • As fast as DTL and EEX
  • Elixir, MIX and HEX support
  • Custom Tags, ARIA, Web Components

Credits

OM A HUM

nitro's People

Contributors

221v avatar 5ht avatar arun-babu avatar cxa avatar doxtop avatar etxemag75 avatar fxmy avatar fycth avatar g-grand avatar irinakostiuk avatar kianmeng avatar konzee avatar m-2k avatar ne-luboff avatar pal-alex avatar renovate-bot avatar schutm avatar seb3s avatar spoowy avatar sunrisegg avatar totallynotmay avatar umka1332 avatar victoryks avatar xafizoff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nitro's Issues

Get/Set Browser Cookies

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');">>),

{reason,{badrecord,elementname}}

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}]}]}

nitro:q looks wrong.

For nitro:q you have

nitro/src/nitro.erl

Lines 8 to 10 in 14c7cae

q(Key) -> q(Key,get(Key)).
q(_,undefined) -> [];
q(_,Val) -> Val.

I suspect what you want is:

q(Key) -> get(Key, []).
q(Key, Default) ->
  case get(Key) of
    undefined -> Default;
    Value     -> Value
  end.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.