spree framework overview

36
Spree An open source e-commerce framework for Ruby on Rails ©Beansmile

Upload: martinhong91

Post on 03-Jul-2015

629 views

Category:

Technology


4 download

DESCRIPTION

This is a slide to introduce something about Spree, which is an open source e-commerce framework for Ruby on Rails. Through it, I'll show something Spree allows we to do with it, such as, customize the views, models or controllers.

TRANSCRIPT

Page 1: Spree framework overview

Spree An open source e-commerce framework

for Ruby on Rails

©Beansmile

Page 2: Spree framework overview

Martin

!  From Beansmile

! http://weibo.com/hongzeqin

! [email protected]

Page 3: Spree framework overview

A Spree Demo Site

! http://best-boutique-7789.spree.mx/

Page 4: Spree framework overview

Overview-Homepage

Demo: http://best-boutique-7789.spree.mx/

Page 5: Spree framework overview

Overview-Products List

Page 6: Spree framework overview

Overview-Product Details

Page 7: Spree framework overview

Overview-Cart

Page 8: Spree framework overview

Overview-Admin(Procuts)

Page 9: Spree framework overview

Overview-Configurations

Page 10: Spree framework overview

Business System

Page 11: Spree framework overview

Associations

Page 12: Spree framework overview

Advantages

!  Customization

!  Configurable

!  Extendable

!  Less Prerequisites

Page 13: Spree framework overview

Override views

!   There are two ways to do this:

1.  Using Deface

Deface is a standalone Rails 3 library that enables you to customize Erb templates without needing to directly edit the underlying view file. Deface allows you to use standard CSS3 style selectors to target any element (including Ruby blocks), and perform an action against all the matching elements. Now the official repo is located at spree/deface.

2. Template replacement

Sometimes the customization required to a view are so substantial that using a Deface override seems impractical. Spree also supports the duplication of views within an application or extension that will completely replace the file of the same name in Spree.

Page 14: Spree framework overview

Using Deface-Example

Page 15: Spree framework overview

Using Deface-Example

If you wanted to insert some code just before the #registration div on the page you would define an override as follows:

Note: the :name key is important! 1.  Locate the override; 2.  Disable default overrides from Spree extensions;

Page 16: Spree framework overview

Deface: locate overrides

Page 17: Spree framework overview

Deface: disable overrides

Page 18: Spree framework overview

Override controllers/models

!  Logic customization:

1. Extending Classes

2. Overriding Controller Action Responses

3. Product Images Styles

Page 19: Spree framework overview

Extending Classes

!   Adding a custom method to the Product model: app/models/product_decorator.rb

Page 20: Spree framework overview

Extending Classes

!   Adding a custom action to the ProductsController:

app/controllers/products_controller_decorator.rb

Page 21: Spree framework overview

Magic: decorator

config/application.rb

Page 22: Spree framework overview

Overriding Controller Action Responses ! respond_override

The respond_override method is used to customize the response from any action, and is built on top of Rails 3’s respond_with method.

Page 23: Spree framework overview

Product Images

! Imagemagick

!   Paperclip

!   Image Model

Problems:

styles

Page 24: Spree framework overview

Other Customizations

!   Asset Customization:

Through regular overriding.

!   Checkout Flow:

State machine allows you to hook transitions.

To add or remove steps to the checkout flow, you must re-define the entire checkout flow.

Page 25: Spree framework overview

Plugin/Extension

!   Based on rails engines:

Generators, migrations, configs, rake tasks, etc…

!   Related to Customizations:

Overrides, configurations, etc…

!   Easy codes organizations:

Put your codes independently, easy upgrading, etc…

!   Themes

Page 26: Spree framework overview

Most scenes use extensions

!   Custom Shipping Method

!   Custom Payment Method

!   Custom Promotions

!   Need to extend some functions: Recommendation, Comment, Social, Better Showing, etc…

Page 27: Spree framework overview

Other functions

!   I18n

!   Mailers

!   Analytics

!   Etc…

Page 28: Spree framework overview

Some Shortages

!   Images:

Styles, configurations…

!   Checkout Steps:

Too tedious, synchronous

!   Promotion system:

Hard to use

Page 29: Spree framework overview

They have finished…

!  Removing Support for Ruby 1.8.7

!  Split Core

!  Split Shipments

!  Remove Jirafe Dashboard

Page 30: Spree framework overview

They have finished…

!   Model translations(Awesome!)

Based on the gem: globalize3(https://github.com/svenfuchs/globalize3)

!   Support Rails 4.0(finished on SEPTEMBER 16, 2013)

!   More friendly users and developers documents

Page 31: Spree framework overview

They are doing…

!  Fast Checkout with Backbone. Marionette

!  Optimize the promotion system

!  Others…

Let’s expect more amazing functions!

Page 32: Spree framework overview

Our works…

Page 33: Spree framework overview

Our works…

Page 34: Spree framework overview

Our works…

States and cities in China(Cascade)

One-page check out flow

Page 35: Spree framework overview

Learning Spree

!   Calculators

!   How to implement decorator?

!   State machines

!   Generators

!   Etc…

Page 36: Spree framework overview

End & Thanks

!   Spree Documents:

http://spreecommerce.com/developers/overview

!   Spree Blog:

http://spreecommerce.com/blog