bugfix
This commit is contained in:
parent
01bbb82b5d
commit
07c5711165
@ -43,7 +43,7 @@ class ConfiguredServer:
|
||||
for p,prefix in config.website.paths:
|
||||
res = ProcessorResource(prefix,p,show_index=True,
|
||||
follow_symlinks=True,
|
||||
indexs=configure.website.indexes,
|
||||
processors=configure.website.processors)
|
||||
indexes=config.website.indexes,
|
||||
processors=config.website.processors)
|
||||
self.app.router.register_resource(res)
|
||||
|
||||
|
@ -49,8 +49,11 @@ def setupTemplateEngine():
|
||||
config = getConfig()
|
||||
subffixes = [ i[0] for i in config.website.processors if i[1] == 'tmpl' ]
|
||||
print(subffixes)
|
||||
paths = [ os.path.abspath(p) for p,prefix in config.website.paths ]
|
||||
loader = TmplLoader(paths,config.website.indexes,subffixes,inherit=True)
|
||||
# paths = [ os.path.abspath(p) for p,prefix in config.website.paths ]
|
||||
loader = TmplLoader(config.website.paths,
|
||||
config.website.indexes,
|
||||
subffixes,
|
||||
inherit=True)
|
||||
engine = TemplateEngine(loader)
|
||||
g = ServerEnv()
|
||||
g.tmpl_engine = engine
|
||||
|
@ -52,7 +52,7 @@ class ProcessorResource(StaticResource,Url2File):
|
||||
show_index: bool=False, follow_symlinks: bool=False,
|
||||
append_version: bool=False,
|
||||
indexes:list=[],
|
||||
processors:dict={}) None:
|
||||
processors:dict={}) -> None:
|
||||
StaticResource.__init__(self,prefix, directory,
|
||||
name=name,
|
||||
expect_handler=expect_handler,
|
||||
@ -67,10 +67,10 @@ class ProcessorResource(StaticResource,Url2File):
|
||||
self._routes.update({'OPTIONS':gr})
|
||||
self._routes.update({'DELETE':gr})
|
||||
self._routes.update({'TRACE':gr})
|
||||
self.y_processors = []
|
||||
self.y_processors = processors
|
||||
self.y_prefix = prefix
|
||||
self.y_directory = directory
|
||||
self.y_indexes = []
|
||||
self.y_indexes = indexes
|
||||
self.y_env = DictObject()
|
||||
|
||||
def setProcessors(self, processors):
|
||||
|
@ -27,16 +27,15 @@ class Url2File:
|
||||
real_path = os.path.abspath(rp)
|
||||
if os.path.isdir(real_path):
|
||||
return True
|
||||
else
|
||||
return False
|
||||
|
||||
|
||||
def isFile(self,url:str) ->bool:
|
||||
if url.startswith(self.starts):
|
||||
rp = self.path + url[len(self.starts):]
|
||||
real_path = os.path.abspath(rp)
|
||||
if os.path.isfile(real_path):
|
||||
return True
|
||||
else
|
||||
return False
|
||||
|
||||
|
||||
@ -87,12 +86,21 @@ class Url2File:
|
||||
|
||||
class TmplUrl2File(Url2File):
|
||||
def __init__(self,paths,indexes, subffixes=['.tmpl'],inherit=False):
|
||||
Url2File.__init__(self,paths,indexes=indexes,inherit=inherit)
|
||||
self.paths = paths
|
||||
self.u2fs = [ Url2File(p,prefix,indexes,inherit=inherit) \
|
||||
for p,prefix in paths ]
|
||||
self.subffixes = subffixes
|
||||
|
||||
def url2file(self,url):
|
||||
for u2f in self.u2fs:
|
||||
fp = u2f.url2file(url)
|
||||
if fp:
|
||||
return fp
|
||||
return None
|
||||
|
||||
def list_tmpl(self):
|
||||
ret = []
|
||||
for rp in self.paths:
|
||||
for rp,_ in self.paths:
|
||||
p = os.path.abspath(rp)
|
||||
[ ret.append(i) for i in listFile(p,suffixs=self.subffixes,rescursive=True) ]
|
||||
return sorted(ret)
|
||||
|
Loading…
Reference in New Issue
Block a user