gallery template

This commit is contained in:
Andreas Stephanides
2017-02-19 00:40:24 +01:00
parent fcfc04a594
commit 539646fd37
4 changed files with 111 additions and 37 deletions

View File

@@ -24,6 +24,11 @@ app.config.from_object(__name__)
def list_dir(mypath):
return [f for f in os.listdir(mypath) if isfile(os.path.join(mypath, f)) and re.match('.*\.md.*',f) is None]
def list_img(mypath):
return [f for f in os.listdir(mypath) if isfile(os.path.join(mypath, f)) and re.match('.*\.jpg',f) is not None]
def get_sub_pages(path, page):
ppath=page.path
cc=len(path.split('/'))
@@ -95,17 +100,18 @@ def post(name='index'):
if is_index == True and not page is None:
ld=list_dir(path2)
il=list_img(path2)
sp=get_sub_pages(path,page)
spi=get_sub_ipages(path,page)
else:
ld=[]
sp=[]
spi=[]
il=[]
if not page is None:
page_defaults(page,is_index,path)
app.logger.info("Render Template"+page["template"] +"for "+path)
return render_template(page.meta["template"], ld=ld, post=page, sp=sp, spi=spi, pth=path, pagebreadcrumbs=get_bc(path,page))
return render_template(page.meta["template"], ld=ld, post=page, sp=sp, spi=spi, il=il, pth=path, pagebreadcrumbs=get_bc(path,page))
if os.path.exists(u'{}/{}'.format(FLATPAGES_ROOT,path)):
return send_from_directory(FLATPAGES_ROOT,path)