breadcrumb
This commit is contained in:
26
__init__.py
26
__init__.py
@@ -15,7 +15,7 @@ FLATPAGES_ROOT = abspath(cfg.pages_root)
|
||||
FLATPAGES_FP_ROOT = abspath(cfg.pages_root)
|
||||
|
||||
app = Flask(__name__)
|
||||
flatpages = FlatPages(app,'FP')
|
||||
flatpages = FlatPages(app)
|
||||
flatpages.get('index')
|
||||
freezer = Freezer(app)
|
||||
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)]
|
||||
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):
|
||||
is_index=False
|
||||
if path.split('/')[-1]=='index':
|
||||
if not ( re.match('.*index',path) is None):
|
||||
is_index=True
|
||||
pathi = path
|
||||
path='/'.join(path.split('/')[0:-1])
|
||||
pathi = u'{}/{}'.format(path, 'index')
|
||||
page = flatpages.get(pathi)
|
||||
if not page is None:
|
||||
is_index=True
|
||||
page = flatpages.get(pathi)
|
||||
else:
|
||||
page=flatpages.get(path)
|
||||
return (is_index, path, page)
|
||||
@@ -49,6 +59,8 @@ def get_flatpage(path):
|
||||
def pjoin (rt,pth):
|
||||
return u'{}/{}'.format(rt,pth)
|
||||
|
||||
def pjoin2 (pth):
|
||||
return u'/'.join(pth) or u''
|
||||
|
||||
def misskey(a,key):
|
||||
if not a.has_key(key):
|
||||
@@ -81,7 +93,7 @@ def post(name='index'):
|
||||
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)
|
||||
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)):
|
||||
return send_from_directory(FLATPAGES_ROOT,path)
|
||||
|
||||
@@ -1,19 +1,26 @@
|
||||
<LINK href="/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css">
|
||||
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<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>
|
||||
{{post.date}}
|
||||
{{ post.html|safe }}
|
||||
|
||||
<br>
|
||||
|
||||
Unterordner:
|
||||
<ul>
|
||||
<b id="up_head"> Unterordner: </b>
|
||||
<ul class="nav flex-column" labeledby="uo_head">
|
||||
{% for d in spi %}
|
||||
<li>
|
||||
<a href="{{url_for('post',name=d['path'])}}">{{d.title}} {{'/'.join(d.path.split('/')[-2:-1])}}</a>
|
||||
<li class="nav-item">
|
||||
<a href="{{url_for('post',name=d['path'])}}" class="nav-link">{{d.title}} {{'/'.join(d.path.split('/')[-2:-1])}}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
Reference in New Issue
Block a user