-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathsystem.coffee
52 lines (39 loc) · 1.08 KB
/
system.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Achievement = require "./system/achievement"
Ajax = require "ajax"
Applications = require "./system/applications"
Bindable = require "bindable"
FS = require "./system/fs"
Model = require "model"
SystemModule = require "./system/module"
Template = require "./system/template"
UI = require "ui"
module.exports = (I={}, self=Model(I)) ->
I.dbName ?= 'zine-os'
self.include Bindable,
FS, # Include FS before other modules
Achievement,
Applications,
require("./system/messaging"),
SystemModule,
Template
{title} = require "./pixie"
[..., version] = title.split('-')
# Log system events
self.on "*", console.log
self.extend
ajax: Ajax()
version: -> version
require: require
stylus: require "./lib/stylus.min"
Observable: UI.Observable
UI: UI
launchIssue: (date) ->
require("./issues/#{date}")()
invokeBefore UI.Modal, "hide", ->
self.Achievement.unlock "Dismiss modal"
return self
invokeBefore = (receiver, method, fn) ->
oldFn = receiver[method]
receiver[method] = ->
fn()
oldFn.apply(receiver, arguments)