Have you checked out Ghost Desktop yet? It's our little app for Windows, macOS, and Linux, allowing users to work on their publications without being confined by the limits of a browser. We already implemented a host of native features, and we have even bigger plans for the future.
Node.js on the Desktop
Willy Wonka's App Factory
Let's take a look at the source. It starts with a
package.json, just like Node developers are used to. As you can tell from the dependencies, we're using Ember and a handful of Node modules. We even built ember-electron, integrating Ember Cli with Electron.
To understand how it all comes together, let's follow the path of the app booting up. To start the app as a developer, you run
npm start, which in turn calls
ember electron. Electron starts with a simple file, much like a Node.js application - in our case, that's
main/app.js. Note that when Ghost Desktop starts, it initially does not have a visible window - the main process does not have a user interface. In there, we wait for the application to finish its native boot process before creating a new
BrowserWindow, we fire up an Ember application - it manages the addition of blogs, the quick switcher on the left, and everything else you can see. If you browse the source code, you will even see us requiring Node modules, including native ones.
However, due to the tremendous power available to the code that runs inside the window, we do not simply load your blog. We use a special HTML element called a
<WebView /> - which is sort of like an
Iframe and at home inside the Chromium engine. When you add a blog, we create a new
Before a blog gets to load, we pre-load a series of functions, augmenting the APIs available to the blog. Once we have augmented the global scope, we remove Node privileges inside the
<WebView />. In this moment, Ghost Desktop becomes a slightly more powerful browser, tailored specifically to the needs of the Ghost Admin interface. From there, Ghost Desktop has full control over Ghost Admin, while Ghost Admin is able to call a set collection of APIs made available to it.
We have big plans for the future: A powerful offline mode, allowing to work on posts without an active connection. Native integration with your favorite editors, whether that is Microsoft Word or Sublime. Easier management for those creative souls who manage multiple blogs. If you'd like work on some Open Source code with us, join us in our GitHub repository!
Subscribe to Ghost Dev
Get the latest posts delivered right to your inbox