breadcrumb
This commit is contained in:
24
__init__.py
24
__init__.py
@@ -15,7 +15,7 @@ FLATPAGES_ROOT = abspath(cfg.pages_root)
|
|||||||
FLATPAGES_FP_ROOT = abspath(cfg.pages_root)
|
FLATPAGES_FP_ROOT = abspath(cfg.pages_root)
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
flatpages = FlatPages(app,'FP')
|
flatpages = FlatPages(app)
|
||||||
flatpages.get('index')
|
flatpages.get('index')
|
||||||
freezer = Freezer(app)
|
freezer = Freezer(app)
|
||||||
app.config.from_object(__name__)
|
app.config.from_object(__name__)
|
||||||
@@ -33,15 +33,25 @@ def get_sub_ipages(path, page):
|
|||||||
ps=[p for p in flatpages if p.path.startswith(path) and not ( re.match('.*index',p.path) is None) and ( re.match(ppath,p.path) is None)]
|
ps=[p for p in flatpages if p.path.startswith(path) and not ( re.match('.*index',p.path) is None) and ( re.match(ppath,p.path) is None)]
|
||||||
return ps
|
return ps
|
||||||
|
|
||||||
|
|
||||||
|
def get_bc(path, page):
|
||||||
|
ppath=page.path
|
||||||
|
elements=path.split('/')#[0:-1]
|
||||||
|
elements2=['index']
|
||||||
|
for i in range(0,len(elements)):
|
||||||
|
elements2.append(pjoin2(elements[0:i])+u'/index')
|
||||||
|
ps=[p for p in flatpages if p.path in elements2 ]
|
||||||
|
return ps
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_flatpage(path):
|
def get_flatpage(path):
|
||||||
is_index=False
|
is_index=False
|
||||||
if path.split('/')[-1]=='index':
|
if not ( re.match('.*index',path) is None):
|
||||||
is_index=True
|
is_index=True
|
||||||
|
pathi = path
|
||||||
path='/'.join(path.split('/')[0:-1])
|
path='/'.join(path.split('/')[0:-1])
|
||||||
pathi = u'{}/{}'.format(path, 'index')
|
|
||||||
page = flatpages.get(pathi)
|
page = flatpages.get(pathi)
|
||||||
if not page is None:
|
|
||||||
is_index=True
|
|
||||||
else:
|
else:
|
||||||
page=flatpages.get(path)
|
page=flatpages.get(path)
|
||||||
return (is_index, path, page)
|
return (is_index, path, page)
|
||||||
@@ -49,6 +59,8 @@ def get_flatpage(path):
|
|||||||
def pjoin (rt,pth):
|
def pjoin (rt,pth):
|
||||||
return u'{}/{}'.format(rt,pth)
|
return u'{}/{}'.format(rt,pth)
|
||||||
|
|
||||||
|
def pjoin2 (pth):
|
||||||
|
return u'/'.join(pth) or u''
|
||||||
|
|
||||||
def misskey(a,key):
|
def misskey(a,key):
|
||||||
if not a.has_key(key):
|
if not a.has_key(key):
|
||||||
@@ -81,7 +93,7 @@ def post(name='index'):
|
|||||||
if not page is None:
|
if not page is None:
|
||||||
page_defaults(page,is_index,path)
|
page_defaults(page,is_index,path)
|
||||||
app.logger.info("Render Template"+page["template"] +"for "+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)
|
return render_template(page.meta["template"], ld=ld, post=page, sp=sp, spi=spi, pth=path, pagebreadcrumbs=get_bc(path,page))
|
||||||
|
|
||||||
if os.path.exists(u'{}/{}'.format(FLATPAGES_ROOT,path)):
|
if os.path.exists(u'{}/{}'.format(FLATPAGES_ROOT,path)):
|
||||||
return send_from_directory(FLATPAGES_ROOT,path)
|
return send_from_directory(FLATPAGES_ROOT,path)
|
||||||
|
|||||||
@@ -1,19 +1,26 @@
|
|||||||
<LINK href="/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css">
|
<LINK href="/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css">
|
||||||
|
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
|
<nav class="breadcrumb" style="background-color: #FFF">
|
||||||
|
{% for b in pagebreadcrumbs %}
|
||||||
|
<a href="{{url_for('post',name=b.path)}}" class="breadcrumb-item">{{b.title}} </a>
|
||||||
|
{% endfor %}
|
||||||
|
<a href="{{url_for('post',name=post.path)}}" class="breadcrumb-item active">{{post.title}} </a>
|
||||||
|
</nav>
|
||||||
<h1>{{post.title}}</h1>
|
<h1>{{post.title}}</h1>
|
||||||
{{post.date}}
|
{{post.date}}
|
||||||
{{ post.html|safe }}
|
{{ post.html|safe }}
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
Unterordner:
|
<b id="up_head"> Unterordner: </b>
|
||||||
<ul>
|
<ul class="nav flex-column" labeledby="uo_head">
|
||||||
{% for d in spi %}
|
{% for d in spi %}
|
||||||
<li>
|
<li class="nav-item">
|
||||||
<a href="{{url_for('post',name=d['path'])}}">{{d.title}} {{'/'.join(d.path.split('/')[-2:-1])}}</a>
|
<a href="{{url_for('post',name=d['path'])}}" class="nav-link">{{d.title}} {{'/'.join(d.path.split('/')[-2:-1])}}</a>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
Reference in New Issue
Block a user