routing

19 views
Skip to first unread message

Roelof Wobben

unread,
Feb 9, 2015, 2:03:03 PM2/9/15
to nitro...@googlegroups.com
Hello,

In all tutorials there is mentioned this ;

Root page maps to index.erl
http://localhost:8000/ ->  index.erl

Where and how does this mapping take place.

Roelof



Jesse Gumm

unread,
Feb 9, 2015, 3:46:28 PM2/9/15
to nitrogenweb
Hi Roelof,

This is done in Nitrogen's dynamic_route_handler
(https://github.com/nitrogen/nitrogen_core/blob/master/src/handlers/route/dynamic_route_handler.erl#L58)

You're free to deploy your own route handler by calling:

nitrogen:handler(my_route_handler, []) inside nitrogen_main_handler.erl

And making your own route handler is described in the docs here:
https://github.com/nitrogen/nitrogen_core/blob/master/doc/org-mode/handlers/route.org

(I'm linking the docs from github rather than nitrogenproject.com as I
haven't yet had achance to deploy the new docs to
nitrogenproject.com).

-Jesse
> --
> You received this message because you are subscribed to the Google Groups
> "Nitrogen Project / The Nitrogen Web Framework for Erlang" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to nitrogenweb...@googlegroups.com.
> To post to this group, send email to nitro...@googlegroups.com.
> Visit this group at http://groups.google.com/group/nitrogenweb.
> For more options, visit https://groups.google.com/d/optout.



--
Jesse Gumm
Owner, Sigma Star Systems
414.940.4866 || sigma-star.com || @jessegumm

Roelof Wobben

unread,
Feb 9, 2015, 3:57:00 PM2/9/15
to nitro...@googlegroups.com
Thanks, Im coming from ruby and they work with a routes file.

Is there somewhere a tutorial where I can see how to make a menu which is working with the routes.

Roelof


Op maandag 9 februari 2015 21:46:28 UTC+1 schreef Jesse Gumm:

Jesse Gumm

unread,
Feb 9, 2015, 4:03:03 PM2/9/15
to nitrogenweb
Probably the closest thing to that would be using the
named_routes_handler, defined here:
https://github.com/nitrogen/nitrogen_core/blob/master/src/handlers/route/named_route_handler.erl

The comments at the top show how you invoke it, then you end up
loading your routes into the 2nd argument of the
nitrogen:handler(named_route_handler, MyRoutes).

-Jesse

-Jesse

-Jesse

Roelof Wobben

unread,
Feb 10, 2015, 4:52:27 AM2/10/15
to nitro...@googlegroups.com
Thanks,

Could I use the chat demo or another demo to make a shopping cart which is updated because a customer presses the buy me button.
And that without any javascript ?


Roelof


Op maandag 9 februari 2015 22:03:03 UTC+1 schreef Jesse Gumm:

Jesse Gumm

unread,
Feb 10, 2015, 8:07:34 AM2/10/15
to nitrogenweb

Sure, no reason I can think of that you couldn't. You can do most things in Nitrogen without writing Javascript, but some of the erlang you write will generate Javascript.

So the client would still need to support Javascript.

-Jesse

--
Jesse Gumm
Owner, Sigma Star Systems
414.940.4866 || sigma-star.com || @jessegumm

Reply all
Reply to author
Forward
0 new messages