2012-01-16 17:55:13 -08:00
|
|
|
NEWSBLUR.Router = Backbone.Router.extend({
|
|
|
|
|
|
|
|
routes: {
|
|
|
|
"": "index",
|
|
|
|
"add/?": "add_site",
|
|
|
|
"try/?": "try_site",
|
|
|
|
"site/:site_id/:slug": "site",
|
2012-06-30 11:59:17 -07:00
|
|
|
"site/:site_id/": "site",
|
|
|
|
"site/:site_id": "site",
|
2012-02-10 19:33:31 -08:00
|
|
|
"social/:user_id/:slug": "social",
|
2012-06-30 11:59:17 -07:00
|
|
|
"social/:user_id/": "social",
|
|
|
|
"social/:user_id": "social",
|
2012-01-16 17:55:13 -08:00
|
|
|
"user/*user": "user"
|
|
|
|
},
|
|
|
|
|
2012-01-18 17:39:00 -08:00
|
|
|
index: function() {
|
2012-07-10 15:26:34 -07:00
|
|
|
// NEWSBLUR.log(["index"]);
|
2012-01-18 17:39:00 -08:00
|
|
|
NEWSBLUR.reader.show_splash_page();
|
|
|
|
},
|
2012-01-16 17:55:13 -08:00
|
|
|
|
|
|
|
add_site: function() {
|
2012-07-10 15:26:34 -07:00
|
|
|
NEWSBLUR.log(["add", window.location, $.getQueryString('url')]);
|
2012-01-16 17:55:13 -08:00
|
|
|
NEWSBLUR.reader.open_add_feed_modal({url: $.getQueryString('url')});
|
|
|
|
},
|
|
|
|
|
|
|
|
try_site: function() {
|
2012-07-10 15:26:34 -07:00
|
|
|
NEWSBLUR.log(["try", window.location]);
|
2012-01-16 17:55:13 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
site: function(site_id, slug) {
|
2012-07-10 15:26:34 -07:00
|
|
|
// NEWSBLUR.log(["site", site_id, slug]);
|
2012-01-25 09:52:34 -08:00
|
|
|
site_id = parseInt(site_id, 10);
|
2012-05-23 10:02:30 -07:00
|
|
|
var feed = NEWSBLUR.reader.model.get_feed(site_id);
|
|
|
|
if (feed) {
|
2012-04-19 22:38:00 -07:00
|
|
|
NEWSBLUR.reader.open_feed(site_id, {force: true});
|
|
|
|
} else {
|
|
|
|
NEWSBLUR.reader.load_feed_in_tryfeed_view(site_id, {force: true, feed: {
|
2012-06-30 11:59:17 -07:00
|
|
|
feed_title: _.string.humanize(slug || "")
|
2012-04-19 22:38:00 -07:00
|
|
|
}});
|
|
|
|
}
|
2012-02-10 19:33:31 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
social: function(user_id, slug) {
|
2012-07-10 15:26:34 -07:00
|
|
|
// NEWSBLUR.log(["router:social", user_id, slug]);
|
2012-04-11 15:20:57 -07:00
|
|
|
var feed_id = "social:" + user_id;
|
2012-04-30 12:20:04 -07:00
|
|
|
if (NEWSBLUR.reader.model.get_feed(feed_id)) {
|
|
|
|
NEWSBLUR.reader.open_social_stories(feed_id, {force: true});
|
|
|
|
} else {
|
|
|
|
NEWSBLUR.reader.load_social_feed_in_tryfeed_view(feed_id, {force: true, feed: {
|
|
|
|
username: _.string.humanize(slug),
|
|
|
|
id: feed_id,
|
|
|
|
user_id: parseInt(user_id, 10),
|
|
|
|
feed_title: _.string.humanize(slug)
|
|
|
|
}});
|
|
|
|
}
|
2012-01-16 17:55:13 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
user: function(user) {
|
2012-07-10 15:26:34 -07:00
|
|
|
NEWSBLUR.log(["user", user]);
|
2012-01-16 17:55:13 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|