Skip to content

Commit

Permalink
Added a hasnbang for URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
rukshn committed Nov 11, 2014
1 parent 37db8ed commit 2c6d5b4
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions assets/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,34 @@ $("img").error(function () {
$(this).unbind("error").attr("src", "http://www.piraten-oberpfalz.de/files/2009/08/orange-twitter-egg.jpg");
});

//The hashbang for better Goolge crawling

Ember.Location.registerImplementation('hashbang', Ember.HashLocation.extend({
getURL: function () {
return Ember.get(this, 'location').hash.substr(2);
},

setURL: function (path) {
Ember.get(this, 'location').hash = '!' + path;
Ember.set(this, 'lastSetURL', '!' + path);
},

onUpdateURL: function (callback) {
var self = this;
var guid = Ember.guidFor(this);

Ember.$(window).bind('hashchange.ember-location-' + guid, function () {
Ember.run(function() {
var path = location.hash.substr(2);
if (Ember.get(self, 'lastSetURL') === path) { return; }
Ember.set(self, 'lastSetURL', null);
callback(path);
});
});
},

formatURL: function (url) {
return '#!' + url;
}
}));

0 comments on commit 2c6d5b4

Please sign in to comment.