Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

64
here it .is

description

Talk given at Five Pound App at The Skiff in Brighton on the 15th July 2009:http://fivepoundapp.com/meetup/18/

Transcript of Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

Page 1: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

here it .is↜

Page 2: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

1. hereit.is

2. Architecture

3. REST

4. CSS3

Page 3: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3
Page 4: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

http://www.somehugeenormousurl.com/3fa3sdfasdca/tags/urls/test.php?

foo=2385158124&bar=acewcjlasjilejfalisj

Page 5: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

http://tr.im/qXkQ

Page 6: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

short url → long url → thing

Page 7: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3
Page 8: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

short url → thing

Page 9: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

http://twitpic.com/9arhr

Page 10: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3
Page 11: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

http://maps.google.co.uk/maps?q=brighton&ie=UTF8&ll=50.81971,-0.136642&spn=0.095002,0.116558&z=13&iwloc=A

Page 12: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

http://hereit.is/brighton

Page 13: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

short url → thing

http://hereit.is/brighton →

Latitude: 50.819716Longitude: -0.136572Zoom: 12Bubble text: Brighton

Page 14: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3
Page 15: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

Demo

Page 16: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

Architecture

Page 17: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

index.htmlabout.htmlcontact.htmlunicorns.html

Page 18: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

GET unicorns.html

Page 19: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

<html><head><title>Unicorns</title></head><body><h1>Unicorns!</h1></body></html>

Page 20: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

index.phpabout.phpcontact.phpelephants.php

Page 21: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

GET elephants.php

Page 22: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3
Page 23: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

<html><head><title>Elephants</title></head><body><h1>Elephants for Bob!</h1></body></html>

Page 24: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

index.phpabout.phpcontact.phpelephants.php

Page 25: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

index.phpabout.phpcontact.phpanimals.phpantelopes/

antelopesarespringy.phphorns.php

aardvarks/adoptanaardvark.phptheyhavebignoses.php

lions/manes.phpteeth.phplionking/

disney.phpelephants/

index.phpmyelephants.phpsomeotherelephants.php

unicorns/unicornsareforhtmllosers.php

hyenas/hahaha.php

zebras/stripey.phphorses/

lessstripey.php

Page 26: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

Sad panda.

Page 27: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

Request

App

Page 28: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

Response

App

Page 29: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

Web application architectureor

how to rip off Django.

App

Page 30: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

..but why didn’t you just use Django?

Page 31: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

erm, good question.

Page 32: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

MVCModel, view, controller

Page 33: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

MVCModel, view, controller

Model, template, view(and one controller, sort of)

Page 34: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

Front controller

Page 35: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

Front controller‣ Figures out what to do with your

request (routing).

‣ url → view

Page 36: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

Front controller

View ViewView

Page 37: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

ViewsDjango:

[A view] “describes the data that gets presented to the user. It’s not necessarily how the data looks, but which data is presented.”

Page 38: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

ViewsDjango:

“A view is simply a Python function that takes a Web request and returns a Web response.”

Page 39: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

Viewshereit.is:

“A view is simply a PHP object that has a render() method that takes a Web request and returns a Web response.”

Page 40: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

Front controller

View

Models

Page 41: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

Models

‣ “representation of the data on which

the application operates.”

Page 42: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

Models

‣ hereit.is has one model - the placemark, a representation of a location.

‣ Slug (url), latitude, longitude, zoom, bubble text.

Page 43: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

Front controller

View

Models Template+

Page 44: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

Templates

‣ How information is presented to the user. HTML with holes poked in it.

‣ Django has a lovely templating system.‣ hereit.is doesn’t (just PHP includes).

Page 45: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

Front controller

+

View

Models Template +

View

Models Template

View

Models Template+

Request

Page 46: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

Front controller

View

Models Template+

Response

Page 47: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

REST

Page 48: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

Web services allow computers to talk to each other

BEEP, E-Business XML, Hessian, JSON-RPC,

Qworum, SOAP, UDDI, WSDL, WSFL, BPEL, WSCL,

XINS, XLANG, XML-RPC, OMG WTF BBQ.

Page 49: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

REST

‣ Representational State Transfer.‣ Nice and simple.‣ “The World Wide Web is the key

example of RESTful design.”

Page 50: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

Resources

‣ The “things” (nouns) that are important to your application.

‣ Have unique urls.‣ Often (but not always) map to

database tables/models.‣ Interact using HTTP methods: GET,

POST, PUT, DELETE (verbs).

Page 51: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

Representations

‣ How the resource is described.‣ HTML is a representation.‣ Other representations may be easier for

machines to understand.

Page 52: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

hereit.is

‣ Designed around a RESTful architecture.

‣ One type of resource - the placemark.‣ Responds correctly to GET, POST,

HEAD, OPTIONS‣ Needs more work.

Page 53: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

GET http://hereit.is/brighton<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

<title>hereit.is - short urls for geographical locations</title>

<meta http-equiv="content-type" content="text/html; charset=utf-8" />

<!-- Stylesheets --><link rel="stylesheet" href="/css/main.css" type="text/css" media="all" />

<!-- Map display scripts --><script type="text/javascript" src="http://www.google.com/jsapi?key=ABQIAAAAcdB-etWpkJ7tBx3xRD6e5hRHLF8DnXNo3WfrkRC1RUZDQQmuaxR0xYg16J7sqocLaYWbfludrEpQiw"></script>

<script type="text/javascript">var placemark = {"slug":"brighton","latitude":"50.819716","longitude":"-0.136572","zoom":"12","bubble":"Brighton"}</script>

<script type="text/javascript" src="js/util.js"></script><script type="text/javascript" src="js/display_map.js"></script>

</head><body>

<h1>here it .is</h1> <h2>Names for Places.</h2>

<div id="beta_badge">beta</div>

<noscript><div class="error_message"><h3>Sorry!</h3><p>Your browser doesn't seem to support JavaScript, or JavaScript is turned off. You really need JavaScript to use hereit.is.</p></div></noscript>

<div id="map"></div>

<p class="gmaps_link"><a href="http://maps.google.com/?q=50.819716,-0.136572&amp;z=12" title="View on Google Maps">Visit this location on Google Maps</a></p>

<!-- Google Analytics --><script type="text/javascript">var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));</script><script type="text/javascript">try {var pageTracker = _gat._getTracker("UA-8869088-1");pageTracker._trackPageview();} catch(err) {}</script>

<p id="credits">a <a href="http://bombcircle.net" title="bombcircle">bombcircle</a> production</p>

</body> </html>

Page 54: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

GET http://hereit.is/brighton.json{ "type":"FeatureCollection", "features":[ { "type":"Feature", "geometry":{ "type":"Point", "coordinates":[ -0.136572, 50.819716 ] }, "properties":{ "id":"1", "description":"Brighton", "zoom":"12" } } ]}

See http://geojson.org/

Page 55: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

GET http://hereit.is/brighton.kml

<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://www.opengis.net/kml/2.2"><Document><Placemark><description>Brighton</description><Point><coordinates>-0.136572,50.819716

</coordinates></Point>

</Placemark></Document>

</kml>

See http://code.google.com/apis/kml/documentation/

Page 56: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

Demo

Page 57: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

CSS3

Page 58: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

Logo

Curved corners

Shadows

Page 59: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

Logo

Curved corners

Shadows

100% image-free

Page 60: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

Logo

Curved corners

Shadows

(except this bit, of course)

100% image-free

Page 61: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

h1::before {content: "\219C";

}

div#map {-webkit-box-shadow: 5px 5px 10px #888;-moz-box-shadow: 5px 5px 10px #888;

}

div#content {-webkit-border-radius: 20px;-moz-border-radius: 20px;

}

Page 62: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

Graceful DegradationAKA “it doesn’t look completely shit in IE.”

Page 63: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

Roadmap

‣ iPhone (native or HTML5 geolocation)?‣ Admin?‣ Richer landing pages?‣ More complete API?‣ ... any suggestions?

Page 64: Five Pound App talk: hereit.is, Web app architecture, REST, CSS3

FIN.http://j4mie.org

http://www.flickr.com/photos/wvs/2709609640/http://www.flickr.com/photos/brajeshwar/214854623/http://www.flickr.com/photos/oskay/265899766/http://www.flickr.com/photos/jacquedavis/2866832088/http://www.flickr.com/photos/j4mie/488151124/http://www.flickr.com/photos/j4mie/3560406460/http://www.flickr.com/photos/j4mie/3559584815/