 
       callback? err
 
-
-  # runApp:(nodeView, callback)->
-
-  #   folder = nodeView.getData()
-  #   folder.emit "fs.job.started"
-  #   kodingAppsController = KD.getSingleton 'kodingAppsController'
-
-  #   manifest = KodingAppsController.getManifestFromPath folder.path
-
-  #   KD.getSingleton("appManager").open manifest.name, =>
-  #     folder.emit "fs.job.finished"
-  #     callback?()
+  publishApp:(nodeView)->
+
+    folder = nodeView.getData()
+    folder.emit "fs.job.started"
+
+    KodingAppsController.createJApp path: folder.path, (err, app)->
+      folder.emit "fs.job.finished"
+
+      if err or not app
+        warn err
+        return new KDNotificationView
+          title : "Failed to publish"
+
+      new KDNotificationView
+        title: "Published successfully!"
+
+      KD.singletons
+        .router.handleRoute "/Apps/#{app.manifest.authorNick}/#{app.name}"
+
 
   cloneRepo: (nodeView) ->
     folder   = nodeView.getData()

      vmName : folder.vmName
      path   : folder.path
    modal.on "RepoClonedSuccessfully", => @notify "Repo cloned successfully.", "success"

  # publishApp:(nodeView)->

  #   folder = nodeView.getData()

  #   folder.emit "fs.job.started"
  #   KD.getSingleton('kodingAppsController').publishApp folder.path, (err)=>
  #     folder.emit "fs.job.finished"
  #     unless err
  #       @notify "App published!", "success"
  #     else
  #       @notify "Publish failed!", "error", err
  #       message = err.message or err
  #       modal = new KDModalView
  #         title        : "Publish failed!"
  #         overlay      : yes
  #         cssClass     : "new-kdmodal"
  #         content      : "<div class='modalformline'>#{message}</div>"
  #         buttons      :
  #           "Close"    :
  #             style    : "modal-clean-gray"
  #             callback : (event)->
  #               modal.destroy()

  # makeNewApp:(nodeView)->
  #   KD.getSingleton('kodingAppsController').makeNewApp()

  cmOpenFile:      (nodeView, contextMenuItem)-> @openFile nodeView
  cmPreviewFile:   (nodeView, contextMenuItem)-> @previewFile nodeView
  # cmMakeNewApp:    (nodeView, contextMenuItem)-> @makeNewApp nodeView
  cmCompile:       (nodeView, contextMenuItem)-> @compileApp nodeView
  cmPublish:       (nodeView, contextMenuItem)-> @publishApp nodeView
  cmOpenFileWithApp: (nodeView, contextMenuItem)-> @openFileWithApp  nodeView, contextMenuItem
  cmCloneRepo:     (nodeView, contextMenuItem)-> @cloneRepo nodeView
  cmDropboxChooser:(nodeView, contextMenuItem)-> @chooseFromDropbox nodeView
