hacking the mid-end: advanced rails ui techniques

46
Hacking the Mid-End Advanced Rails UI Techniques Michael Bleigh Chris Selmer

Upload: michael-bleigh

Post on 18-May-2015

3.348 views

Category:

Technology


0 download

DESCRIPTION

These were the slides presented by Michael Bleigh and Chris Selmer at RailsConf Europe 2008 in Berlin. For more info including the code used in the livecoding demo, visit http://bit.ly/hacking-the-midend.

TRANSCRIPT

Page 1: Hacking the Mid-End: Advanced Rails UI Techniques

Hacking the Mid-EndAdvanced Rails UI Techniques

Michael BleighChris Selmer

Page 2: Hacking the Mid-End: Advanced Rails UI Techniques
Page 3: Hacking the Mid-End: Advanced Rails UI Techniques
Page 4: Hacking the Mid-End: Advanced Rails UI Techniques

Overview

•Defining the “Mid-End”

•Solving Mid-End Problems

•Examples

Page 5: Hacking the Mid-End: Advanced Rails UI Techniques

What is the Mid-End?

Page 6: Hacking the Mid-End: Advanced Rails UI Techniques

MVC

Page 7: Hacking the Mid-End: Advanced Rails UI Techniques

MVCBack-End

Page 8: Hacking the Mid-End: Advanced Rails UI Techniques

MVCFront-End

Page 9: Hacking the Mid-End: Advanced Rails UI Techniques

MVC+I

Page 10: Hacking the Mid-End: Advanced Rails UI Techniques

MVC+I(I is for Interaction)

Page 11: Hacking the Mid-End: Advanced Rails UI Techniques

BuzzwordBS

Page 12: Hacking the Mid-End: Advanced Rails UI Techniques

But Not Really...

Page 13: Hacking the Mid-End: Advanced Rails UI Techniques

MVC+IMid-End

Page 14: Hacking the Mid-End: Advanced Rails UI Techniques

The Mid-End is all about abstraction.

Page 15: Hacking the Mid-End: Advanced Rails UI Techniques

Front-End

Mid-End

Back-End

Smart Partials XHTML/CSS

Smart Helpers App Structure

Page 16: Hacking the Mid-End: Advanced Rails UI Techniques

Why?Focus on strengths.

Page 17: Hacking the Mid-End: Advanced Rails UI Techniques

Four goals of the mid-end:

•Fast

•Accessible

•Intuitive

•Responsive

Page 18: Hacking the Mid-End: Advanced Rails UI Techniques

Fast

Page 19: Hacking the Mid-End: Advanced Rails UI Techniques
Page 20: Hacking the Mid-End: Advanced Rails UI Techniques

NO LOADING WHATSOEVER

Page 21: Hacking the Mid-End: Advanced Rails UI Techniques

Accessible

Page 22: Hacking the Mid-End: Advanced Rails UI Techniques

UJS is an automatic best practice.

Page 23: Hacking the Mid-End: Advanced Rails UI Techniques

Rails isn’t perfect here.

Page 24: Hacking the Mid-End: Advanced Rails UI Techniques

RESTful Confusion

<a onclick="if (confirm('Are you sure?')) { var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;var m = document.createElement('input'); m.setAttribute('type', 'hidden'); m.setAttribute('name', '_method'); m.setAttribute('value', 'delete'); f.appendChild(m);f.submit(); };return false;" href="/users/bob">Delete</a>

<%= link_to "Delete", user, :method => :delete, :confirm => "Are you sure?" %>

Page 26: Hacking the Mid-End: Advanced Rails UI Techniques

Intuitive

Page 27: Hacking the Mid-End: Advanced Rails UI Techniques

Am I building a web application?

ORAm I building a desktop application on the web?

Page 28: Hacking the Mid-End: Advanced Rails UI Techniques
Page 29: Hacking the Mid-End: Advanced Rails UI Techniques
Page 30: Hacking the Mid-End: Advanced Rails UI Techniques

No Wrong Choice(but web apps are right)

Page 31: Hacking the Mid-End: Advanced Rails UI Techniques

Responsive

Page 32: Hacking the Mid-End: Advanced Rails UI Techniques
Page 33: Hacking the Mid-End: Advanced Rails UI Techniques

Great Job,USERNAME!

Page 34: Hacking the Mid-End: Advanced Rails UI Techniques

Solving Mid-End Problems

Page 35: Hacking the Mid-End: Advanced Rails UI Techniques

The Toolset

•Helpers

•Partials

• jQuery (Prototype works too)

•LowPro

Page 36: Hacking the Mid-End: Advanced Rails UI Techniques

The Approach

•Build it without Javascript

•Abstract UI into helpers and partials

•Add in UJS layer

Page 37: Hacking the Mid-End: Advanced Rails UI Techniques

Example 1:TPS Reports

Page 38: Hacking the Mid-End: Advanced Rails UI Techniques

The Problem

Your online TPS Reports take forever to generate.

Page 39: Hacking the Mid-End: Advanced Rails UI Techniques

The Approach

• Provide a helpful message to users

• Move generation to a new page

• For JS users

• Replace message with spinner

• Fetch page in background

• Display results

Page 40: Hacking the Mid-End: Advanced Rails UI Techniques

Example 2:Dynamic Tabs

Page 41: Hacking the Mid-End: Advanced Rails UI Techniques

The Problem

I want a tabbed informationinterface that is still fast forthose without Javascript.

Page 42: Hacking the Mid-End: Advanced Rails UI Techniques

The Approach

•Create a helper for back-end developers

•Create a template for front-end developers

•Add in Javascript interaction.

Page 43: Hacking the Mid-End: Advanced Rails UI Techniques

Wrap Up

Page 44: Hacking the Mid-End: Advanced Rails UI Techniques

Ruby, Rails, and UJS give you powerful tools for

abstraction.

Page 45: Hacking the Mid-End: Advanced Rails UI Techniques

Make everyone’s life easier, including yours.

Page 46: Hacking the Mid-End: Advanced Rails UI Techniques

Thanks!

http://intridea.com/blog