JSON all the way
Javascript in the humanitarian world
Slide 2
Slide 2 text
Who the hell..?
我们是谁
Ronan Berder
খ۽
Makara Wang
ԦߒӉ
Wiredcraft
http://wiredcraft.com
Slide 3
Slide 3 text
And what do you do?
我们做什么
• Data centric apps
• Humanitarian and non-profit space
• In Shanghai and Washington, DC
(and soon SF)
Slide 4
Slide 4 text
Before we get started
引言
Slide 5
Slide 5 text
What’s Reliefweb?
Reliefweb是什么
• Re-launched in 2011
• News for the humanitarian world
• Built on Drupal... I know
(PHP + MySQL + Sphinx)
Slide 6
Slide 6 text
http://reliefweb.int
Slide 7
Slide 7 text
What then?
客户需求
• Need to innovate
• Built a prototype and pitched it:
User profiles + Mobile
Slide 8
Slide 8 text
The breakup
失败
Slide 9
Slide 9 text
What happened?
为什么
• Fighting the framework
• Performance concerns
• Way too many layers
Slide 10
Slide 10 text
Slide 11
Slide 11 text
Back to the whiteboard
更高要求
• We need consistency
• We need simplicity
• We need flexibility
• We need speed
And about a million other things...
Slide 12
Slide 12 text
So, what do we build?
目标
Slide 13
Slide 13 text
http://humanitarianid.org
Slide 14
Slide 14 text
Who will save us?
救星来了
Slide 15
Slide 15 text
Why JS?
• Great for a RESTful API
• Great too for a light client
• Other perks; performance, tools...
And... we already know it.
Slide 16
Slide 16 text
The back-end
服务端
Slide 17
Slide 17 text
Bones for the API
什么是 Bones
• RESTful JSON + OAuth
• Bones = express.js + backbone.js
https://github.com/developmentseed/bones
• Share models on client and server
Slide 18
Slide 18 text
Show me the code
Slide 19
Slide 19 text
And then some more...
更多规范
• JSON Schema
• OAuth
• REST
Slide 20
Slide 20 text
The front-end
客户端
Slide 21
Slide 21 text
Using what we know
最流行的
• HTML5 + jQuery mobile + Backbone.js
• Phonegap
• and... Jekyll
Slide 22
Slide 22 text
Why Jekyll?
• HTML5 apps can get messy
• Jekyll gives us templates & includes
And we’ll be able to host it on Github pages...
Slide 23
Slide 23 text
Show me the code
Slide 24
Slide 24 text
A tiny bit about storage
存储方案
Slide 25
Slide 25 text
Elastic search
• Started with CouchDB
• Now Elastic Search & Redis, because:
• Full text search,
• Document oriented,
• REST API,
Slower, but we don’t care.
Slide 26
Slide 26 text
Show me the code
Slide 27
Slide 27 text
A few thoughts
少少结论
Slide 28
Slide 28 text
Why so serious?
不好的
• Not a lot of best practices
but we’re trying hard to build some
• Some stuff still sucks
jQuery mobile, I’m looking at you
Slide 29
Slide 29 text
The good stuff
好的
• JSON all the way
• Javascript all the way
And performance, tools, community...
Slide 30
Slide 30 text
Slide 31
Slide 31 text
What we see
我们看到的未来
• The line is getting blurry:
• more fragmentation...
• but more communication
• Loosely coupled systems