Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Spree Framework Overview

Martin
September 23, 2013

Spree Framework Overview

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.

Martin

September 23, 2013
Tweet

More Decks by Martin

Other Decks in Programming

Transcript

  1. 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.
  2. 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;
  3. Extending Classes !   Adding a custom method to the

    Product model: app/models/product_decorator.rb
  4. Extending Classes !   Adding a custom action to the

    ProductsController: app/controllers/products_controller_decorator.rb
  5. 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.
  6. 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.
  7. 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
  8. Most scenes use extensions !   Custom Shipping Method !

      Custom Payment Method !   Custom Promotions !   Need to extend some functions: Recommendation, Comment, Social, Better Showing, etc…
  9. Some Shortages !   Images: Styles, configurations… !   Checkout

    Steps: Too tedious, synchronous !   Promotion system: Hard to use
  10. They have finished… !  Removing Support for Ruby 1.8.7 !

     Split Core !  Split Shipments !  Remove Jirafe Dashboard
  11. 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
  12. They are doing… !  Fast Checkout with Backbone. Marionette !

     Optimize the promotion system !  Others… Let’s expect more amazing functions!
  13. Learning Spree !   Calculators !   How to implement

    decorator? !   State machines !   Generators !   Etc…