Sha256: b46de0f97f193ebf2cfc2fe89670481a2a42032a16baabc1e85c3d07ae8bc196

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

#!/usr/bin/env ruby

require 'lockr/http/httplockrinit'
require 'erb'
require 'clipboard'  
require 'padrino-helpers'

include ERB::Util

init = HttpLockrInit.new()
init.start()

# now start sinatra
require 'sinatra'

if init.getLoadBrowser
  require "browser_gui"  
end

register Padrino::Helpers

set :pwdmgr, init.getPwdMgr()
# server config
set :public_dir, File.expand_path('../../resources/static', __FILE__) 
set :bind, '127.0.0.1'
set :port, 32187
set :views, File.expand_path('../../resources/views', __FILE__) 
enable :run
 
get '/' do
  dir = settings.pwdmgr.list()
  erb :index, :locals => { :directory => dir }
end

get '/password' do
  id = params[:id]
  username = params[:username]
  settings.pwdmgr.copy_to_clipboard( id, username)
  redirect '/'
end

post '/password' do
  id = params[:id]
  username = params[:username]
  password = params[:password]
  newPwdstore = settings.pwdmgr.add( id, username, password)
  dir = settings.pwdmgr.list()
  redirect '/'
end

patch '/password' do
  id = params[:id]
  username = params[:username]
  password = params[:password]
  settings.pwdmgr.change( id, username, password)
  redirect '/'
end

delete '/password' do
  id = params[:id]
  username = params[:username]
  settings.pwdmgr.delete( id, username)
  redirect '/'
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lockr-0.5.1 bin/httplockr.rb