Giter Club home page Giter Club logo

josie's Introduction

JOSIE

Josie is a simple starter single page app, written in JavaScript designed to make use of the [WordPress REST API](http://wp-api.org). It runs separately from the WordPress install and is designed to be a starting point for developing an app that uses WordPress as its back-end CMS. The goal is to create starting point for a hybrid web and mobile app.

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.

In Depth Tutorials

This code was written as example code for a series of articles I wrote for Torque. You can read them here:

Setting Up The Node Server

@TODO Use grunt for this

On a server with Node.js installed, cd into your www dir and then:

  • Clone this repo:

git clone https://github.com/Shelob9/josie.git app

  • Switch into the directory:

cd app

  • Install Express:

npm install express

  • Start the server

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.

Requirements & Recommendations For Your WordPress Site

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.

Setting Up The App

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:

  • rootURL - The URL for the WordPress REST API. Typically this is your url /wp-json, but it can be changed with a filter.
  • siteTitle - The name of the app/site.
  • postsPerPage - Number of posts to show per page.
  • mainContainer - The container to populate post data into. If using index.html as is, use "#main".
  • mainMenuContainer - The container to populate the menu into. If using index.html as is, use "#main-menu"
  • mainMenuName - The name of the menu, set in the WordPress menu editor to get items from. Set to false to not use or if you have not added the menu endpoint.

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.

License, Copyright etc.

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:

  • Handlebars.js
  • Foundation
  • Fastclick
  • jQuery
  • Modernizer

josie's People

Contributors

shelob9 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.