Giter Club home page Giter Club logo

spree_easy_homepage's Introduction

Spree Easy Homepage

This is a complete open source Spree extension for easily managing your homepage products. The current default operation for managing your homepage is cumbersome and time consuming for what is suppose to be a simple operation. Spree also does not include related frontend helpers which would require effort from the programmer to create and maintain.

Spree Easy Homepage Demonstration

Spree Easy Homepage provides a beautiful and intuitive interface for populating and categorizing products without compromising ease of use. Developers would be delighted to know that setup is as simple as calling a single method from the view.

Getting Started

Add this extension to your Gemfile with this line:
gem 'spree_easy_homepage'
Install the gem
bundle install
Run the install generators from your console
rails g spree_easy_homepage:install

Frontend Setup

To populate your homepage with products

Expose this gem's frontend helper in your controller, eg:

class ApplicationController < ActionController::Base
  helper Spree::EasyHomepageHelper
end

Then from your view, add the helper method fill_with_sections eg:

<div class="row">
  <%= fill_with_sections %>
</div>

Admins can manage their Homepage by navigating to the configurations tab from the Admin sidebar.

Thats it!

fill_with_sections defaults to use the product "tile" partial in app/views/spree/products/_product.html.erb. If none are found in your project folder, the call is delegated to the official "tile" partial used by Spree.

The default product "tile" partial can be optionally overridden by passing locals: {product_partial: '/path/to/tile_partial'} in fill_with_sections arguments. EG:

fill_with_sections(locals: {product_partial: 'spree/shared/product_tile'})

If you want to pass variables to the product "tile" partial, you can use product_locals: {}, similar to the procedure above. EG:

fill_with_sections(locals: {product_locals: {taxon: @taxon, product_tile_size: :small}})

deep inside the helper, between the products loop, the locals passed from the above code is passed to the product "tile" partial:

render partial: 'spree/products/product', locals: {product: product, taxon: @taxon, product_tile_size: :small}

Information

Editing the view generated by fill_with_sections

By default, fill_with_sections renders the _home_sections.html.erb partial located in app/views/spree/shared/. To change the default path.

fill_with_sections(partial: 'spree/shared/custom_home_sections')

or simply create a _home_sections.html.erb partial file in your spree/shared folder.

If you want to edit the HTML elements outputted by fill_with_sections. Investigate the shared/_home_sections.html.erb partial from the gem then override with your edited version in your main project as instructed above.

Testing via Rspec

From the gem's root folder

bundle install

Generate a dummy app via Rspec

bundle exec rake generate_dummy_app

Then call Rspec

rspec

Note: for feature tests, chrome (headless) is selected by default.

Run the install generators from your console
rails g spree_easy_homepage:install

Contributing

This gem has only been released recently. Feedback is appreciated. I have no guidelines for pull-requests other than the basic description and reproduction steps (for bugs). Proper OOP must be followed for feature submissions.

Copyright (c) 2020 Jibril Tapiador, released under the New BSD License.

spree_easy_homepage's People

Contributors

sergei3456 avatar

Watchers

 avatar James Cloos 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.