+ All Categories
Home > Technology > Web Apps for the Masses

Web Apps for the Masses

Date post: 13-Jan-2015
Category:
Upload: david-tufts
View: 1,910 times
Download: 0 times
Share this document with a friend
Description:
Using WordPress to develop Web Apps, and adding an API to WordPress
Popular Tags:
31
Web Apps for the Masses @davidscotttufts davidscotttufts.com Photo by razorray15
Transcript
Page 1: Web Apps for the Masses

Web Apps for the Masses

@davidscotttufts

davidscotttufts.com

Photo by razorray15

Page 2: Web Apps for the Masses

About Me • Born and raised in Brazil

• Live in Grand Rapids, Michigan

• 1 beautiful wife

• 6 great kids (5 boys and 1 girl)

• Co-founder at Rocketwood

• Web Producer at RBC Ministries

• Developing KickPress, a WordPress plugin

Page 3: Web Apps for the Masses

The Sweet Smell of Success

Graph by Francesco Schwarz

In under 2 years with WordPress on odb.org

• From 2.1 million to 5 million page views per month

• From 0 to 140,000 subscribers to daily email

• From 0 to 100,000 mobile app sales

• From 0 to 90,000 Facebook fans

• Web donations increased 50%+

• 40% less hardware

• 30% savings

Page 4: Web Apps for the Masses

We are the 15.7%

Photo by Tim Wilson

Page 5: Web Apps for the Masses

WordPress Evolution

1. Blog 2. Multi-User 3. Custom Post Types 4. CMS 5. What’s next?

Illustration by Rob Green

Page 6: Web Apps for the Masses

Popular Web Apps

Page 7: Web Apps for the Masses

Features of Web Apps

Offer a service

Safe-keeping of your personal data

Access to your personal data through an API

Roles and permissions for controlled and/or restricted access

Page 8: Web Apps for the Masses

They own you r data!

Photo by Rob Young

Page 9: Web Apps for the Masses

WordPress Web Apps

Page 10: Web Apps for the Masses

With no API, users are limited in how the can access their data

Illustration by Eric Tufts

Page 11: Web Apps for the Masses

Separating content from presentation

Illustration by Eric Tufts

Page 12: Web Apps for the Masses

Illustration by Eric Tufts

Page 13: Web Apps for the Masses
Page 14: Web Apps for the Masses

Photo by Sarah Fleming

No WordPress core files or database tables were harmed in the production of this plugin

Page 15: Web Apps for the Masses

Custom Post Types

KickPress allows for easy Custom Post Type management

• Create new post types

• Assign Roles and Capabilities per post type

• Manage custom workflows

• Extend post types with modules

Photo by Brad Coy

Page 16: Web Apps for the Masses

Advanced custom post type management

Page 17: Web Apps for the Masses

Advanced roles and capabilities for managing user permissions

Page 18: Web Apps for the Masses

3 kinds of API requests to the server

1. // Request for a full page from the theme

kickpress_is_fullpage();

2. // Request for a page fragment via Ajax

kickpress_is_ajax();

3. // Remote API request or action

kickpress_is_remote_api();

Page 19: Web Apps for the Masses

1. Full Page Requests

Page 20: Web Apps for the Masses

Triggering the KickPress API

{site}.com/how-to/ {Archive page for custom post type called “How To”}

{site}.com/how-to/api/add/

{site}.com/how-to/api/save/

{site}.com/how-to/using-powerpoint/api/edit/

More Examples:

{site}.com/2012/02/18/wordcamp/api/edit/

{site}.com/2012/02/18/wordcamp/api/save/

{site}.com/2012/02/18/wordcamp/api/delete/

{site}.com/2012/02/18/wordcamp/api/bookmark/

{site}.com/2012/02/18/wordcamp/api/add_term[category]/featured/

API Parameters are appended to the end of the standard WordPress permalinks:

Page 21: Web Apps for the Masses

2. Ajax Requests

Page 22: Web Apps for the Masses

Theme Modifications Add an extra conditional comment to the top of these theme files:

header.php footer.php sidebar.php

<?php

if ( kickpress_is_ajax() ) { return; }

?>

Page 23: Web Apps for the Masses

Theme Modifications Add a conditional blocks for any code that should be ignored on AJAX requests:

<?php get_header(); ?>

<?php if ( kickpress_is_fullpage() ) : ?>

<div id="content-wrapper">

<?php endif; ?>

<?php $post_type = get_post_type(); ?>

<?php get_template_part( 'loop', $post_type ); ?>

<?php $args = array( 'post_type', $post_type );

<?php kickpress_ajax_reload( $args, 'content-wrapper‘ ); ?>

<?php kickpress_is_fullpage( '</div>‘ ); ?>

<?php get_sidebar(); ?>

<?php get_footer(); ?>

Page 24: Web Apps for the Masses

3. Remote API Requests

Page 25: Web Apps for the Masses

Authentication

Photo by Jon Worth

Every registered user is assigned a “token” and a “secret” to be used in generating signatures for making ReSTful OAuth style API calls to the Web App.

Page 26: Web Apps for the Masses

Authentication credentials are available on the user’s profile page

Page 27: Web Apps for the Masses

$token = '{token-from-profile-page}';

$secret = '{secret-from-profile-page}';

$timestamp = time();

$method = 'GET';

$host = 'www.{your domain}.com';

// Create the string to sign

$string_to_sign = $method . "\n" . $host . "\n" . $timestamp . "\n";

// Calculate signature with SHA1 and base64-encoding

$signature = base64_encode(

hash_hmac( 'sha1', $string_to_sign, $secret, true )

);

$authentication_params = array(

'signature' => $signature,

'timestamp' => $timestamp,

'token' => $token

);

// Normalize the query string parameters

$query_parts = normalized_query_parameters( $authentication_params );

$query_string = implode('&', $query_parts);

// Build the URL for the remote API request

$url = 'http://' . $host . '/{post type}/api/{action}/?' . $query_string;

For more information: http://kickpress.org/documentation/api-authentication/

Page 28: Web Apps for the Masses

API Serialized Response { "status":"success", "messages":{ "note":"Term Added" }, "data":{ "terms":[{ "term_id":"7", "name":"Featured", "slug":"featured", "taxonomy":"category", "count":"26" }] } }

Page 30: Web Apps for the Masses

Use KickPress to Build your next Web App in

WordPress


Recommended