Skip to content

Commit

Permalink
Use basepath in more places.
Browse files Browse the repository at this point in the history
  • Loading branch information
Young Hahn committed Apr 15, 2011
1 parent 192b2bc commit d7f4bf3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion mvc/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Bones.models.Tileset = Backbone.Model.extend({
// Pass through function for determining the server-side filepath of a
// Tileset model.
filepath: function(path) {
return path + '/' + this.id + '.mbtiles';
return path + this.options.basepath + this.id + '.mbtiles';
}
});

Expand Down
6 changes: 4 additions & 2 deletions mvc/views.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Backbone.View = Backbone.View.extend({
route: function(ev) {
var fragment = this.href(ev.currentTarget);
if (fragment.charAt(0) === '/') {
// Remove the basepath from the fragment, but leave a /.
fragment = fragment.substr(Bones.settings.basepath.length - 1);
var matched = _.any(Backbone.history.handlers, function(handler) {
if (handler.route.test(fragment)) {
handler.callback(fragment);
Expand Down Expand Up @@ -205,7 +207,7 @@ Bones.views.Map = Bones.views.HUD.extend({
},
render: function() {
$(this.el).html(this.template('Map', {
basepath: this.options.basepath,
basepath: this.model.options.basepath,
features: Bones.settings.features,
id: this.model.get('id'),
name: this.model.get('name'),
Expand Down Expand Up @@ -260,7 +262,7 @@ Bones.views.MapThumb = Backbone.View.extend({
},
render: function() {
$(this.el).html(this.template('MapThumb', {
basepath: this.options.basepath,
basepath: this.model.options.basepath,
id: this.model.get('id'),
name: this.model.get('name'),
thumb: this.model.thumb()
Expand Down
5 changes: 3 additions & 2 deletions templates/App.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
<title>TileStream</title>
<script type='text/javascript'>
// Redirect requests without the hash.
var basepath = '{{basepath}}';
location.href.indexOf('#') === -1 &&
window.location.pathname !== '/' &&
(window.location = '/#' + window.location.pathname);
window.location.pathname !== basepath &&
(window.location = basepath + '#' + window.location.pathname.substr(basepath.length - 1));
</script>

<link rel='shortcut icon' href='/images/favicon.ico' type='image/x-icon' />
Expand Down

0 comments on commit d7f4bf3

Please sign in to comment.