Created
March 25, 2013 23:37
-
-
Save davidvanleeuwen/5241905 to your computer and use it in GitHub Desktop.
Change events for articles to use chapters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Blog.App.vent.bind 'article', (slug) -> | |
chapter = chapters.findArticleBySlug(slug) | |
chapter = chapters.last() unless chapter | |
article = chapter.get('articles').getArticle(slug) | |
unless article | |
Blog.App.vent.trigger('404') | |
return | |
Blog.router.navigate("/articles/#{slug}", {trigger: false}) if slug | |
nav = new Blog.Views.Navigation(model: chapter, collection: chapters) | |
view = new Blog.Views.Article(model: article) | |
Blog.layout.navigation.show(nav) | |
Blog.layout.article.show(view) | |
Blog.App.vent.bind '404', -> | |
nav = new Blog.Views.Navigation(collection: chapters) | |
view = new Blog.Views.NotFound() | |
Blog.layout.navigation.show(nav) | |
Blog.layout.article.show(view) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment