data api + aws = (cms どうでしょう 札幌編)

40
Data API 2.0 + AWS = Jan 17, 2015 CMS どうでしょう - MT/WP 対決列島 札幌編 - たかやま@Six Apart

Upload: yuji-takayama

Post on 14-Jul-2015

1.210 views

Category:

Engineering


5 download

TRANSCRIPT

Data API 2.0 + AWS =

Jan 17, 2015 CMS どうでしょう - MT/WP 対決列島 札幌編 -

たかやま@Six Apart

YUJI TAKAYAMASix Apart, Ltd.

Senior Product Manager Movable Type Lead Engineer

Twitter: @yuji Facebook: Yuji Takayama

Github: yuji Mail: [email protected]

My Social

icon

Today’s Agenda

Movable Type Overview Movable Type 知ってますか?

Movable Type Data API Overview Movable Type Data API とはなんでしょう?

Why Movable Type offers API? なぜ、Movable Type は API を提供しているのでしょう?

Introduce Data API v2.0 Movable Type Data API v2.0 を紹介

Movable Type for AWS + Data API Data API を Movable Type for AWS で使う

What is Movable Type?

2001年 Ver.1.0

2013年 Ver.6.0

Current Ver. 6.0.6

JSON REST API

サーバーインストール型 クラウド型

2015年 サービスイン予定

Data API Overview

Movable Type Data API

REST/JSON API for every websites and applications

Released with Movable Type 6.0 on Oct 17, 2013

Data API Features

REST / JSON API 特殊な処理を必要としない URL ベースの呼び出しと、結果は扱いやすい JSON 形式をサポート

MT Authentication and Role based permission Movable Type が提供するロールベースのユーザー管理機能を利用した認証機能を提供

Pluggable / Extensible Movable Type らしく拡張性も重視。プラグイン (Perl) によるエンドポイントの拡張、

コールバックを利用したフィルター処理、JSON 以外の出力形式を追加することも

JavaScript library available JavaScript 用の開発ライブラリを標準提供。ブラウザの差異も吸収

Data API Case 1 - COACH UNITED

• トップページの記事一覧を Data API で

無限スクロール

• ページ遷移が必要ない

• 【利用者目線】気になる記事を探し

やすく

• 【制作者目線】ページ分割のための

再構築が不要 = 負荷が低減

http://coachunited.jp/

Data API Case 2 - ワンダードライビング

• エンドポイントを独自拡張

• Google Analytics と連携し、アクセス

数の多い記事をランキング表示

• 記事のサムネイルを生成

http://wonderdriving.com/

Data API Case 3 - Movable Type Writer

• 記事投稿ツール

• 生きているサンプル

• Movable Type の管理画面を改造せずに、

ユーザーのニーズに併せる

• コンテンツに合わせて投稿画面をカス

タマイズしてしまう

• Google Chrome App

• AngularJS + Bootstrap3

Why Movable Type offers API?

Build web pages

Responsive Web Design

<html>

Content

Templates

The web of Things“The Web of Things (WoT) is a set of software architectural styles and programming patterns that allow real-world objects to be part of the World Wide Web. Similarly to what the Web (Application Layer) is to

the Internet (Network Layer), the Web of Things provides an Application Layer that simplifies the creation of Internet of Things applications.

Rather than re-inventing completely new standards, the Web of Things reuses existing and well-known Web standards used in the programmable Web (e.g, REST, HTTP, JSON), semantic Web (e.g., JSON-LD,

Microdata, etc.), the real-time Web (e.g, Websockets) and the social Web (e.g., oauth or social networks).”

— Wikipedia http://en.wikipedia.org/wiki/Web_of_Things —

Build web pages

Web pages

Mobile Applications

Templates

TV Watch

fridgeCarDigital

Signage

Data API

<html>

Content

Data API

Any Devices

Other Services

Why Movable Type offers API? Because…

The Web of Things PCやスマホだけにとどまらず、広がっていくウェブの世界

Mobile First, Content First モバイル端末での閲覧に最適化。コンテンツを配信することで通信を最適化

Dynamic Site リッチな表現は必要に応じてフロント側で実現

Not Perl Perl 以外の言語でも Movable Type を使える(JS ライブラリ提供)

Introduce Data API 2.0

Data API Ver. 1.0 Endpoints

READ UPDATE DELETE LIST

Entries ◯ ◯ ◯ ◯

Comments ◯ ◯ ◯ ◯

Categories ◯ △

Blog/Websites ◯ ◯

Trackbacks ◯ ◯ ◯ ◯

Users ◯ ◯

Site Statistics ◯

Assets ◯ (Upload)

Data API Ver. 2.0 EndpointsCREATE READ UPDATE DELETE LIST

Entries ◯ ◯ ◯ ◯ ◯Comments ◯ ◯ ◯ ◯ ◯Categories 🔵 ◯ 🔵 🔵 🔵

Blog/Websites 🔵 ◯ 🔵 🔵 ◯Trackbacks ◯ ◯ ◯ ◯

Users 🔵 ◯ ◯ 🔵 🔵

Site Statistics ◯Assets ◯ (Upload) 🔵 🔵 🔵 🔵

Custom Fields 🔵 🔵 🔵 🔵 🔵

Logs 🔵 🔵 🔵 🔵 🔵

Groups / Group Members 🔵 🔵 🔵 🔵 🔵

Pages 🔵 🔵 🔵 🔵 🔵

Roles 🔵 🔵 🔵 🔵 🔵

Folders 🔵 🔵 🔵 🔵 🔵

Templates / Widgets 🔵 🔵 🔵 🔵 🔵

Tags 🔵 🔵 🔵 🔵 🔵

Themes 🔵

Permissions 🔵

Search 🔵

Available Endpoints are 350% up from v1!

Data API v2.0 Features

Create/read/update/delete every objects ほぼすべてのオブジェクトについて、CRUDのエンドポイントをサポート

Restrict Data API access for each site 各サイト単位で Data API のアクセスを禁止することが可能に

Search entries across the each site サイトを横断して記事の検索が可能に

Build index/archive template インデックス・テンプレート、アーカイブテンプレートの再構築を実行可能に

Make a thumbnail for an asset 任意のサイズのサムネイル画像を作成可能に

Data API v2.0 Features

and more…

Online document available (still writing…)

http://docs.movabletypedataapi.apiary.io/

Data API Demo

Mobile Application x Data API x Website

Mobile Applications

Web Browser

Upload via Data API

Rebuild main index via Data API

Available at Data API v1.0 Available at Data API v2.0

Make thumbnail via Data API

http://54.64.74.149/ User: Melody

Password: mel0dynels0n

Show Login Form

$('#login').click( function() { location.href = “http://path/to/mt-data-api.cgi/v2/authorization?redirectUrl=“+ encodeURIComponent( window.location ) + "&clientId=TestApp";});

Upload File

var fd = new FormData($('#form').get(0)); $.ajax({ url: “http://path/to/mt-data-api.cgi/v2/assets/upload", type: "POST", data: fd, processData: false, contentType: false, dataType: 'json', headers: { 'X-MT-Authorization': token } })

Get thumbnail

.done(function( data ) { var url = “http://path/to/mt-data-api.cgi/v2/sites/1/assets/" + data.id + "/thumbnail?width=200&square=1" $.ajax({ url: url, type: "GET", dataType: 'json' }) .done(function( data ) { $('#result').append('<img src="' + data.url + '" width="200">'); }); });

Rebuild main index file

var url = “http://path/to/mt-data-api.cgi/v2/sites/1/templates/35/publish”; $.ajax({ url: url, type: "POST", headers: { 'X-MT-Authorization': t } }) .done(function( data ) { alert('Done!'); });

Template ID of Main Index

Authentication required

Movable Type for AWS

Hourly: $0.07 / h Annual: $499 / y

Movable Type for AWS - System diagram

Movable Type 6.0.6

Amazon Linux 2014.09

starman 0.4009

MySQL 5.5nginx 1.6.2

php-fpm 5.3.29

Perl 5.16.3

Why Movable Type offers API? Because…

All In One Package Movable Type の起動に必要な環境をすべて用意済み

Free Tier Eligible micro インスタンスは、ソフトウェア料が無料

7 days Free Trial どのインスタンスでも、初期起動から7日間はソフトウェア料が無料

yum update movabletype アップデートは yum コマンドで

Data API meets AWS

RDS

MT (API)

EC2

MT (API)

EC2

MT (API)

EC2

ELBELB

MT (CMS)

EC2

MT (CMS)

EC2

Visitors Visitors Visitors Visitors VisitorsAdmin

S3

Static Contents auto scaling

PC / Mobile Device / Machine etc….

Data API 2.0 + AWS = ?

Data API + AWS =

Delightful 作って楽しい、使って楽しい

Useful 便利なインフラ

Scalable サイト・サービスの成長と共に

Movable Type

Thank you for listening

Have fun with Movable Type and Data API !!!