Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

whitelabel your application

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 .document
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .rspec
Octocat-spinner-32 .rvmrc
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 Gemfile
Octocat-spinner-32 Gemfile.lock
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile
Octocat-spinner-32 whitelabel.gemspec
README.md

Whitelabel

This gem helps you providing whitelabel functionality in your application.

Installation

Add this line to your application's Gemfile:

gem 'whitelabel'

And then execute:

$ bundle

Or install it yourself as:

$ gem install whitelabel

Usage

You can start with a pretty simple, file driven whitelabel configuration.

All you need is a config file:

# config/whitelabel.yaml
---
- !ruby/struct:YourLabelClass
  label_id: "white"
  some_config: "for your application"

and an initializer:

# config/initializers/whitelabel.rb
YourLabelClass = Struct.new :label_id, :some_config
Whitelabel.from_file Rails.root.join("config/whitelabel.yml")

Whitelabel works the same way I18n does, just set it up in your ApplicationController:

# app/controllers/application_controller.rb
before_filter :switch_label

def switch_label
  unless Whitelabel.label_for(request.subdomains.first)
    redirect_to(labels_url(subdomain: false), alert: "Please select a Label!")
  end
end

This example uses the subdomain to determine which label should be active, but you can implement whatever you like here.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
Something went wrong with that request. Please try again.