zorglub 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/.travis.yml +7 -0
- data/Changelog +28 -17
- data/Gemfile +5 -0
- data/Gemfile.lock +32 -0
- data/{README.rdoc → README.md} +17 -14
- data/Rakefile +6 -60
- data/TODO +7 -0
- data/example/layout/css.haml +5 -0
- data/example/layout/default.haml +5 -0
- data/example/layout/other.haml +4 -0
- data/example/sample.ru +157 -0
- data/example/view/url1/index.haml +7 -0
- data/example/view/url1/meth0.haml +7 -0
- data/example/view/url3/index.haml +8 -0
- data/lib/version.rb +10 -0
- data/lib/zorglub/app.rb +9 -4
- data/lib/zorglub/engines/sass.rb +22 -0
- data/lib/zorglub/node.rb +31 -27
- data/lib/zorglub/session.rb +6 -6
- data/lib/zorglub.rb +1 -6
- data/spec/data/view/node0/engines.scss +9 -0
- data/spec/node_spec.rb +20 -3
- data/spec/spec_helper.rb +14 -7
- data/zorglub.gemspec +28 -0
- metadata +68 -45
- data/tasks/ann.rake +0 -83
- data/tasks/constants.rb +0 -118
- data/tasks/gem.rake +0 -196
- data/tasks/git.rake +0 -38
- data/tasks/helpers.rb +0 -130
- data/tasks/notes.rake +0 -27
- data/tasks/post_load.rake +0 -35
- data/tasks/rdoc.rake +0 -46
- data/tasks/rubyforge.rake +0 -54
- data/tasks/setup.rb +0 -129
- data/tasks/spec.rake +0 -44
- data/tasks/svn.rake +0 -48
- data/tasks/test.rake +0 -41
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Changelog
CHANGED
@@ -1,26 +1,37 @@
|
|
1
|
-
|
2
|
-
*
|
3
|
-
|
4
|
-
|
5
|
-
*
|
1
|
+
2013-01-08 Jérémy Zurcher <jeremy@asynk.ch>
|
2
|
+
* release 0.6
|
3
|
+
* add sass engine
|
4
|
+
* use Bundler
|
5
|
+
* enable travis
|
6
|
+
* fix and rename inherited_vars in cli_vals
|
6
7
|
|
7
|
-
2012-01-
|
8
|
-
*
|
9
|
-
*
|
10
|
-
*
|
11
|
-
*
|
8
|
+
2012-01-17 Jérémy Zurcher <jeremy@asynk.ch>
|
9
|
+
* release 0.5
|
10
|
+
* Node code cleanup
|
11
|
+
* class and method level directives are now view!, layout!, no_layout!, ...
|
12
|
+
* add view_base_path! and layout_base_path!
|
13
|
+
* before_all and after_all are based on inherited_vars
|
14
|
+
* add Zorglub::Config.debug
|
15
|
+
* Zorglub::App swallows Zorglub::Config
|
12
16
|
|
13
17
|
2012-01-05 Jérémy Zurcher <jeremy@asynk.ch>
|
18
|
+
* release 0.3 and 0.4
|
14
19
|
* haml, file engines
|
15
20
|
* view/layout extention overriding at methode level
|
16
21
|
* optional engine cache
|
17
22
|
* optional engine proc mime-type definition
|
18
23
|
* optional static page generation/cache
|
19
24
|
|
20
|
-
2012-01-
|
21
|
-
*
|
22
|
-
*
|
23
|
-
*
|
24
|
-
*
|
25
|
-
*
|
26
|
-
|
25
|
+
2012-01-04 Jérémy Zurcher <jeremy@asynk.ch>
|
26
|
+
* release 0.2
|
27
|
+
* lots of code cleanup
|
28
|
+
* replace Helpers Module with Node#inherited_var Node@inherited_vars
|
29
|
+
* rewrite session so it is compatible with Rack SessionHash
|
30
|
+
* update test application and write specs
|
31
|
+
|
32
|
+
2011-09-13 Jérémy Zurcher <jeremy@asynk.ch>
|
33
|
+
* usable WIP
|
34
|
+
|
35
|
+
2011-05-26 Jérémy Zurcher <jeremy@asynk.ch>
|
36
|
+
* Project creation
|
37
|
+
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
zorglub (0.0.5)
|
5
|
+
rack
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.1.3)
|
11
|
+
haml (3.1.7)
|
12
|
+
rack (1.4.2)
|
13
|
+
rake (10.0.3)
|
14
|
+
rspec (2.12.0)
|
15
|
+
rspec-core (~> 2.12.0)
|
16
|
+
rspec-expectations (~> 2.12.0)
|
17
|
+
rspec-mocks (~> 2.12.0)
|
18
|
+
rspec-core (2.12.2)
|
19
|
+
rspec-expectations (2.12.1)
|
20
|
+
diff-lcs (~> 1.1.3)
|
21
|
+
rspec-mocks (2.12.1)
|
22
|
+
sass (3.2.5)
|
23
|
+
|
24
|
+
PLATFORMS
|
25
|
+
ruby
|
26
|
+
|
27
|
+
DEPENDENCIES
|
28
|
+
haml
|
29
|
+
rake
|
30
|
+
rspec
|
31
|
+
sass
|
32
|
+
zorglub!
|
data/{README.rdoc → README.md}
RENAMED
@@ -1,12 +1,12 @@
|
|
1
|
-
zorglub
|
1
|
+
# zorglub
|
2
2
|
by Jérémy Zurcher
|
3
|
-
http://
|
3
|
+
http://asynk.ch
|
4
4
|
|
5
|
-
|
5
|
+
## DESCRIPTION:
|
6
6
|
|
7
|
-
a nano web application framework based on rack
|
7
|
+
a nano web application framework based on [rack](http://rack.rubyforge.org/)
|
8
8
|
|
9
|
-
|
9
|
+
## FEATURES:
|
10
10
|
|
11
11
|
* class#method mapping scheme (/class_mapping/method_name/*args)
|
12
12
|
* class level layout and engine specification
|
@@ -17,7 +17,11 @@ a nano web application framework based on rack[http://rack.rubyforge.org/]
|
|
17
17
|
* class level inherited variables
|
18
18
|
* session
|
19
19
|
|
20
|
-
|
20
|
+
## STATUS:
|
21
|
+
|
22
|
+
[![Build Status](https://secure.travis-ci.org/jeremyz/zorglub.png)](http://travis-ci.org/jeremyz/zorglub)
|
23
|
+
|
24
|
+
## SYNOPSIS:
|
21
25
|
|
22
26
|
For a simple test application run:
|
23
27
|
* rackup ./example/sample.ru
|
@@ -25,11 +29,11 @@ For a simple test application run:
|
|
25
29
|
Don't forget to look at
|
26
30
|
* the spec/ folder
|
27
31
|
|
28
|
-
|
32
|
+
## REQUIREMENTS:
|
29
33
|
|
30
34
|
* rack
|
31
35
|
|
32
|
-
|
36
|
+
## DOWNLOAD/INSTALL:
|
33
37
|
|
34
38
|
From rubygems:
|
35
39
|
|
@@ -37,11 +41,9 @@ From rubygems:
|
|
37
41
|
|
38
42
|
or from the git repository on github:
|
39
43
|
|
40
|
-
|
41
|
-
cd zorglub
|
42
|
-
rake gem:install
|
44
|
+
git clone git://github.com/jeremyz/zorglub.git && cd zorglub && rake install
|
43
45
|
|
44
|
-
|
46
|
+
## RESOURCES:
|
45
47
|
|
46
48
|
You can find this project in a few places:
|
47
49
|
|
@@ -50,6 +52,7 @@ Online repositories:
|
|
50
52
|
* https://github.com/jeremyz/zorglub
|
51
53
|
* http://cgit.asynk.ch/cgi-bin/cgit/zorglub/
|
52
54
|
|
53
|
-
|
55
|
+
## LICENSE:
|
56
|
+
|
57
|
+
[MIT](http://www.opensource.org/licenses/MIT) see [MIT_LICENSE](https://github.com/jeremyz/zorglub/blob/master/MIT-LICENSE)
|
54
58
|
|
55
|
-
See MIT-LICENSE file.
|
data/Rakefile
CHANGED
@@ -1,60 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
#
|
8
|
-
# Project general information
|
9
|
-
PROJ.name = 'zorglub'
|
10
|
-
PROJ.authors = 'Jérémy Zurcher'
|
11
|
-
PROJ.email = 'jeremy@asynk.ch'
|
12
|
-
PROJ.url = 'http://cgit.asynk.ch/cgi-bin/cgit/zorglub'
|
13
|
-
PROJ.version = Zorglub::VERSION
|
14
|
-
PROJ.rubyforge.name = 'FIXME'
|
15
|
-
PROJ.readme_file = 'README.rdoc'
|
16
|
-
#
|
17
|
-
# Annoucement
|
18
|
-
PROJ.ann.paragraphs << 'FEATURES' << 'SYNOPSIS' << 'REQUIREMENTS' << 'DOWNLOAD/INSTALL' << 'CREDITS' << 'LICENSE'
|
19
|
-
PROJ.ann.email[:from] = 'jeremy@asynk.ch'
|
20
|
-
PROJ.ann.email[:to] = ['FIXME']
|
21
|
-
PROJ.ann.email[:server] = 'FIXME'
|
22
|
-
PROJ.ann.email[:tls] = false
|
23
|
-
# Gem specifications
|
24
|
-
PROJ.gem.need_tar = false
|
25
|
-
PROJ.gem.files = %w(Changelog MIT-LICENSE README.rdoc Rakefile) + Dir.glob("{ext,lib,spec,tasks}/**/*[^~]").reject { |fn| test ?d, fn }
|
26
|
-
PROJ.gem.platform = Gem::Platform::RUBY
|
27
|
-
PROJ.gem.required_ruby_version = ">= 1.9.2"
|
28
|
-
#
|
29
|
-
# Override Mr. Bones autogenerated extensions and force ours in
|
30
|
-
#PROJ.gem.extras['extensions'] = %w(ext/extconf.rb)
|
31
|
-
#PROJ.gem.extras['required_ruby_version'] = ">= 1.9.2"
|
32
|
-
#
|
33
|
-
# RDoc
|
34
|
-
PROJ.rdoc.exclude << '^ext\/'
|
35
|
-
PROJ.rdoc.opts << '-x' << 'ext'
|
36
|
-
#
|
37
|
-
# Ruby
|
38
|
-
PROJ.ruby_opts = []
|
39
|
-
PROJ.ruby_opts << '-I' << 'lib'
|
40
|
-
#
|
41
|
-
# RSpec
|
42
|
-
PROJ.spec.files.exclude /rbx/
|
43
|
-
PROJ.spec.opts << '--color'
|
44
|
-
#
|
45
|
-
# Rcov
|
46
|
-
PROJ.rcov.opts << '-I lib'
|
47
|
-
#
|
48
|
-
# Dependencies
|
49
|
-
depend_on 'rack'
|
50
|
-
depend_on 'rake', '>=0.8.0'
|
51
|
-
#
|
52
|
-
task :default => [:spec]
|
53
|
-
#
|
54
|
-
desc "Build all packages"
|
55
|
-
task :package => 'gem:package'
|
56
|
-
#
|
57
|
-
desc "Install the gem locally"
|
58
|
-
task :install => 'gem:install'
|
59
|
-
#
|
60
|
-
# EOF
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
RSpec::Core::RakeTask.new
|
5
|
+
|
6
|
+
task :default => :spec
|
data/TODO
ADDED
data/example/sample.ru
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
$LOAD_PATH << File.join(File.dirname( File.absolute_path(__FILE__)), '..', 'lib')
|
4
|
+
#
|
5
|
+
USE_RACK_SESSION=false
|
6
|
+
#
|
7
|
+
require 'zorglub'
|
8
|
+
require 'zorglub/engines/haml'
|
9
|
+
if USE_RACK_SESSION
|
10
|
+
require 'zorglub/rack_session'
|
11
|
+
else
|
12
|
+
require 'zorglub/session'
|
13
|
+
end
|
14
|
+
#
|
15
|
+
class Zorglub::Node
|
16
|
+
@count=0
|
17
|
+
class << self
|
18
|
+
attr_accessor :count
|
19
|
+
end
|
20
|
+
before_all do |node|
|
21
|
+
Zorglub::Node.count +=1
|
22
|
+
end
|
23
|
+
end
|
24
|
+
#
|
25
|
+
class Node1 < Zorglub::Node
|
26
|
+
#
|
27
|
+
def index a1, *a2
|
28
|
+
@title='Index'
|
29
|
+
@links = LINKS
|
30
|
+
# there's a view so the below will be lost !
|
31
|
+
"<b>should never be seeen</b>"
|
32
|
+
end
|
33
|
+
#
|
34
|
+
def meth0 *args
|
35
|
+
@title='meth0'
|
36
|
+
@links = LINKS
|
37
|
+
# method level engine
|
38
|
+
engine! 'tmp-engine'
|
39
|
+
# there's a view so the below will be lost !
|
40
|
+
"<b>should never be seeen</b>"
|
41
|
+
end
|
42
|
+
#
|
43
|
+
def meth1 *args
|
44
|
+
@title='meth1'
|
45
|
+
@links = LINKS
|
46
|
+
# method level engine (layout/other.haml)
|
47
|
+
layout! 'other'
|
48
|
+
# specific method view (view/url1/meth0.haml)
|
49
|
+
view! File.join( 'url1','meth0')
|
50
|
+
# there's a view so the below will be lost !
|
51
|
+
"<b>should never be seeen</b>"
|
52
|
+
end
|
53
|
+
#
|
54
|
+
def jump *args
|
55
|
+
redirect r(:index,1,2,3)
|
56
|
+
end
|
57
|
+
#
|
58
|
+
end
|
59
|
+
#
|
60
|
+
HAML_PROC = Proc.new { |path,obj| Haml::Engine.new( File.open(path,'r').read ).render(obj) }
|
61
|
+
#
|
62
|
+
APP = Zorglub::App.new do
|
63
|
+
register_engine! :haml, 'haml', Zorglub::Engines::Haml.method(:proc)
|
64
|
+
register_engine! 'tmp-engine', 'haml', HAML_PROC
|
65
|
+
opt! :debug, true
|
66
|
+
opt! :engine, :haml
|
67
|
+
opt!:root, File.dirname( File.absolute_path(__FILE__) )
|
68
|
+
opt(:session_options)[:enabled] = true
|
69
|
+
map '/url1', Node1
|
70
|
+
end
|
71
|
+
#
|
72
|
+
class Node2 < Zorglub::Node
|
73
|
+
#
|
74
|
+
map APP, '/url2'
|
75
|
+
layout! 'css'
|
76
|
+
# class level engine
|
77
|
+
engine! 'tmp-engine'
|
78
|
+
# class level css
|
79
|
+
cli_val :css, 'class_level.css'
|
80
|
+
#
|
81
|
+
def index *args
|
82
|
+
"<title>Node2:index</title><b>START</b>#{html}<a href=#{Node2.r(:meth0)}>next</a><br/><b>END</b>"
|
83
|
+
end
|
84
|
+
#
|
85
|
+
def meth0 *args
|
86
|
+
# instance level css
|
87
|
+
cli_val :css, 'instance_level.css'
|
88
|
+
"<title>Node2:meth0</title><b>START</b>#{html}<a href=#{Node2.r(:meth1,1,2)}>next</a><br/><b>END</b>"
|
89
|
+
end
|
90
|
+
#
|
91
|
+
def meth1 *args
|
92
|
+
more = Node2.partial :meth0, *args
|
93
|
+
"<title>Node2:meth1</title><b>partial</b><br/>#{more}<br/><b>done</b><br/><a href=#{Node0.r}>back</a>"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
#
|
97
|
+
class Node3 < Zorglub::Node
|
98
|
+
#
|
99
|
+
map APP, '/url3'
|
100
|
+
no_layout!
|
101
|
+
#
|
102
|
+
def index *args
|
103
|
+
@title = "Session tests"
|
104
|
+
t = Time.now
|
105
|
+
if session[:now].nil?
|
106
|
+
session[:now] = t
|
107
|
+
@data = "#{t.strftime('%H:%M:%S')} FIRST"
|
108
|
+
elsif t-session[:now]>10
|
109
|
+
session[:now] = t
|
110
|
+
@data = "#{t.strftime('%H:%M:%S')} UPDATE"
|
111
|
+
else
|
112
|
+
@data = "#{session[:now].strftime('%H:%M:%S')} CURRENT"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
def reset
|
116
|
+
session.clear
|
117
|
+
redirect :index
|
118
|
+
end
|
119
|
+
#
|
120
|
+
end
|
121
|
+
#
|
122
|
+
class Node0 < Zorglub::Node
|
123
|
+
#
|
124
|
+
map APP, '/'
|
125
|
+
#
|
126
|
+
def index
|
127
|
+
html = "<html><body><ul>"
|
128
|
+
html << "<li><a href=\"#{Node1.r('index','a',2,'c')}\">Node1</a> engine, layout, view, redirect tests</li>"
|
129
|
+
html << "<li><a href=\"#{Node2.r}\">Node2</a> css helper tests</li>"
|
130
|
+
html << "<li><a href=\"#{Node3.r}\">Node3</a> session test</li>"
|
131
|
+
html << "</ul></body></html>"
|
132
|
+
html
|
133
|
+
end
|
134
|
+
#
|
135
|
+
end
|
136
|
+
#
|
137
|
+
Node1::LINKS= [
|
138
|
+
[Node1.r('index','arg1','arg2','arg3'),'index'],
|
139
|
+
[Node1.r('meth0'),'meth0'],
|
140
|
+
[Node1.r('meth1','one','two'),'meth1 with args'],
|
141
|
+
[Node1.r('jump','one','two'),'test redirect'],
|
142
|
+
[Node0.r,'back'],
|
143
|
+
]
|
144
|
+
#
|
145
|
+
puts APP.to_hash.inspect
|
146
|
+
puts " **** "+( USE_RACK_SESSION ? 'USE Rack Session' : 'USE builtin Session' )
|
147
|
+
#
|
148
|
+
map '/' do
|
149
|
+
use Rack::Lint
|
150
|
+
use Rack::ShowExceptions
|
151
|
+
if USE_RACK_SESSION
|
152
|
+
use Rack::Session::Cookie, :key=>APP.opt(:session_options)[:key], :secret=>APP.opt(:session_options)[:secret],
|
153
|
+
:path=>'/', :http_only=>true, :expire_after=>30
|
154
|
+
end
|
155
|
+
run APP
|
156
|
+
end
|
157
|
+
#
|
data/lib/version.rb
ADDED
data/lib/zorglub/app.rb
CHANGED
@@ -25,11 +25,16 @@ module Zorglub
|
|
25
25
|
:ugly => false,
|
26
26
|
:encoding => 'utf-8'
|
27
27
|
},
|
28
|
+
:sass_options => {
|
29
|
+
:syntax => :scss,
|
30
|
+
:cache => :false,
|
31
|
+
:style => :compressed
|
32
|
+
},
|
28
33
|
:session_options => {
|
29
|
-
:
|
30
|
-
:
|
31
|
-
:
|
32
|
-
:
|
34
|
+
:enabled => false,
|
35
|
+
:key => 'zorglub.sid',
|
36
|
+
:secret => 'session-secret-secret',
|
37
|
+
:sid_len => 64
|
33
38
|
}
|
34
39
|
}
|
35
40
|
instance_eval &block if block_given?
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- coding: UTF-8 -*-
|
2
|
+
#
|
3
|
+
require 'sass'
|
4
|
+
#
|
5
|
+
module Zorglub
|
6
|
+
module Engines
|
7
|
+
module Sass
|
8
|
+
def self.proc path,obj
|
9
|
+
if obj.app.opt(:engines_cache_enabled)
|
10
|
+
key = path.sub obj.app.opt(:root),''
|
11
|
+
sass = obj.app.engines_cache[key] ||= ::Sass::Engine.new( ::File.open(path,'r'){|f| f.read }, obj.app.opt(:sass_options) )
|
12
|
+
else
|
13
|
+
sass = ::Sass::Engine.new( ::File.open(path,'r'){|f| f.read }, obj.app.opt(:sass_options) )
|
14
|
+
end
|
15
|
+
css = sass.render
|
16
|
+
return css, 'text/css'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
#
|
22
|
+
# EOF
|
data/lib/zorglub/node.rb
CHANGED
@@ -154,58 +154,60 @@ module Zorglub
|
|
154
154
|
"You are being redirected, please follow this link to: <a href='#{target}'>#{target}</a>!"
|
155
155
|
end
|
156
156
|
#
|
157
|
-
# inherited
|
157
|
+
# class level inherited values are key=>array, copied at inheritance
|
158
|
+
# so they can be extanded at class level
|
159
|
+
# values are copied from class into instance at object creation
|
160
|
+
# so that can be extanded without modifying class level values
|
161
|
+
# typical usage are css or js inclusions
|
158
162
|
#
|
159
|
-
@
|
163
|
+
@cli_vals = { }
|
160
164
|
#
|
161
165
|
class << self
|
162
166
|
#
|
163
|
-
attr_reader :
|
167
|
+
attr_reader :cli_vals
|
164
168
|
#
|
165
|
-
def
|
166
|
-
|
169
|
+
def cli_val sym, *args
|
170
|
+
vals = @cli_vals[sym] ||=[]
|
167
171
|
unless args.empty?
|
168
|
-
|
169
|
-
|
172
|
+
vals.concat args
|
173
|
+
vals.uniq!
|
170
174
|
end
|
171
|
-
|
175
|
+
vals
|
172
176
|
end
|
173
177
|
#
|
174
178
|
end
|
175
179
|
#
|
176
|
-
def
|
177
|
-
|
180
|
+
def cli_val sym, *args
|
181
|
+
vals = @cli_vals[sym] ||=[]
|
178
182
|
unless args.empty?
|
179
|
-
|
180
|
-
|
183
|
+
vals.concat args
|
184
|
+
vals.uniq!
|
181
185
|
end
|
182
|
-
|
186
|
+
vals
|
183
187
|
end
|
184
188
|
#
|
185
189
|
# before_all and after_all hooks
|
186
190
|
#
|
187
|
-
@
|
188
|
-
@
|
191
|
+
@cli_vals[:before_all] = []
|
192
|
+
@cli_vals[:after_all] = []
|
189
193
|
class << self
|
190
|
-
#
|
191
|
-
attr_reader :hooks
|
192
194
|
#
|
193
195
|
def call_before_hooks obj
|
194
|
-
@
|
196
|
+
@cli_vals[:before_all].each do |blk| blk.call obj end
|
195
197
|
end
|
196
198
|
#
|
197
199
|
def before_all &blk
|
198
|
-
@
|
199
|
-
@
|
200
|
+
@cli_vals[:before_all]<< blk
|
201
|
+
@cli_vals[:before_all].uniq!
|
200
202
|
end
|
201
203
|
#
|
202
204
|
def call_after_hooks obj
|
203
|
-
@
|
205
|
+
@cli_vals[:after_all].each do |blk| blk.call obj end
|
204
206
|
end
|
205
207
|
#
|
206
208
|
def after_all &blk
|
207
|
-
@
|
208
|
-
@
|
209
|
+
@cli_vals[:after_all]<< blk
|
210
|
+
@cli_vals[:after_all].uniq!
|
209
211
|
end
|
210
212
|
#
|
211
213
|
end
|
@@ -217,12 +219,12 @@ module Zorglub
|
|
217
219
|
def inherited sub
|
218
220
|
sub.engine! engine||(self==Zorglub::Node ? UNDEFINED : nil )
|
219
221
|
sub.layout! layout||(self==Zorglub::Node ? UNDEFINED : nil )
|
220
|
-
sub.instance_variable_set :@
|
221
|
-
@
|
222
|
+
sub.instance_variable_set :@cli_vals, {}
|
223
|
+
@cli_vals.each do |s,v| sub.cli_val s, *v end
|
222
224
|
end
|
223
225
|
#
|
224
226
|
def call env
|
225
|
-
meth, *args = env['PATH_INFO'].sub(/^\//,'').split
|
227
|
+
meth, *args = env['PATH_INFO'].sub(/^\//,'').split(/\//)
|
226
228
|
meth||= 'index'
|
227
229
|
puts "=> #{meth}(#{args.join ','})" if app.opt :debug
|
228
230
|
node = self.new env, {:engine=>engine,:layout=>layout,:view=>r(meth),:method=>meth,:args=>args,:static=>static}
|
@@ -242,7 +244,7 @@ module Zorglub
|
|
242
244
|
resp = node.response
|
243
245
|
resp.status = 404
|
244
246
|
resp['Content-Type'] = 'text/plain'
|
245
|
-
resp.write "%s mapped at %p can't respond to : %p" % [ node.class.name, node.
|
247
|
+
resp.write "%s mapped at %p can't respond to : %p" % [ node.class.name, node.map, node.request.env['PATH_INFO'] ]
|
246
248
|
resp
|
247
249
|
end
|
248
250
|
#
|
@@ -255,6 +257,8 @@ module Zorglub
|
|
255
257
|
@options = options
|
256
258
|
@request = Rack::Request.new env
|
257
259
|
@response = Rack::Response.new
|
260
|
+
@cli_vals ={}
|
261
|
+
self.class.cli_vals.each do |s,v| cli_val s, *v end
|
258
262
|
end
|
259
263
|
#
|
260
264
|
def state state=nil
|
data/lib/zorglub/session.rb
CHANGED
@@ -47,7 +47,7 @@ module Zorglub
|
|
47
47
|
#
|
48
48
|
def clear
|
49
49
|
load_data!
|
50
|
-
# @response.delete_cookie @options[:
|
50
|
+
# @response.delete_cookie @options[:key]
|
51
51
|
# @sessions.delete @sid
|
52
52
|
# @sid = nil
|
53
53
|
super
|
@@ -95,11 +95,11 @@ module Zorglub
|
|
95
95
|
#
|
96
96
|
def load_data!
|
97
97
|
return if loaded?
|
98
|
-
if @options[:
|
99
|
-
sid = @request.cookies[@options[:
|
98
|
+
if @options[:enabled]
|
99
|
+
sid = @request.cookies[@options[:key]]
|
100
100
|
if sid.nil?
|
101
101
|
sid = generate_sid!
|
102
|
-
@response.set_cookie @options[:
|
102
|
+
@response.set_cookie @options[:key], sid
|
103
103
|
end
|
104
104
|
replace @sessions[sid] ||={}
|
105
105
|
@sessions[sid] = self
|
@@ -126,7 +126,7 @@ module Zorglub
|
|
126
126
|
# SecureRandom is available since Ruby 1.8.7.
|
127
127
|
# For Ruby versions earlier than that, you can require the uuidtools gem,
|
128
128
|
# which has a drop-in replacement for SecureRandom.
|
129
|
-
def sid_algorithm; SecureRandom.hex(@options[:
|
129
|
+
def sid_algorithm; SecureRandom.hex(@options[:sid_len]); end
|
130
130
|
rescue LoadError
|
131
131
|
require 'openssl'
|
132
132
|
# Using OpenSSL::Random for generation, this is comparable in performance
|
@@ -134,7 +134,7 @@ module Zorglub
|
|
134
134
|
# have the same behaviour as the SecureRandom::hex method of the
|
135
135
|
# uuidtools gem.
|
136
136
|
def sid_algorithm
|
137
|
-
OpenSSL::Random.random_bytes(@options[:
|
137
|
+
OpenSSL::Random.random_bytes(@options[:sid_len] / 2).unpack('H*')[0]
|
138
138
|
end
|
139
139
|
rescue LoadError
|
140
140
|
# Digest::SHA2::hexdigest produces a string of length 64, although
|