Commit d60394338f9737374c08c964a1d3c9a7e02ed517

Fix URL routing and error handling

  - Fix URL routing to start with index page. Changed location.origin
which is only available in Chrome to standart location.protocol and
location.hostname.
  - Add error handling and reporting in the console; in Page views.
  
300300 _.each(children, function(child) {
301301 child = M.sanitize(child);
302302 var model = M.pages.get(child);
303 if(!_.isObject(model)) {
304 console.log('Error: Cannot find page '+ child +' which is defined as children of ' + page);
305 return false;
306 }
303307 var children = model.get('children');
304308 if(_.isEmpty(children)) {
305309 li = '<li><a href="#/' + child + '">' + M.humanReadable(child) + '</a></li>';
354354 var new_page = new Page(page);
355355 var contents = [];
356356 _.each(page.content, function(content) {
357 if(_.isEmpty(content)) {
358 console.log('Empty content for ' + page.name);
359 return;
360 }
357361 var Item = type_map.model[content.type];
358362 if(!Item) {
359 console.log('Error initing item: ', content);
363 console.log('Error: Invalid type '+ content.type +' for ', content);
360364 return;
361365 }
362366 var item = new Item(content);
379379 Backbone.history.start();
380380 // start with index page
381381 var location = window.location;
382 location.href = location.origin + location.pathname + '#/index';
382 location.href = location.protocol + '//' + location.hostname +
383 location.pathname + '#/index';
383384 M.simHeir();
384385};
385386