Spree Extension for easily managing your Homepage products.

Last updated on: September 09 at 09:51 PM

source code bug tracker
5 5 2
owner:  NuclearMachine

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

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

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

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}


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


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

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


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.

compatible spree versions
tags spree versions
master >= 3.2.0, < 5.0
Jibril Tapiador