Sha256: e2b3c27263111030f80d1cb1ddecdea37281cac6e8e0e80637c665c23e30b849
Contents?: true
Size: 1.73 KB
Versions: 4
Compression:
Stored size: 1.73 KB
Contents
require 'sinatra/base' require 'erb' require 'time' if defined? Encoding Encoding.default_external = Encoding::UTF_8 end module RolloutUi User = Struct.new(:id) class Server < Sinatra::Base dir = File.dirname(File.expand_path(__FILE__)) set :views, "#{dir}/server/views" set :public, "#{dir}/server/public" set :static, true helpers do include Rack::Utils alias_method :h, :escape_html def partial? @partial end def partial(template, local_vars = {}) @partial = true erb(template.to_sym, {:layout => false}, local_vars) ensure @partial = false end def url_path(*path_parts) [ path_prefix, path_parts ].join("/").squeeze('/') end alias_method :u, :url_path def path_prefix request.env['SCRIPT_NAME'] end def section(key, *args, &block) @sections ||= Hash.new{ |k,v| k[v] = [] } if block_given? @sections[key] << block else @sections[key].inject(''){ |content, block| content << block.call(*args) } if @sections.keys.include?(key) end end end get "/?" do @wrapper = RolloutUi::Wrapper.new @features = @wrapper.features.map{ |feature| RolloutUi::Feature.new(feature) } response["Cache-Control"] = "max-age=0, private, must-revalidate" erb :index, { :layout => true } end post '/:feature/update' do @feature = RolloutUi::Feature.new(params["feature"]) @feature.percentage = params["percentage"] if params["percentage"] @feature.groups = params["groups"] if params["groups"] @feature.user_ids = params["users"] if params["users"] redirect url_path end end end
Version data entries
4 entries across 4 versions & 2 rubygems
Version | Path |
---|---|
rollout_ui-0.2.1 | lib/rollout_ui/server.rb |
rollout_ui-0.2.0 | lib/rollout_ui/server.rb |
bitlove-rollout_ui-0.1.0 | lib/rollout_ui/server.rb |
rollout_ui-0.1.0 | lib/rollout_ui/server.rb |