Sha256: f83c59a1477b2328f7f80c9120f20bd73a2d0e29e347acbe7534571d3db3c02d
Contents?: true
Size: 1.84 KB
Versions: 1
Compression:
Stored size: 1.84 KB
Contents
require 'sinatra/base' require 'wpa_cli_ruby' require_relative 'wpa_cli_web/access_point_list' class WpaCliWeb < Sinatra::Base include WpaCliRuby configure do set :product_name, "Radiodan" set :method_override, true set :public_folder, File.expand_path(File.join(File.dirname(__FILE__), 'wpa_cli_web', 'public')) set :views, File.expand_path(File.join(File.dirname(__FILE__), 'wpa_cli_web', 'views')) end helpers do def product_name settings.product_name end end def wpa_cli_client if ENV['RACK_ENV'] == "development" WpaCli.new(DummyWpaCliWrapper.new) else WpaCli.new end end before do @host = request.host_with_port end get '/' do redirect '/access_points' end get '/access_points' do access_point_list = AccessPointList.new(wpa_cli_client) @access_points = access_point_list.access_points if request.xhr? erb :access_points_list, :layout => false else erb :access_points end end post '/networks' do id = wpa_cli_client.add_network ssid = params[:ssid] redirect "/networks/#{id}?ssid=#{ssid}" end get '/networks/:id' do @id = params[:id] begin @ssid = wpa_cli_client.get_network(@id, 'ssid') rescue WpaCliRuby::NetworkNotFound @ssid = params[:ssid] end erb :networks_edit end put '/networks/:id' do id = params[:id] ssid = params[:ssid] password = params[:password] wpa_cli_client.set_network(id, "ssid", ssid) if password wpa_cli_client.set_network(id, "psk", password) else wpa_cli_client.set_network(id, "key_mgmt", "NONE") end wpa_cli_client.set_network(id, "disabled", 0) wpa_cli_client.save_config redirect "/restart" end get '/restart' do erb :restart end post '/restart' do erb :restarting end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wpa_cli_web-0.0.6 | lib/wpa_cli_web.rb |