diff --git a/src/core/gui.coffee b/src/core/gui.coffee index 98711fd..8910ebe 100644 --- a/src/core/gui.coffee +++ b/src/core/gui.coffee @@ -102,32 +102,27 @@ self.OS.GUI = _GUI.launch app, args loadApp: (app, ok, err) -> - path = "packages/#{app}/" - _API.script path + "main.js", - (d) -> + path = "os:///packages/#{app}" + path = _OS.setting.system.packages[app].path if _OS.setting.system.packages[app].path + js = path + "/main.js" + js.asFileHandler().read (d) -> #load css file - _API.get "#{path}main.css", - () -> - $ '', { rel: 'stylesheet', type: 'text/css', 'href': "#{path}main.css" } - .appendTo 'head' - , () -> + css = "#{path}/main.css" + css.asFileHandler().onready (d) -> + $ '', { rel: 'stylesheet', type: 'text/css', 'href': "#{_API.handler.get}/#{css}" } + .appendTo 'head' + , () -> #launch if _OS.APP[app] # load app meta data - _API.get "#{path}package.json", - (data) -> - _OS.APP[app].meta = data - ok app - , (e, s) -> - _courrier.osfail "Cannot read application metadata: #{app}", e, s - err e, s + "#{path}/package.json".asFileHandler().read (data) -> + data.path = path + _OS.APP[app].meta = data + ok app + , "json" else ok app - , (e, s) -> - #BUG report here - _courrier.osfail "Cannot load application script: #{app}", e, s - console.log "bug report", e, s, path - err e,s + , "script" launch: (app, args) -> if not _OS.APP[app] # first load it @@ -147,7 +142,8 @@ self.OS.GUI = iconclass: meta.iconclass || "" app: app onbtclick: () -> app.toggle() - data.icon = "packages/#{meta.app}/#{meta.icon}" if meta.icon + # TODO: this path is not good, need to create a blob of it + data.icon = "#{_API.handler.get}/#{meta.path}/#{meta.icon}" if meta.icon # TODO: add default app icon class in system setting # so that it can be themed data.iconclass = "fa fa-cogs" if (not meta.icon) and (not meta.iconclass) @@ -369,9 +365,9 @@ self.OS.GUI = "CoreServices/Spotlight", "CoreServices/Calendar" ] + #_GUI.launch "DummyApp" # startup application here _courrier.observable.one "desktoploaded", () -> - console.log "startup app" - _GUI.launch "DummyApp" + #_GUI.launch "DummyApp" #_GUI.launch "NotePad" \ No newline at end of file diff --git a/src/core/handlers/RemoteHandler.coffee b/src/core/handlers/RemoteHandler.coffee index 4dafb8d..e41de56 100644 --- a/src/core/handlers/RemoteHandler.coffee +++ b/src/core/handlers/RemoteHandler.coffee @@ -1,4 +1,6 @@ self.OS.API.handler = + get: "lua-api/fs/get" + scandir: (p, c ) -> path = "lua-api/fs/scandir" _API.post path, { path: p }, c, (e, s) -> @@ -13,11 +15,11 @@ self.OS.API.handler = _API.post path, { path: p }, c, (e, s) -> _courrier.osfail "Fail to get file metadata: #{p}", e, s - readfile: (p, c) -> + readfile: (p, c, t) -> path = "lua-api/fs/get/" _API.get path + p, c, (e, s) -> _courrier.osfail "Fail to read file: #{p}", e, s - , "text" + , t move: (s, d, c) -> path = "lua-api/fs/move" diff --git a/src/core/vfs.coffee b/src/core/vfs.coffee index f2ae311..d0c24de 100644 --- a/src/core/vfs.coffee +++ b/src/core/vfs.coffee @@ -68,9 +68,9 @@ class BasicFileHandler me.ready = true f() - read: (f) -> + read: (f, t) -> me = @ - @onready (() -> me.action "read", null, f) + @onready (() -> me.action "read", t, f) write: (d, f) -> me = @ @@ -136,7 +136,7 @@ class RemoteFileHandler extends self.OS.API.VFS.BasicFileHandler when "read" return _API.handler.scandir @path, f if @info.type is "dir" #read the file - _API.handler.readfile @path, f + _API.handler.readfile @path, f, if p then p else "text" when "mk" return f { error: "#{@path} is not a directory" } if @info.type is "file" _API.handler.mkdir "#{@path}/#{p}", f diff --git a/src/packages/DummyApp/Makefile b/src/packages/DummyApp/Makefile index 159e7bd..b2eb2d7 100644 --- a/src/packages/DummyApp/Makefile +++ b/src/packages/DummyApp/Makefile @@ -4,7 +4,7 @@ jsfiles = cssfiles = main.css -copyfiles = scheme.html package.json +copyfiles = scheme.html package.json icon.png PKG_NAME=DummyApp diff --git a/src/packages/DummyApp/icon.png b/src/packages/DummyApp/icon.png new file mode 100644 index 0000000..6073c9c Binary files /dev/null and b/src/packages/DummyApp/icon.png differ diff --git a/src/packages/DummyApp/main.css b/src/packages/DummyApp/main.css index e69de29..01c49a5 100644 --- a/src/packages/DummyApp/main.css +++ b/src/packages/DummyApp/main.css @@ -0,0 +1,7 @@ +.dummyapp-icon { + background-image: url("icon.png"); + background-color: blueviolet; + display: block; + width: 32px; + height: 32px; +} \ No newline at end of file