changed parameter name
This commit is contained in:
parent
3b8632f8a7
commit
695e32bbfa
17
hyde.rb
17
hyde.rb
|
@ -36,9 +36,9 @@ module Hyde
|
||||||
|
|
||||||
# Interchangeable glob/regex/string pattern matching
|
# Interchangeable glob/regex/string pattern matching
|
||||||
module PatternMatching
|
module PatternMatching
|
||||||
def prep_path(path,safe_regexp: true)
|
def prep_path(path,match_full_path: false)
|
||||||
raise Exception, "Not permitted" if @lock_methods
|
raise Exception, "Not permitted" if @lock_methods
|
||||||
@safe_regexp = safe_regexp
|
@match_full_path = match_full_path
|
||||||
@path = normalize(path) if path.kind_of? String
|
@path = normalize(path) if path.kind_of? String
|
||||||
@path = path if path.kind_of? Regexp
|
@path = path if path.kind_of? Regexp
|
||||||
end
|
end
|
||||||
|
@ -53,8 +53,8 @@ module Hyde
|
||||||
# 3) safe regexp means match only the part before the next slash
|
# 3) safe regexp means match only the part before the next slash
|
||||||
# 2) a .match? only returns when there are no leftovers
|
# 2) a .match? only returns when there are no leftovers
|
||||||
# this forces the matching to work somewhat consistently
|
# this forces the matching to work somewhat consistently
|
||||||
test = @path.match normalize_input(path) unless @safe_regexp
|
test = @path.match normalize_input(path) if @match_full_path
|
||||||
test = @path.match split_path[0] if @safe_regexp
|
test = @path.match split_path[0] unless @match_full_path
|
||||||
if test and (test.pre_match == "") and (test.post_match == "") then
|
if test and (test.pre_match == "") and (test.post_match == "") then
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
|
@ -137,8 +137,8 @@ module Hyde
|
||||||
class Probe
|
class Probe
|
||||||
include Hyde::PatternMatching
|
include Hyde::PatternMatching
|
||||||
include Hyde::PublicContextControlMethods
|
include Hyde::PublicContextControlMethods
|
||||||
def initialize (path, safe_regexp: true, &block_optional)
|
def initialize (path, match_full_path: false, &block_optional)
|
||||||
prep_path path, safe_regexp: safe_regexp
|
prep_path path, match_full_path: match_full_path
|
||||||
@block = block_optional
|
@block = block_optional
|
||||||
end
|
end
|
||||||
def match(request)
|
def match(request)
|
||||||
|
@ -201,8 +201,8 @@ module Hyde
|
||||||
class Pathspec
|
class Pathspec
|
||||||
include Hyde::PatternMatching
|
include Hyde::PatternMatching
|
||||||
include Hyde::Handlers
|
include Hyde::Handlers
|
||||||
def initialize (path, root_path: nil, safe_regexp: true, &block)
|
def initialize (path, root_path: nil, match_full_path: false, &block)
|
||||||
prep_path path, safe_regexp: safe_regexp
|
prep_path path, match_full_path: match_full_path
|
||||||
@chain = []
|
@chain = []
|
||||||
@handles = {}
|
@handles = {}
|
||||||
@root_override = root_path
|
@root_override = root_path
|
||||||
|
@ -266,7 +266,6 @@ module Hyde
|
||||||
end
|
end
|
||||||
# passthrough to the next path object
|
# passthrough to the next path object
|
||||||
next_pathspec = @chain.find { |x| x.match? cut_path }
|
next_pathspec = @chain.find { |x| x.match? cut_path }
|
||||||
puts next_pathspec.inspect
|
|
||||||
next_pathspec.match request if next_pathspec
|
next_pathspec.match request if next_pathspec
|
||||||
unless next_pathspec then
|
unless next_pathspec then
|
||||||
# throw 404 if nowhere to go
|
# throw 404 if nowhere to go
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
require_relative 'hyde'
|
require_relative 'hyde'
|
||||||
|
|
||||||
server = Hyde::Server.new Port: 8000 do
|
server = Hyde::Server.new Port: 8000 do
|
||||||
root "/home/yessiest/hyde/test/"
|
root Dir::pwd+"/test/"
|
||||||
serve "index.html"
|
serve "index.html"
|
||||||
index ["index.html"]
|
index ["index.html"]
|
||||||
path "about" do
|
path "about" do
|
||||||
|
@ -16,8 +16,8 @@ server = Hyde::Server.new Port: 8000 do
|
||||||
end
|
end
|
||||||
path "uploads" do
|
path "uploads" do
|
||||||
index ["index.html"]
|
index ["index.html"]
|
||||||
serve "**/*.md", safe_regex: false
|
serve "**/*.md", match_full_path: true
|
||||||
serve ["*.html","**/*.html"], safe_regex: false
|
serve ["*.html","**/*.html"], match_full_path: true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue