d.mix: Programming by a Sample

49
stanford hci group http://hci.stanford.edu UIST · 10 October 2007 Programming by a Sample: Rapidly Creating Web Applications with d.mix Björn Hartmann, Leslie Wu Kevin Collins, Scott R. Klemmer

description

UIST 2007 presentationBjoern HartmannLeslie WuScott KlemmerStanford HCI

Transcript of d.mix: Programming by a Sample

Page 1: d.mix: Programming by a Sample

stanford hci group

http://hci.stanford.eduUIST · 10 October 2007

Programming by a Sample: Rapidly Creating Web Applications with d.mix

Björn Hartmann, Leslie WuKevin Collins, Scott R. Klemmer

Page 2: d.mix: Programming by a Sample

2

How would you share UIST highlights with colleagues back home?

Page 3: d.mix: Programming by a Sample

3

How would you retrieve the same data programmatically?

It’s easy to understand the sites, but not the services.

Page 4: d.mix: Programming by a Sample

4

Page 5: d.mix: Programming by a Sample

5

Web sites and their APIs are correlated…

[flickr.com]

…let’s leverage that fact!

Page 6: d.mix: Programming by a Sample

6

Give me the code for this!

Page 7: d.mix: Programming by a Sample

7

To retrieve this image, use:flickr.photos.getInfo(

user_id = '73866493@N00', photo_id= ‘3208312’)

Page 8: d.mix: Programming by a Sample

8

d.mix active wikiSource code generated by d.mix

Rendered Page

is executed in the active wiki

Page 9: d.mix: Programming by a Sample

9

Scenario

Page 10: d.mix: Programming by a Sample

10

Page 11: d.mix: Programming by a Sample

11

Page 12: d.mix: Programming by a Sample

12

Page 13: d.mix: Programming by a Sample

13

d.mix users

Lead Users Web Developers End Users

Site owners or lead users define mappings between sites and services (once).

Page 14: d.mix: Programming by a Sample

14

Lead Users Web Developers End Users

Web developers create d.mix applications

Page 15: d.mix: Programming by a Sample

15

Lead Users Web Developers End Users

End-users run (and tailor) applicationsin the d.mix wiki.

Page 16: d.mix: Programming by a Sample

16

d.mix Proxy Architecture

Original PageRewritten page with API annotationsProxy Server

Site-to-Service Map(hosted on d.mix wiki)

Page 17: d.mix: Programming by a Sample

17

Authoring the Site-to-Service Map…Without Help From the Site Owner

1 Map URL to Page Type2 Identify visual elements in page to

annotate (using XPath/CSS selectors)

3 Extract arguments for service calls from page source

4 Bind arguments to web service code snippet

Page 18: d.mix: Programming by a Sample

18

Why Not Just Scrape?

• Scraping at design-time rather than at run-time minimizes brittleness

• Web service calls can be parameterized

• Scraping at run-time can lead to lock-out

Page 19: d.mix: Programming by a Sample

19

Page 20: d.mix: Programming by a Sample

20

Page URL:flickr.com/photos/<username>/<photoid>/…

