0

My question is simple. Imagine that you have a project built with marionette/backbone and you have two target medias: mobile and desktop. There is a backing server, written in DJango (or Ruby, or etc.).

How can I organize the project, so I can compile it to mobile and make it run for desktop? I mean, imagine collections, that have a url parameter. Set it to relative? To absolute, from scratch?

The project already has a feasible layout where I can compile it using r.js. It's pretty much like this:

repo-root/
 - src/
  - assets/
   - css/
   - images/
  - project-code/
  - vendor/
  - build.js
  - config.xml (phonegap conf)
  - index.html
  - main.js
 - tests/
- bower.json
- .gitignore

here's an example of a collection:

define(function(require){
    "use strict";
    var Backbone = require("backbone");
    var FeatureClass = require("atlas-backbone/models/FeatureClass");
    return Backbone.Collection.extend({

        url: "api/featureclasses",
        model: FeatureClass

    });
});

My question is how to organize this, so it can be compiled to a mobile device and run in a desktop version.

George Silva
  • 3,454
  • 10
  • 39
  • 64
  • Collections handles data, it's designed to be independendent from presentation (mobile, desktop, tablet etc.) – Lesha Ogonkov Sep 14 '15 at 19:44
  • @LeshaOgonkov: ok, sure. But how should I define it's URL, if it's designed to work from a mobile device talking to a remote server (absolute URL, like: http://foo.com/api/featureclasses) and should work in dev and production with a desktop machine (relative URL like api/featureclasses)? – George Silva Sep 14 '15 at 20:04
  • mock it locally? I'm prefer use relative paths to make it simpler, so locally you will get `dev.local/api/foo`, pointed to your mock server. You could use absolute paths, but then you need to edit your `hosts` file in some tricky way. – Lesha Ogonkov Sep 14 '15 at 20:08
  • Ok, great. Can you give some examples on how to mock it? I have a dev django server giving me responses already. But I do understand how mocking it would be much easier to fast-forward development and detach the development of both worlds. – George Silva Sep 14 '15 at 20:27
  • run your server in dev mode and point your requests to `localhost:some_port`, you can edit your `hosts` file to have alias on your domain (in case if you need domain cookies to work) – Lesha Ogonkov Sep 14 '15 at 20:31

1 Answers1

1

In my current job on my current project we make extensive use of Gulp and gulp tasks. We have Gulp tasks for production and for development, and setup different pipelines for each.

Optionally, if you would like to manage such things independently you can utilize more antiquated methods such as a mock server, relative URLs, or host file changes.

Tyler Durden
  • 1,506
  • 13
  • 21