From 323477df9ef64bbc9a46a18142774076b8c40286 Mon Sep 17 00:00:00 2001 From: Nicklas Gummesson Date: Mon, 9 Mar 2015 12:12:34 +0100 Subject: [PATCH] Update docs --- doc/frontend/README.md | 3 ++- doc/frontend/urls.md | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 doc/frontend/urls.md diff --git a/doc/frontend/README.md b/doc/frontend/README.md index 7add218570..ebd2219b1f 100644 --- a/doc/frontend/README.md +++ b/doc/frontend/README.md @@ -2,4 +2,5 @@ Here you will find all documentation - [Backbone with organizations](doc/frontend/js/backbone-with-organizations.md) - [Global objects](doc/frontend/js/global-objects.md) -- [Conventions](doc/frontend/conventions) +- [Conventions](doc/frontend/js/conventions.md) +- [URLs](doc/frontend/urls.md) diff --git a/doc/frontend/urls.md b/doc/frontend/urls.md new file mode 100644 index 0000000000..1d1d2c6335 --- /dev/null +++ b/doc/frontend/urls.md @@ -0,0 +1,15 @@ +URLs within the application might be necessary. + +To avoid constructing these URLS manually, i.e. concatenating strings and thus duplicating logic, there are convenient ways of constructing them. Depending on context (server- or client-side) you might take one approach or another. + +## Rails +In Rails simply use the [standard routing helper methods](http://guides.rubyonrails.org/v3.2.21/routing.html). Have a look at [routes.rb](https://github.com/CartoDB/cartodb/blob/master/config/routes.rb) for the semantic names and paths available. + +## Client-side +For a current sub-app you can access URLs through the current router model, e.g. `router.currentUrl()`. + +For a URL that is associated with a specific model you can access the URL by call `.viewUrl()` on that model, and chaining methods afterwards to "drill down" on what (available) path you want, e.g. +- `user.viewUrl().dashboard().datasets())`, the URL to a user's datasets on the dashboard. +- `vis.viewUrl().public()`, the URL to a visualization's public page. + +See the [models](https://github.com/CartoDB/cartodb/blob/master/lib/assets/test/spec/cartodb/common/urls) for available models and methods.