Regular Expression:%r{flickr.com//?photos/ [^/]+/\d+/?&script}

Page 21: d.mix: Programming by a Sample

21

Photo Title

Image URL

Tag Search

Page 22: d.mix: Programming by a Sample

22

Photo Title

Image URL

Tag Search

(doc/"#title_div")

(doc/"div.photoImgDiv")

(doc/"div.TagList")

Page 23: d.mix: Programming by a Sample

23

flickr.photos.getInfo( photo_id = “298655528”).title

info = flickr.photos.getInfo( photo_id = “298655528”)URL = “http://farm”+ info.farm-id + “.static.flickr.com/” + info.server-id + “/” + info.attributes[”id”] + “_” + info.secret + “.jpg”

flickr.photos.search( tags = “yosemite ...”)

Extracted from page source:Within <div> for all tags:

tag=div.at("a.Plain").inner_html

Page 24: d.mix: Programming by a Sample

24

Putting it all together…

def self.annotate_photopage_tags(doc)(doc/"div").reject{…}.each do |div|

tag = div.at("a.Plain").inner_htmlsrc = generate_tag_search_source (...)doc.at("body").inner_html +=

make_context_menu(div.at("a.Plain"),["Images matching tag #{tag}"],[src])

end

Page 25: d.mix: Programming by a Sample

25

Putting it all together…

Extract tag namedef self.annotate_photopage_tags(doc)(doc/"div").reject{…}.each do |div|

tag = div.at("a.Plain").inner_htmlsrc = generate_tag_search_source (...)doc.at("body").inner_html +=

make_context_menu(div.at("a.Plain"),["Images matching tag #{tag}"],[src])

end

Page 26: d.mix: Programming by a Sample

26

def self.annotate_photopage_tags(doc)(doc/"div").reject{…}.each do |div|

tag = div.at("a.Plain").inner_htmlsrc = generate_tag_search_source (...)doc.at("body").inner_html +=

make_context_menu(div.at("a.Plain"),["Images matching tag #{tag}"],[src])

end

Putting it all together…

Instantiate Source Example

Page 27: d.mix: Programming by a Sample

27

Putting it all together…

Add annotation to original page

def self.annotate_photopage_tags(doc)(doc/"div").reject{…}.each do |div|

tag = div.at("a.Plain").inner_htmlsrc = generate_tag_search_source (...)doc.at("body").inner_html +=

make_context_menu(div.at("a.Plain"),["Images matching tag #{tag}"],[src])

end

Page 28: d.mix: Programming by a Sample

28

Dataflow Summary

d.mix run time

d.mix design time

invokes

Web service

sends

code to

Web site

addsannotation

Page 29: d.mix: Programming by a Sample

29

Active Wiki• Wiki editor provides

syntax-highlighting for Ruby script

• Sandboxed execution runs script with limited capabilities

• Libraries facilitate invoking web services and manipulating results

Page 30: d.mix: Programming by a Sample

30

Beyond the Desktop Browser

Page 31: d.mix: Programming by a Sample

31

What we borrowed and what we wrote

Front end•Yahoo! UI (annotation UI)•JQuery (selectors)•Bookmarklet•UI logic

Back end•MouseHole (proxy)•Tepee (wiki)•Freakyfreakysandbox (safe execution)•Hpricot (selectors)•Annotation code•Site-to-service map•API wrappers•d.mix library

Page 32: d.mix: Programming by a Sample

32

Prototype Site-to-Service LibraryAPI Supported Actions Site-to-

Service map code size

• Get images from a user’s photo stream, with or without meta data• Get images from an image set• Get images from individual photo pages• Get images matching tags, global or per user, from tag clouds and photo pages• Get images by global image id• Get images from full-text search

355 lines

• Single web search result• Web search result set

54 lines• Retrieve a user’s videos• Retrieve most recent videos• Single search result• Search result set

115 lines

Page 33: d.mix: Programming by a Sample

33

First-use Lab Study (n=8)

• All participants had some programming experience, knew HTML

• Four had no experience with web APIs

• 75 minute sessions:Demonstration, warm-up, two design tasks

Page 34: d.mix: Programming by a Sample

34

Total lines of code

54

Written by participant

13

Generated by d.mix

41

Generated lines modified by participant

4

Page 35: d.mix: Programming by a Sample

35

Page 36: d.mix: Programming by a Sample

36

Lessons LearnedHow do I know what I can

sample?

?

Page 37: d.mix: Programming by a Sample

37

Lessons LearnedHow do I know what I can

sample?

Page 38: d.mix: Programming by a Sample

38

Sample from link to content

Sample content directly

Lessons LearnedOffer multiple ways to sample

information.

Page 39: d.mix: Programming by a Sample

39

LimitationsProxying the logged-in web is

challenging

Page 40: d.mix: Programming by a Sample

40

LimitationsProxying the logged-in web is

challenging

Page 41: d.mix: Programming by a Sample

41

LimitationsHow can one sample APIs that

provide interactive widgets intead of data?

Page 42: d.mix: Programming by a Sample

42

Related Work

Greasemonkey

Chickenfoot [Bolin, UIST2005]

Koala [Little, CHI2007]

Yahoo! Pipes

Open Kapow

Marmite [Wong, CHI2007]

IBM QEDWiki

Intel MashMaker [Ennals, SIGMOD2007]

Relations, Cards, and Search Templates [Dontcheva, UIST2007]

Citrine [Stylos, UIST2004]

WinCuts[Tan, CHI2004]

Clip, connect, clone[Fujima, UIST2004]

Hunter Gatherer[schraefel, WWW2002]

Facades[Stuerzlinger, UIST2006]

End-user Page Modification &Automation

End-user PAGECreation

Deep Copy & paste

Mica[Stylos, VL/HCC2006]

Assieme[Hoffmann, UIST2007]

Finding APIExamples

Page 43: d.mix: Programming by a Sample

43

Greasemonkey

Chickenfoot [Bolin, UIST2005]

Koala [Little, CHI2007]

End-user Page Modification &Automation

Page 44: d.mix: Programming by a Sample

44

Yahoo! Pipes

Open Kapow

Marmite [Wong, CHI2007]

IBM QEDWiki

Intel MashMaker [Ennals, SIGMOD2007]

Relations, Cards, and

Search Templates [Dontcheva, UIST2007]

End-user AuTHORING TOOLS

Page 45: d.mix: Programming by a Sample

45

Assieme[Hoffmann, UIST2007]

Mica[Stylos, VL/HCC2006]

API SEARCHTOOLS

Page 46: d.mix: Programming by a Sample

46

Contributions

• Search for programming examples in the solution domain, not the code domain.

• d.mix instantiates this idea for web service APIs through a site-to-service map.

• Integration of page annotation and script hosting enables rapid experimentation.

Page 47: d.mix: Programming by a Sample

47

Current WorkRe:MixReformatting existing web applications formobile device use

JuxtaposeExploring designalternatives inparallel

Page 48: d.mix: Programming by a Sample

48

AcknowledgmentsFunding

NSF grant IIS-0534662SAP Stanford Graduate Fellowship

Microsoft New Faculty FellowshipIntel (equipment donation)

Help Wendy Ju, Leith Abdulla, Michel

Krieger,whytheluckystiff

Imagesmorguefile.com

Page 49: d.mix: Programming by a Sample

stanford hci group

hci.stanford.edu/dmix