-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtestserver.rb
More file actions
executable file
·49 lines (42 loc) · 1.28 KB
/
Copy pathtestserver.rb
File metadata and controls
executable file
·49 lines (42 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env ruby
require 'rubygems'
require 'sinatra'
require 'json'
require 'faker'
set :public, File.dirname(__FILE__)
get '/' do
haml :home
end
get '/users' do
names = Array.new(7) { { :id => rand(2000), :name => Faker::Name.name } }
content_type :json
names.to_json
end
post '/showme' do
content_type :text
params.inspect
end
__END__
@@ layout
!!! XML
!!! STRICT
%html{'xml:lang' => 'en', :lang => 'en', :xmlns => 'http://www.w3.org/1999/xhtml'}
%head
%title facelist test server
%link{:rel => 'stylesheet', :type => 'text/css', :href => '/screen.css'}
%script{:type => 'text/javascript', :src => '/jquery-1.3.2.min.js'}
%script{:type => 'text/javascript', :src => '/jquery.listface.js'}
:javascript
$(document).ready(function() { $.listface('users', { url: '/users', min: 2, param: 'query', attribute: { value: 'id', name: 'name' } }) })
$(document).ready(function() { $.listface('people', { url: '/users', min: 2, param: 'query', attribute: { value: 'id', name: 'name' } }) })
%body
#wrap
= yield
@@ home
%form{:action => '/showme', :method => 'post'}
%p
%input{:type => 'text', :name => 'users', :id => 'users'}
%p
%input{:type => 'text', :name => 'people', :id => 'people'}
%p
%button{:type => 'submit'} Submit