Git Product home page Git Product logo

sprangular's Introduction

Sprangular

Spree + Angular.js + Bootstrap

Features Overview

  • Full Spree front-end
  • Single page checkout
  • 1-click checkout
  • Product listing with infinite scroll
  • Product search with auto-complete
  • Easy to override templates/controllers
  • Easy to add new routes/controllers/templates
  • Full Google Analytics support via Angularytics
  • Variant selection by option type
  • Cart dropdown/popover
  • Lookup shipping & tax by zip code (Planned)
  • Newsletter signup form (optional) via spree_chimpy
  • Example rails app DynamoMTL/sprangular-demo

Installing

Create a rails project

rails new <your-app-name>
cd <you-app-name>

Add spree, sprangular and rails-assets source in your Gemfile. (notice we dont use the spree umbrella gem, because it contains the generic spree_frontend)

source 'https://rails-assets.org'

gem 'spree_core', '~> 2.3.4'
gem 'spree_api', '~> 2.3.4'
gem 'spree_backend', '~> 2.3.4'
gem 'spree_sample', '~> 2.3.4'
gem 'sprangular', github: 'DynamoMTL/sprangular'

Run bundler

bundle

Then install spree into your app

spree install --auto-accept

Then install sprangular:

rails generate sprangular:install

The admin is now accessible at http://localhost:3000/spree/admin

Events

The following events are emitted

  • cart.add
  • cart.empty
  • account.login
  • account.logout
  • loading.start
  • loading.end
# show modal when item added to cart
$scope.$on 'cart.add', ->
  $scope.showModal = true

Caching templates

By default templates are fetched on-demand. Templates in app/assets/templates/layout are pre-generated and cached in the layout for increased speed. You can add additional templates to be pre-cached, by setting config.cached_paths. Example:

# config/initializers/sprangular.rb
Sprangular::Engine.config.cached_paths += %w(products)

Overriding

Views

Copy the template to your app/assets/templates directory. The host app's version always takes presidence.

Controllers/Resources

Create a app/assets/javascripts/sprangular/controllers or resources directory, and copy the gem version of the script. The host app's version always takes presidence.

Adding

Routes

Edit your app/assets/javascripts/sprangular/extraRoutes.coffee and add the route. For example:

Sprangular.config ($routeProvider) ->

  $routeProvider
    .when '/about',
      template: '<h1>#1 Internet Site</h1>'

Existing Stores

Sprangular configures Rack::Rewrite to provide a 301 redirect for your existing URLs. URLs like /products become /#!/products

Development

This gem contains a dummy spree app in the spec/dummy folder. You can use that to test out changes when modifying this gem. Just bootstrap the database and start the server:

cd spec/dummy
rake db:reset AUTO_ACCEPT=1 && rake spree_sample:load
rails server

License

MIT

sprangular's People

Contributors

joshnuss avatar bryanmtl avatar rposborne avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.