Compare commits
No commits in common. "37d242cde13dcc4eec1581f4e7b14dd18bb2a256" and "abff0ef3baea059db489e582a6236f74281bcef0" have entirely different histories.
37d242cde1
...
abff0ef3ba
8
hyde.rb
8
hyde.rb
|
@ -109,7 +109,6 @@ module Hyde
|
||||||
@response = response
|
@response = response
|
||||||
@handles = {}
|
@handles = {}
|
||||||
@indexlist = []
|
@indexlist = []
|
||||||
@vars = {}
|
|
||||||
end
|
end
|
||||||
attr_reader :request
|
attr_reader :request
|
||||||
attr_reader :response
|
attr_reader :response
|
||||||
|
@ -117,7 +116,6 @@ module Hyde
|
||||||
attr_accessor :path
|
attr_accessor :path
|
||||||
attr_accessor :handles
|
attr_accessor :handles
|
||||||
attr_accessor :indexlist
|
attr_accessor :indexlist
|
||||||
attr_accessor :vars
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Context object with safe path encapsulation
|
# Context object with safe path encapsulation
|
||||||
|
@ -128,8 +126,6 @@ module Hyde
|
||||||
@request = request.request
|
@request = request.request
|
||||||
@response = request.response
|
@response = request.response
|
||||||
@handles = request.handles
|
@handles = request.handles
|
||||||
@indexlist = request.indexlist
|
|
||||||
@vars = request.vars
|
|
||||||
end
|
end
|
||||||
undef :path=
|
undef :path=
|
||||||
undef :filepath=
|
undef :filepath=
|
||||||
|
@ -241,12 +237,8 @@ module Hyde
|
||||||
def handle(code, &block)
|
def handle(code, &block)
|
||||||
@handles[code] = block
|
@handles[code] = block
|
||||||
end
|
end
|
||||||
def preprocess(&block)
|
|
||||||
@preprocessor = block
|
|
||||||
end
|
|
||||||
def match(request)
|
def match(request)
|
||||||
raise Exception, "Not permitted" if @lock_methods
|
raise Exception, "Not permitted" if @lock_methods
|
||||||
self.instance_exec request, &@preprocessor if @preprocessor
|
|
||||||
if match? request.path then
|
if match? request.path then
|
||||||
match_path = normalize_input(request.path).match(@path)
|
match_path = normalize_input(request.path).match(@path)
|
||||||
next_path = match_path[0]
|
next_path = match_path[0]
|
||||||
|
|
|
@ -15,18 +15,8 @@ server = Hyde::Server.new Port: 8000 do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
path "uploads" do
|
path "uploads" do
|
||||||
preprocess { |request| puts request.inspect }
|
serve "**/*.md", match_full_path: true
|
||||||
index ["index.html"]
|
serve ["*.html","**/*.html"], match_full_path: true
|
||||||
serve ["**/*.md","*.html","**/*.html"], match_full_path: true
|
|
||||||
end
|
|
||||||
path ["vars_1","vars_2"] do
|
|
||||||
preprocess do |request|
|
|
||||||
request.vars["flag"] = "yes" if request.filepath.match "vars_1"
|
|
||||||
end
|
|
||||||
serve "view" do |ctx|
|
|
||||||
ctx.response.body = "Flag: #{ctx.vars["flag"]}"
|
|
||||||
ctx.response['Content-Type'] = "text/plain"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue