Extension to add theme support to spree.
Last updated on: September 24 at 10:36 AM
source code bug trackerThis extension allows the admin to upload new spree store themes from backend. This extension provides an interface where admin can manage all the themes by editing them, deleting old themes and publishing theme to store for the users.
Admin can even preview the theme after modifying it from the backend before publishing it to the users.
Try Spree Themes for Spree 3-4 with direct deployment on Heroku:
Go to - https://github.com/vinsol-spree-contrib/spree_themes/wiki/Steps-to-Publish-a-Theme
Try Spree Themes with direct deployment on Heroku:
For SPREE 3.2
https://github.com/vinsol-spree-contrib/theme-BigShop/archive/3-2-stable.zip
https://github.com/vinsol-spree-contrib/theme-ClassicWhite/archive/3-2-stable.zip
https://github.com/vinsol-spree-contrib/theme-OnlineStore/archive/3-2-stable.zip
https://github.com/vinsol-spree-contrib/theme-CrownTheme/archive/3-2-stable.zip
https://github.com/vinsol-spree-contrib/theme-LatticeTheme/archive/3-2-stable.zip
https://github.com/vinsol-spree-contrib/theme-Matrix/archive/3-2-stable.zip
https://github.com/vinsol-spree-contrib/theme-Unite/archive/3-2-stable.zip
https://github.com/vinsol-spree-contrib/theme-CrownTheme-2/archive/3-2-stable.zip
This extension currently supports Ruby 2.4.2, Rails 5.1 and Spree 3.4.
Some of the current functionalities are:-
For SPREE 3.4
gem 'vinsol_spree_themes', github: 'vinsol-spree-contrib/spree_themes', branch: 'master'
For SPREE 3.3
gem 'vinsol_spree_themes', github: 'vinsol-spree-contrib/spree_themes', branch: '3-3-stable'
For SPREE 3.2
gem 'vinsol_spree_themes', github: 'vinsol-spree-contrib/spree_themes', branch: '3-2-stable'
Note:- Add this gem at the end of your gemfile as it has some sprocket-rails dependency and needs to be loaded after all gems are loaded.
ruby
gem 'sprockets-helpers', '~> 1.2.1'
Note:- This gem is dependent for the preview feature.
Install the gem using Bundler:
ruby
bundle install
Copy & run migrations
ruby
bundle exec rails g vinsol_spree_themes:install
Restart your server
ruby
rails server
Make sure to set the following config in environment file development.rb
.
config.assets.debug = false
After installing the extension, admin will see a tab vinsol spree themes
on left sidebar of admin panel. Or you can visit the link
http://localhost:3000/admin/themes
Then, admin uploads the new theme in zip file(Download sample themes from the links added below). Once uploaded, admin can preview the theme and also modify it accordingly through the editor.
Theme templates can be modified through the editor. Later theme can be published for the spree store users.
Note:- Before publishing the theme, admin needs to compile it using the link provided with other options for all assets to load properly.
Once the extension is installed, admin gets a spree store default theme uploaded on the system and is published for the store users.
Besides preview and publishing, admin can delete the uploaded theme or download it in zip format.
Some spree store themes can be cloned from the following link:-
After clonning, zip the files of the theme and upload the zip file from the admin interface.
Yay!! new theme is ready to be published.
Theme file structure for the zip file to be uploaded:-
Note:- When uploading, files starting with '__' or '.' will be ignored
Create a meta_info.yml file on the theme directory which contains the meta info of the theme. Format of the file should be following:- * name: Name of the theme * version: Version of the theme * authors: Authors of the theme
Note:- Add new javascript files to javascripts directory and new stylesheet files to stylesheets directory. For adding js and css manifest files, file name should be script.manifest.js or style.manifest.css. If using sass, use style.manifest.scss files instead of .css.
If you wish to modify the theme directly from the filesystem, follow these steps:-
Publish the theme which need to be updated/modified.
Update the theme assets, stylesheets, scripts and templates from the path.
public/vinsol_spree_themes/<theme_name>/
or
public/vinsol_spree_themes/current/
If application is running, reload the store page and you will see the changes on the browser.
Once all the changes are done and final theme is ready, run the following rake task to sync the updated files with the database.
bundle exec rake db:sync_templates THEME_NAME=<theme_name>
Admin can download the theme in the zip format after modifying it. While uploading the downloaded theme, admin needs to follow the below steps:-
Make sure to change the theme name (Theme name is the name of the zip file).
Make sure to update the meta info of the theme in the file meta_info.yml
when the theme is updated.
Extract the downloaded zip file and then need to compress the files within the extracted folder. Otherwise, the theme structure will change and there will be issue while uploading.
Set the following configuration for production environment in environment file production.rb
:
ruby
config.assets.compile = true
config.public_file_server.enabled = true
Also, set the assets compressors in production.rb
file.
ruby
config.assets.js_compressor = :uglifier
config.assets.css_compressor = :sass
For Capistrano: Add the following path to the shared linked dir in deploy.rb file.
set :linked_dirs, %w( public/vinsol_spree_themes )
While developing this extensions, we faced few issues related to assets precompilation, spree fragment caching and rails template caching. To resolve these issues we made few assumptions:
For clearing cache, we used rails resolvers. We are assuming that whenever the template is modified, we are clearing the cache.
When previewing the theme, we remove the cache directory under tmp/cache
for proper theme rendering.
We are assuming the theme zip filename to be the theme name and admin cannot upload the other theme with the same name.
We need to compile and minify the assets before publishing the theme using the compile link for proper rendering of theme.
Rails app is using centeral cache store. So that Rails.cache.clear can flush cache for all application servers.
First bundle your dependencies, then run rake
. rake
will default to building the dummy app if it does not exist, then it will run specs. The dummy app can be regenerated by using rake test_app
.
bundle
bundle exec rake
When testing your applications integration with this extension you may use it's factories. Simply add this require statement to your spec_helper:
require 'vinsol_spree_themes/factories'
Some other features which need to work on and are under development:-
If you'd like to contribute, please follow the below steps:-
Copyright (c) 2017 vinsol.com, released under the New MIT License