var SiteRouter = Router.extend({ el: "body", routes: { "/": 'login', "/index/:keyword": 'index', "/index": 'index', "/login": 'login', "/logout": 'logout', "/signup": 'signup', "/details/:id": 'details', "/details/:id/settings": 'threadSettings', "/post": 'post', "/post/:keyword": 'post', "/comment/:id/edit": 'editComment', "/keywords": 'keywords', "/search": 'search', "/mail": 'mailbox', "/mail/:mailbox": 'mailbox', "/mail/compose": 'compose', "/mail/compose/:username": 'compose', "/mail/read/:id": 'message', "/mail/reply/:id": 'compose', "/profile": 'profile', "/profile/:username": 'profile', "/profile/:username/edit": 'editProfile', }, initialize: function(){ $(".logout").click(() => this.logout()) }, index: function(keyword){ app.view = new IndexView () app.view.load(keyword) }, login: function(){ app.view = new LoginView () }, logout: function(){ auth.log_out() window.location.href = "/logout" }, signup: function(){ app.view = new SignupView () }, details: function(id){ app.view = new DetailsView () app.view.load(id) }, threadSettings: function(id){ app.view = new DetailsView ({ settings: true }) app.view.load(id) }, editComment: function(id){ app.view = new EditCommentForm () app.view.load(id) }, keywords: function(){ app.view = new KeywordsView () app.view.load() }, mailbox: function(box){ app.view = new MailboxView () app.view.load(box) }, message: function(id){ app.view = new MessageView () app.view.load(id) }, post: function(keyword){ app.view = new ThreadForm () app.view.load(keyword || "") }, profile: function(username){ app.view = new ProfileView () app.view.load(username || auth.user.username) }, editProfile: function(username){ app.view = new ProfileForm () app.view.load(username || auth.user.username) }, compose: function(username){ app.view = new ComposeView () app.view.load(username) }, search: function(){ app.view = new SearchResults () app.view.load() }, error404: function(){ $("content").hide() $("#error_404").show() $("h1").html("404 not found") $("body").removeClass("loading") $("#error_404").append('') }, })