Showing the changes to assets/javascripts/app (1 of 4 files). Show all
Unified · Split
| @@ -34,19 +34,24 @@ class app.Router · 33 unmodified lines | |||
| 34 | return | 34 | return |
| 35 | 35 | ||
| 36 | before: (context, next) -> | 36 | before: (context, next) -> |
| 37 | previousContext = @context | ||
| 37 | @context = context | 38 | @context = context |
| 38 | @trigger 'before', context | 39 | @trigger 'before', context |
| 39 | next() | 40 | |
| 40 | return | 41 | if res = next() |
| 42 | @context = previousContext | ||
| 43 | return res | ||
| 44 | else | ||
| 45 | return | ||
| 41 | 46 | ||
| 42 | doc: (context, next) -> | 47 | doc: (context, next) -> |
| 43 | if doc = app.docs.findBySlug(context.params.doc) or app.disabledDocs.findBySlug(context.params.doc) | 48 | if doc = app.docs.findBySlug(context.params.doc) or app.disabledDocs.findBySlug(context.params.doc) |
| 44 | context.doc = doc | 49 | context.doc = doc |
| 45 | context.entry = doc.toEntry() | 50 | context.entry = doc.toEntry() |
| 46 | @triggerRoute 'entry' | 51 | @triggerRoute 'entry' |
| 52 | return | ||
| 47 | else | 53 | else |
| 48 | next() | 54 | return next() |
| 49 | return | ||
| 50 | 55 | ||
| 51 | type: (context, next) -> | 56 | type: (context, next) -> |
| 52 | doc = app.docs.findBySlug(context.params.doc) | 57 | doc = app.docs.findBySlug(context.params.doc) |
| @@ -55,9 +60,9 @@ class app.Router · 2 unmodified lines | |||
| 55 | context.doc = doc | 60 | context.doc = doc |
| 56 | context.type = type | 61 | context.type = type |
| 57 | @triggerRoute 'type' | 62 | @triggerRoute 'type' |
| 63 | return | ||
| 58 | else | 64 | else |
| 59 | next() | 65 | return next() |
| 60 | return | ||
| 61 | 66 | ||
| 62 | entry: (context, next) -> | 67 | entry: (context, next) -> |
| 63 | doc = app.docs.findBySlug(context.params.doc) | 68 | doc = app.docs.findBySlug(context.params.doc) |
| @@ -66,36 +71,39 @@ class app.Router · 2 unmodified lines | |||
| 66 | context.doc = doc | 71 | context.doc = doc |
| 67 | context.entry = entry | 72 | context.entry = entry |
| 68 | @triggerRoute 'entry' | 73 | @triggerRoute 'entry' |
| 74 | return | ||
| 69 | else | 75 | else |
| 70 | next() | 76 | return next() |
| 71 | return | ||
| 72 | 77 | ||
| 73 | root: -> | 78 | root: -> |
| 74 | if app.isSingleDoc() | 79 | return '/' if app.isSingleDoc() |
| 75 | setTimeout (-> window.location = '/'), 0 | 80 | @triggerRoute 'root' |
| 76 | else | ||
| 77 | @triggerRoute 'root' | ||
| 78 | return | 81 | return |
| 79 | 82 | ||
| 80 | settings: -> | 83 | settings: (context) -> |
| 84 | return "/#/#{context.path}" if app.isSingleDoc() | ||
| 81 | @triggerRoute 'settings' | 85 | @triggerRoute 'settings' |
| 82 | return | 86 | return |
| 83 | 87 | ||
| 84 | offline: -> | 88 | offline: (context)-> |
| 89 | return "/#/#{context.path}" if app.isSingleDoc() | ||
| 85 | @triggerRoute 'offline' | 90 | @triggerRoute 'offline' |
| 86 | return | 91 | return |
| 87 | 92 | ||
| 88 | about: (context) -> | 93 | about: (context) -> |
| 94 | return "/#/#{context.path}" if app.isSingleDoc() | ||
| 89 | context.page = 'about' | 95 | context.page = 'about' |
| 90 | @triggerRoute 'page' | 96 | @triggerRoute 'page' |
| 91 | return | 97 | return |
| 92 | 98 | ||
| 93 | news: (context) -> | 99 | news: (context) -> |
| 100 | return "/#/#{context.path}" if app.isSingleDoc() | ||
| 94 | context.page = 'news' | 101 | context.page = 'news' |
| 95 | @triggerRoute 'page' | 102 | @triggerRoute 'page' |
| 96 | return | 103 | return |
| 97 | 104 | ||
| 98 | help: (context) -> | 105 | help: (context) -> |
| 106 | return "/#/#{context.path}" if app.isSingleDoc() | ||
| 99 | context.page = 'help' | 107 | context.page = 'help' |
| 100 | @triggerRoute 'page' | 108 | @triggerRoute 'page' |
| 101 | return | 109 | return |