49
Better Living through Resourceful Plugins Ben Scofield 2 September 2008 RailsConf Europe 1

Resourceful Plugins

Embed Size (px)

Citation preview

Page 1: Resourceful Plugins

Better Living through Resourceful Plugins

Ben Scofield 2 September 2008RailsConf Europe

1

Page 2: Resourceful Plugins

Agenda

2

Page 3: Resourceful Plugins

• What?

• Definition

• Alternatives

• Philosophy

• Examples

• The Tour (live coding!)

Part One

3

Page 4: Resourceful Plugins

• How?

• Process (live coding!)

• Hands-on!

Part Two

4

Page 5: Resourceful Plugins

Definition

5

Page 6: Resourceful Plugins

Pluginsflickr: e2

6

Page 7: Resourceful Plugins

Resourcefulflickr: matko_deo

7

Page 8: Resourceful Plugins

MacGyverflickr: 3epmedia

8

Page 9: Resourceful Plugins

RESTflickr: pejmanphotos

9

Page 10: Resourceful Plugins

Resourcesflickr: hey-helen

10

Page 11: Resourceful Plugins

Modularityflickr: joriel

11

Page 12: Resourceful Plugins

Alternatives

12

Page 13: Resourceful Plugins

Applications13

Page 14: Resourceful Plugins

Enginesflickr: daveseven

14

Page 15: Resourceful Plugins

Gemsflickr: afternoon_sunlight

15

Page 16: Resourceful Plugins

Restful Authentication16

Page 17: Resourceful Plugins

Philosophy

17

Page 18: Resourceful Plugins

Customizableflickr: foshie

18

Page 19: Resourceful Plugins

19

Page 20: Resourceful Plugins

Upgradeableflickr: despotes

20

Page 21: Resourceful Plugins

21

Page 22: Resourceful Plugins

Non-Invasiveflickr: kittenwants

22

Page 23: Resourceful Plugins

23

Page 24: Resourceful Plugins

Future-Proofflickr: jurvetson

24

Page 25: Resourceful Plugins

25

Page 26: Resourceful Plugins

Examples

26

Page 27: Resourceful Plugins

Sandstonehttp://github.com/vigetlabs/sandstone/tree/master

27

Page 29: Resourceful Plugins

The Tour

29

Page 30: Resourceful Plugins

class BlogetGenerator < Rails::Generator::Base def manifest template_dir = File.join(File.dirname(__FILE__), 'templates') record do |m| m.class_collisions "Blog", "Blogger", "Post", "Comment" m.class_collisions "PostsController", "CommentsController"

Dir.chdir(template_dir) do # handle models, controllers, helpers, and views %w(models controllers helpers views).each do |area| m.directory(File.join('app', area)) Dir.glob(File.join(area, '**', '*')).each do |file| m.directory(File.join('app', file)) if File.directory?(file) m.file(file, File.join('app', file)) if File.file?(file) end end # handle tests m.directory('test') Dir.glob(File.join('test', '**', '*')).each do |file| m.directory(file) if File.directory?(file) m.file(file, file) if File.file?(Generator

30

Page 31: Resourceful Plugins

class PostsController < ApplicationController include Bloget::Controllers::PostsController end

Templates31

Page 32: Resourceful Plugins

require File.dirname(__FILE__) + '/../bloget_test_helper'

class PostsControllerTest < ActionController::TestCase tests PostsController

def test_should_show_index_of_posts get :index assert_response :success end

def test_should_be_able_to_get_index_posts_as_Atom_feed get :index, :format => 'atom' assert_response :success end def test_should_show_individual_post post = create_post post.publish! get :show, :id => post.permalink assert_response :success end

Tests32

Page 33: Resourceful Plugins

require 'action_controller'

module Bloget module Controllers module PostsController def self.included(base) base.class_eval do around_filter :load_post, :only => [:show, :edit, :update, : before_filter :login_required, :except => [ :index, :show ] before_filter :authenticate_blogger, :only => [:new, :create before_filter :authenticate_for_post, :only => [:edit, :upda before_filter :check_post_state, :only => [:show]

layout 'bloget' end end

Lib33

Page 34: Resourceful Plugins

namespace :bloget do desc "Installs required and recommended plugins for Bloget." task :install_friends do Dir.chdir(RAILS_ROOT) do puts `ruby script/plugin install http://svn.techno-weenie.net/pro puts `ruby script/plugin install svn://errtheblog.com/svn/plugins puts `ruby script/plugin install http://elitists.textdriven.com/s end end desc "Sets up a Rails app with the recommended infrastructure for Blo task :setup_app => [:load_rails, :install_friends] do Rails::Generator::Scripts::Generate.new.run(['authenticated', 'user Rails::Generator::Scripts::Generate.new.run(['bloget_app']) end desc "Installs Bloget" task :install => :load_rails do Rails::Generator::Scripts::Generate.new.run(['bloget']) end end

Rake34

Page 35: Resourceful Plugins

Live Coding!

35

Page 36: Resourceful Plugins

Break!

36

Page 37: Resourceful Plugins

Process

37

Page 38: Resourceful Plugins

Processflickr: rideyourbike

38

Page 39: Resourceful Plugins

Buildflickr: dumbo

39

Page 40: Resourceful Plugins

Identifyflickr: nickwheeleroz

40

Page 41: Resourceful Plugins

Extractflickr: jensteele

41

Page 42: Resourceful Plugins

Supportflickr: damonabnormal

42

Page 43: Resourceful Plugins

Cleanupflickr: pigpogm

43

Page 44: Resourceful Plugins

Testflickr: cobalt123

44

Page 45: Resourceful Plugins

Live Coding!

45

Page 46: Resourceful Plugins

Break?

46

Page 47: Resourceful Plugins

Hands-On!

47

Page 48: Resourceful Plugins

• User Management

• Invitation Management

• Forums

• Friendships

• Messaging

• ....

Suggestions

48