zuk-picnic 0.7.999.20090212
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +1 -0
- data/History.txt +68 -0
- data/LICENSE.txt +165 -0
- data/Manifest.txt +29 -0
- data/README.txt +31 -0
- data/Rakefile +62 -0
- data/lib/picnic/authentication.rb +218 -0
- data/lib/picnic/cli.rb +165 -0
- data/lib/picnic/conf.rb +135 -0
- data/lib/picnic/controllers.rb +4 -0
- data/lib/picnic/logger.rb +41 -0
- data/lib/picnic/server.rb +98 -0
- data/lib/picnic/service_control.rb +274 -0
- data/lib/picnic/version.rb +9 -0
- data/lib/picnic.rb +48 -0
- data/setup.rb +1585 -0
- data/test/picnic_test.rb +11 -0
- data/test/test_helper.rb +2 -0
- data/vendor/camping-2.0.20090212/CHANGELOG +118 -0
- data/vendor/camping-2.0.20090212/COPYING +18 -0
- data/vendor/camping-2.0.20090212/README +119 -0
- data/vendor/camping-2.0.20090212/Rakefile +174 -0
- data/vendor/camping-2.0.20090212/bin/camping +99 -0
- data/vendor/camping-2.0.20090212/doc/camping.1.gz +0 -0
- data/vendor/camping-2.0.20090212/examples/README +5 -0
- data/vendor/camping-2.0.20090212/examples/blog.rb +375 -0
- data/vendor/camping-2.0.20090212/examples/campsh.rb +629 -0
- data/vendor/camping-2.0.20090212/examples/tepee.rb +242 -0
- data/vendor/camping-2.0.20090212/extras/Camping.gif +0 -0
- data/vendor/camping-2.0.20090212/extras/flipbook_rdoc.rb +491 -0
- data/vendor/camping-2.0.20090212/extras/permalink.gif +0 -0
- data/vendor/camping-2.0.20090212/lib/camping/ar/session.rb +132 -0
- data/vendor/camping-2.0.20090212/lib/camping/ar.rb +78 -0
- data/vendor/camping-2.0.20090212/lib/camping/mab.rb +26 -0
- data/vendor/camping-2.0.20090212/lib/camping/reloader.rb +163 -0
- data/vendor/camping-2.0.20090212/lib/camping/server.rb +158 -0
- data/vendor/camping-2.0.20090212/lib/camping/session.rb +74 -0
- data/vendor/camping-2.0.20090212/lib/camping-unabridged.rb +638 -0
- data/vendor/camping-2.0.20090212/lib/camping.rb +54 -0
- data/vendor/camping-2.0.20090212/setup.rb +1551 -0
- data/vendor/camping-2.0.20090212/test/apps/env_debug.rb +65 -0
- data/vendor/camping-2.0.20090212/test/apps/forms.rb +95 -0
- data/vendor/camping-2.0.20090212/test/apps/misc.rb +86 -0
- data/vendor/camping-2.0.20090212/test/apps/sessions.rb +38 -0
- data/vendor/camping-2.0.20090212/test/test_camping.rb +54 -0
- metadata +128 -0
@@ -0,0 +1,65 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
begin require "rubygems" rescue LoadError end
|
4
|
+
require "camping"
|
5
|
+
|
6
|
+
Camping.goes :EnvDebug
|
7
|
+
|
8
|
+
module EnvDebug
|
9
|
+
module Controllers
|
10
|
+
class ShowEnv < R '/', '/(.*)'
|
11
|
+
def get(extra = nil)
|
12
|
+
@extra = extra
|
13
|
+
render :show_env
|
14
|
+
end
|
15
|
+
alias post get
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
module Views
|
20
|
+
def layout
|
21
|
+
html do
|
22
|
+
head{ title C }
|
23
|
+
body do
|
24
|
+
ul do
|
25
|
+
li{ a "show env", :href=>R(ShowEnv)}
|
26
|
+
end
|
27
|
+
p { yield }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def _print_hash(hash)
|
33
|
+
hash.keys.sort.each do |key|
|
34
|
+
value = hash[key]
|
35
|
+
pre "%30s: %s" % [key.inspect, value.inspect]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def show_env
|
40
|
+
b "extra: #{@extra.inspect}"
|
41
|
+
h2 "@status : #{@status.inspect}"
|
42
|
+
h2 "@method : #{@method.inspect}"
|
43
|
+
h2 "@root : #{@root.inspect}"
|
44
|
+
h2 "@env :"
|
45
|
+
_print_hash @env
|
46
|
+
h2 "@input : "
|
47
|
+
_print_hash @input
|
48
|
+
h2 "@headers :"
|
49
|
+
_print_hash @headers
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# For CGI
|
56
|
+
if $0 == __FILE__
|
57
|
+
EnvDebug.create if EnvDebug.respond_to? :create
|
58
|
+
if ARGV.any?
|
59
|
+
require 'camping/fastcgi'
|
60
|
+
#Dir.chdir('/var/camping/blog/')
|
61
|
+
Camping::FastCGI.start(EnvDebug)
|
62
|
+
else
|
63
|
+
puts EnvDebug.run
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require "camping"
|
2
|
+
|
3
|
+
Camping.goes :Forms
|
4
|
+
|
5
|
+
module Forms
|
6
|
+
module Controllers
|
7
|
+
class Index < R '/'
|
8
|
+
def get; render :index end
|
9
|
+
end
|
10
|
+
class GetForm
|
11
|
+
def get; render :get_form; end
|
12
|
+
end
|
13
|
+
class GetFormResult
|
14
|
+
def get; render :form_result; end
|
15
|
+
end
|
16
|
+
class PostForm
|
17
|
+
def get; render :post_form; end
|
18
|
+
def post; render :form_result; end
|
19
|
+
end
|
20
|
+
class FileForm
|
21
|
+
def get; render :file_form; end
|
22
|
+
def post; render :form_result; end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
module Views
|
27
|
+
def layout
|
28
|
+
html do
|
29
|
+
head{ title C }
|
30
|
+
body do
|
31
|
+
ul do
|
32
|
+
li{ a "index", :href=>R(Index)}
|
33
|
+
li{ a "get form", :href=>R(GetForm)}
|
34
|
+
li{ a "post form", :href=>R(PostForm)}
|
35
|
+
li{ a "file form", :href=>R(FileForm)}
|
36
|
+
end
|
37
|
+
p { yield }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def form_result
|
43
|
+
p @input.inspect
|
44
|
+
end
|
45
|
+
|
46
|
+
def index
|
47
|
+
h1 "Welcome on the Camping test app"
|
48
|
+
end
|
49
|
+
|
50
|
+
def get_form
|
51
|
+
form :action=>R(GetFormResult), :method=>:get do
|
52
|
+
label "Give me your name!", :for=>:name
|
53
|
+
input :type=>:text, :name=>:name; br
|
54
|
+
input :type=>:text, :name=>"arr[]"; br
|
55
|
+
input :type=>:text, :name=>"arr[]"; br
|
56
|
+
input :type=>:text, :name=>"hash[x]"; br
|
57
|
+
input :type=>:text, :name=>"hash[y]"; br
|
58
|
+
|
59
|
+
input :type=>:submit
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def post_form
|
64
|
+
form :action=>R(PostForm), :method=>:post do
|
65
|
+
label "Give me your name!", :for=>:name
|
66
|
+
input :type=>:text, :name=>:name; br
|
67
|
+
input :type=>:text, :name=>"arr[]"; br
|
68
|
+
input :type=>:text, :name=>"arr[]"; br
|
69
|
+
input :type=>:text, :name=>"hash[x]"; br
|
70
|
+
input :type=>:text, :name=>"hash[y]"; br
|
71
|
+
|
72
|
+
input :type=>:submit
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def file_form
|
77
|
+
form :action=>R(FileForm), :method=>:post, :enctype=>"multipart/form-data" do
|
78
|
+
input :type=>:text, :name=>"arr"
|
79
|
+
input :type=>:text, :name=>"arr"; br
|
80
|
+
input :type=>:file, :name=>"first_file"; br
|
81
|
+
input :type=>:file, :name=>"files[]"; br
|
82
|
+
input :type=>:file, :name=>"files[]"; br
|
83
|
+
input :type=>:submit
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# For CGI
|
92
|
+
if $0 == __FILE__
|
93
|
+
Forms.create
|
94
|
+
Forms.run
|
95
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require "camping"
|
2
|
+
|
3
|
+
Camping.goes :Misc
|
4
|
+
|
5
|
+
module Misc
|
6
|
+
module Controllers
|
7
|
+
class Index < R '/'
|
8
|
+
def get; render :index end
|
9
|
+
end
|
10
|
+
class RenderPartial
|
11
|
+
def get; render :_partial; end
|
12
|
+
end
|
13
|
+
class Xsendfile
|
14
|
+
def get
|
15
|
+
@headers["X-Sendfile"] = File.expand_path(__FILE__)
|
16
|
+
"You shouldn't get this text"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
class Links < R '/links', '/links/(\w+)/with/(\d+)/args'
|
20
|
+
def get(*args); render :links; end
|
21
|
+
end
|
22
|
+
class Redirect
|
23
|
+
def get; redirect(RR) end
|
24
|
+
end
|
25
|
+
class RR
|
26
|
+
def get; render :rr; end
|
27
|
+
end
|
28
|
+
class BadLinks
|
29
|
+
def get; render :bad_links; end
|
30
|
+
end
|
31
|
+
class BadMethod; end
|
32
|
+
end
|
33
|
+
|
34
|
+
module Views
|
35
|
+
def layout
|
36
|
+
html do
|
37
|
+
head{ title C }
|
38
|
+
body do
|
39
|
+
ul do
|
40
|
+
li{ a "index", :href=>R(Index)}
|
41
|
+
li{ a "render partial", :href=>R(RenderPartial)}
|
42
|
+
li{ a "X-Sendfile", :href=>R(Xsendfile)}
|
43
|
+
li{ a "Links", :href=>R(Links)}
|
44
|
+
li{ a "BadLinks", :href=>R(BadLinks)}
|
45
|
+
li{ a "Redirect", :href=>R(Redirect)}
|
46
|
+
li{ a "BadMethod", :href=>R(BadMethod)}
|
47
|
+
end
|
48
|
+
p { yield }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def _partial
|
54
|
+
a "go back to index", :href=>R(Index)
|
55
|
+
end
|
56
|
+
|
57
|
+
def index
|
58
|
+
h1 "Welcome on the Camping test app"
|
59
|
+
end
|
60
|
+
|
61
|
+
def links
|
62
|
+
a "plain", :href=>R(Links); br
|
63
|
+
a "with args and hash", :href=>R(Links, "moo", 3, :with=>"Hash"); br
|
64
|
+
a "with args and mult. hash", :href=>R(Links, "hoi", 8, :with=>"multiple", 3=>"hash"); br
|
65
|
+
# TODO : with <AR::Base object
|
66
|
+
end
|
67
|
+
|
68
|
+
def bad_links
|
69
|
+
a "null controller", :href=>R(nil)
|
70
|
+
a "bad arity", :href=>R(RR, :moo)
|
71
|
+
a "bad args", :href=>R(Links, 3, "moo")
|
72
|
+
end
|
73
|
+
|
74
|
+
def rr
|
75
|
+
p "got redirected"
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# For CGI
|
83
|
+
if $0 == __FILE__
|
84
|
+
Misc.create
|
85
|
+
Misc.run
|
86
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "rubygems"
|
4
|
+
require "camping"
|
5
|
+
|
6
|
+
Camping.goes :Sessions
|
7
|
+
require 'camping/session'
|
8
|
+
|
9
|
+
module Sessions
|
10
|
+
include Camping::Session
|
11
|
+
module Controllers
|
12
|
+
class One < R('/')
|
13
|
+
def get
|
14
|
+
@state = C::H['one',rand(100)]
|
15
|
+
puts "1:" + @state.inspect
|
16
|
+
redirect R(Two)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class Two < R('/steptwo')
|
21
|
+
def get
|
22
|
+
@state['two'] = "This is in two"
|
23
|
+
puts "2:" + @state.inspect
|
24
|
+
redirect R(Three)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class Three < R('/stepthree')
|
29
|
+
def get
|
30
|
+
@state['three'] = "This is in three"
|
31
|
+
puts "3:" + @state.inspect
|
32
|
+
return "Accumulated state across redirects: #{@state.inspect}"
|
33
|
+
redirect R(Three)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
|
3
|
+
require "camping"
|
4
|
+
|
5
|
+
class Test_Camping_class_methods < Test::Unit::TestCase
|
6
|
+
def test_escape_from_the_doc
|
7
|
+
assert_equal "I%27d+go+to+the+museum+straightway%21", Camping.escape("I'd go to the museum straightway!")
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_utf8_escape
|
11
|
+
assert_equal "%E6%97%A5%E6%9C%AC%E5%9B%BD", Camping.escape("\346\227\245\346\234\254\345\233\275")
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_unescape_from_the_doc
|
15
|
+
assert_equal "I'd go to the museum straightway!", Camping.un("I%27d+go+to+the+museum+straightway%21")
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_utf8_unescape
|
19
|
+
assert_equal "\346\227\245\346\234\254\345\233\275", Camping.un("%E6%97%A5%E6%9C%AC%E5%9B%BD")
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_qsp_from_the_doc
|
23
|
+
input = Camping.qsp("name=Philarp+Tremain&hair=sandy+blonde")
|
24
|
+
assert_equal "Philarp Tremain", input.name
|
25
|
+
assert_equal "sandy blonde", input.hair
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_qsp_with_array
|
29
|
+
input = Camping.qsp("users[]=why&users[]=rambo")
|
30
|
+
assert_equal ["why", "rambo"], input.users
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_qsp_with_hash
|
34
|
+
input = Camping.qsp("post[id]=1&post[user]=_why")
|
35
|
+
hash = {'post' => {'id' => '1', 'user' => '_why'}}
|
36
|
+
assert_equal hash, input
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_qsp_malformed1
|
40
|
+
input = Camping.qsp("name=Philarp+Tremain&&hair=sandy+blonde")
|
41
|
+
assert_equal "Philarp Tremain", input.name
|
42
|
+
assert_equal "sandy blonde", input.hair
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_qsp_malformed2
|
46
|
+
input = Camping.qsp("morta==del")
|
47
|
+
assert_equal "=del", input.morta
|
48
|
+
end
|
49
|
+
|
50
|
+
# TODO : Test Camping.kp
|
51
|
+
# TODO : Test Camping.run
|
52
|
+
|
53
|
+
end
|
54
|
+
|
metadata
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: zuk-picnic
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.7.999.20090212
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matt Zukowski
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-02-12 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: markaby
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0"
|
23
|
+
version:
|
24
|
+
- !ruby/object:Gem::Dependency
|
25
|
+
name: activesupport
|
26
|
+
version_requirement:
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: "0"
|
32
|
+
version:
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: hoe
|
35
|
+
version_requirement:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.8.2
|
41
|
+
version:
|
42
|
+
description: Camping for sissies
|
43
|
+
email: matt@roughest.net
|
44
|
+
executables: []
|
45
|
+
|
46
|
+
extensions: []
|
47
|
+
|
48
|
+
extra_rdoc_files:
|
49
|
+
- CHANGELOG.txt
|
50
|
+
- History.txt
|
51
|
+
- LICENSE.txt
|
52
|
+
- Manifest.txt
|
53
|
+
- README.txt
|
54
|
+
files:
|
55
|
+
- CHANGELOG.txt
|
56
|
+
- History.txt
|
57
|
+
- LICENSE.txt
|
58
|
+
- Manifest.txt
|
59
|
+
- README.txt
|
60
|
+
- Rakefile
|
61
|
+
- lib/picnic.rb
|
62
|
+
- lib/picnic/authentication.rb
|
63
|
+
- lib/picnic/cli.rb
|
64
|
+
- lib/picnic/conf.rb
|
65
|
+
- lib/picnic/controllers.rb
|
66
|
+
- lib/picnic/logger.rb
|
67
|
+
- lib/picnic/server.rb
|
68
|
+
- lib/picnic/service_control.rb
|
69
|
+
- lib/picnic/version.rb
|
70
|
+
- setup.rb
|
71
|
+
- test/picnic_test.rb
|
72
|
+
- test/test_helper.rb
|
73
|
+
- vendor/camping-2.0.20090212/CHANGELOG
|
74
|
+
- vendor/camping-2.0.20090212/COPYING
|
75
|
+
- vendor/camping-2.0.20090212/README
|
76
|
+
- vendor/camping-2.0.20090212/Rakefile
|
77
|
+
- vendor/camping-2.0.20090212/bin/camping
|
78
|
+
- vendor/camping-2.0.20090212/doc/camping.1.gz
|
79
|
+
- vendor/camping-2.0.20090212/examples/README
|
80
|
+
- vendor/camping-2.0.20090212/examples/blog.rb
|
81
|
+
- vendor/camping-2.0.20090212/examples/campsh.rb
|
82
|
+
- vendor/camping-2.0.20090212/examples/tepee.rb
|
83
|
+
- vendor/camping-2.0.20090212/extras/Camping.gif
|
84
|
+
- vendor/camping-2.0.20090212/extras/flipbook_rdoc.rb
|
85
|
+
- vendor/camping-2.0.20090212/extras/permalink.gif
|
86
|
+
- vendor/camping-2.0.20090212/lib/camping-unabridged.rb
|
87
|
+
- vendor/camping-2.0.20090212/lib/camping.rb
|
88
|
+
- vendor/camping-2.0.20090212/lib/camping/ar.rb
|
89
|
+
- vendor/camping-2.0.20090212/lib/camping/ar/session.rb
|
90
|
+
- vendor/camping-2.0.20090212/lib/camping/mab.rb
|
91
|
+
- vendor/camping-2.0.20090212/lib/camping/reloader.rb
|
92
|
+
- vendor/camping-2.0.20090212/lib/camping/server.rb
|
93
|
+
- vendor/camping-2.0.20090212/lib/camping/session.rb
|
94
|
+
- vendor/camping-2.0.20090212/setup.rb
|
95
|
+
- vendor/camping-2.0.20090212/test/apps/env_debug.rb
|
96
|
+
- vendor/camping-2.0.20090212/test/apps/forms.rb
|
97
|
+
- vendor/camping-2.0.20090212/test/apps/misc.rb
|
98
|
+
- vendor/camping-2.0.20090212/test/apps/sessions.rb
|
99
|
+
- vendor/camping-2.0.20090212/test/test_camping.rb
|
100
|
+
has_rdoc: true
|
101
|
+
homepage: http://picnic.rubyforge.org
|
102
|
+
post_install_message:
|
103
|
+
rdoc_options:
|
104
|
+
- --main
|
105
|
+
- README.txt
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: "0"
|
113
|
+
version:
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: "0"
|
119
|
+
version:
|
120
|
+
requirements: []
|
121
|
+
|
122
|
+
rubyforge_project: picnic
|
123
|
+
rubygems_version: 1.2.0
|
124
|
+
signing_key:
|
125
|
+
specification_version: 2
|
126
|
+
summary: Camping for sissies
|
127
|
+
test_files:
|
128
|
+
- test/picnic_test.rb
|