0.0
No commit activity in last 3 years
No release in over 3 years
Generate and manage themes which are made up of templates and assets.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 4.2
 Project Readme

##Shiny Themes

ShinyThemes is my first rails gem and something I extracted from a blog project. The gem very simply manages asset files and updates the asset pipeline configuration to use those assets. The idea is all template, stylesheet, javascript and image assets are grouped together as a 'theme' which is named by it's root directory.

Installation

This gem is a Rails v4 plugin gem

Add this to your Gemfile

gem 'shiny_themes'

And install the new gem

bundle install 

Then run the install generator

rails generate shiny_themes:install

This creates a configuration file that points to a theme name and default layout for each environment. See 'config/themes.yml'

Theme generation and selection

Themes by default are installed to 'app/themes' however this path can be updated by changing config.theme.path. When you create a new theme make sure to restart your application so the asset pipeline picks up the new directory. Generate a new theme using a rails generator simply called theme.

rails generate shiny_themes:theme name_of_theme --layout=optional_default_layout_name

This creates a new default theme with javascript and stylesheet manifests as well as a layout which can be optionally named something other then application. The theme is installed to the path contained in the config, defaults to 'app/themes'.

Controller specific themes

You can select a theme specifically for a controller with the class method renders_theme

renders_theme 'theme_name', options = {layout: 'optional_default_layout'}

Saving theme configuration

You can persist a theme configuration from a specific controller using the update_current_theme method which will update the theme configuration for the controller and by default save the configuration to themes.yml.

update_current_theme 'new_theme', options = { layout: 'optional_default_layout', dont_save: false }

Template Support

Currently the gem only supports the ERB language for templates. This should eventually be expanded however the ERB language is being leveraged by my other projects and was honestly chosen for convenience. I would like to implement HAML and Liquid support eventually.

Stylesheet Support

The gem supports two stylesheet languages, traditional CSS and SCSS/SASS. By default the theme generate command will produce CSS manifest files that use the *=require* type asset import. Provide the generate command with a --sass option and the manifest will be crated as an scss file using @import syntax for asset importing.

rails generate shiny_themes:theme sass_theme --sass

##License

This project rocks and uses MIT-LICENSE.