Starter SPA front-end backed by the WordPress REST API.
GPL-2.0 License
Note: This is all very experimental and under development.
Node and Express are used to create a basic routing engine. This allows for SEO friendly permalinks.
Handlebars.js is used for templating, and methods are provided for getting posts, single posts, taxonomy terms and terms in a taxonomy. Support for managing menus in WordPress is enabled via an optional WordPress plugin. Custom post type and Pods support is planned.
Be sure to read the instructions below as there are some steps that if not followed will prevent this from working properly. Also, this is still under development use in production at your own risk.
This code was written as example code for a series of articles I wrote for Torque. You can read them here:
@TODO Use grunt for this
On a server with Node.js installed, cd into your www dir and then:
git clone https://github.com/Shelob9/josie.git app
cd app
npm install express
node server
Important: By default, the node server will not continue running indefinetly as you may be used to when using Apache or nGinx as a server for WordPress. To keep the server running, one option is to use Forever. For more complete details, see this article.
In order to make this work, you must install the REST API Plugin in WordPress.
You must set the 'json_query_vars' filter to allow offset as a filter, also you need a https://github.com/Shelob9/jp-menu-routemenu endpoint as well as to set cross-domain origin headers properly. Locally I made a plugin that does all of this for you, as well as giving you a server-side API cache and some other fun, useful things.
In index.html, configuration options are set in the object params, which must be added to the window scope after it is defined. The object must have 6 indexes, as follows:
Everything should basically work as is. If you get nothing in the index check the console. You must likely are getting a 404 error on the AJAX requests and need to correct your URLs. You may also be getting a cross-origin error, which means you didn't read the last section or set up the Access-Control-Allow-Origin header wrong.
Copyright 2014 Josh Pollock
Licensed under the terms of the GNU General Public License version 2 or later. Please share with your neighbor.
Includes the following MIT licensed libraries: