Top Banner
Building Javascript Apps with the WordPress JSON API
45

Building Javascript Apps with the WordPress JSON API – LoopConf 2015

Jul 18, 2015

Download

Internet

Jacob Spurlock
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

Building Javascript Apps with the WordPress JSON API

Page 2: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

Jake Spurlock @whyisjake

Page 3: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

Hi

Page 4: Building Javascript Apps with the WordPress JSON API – LoopConf 2015
Page 5: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

WP JSON API

Page 6: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

Node.js

Page 7: Building Javascript Apps with the WordPress JSON API – LoopConf 2015
Page 8: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

Wait, what?

Page 9: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

FASTNODE IS

.js

Page 10: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

php.JS

Page 11: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

WordPress.JS

Page 12: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

Chipotle.JS

Page 13: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

// Let’s get this burrito bowl going… chipotlejs.create({ type: 'bowl', options: { rice: 'white', beans: 'pinto', meat: 'chicken', salsa: [

'green', 'corn' ],

cream: true, cheese: true, guacamole: true, notes: 'Extra guac please!' });

Page 14: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

Build an “App”

Page 15: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

PHP/Javascript Apps• PHP • Javascript • CSS • SQL • MEMCACHED • CDN - FASTLY

• Mongo • Express • Jade • REACT • Backbone • Jquery

Page 16: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

Front-EndBack-End

Page 17: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

Developer

Page 18: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

The conventional seams between disciplines are fraying, and the set of skills necessary to succeed are broader and more nebulous than they’ve been before. These days, you’ve gotta be a real polymath to get ahead; you’ve got to be a full-stack employee.

CHRIS MESSINA

Page 19: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

Developer

Page 20: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

Employee

Page 21: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

SHOUT OUT TO THE CLASSIC STOKING OF FEAR ABOUT BEING LEFT BEHIND SOME ARBITRARY SOCIOTECHNOLOGICAL CURVE DEFINED BY A BUNCH OF 35 YEAR OLD PETER PANS IN SAN FRANCISCO — THIS ONE HAS EXCELLENT CONVERSION RATES

@PHPCEO

Page 22: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

Polymath

Page 23: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

A polymath (Greek: πολυμαθής, polymathēs, "having learned much") is a person whose expertise spans a significant number of different subject areas; such a person is known to draw on complex bodies of knowledge to solve specific problems.

POLYMATH

Page 24: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

A polymath (Greek: πολυμαθής, polymathēs, "having learned much") is a person whose expertise spans a significant number of different subject areas; such a person is known to draw on complex bodies of knowledge to solve specific problems.

POLYMATH

Page 25: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

A polymath (Greek: πολυμαθής, polymathēs, "having learned much") is a person whose expertise spans a significant number of different subject areas; such a person is known to draw on complex bodies of knowledge to solve specific problems complexly.

POLYMATH DEVELOPERS

Page 26: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

10K+CONCURRENT VIEWERS

WIRED.COM LIVEBLOGS

Page 27: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

What about Tumblr?

RE-EVALUATE LIVEBLOGS

Page 28: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

Complexity.

Page 29: Building Javascript Apps with the WordPress JSON API – LoopConf 2015
Page 30: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

Simple

Page 31: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

// Let's loop through each one, and add the response to post meta. // As we get posts, also push those to the main $posts array. // Reversing this so that we have some better logic for updating posts. // Ideally, you don't need to loop through every page, you could just // update the most recent page or two. for ( $i = 0; $i < $times; $i++ ) { // Fetch a batch of posts $response = $this->fetch_and_parse( $url, $i ); $more_posts = $response['response']['posts']; $more_posts = $this->clean_tumblr_response( $more_posts );

if ( ! empty( $more_posts ) ) { update_post_meta( $post_id, 'liveblog_posts_page_' . $i, $more_posts ); }

// Add each of the posts to the main post array. foreach ( $more_posts as $post ) { $posts[] = $post; } }

Page 32: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

Caching

Page 33: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

header( 'Cache-Control: max-age=15, s-maxage=15, stale-while-revalidate=60' );

Page 34: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

REACTFRONT-END

Page 35: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

In addition to taking input data, a component can maintain internal state data.

When a component's state data changes, the rendered markup will be updated by re-invoking render.

REACT IS STATEFUL

Page 36: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

Is this simple?

Page 37: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

Complexity.

Page 38: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

EASY WINSAM I AN IMPOSTER?

Page 39: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

Make code modular.

Page 40: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

Make code simple.

Page 41: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

Sober writers love to use fancy shit like semicolons. Nobody likes to see a semicolon. I see sobriety stains all over writing these days. I think, “Damn, this piece has a chance to be good but the author is too busy looking at their pompous smile in the mirror.”

Write under the influencehttps://medium.com/@3solarmasses/write-under-the-influence-1f6bcb600140

Page 42: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

1. Use Short Sentences

2. Use Short first Paragraphs

3. Use Vigorous English

4. Be Positive, Not Negative

5. Never have only four rules

Hemingway’s 4 Rules

Ernest Hemingway’s Top 5 Tips for Writing Wellhttp://www.copyblogger.com/ernest-hemingway-top-5-tips-for-writing-well/

Page 43: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

Code is Poetry

Page 44: Building Javascript Apps with the WordPress JSON API – LoopConf 2015
Page 45: Building Javascript Apps with the WordPress JSON API – LoopConf 2015

Jake Spurlock @whyisjake