Giter Club home page Giter Club logo

flipper-ui's Introduction

Flipper::UI

UI for the Flipper gem. Note: This is not fully functional yet. The end product will look like this:

flipper web

Installation

Add this line to your application's Gemfile:

gem 'flipper-ui'

And then execute:

$ bundle

Or install it yourself as:

$ gem install flipper-ui

Usage

Rails

Given that you've already initialized Flipper as per the flipper readme:

# config/initializers/flipper.rb
$flipper = Flipper.new(...)

you can mount Flipper::UI to a route of your choice:

# config/routes.rb

YourRailsApp::Application.routes.draw do
  mount Flipper::UI.app($flipper) => '/flipper'
end

Security

You almost certainly want to limit access when using Flipper::UI in production. Using routes constraints is one way to achieve this:

# config/routes.rb

flipper_constraint = lambda { |request| request.remote_ip == '127.0.0.1' }
constraints flipper_constraint do
  mount Flipper::UI.app($flipper) => '/flipper'
end

Another example of a route constrain using the current_user when using Devise or another warden based authentication system:

# initializers/admin_access.rb

class CanAccessFlipperUI
  def self.matches?(request)
    current_user = request.env['warden'].user
    
    return current_user.present? && current_user.respond_to?(:is_admin?) && current_user.is_admin?
  end
end

# config/routes.rb

constraints CanAccessFlipperUI do
  mount Flipper::UI.app($flipper) => '/flipper'
end

Standalone

Minimal example for Rack:

# config.ru

require 'flipper-ui'
require 'flipper/adapters/memory'

adapter = Flipper::Adapters::Memory.new
flipper = Flipper.new(adapter)

run Flipper::UI.app(flipper)

See examples/basic.ru for a more full example

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Fire up the app (bundle exec rake start)
  4. Start up guard (bundle exec guard for automatic coffeescript/sass compilation and such).
  5. Commit your changes (git commit -am 'Added some feature')
  6. Push to the branch (git push origin my-new-feature)
  7. Create new Pull Request

flipper-ui's People

Contributors

felixclack avatar gabceb avatar greatuserongithub avatar jnunemaker avatar panozzaj avatar reinh avatar ryanlower avatar

Watchers

 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.