aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Buesch <m@bues.ch>2019-08-11 16:53:18 +0200
committerMichael Buesch <m@bues.ch>2019-08-11 16:53:18 +0200
commit9d9b18f37997f85d9b79a76e70f2fa1aa580576c (patch)
tree6a39b883af8467604493f9f85d1840e1ff5c1780
parent1d3ec5943cbafcac407c81746af171b403ee7be8 (diff)
downloadcms-9d9b18f37997f85d9b79a76e70f2fa1aa580576c.tar.xz
cms-9d9b18f37997f85d9b79a76e70f2fa1aa580576c.zip
Use nagivation bar mechanisms for $(pagelist)
Signed-off-by: Michael Buesch <m@bues.ch>
-rw-r--r--cms/cms.py67
-rw-r--r--cms/resolver.py21
-rw-r--r--example/cms.css66
-rw-r--r--example/db/macros/PAGELIST4
4 files changed, 110 insertions, 48 deletions
diff --git a/cms/cms.py b/cms/cms.py
index bc69920..62a1724 100644
--- a/cms/cms.py
+++ b/cms/cms.py
@@ -103,7 +103,7 @@ class CMS(object):
"""
return footer
- def __genNavElem(self, body, basePageIdent, activePageIdent, indent = 0):
+ def _genNavElem(self, body, basePageIdent, activePageIdent, indent=0):
if self.db.getNavStop(basePageIdent):
return
subPages = self.db.getSubPages(basePageIdent)
@@ -112,37 +112,38 @@ class CMS(object):
tabs = '\t' + '\t' * indent
if indent > 0:
body.append('%s<div class="navelems">' % tabs)
- for pageElement in subPages:
- pagename, pagelabel, pageprio = pageElement
- if pagelabel:
- body.append('%s\t<div class="%s"> '
- '<!-- %d -->' % (
- tabs,
- "navelem" if indent > 0 else "navgroup",
- pageprio))
- if indent <= 0:
- body.append('%s\t\t<div class="navhead">' %\
- tabs)
- subPageIdent = CMSPageIdent(basePageIdent + [pagename])
- isActive = activePageIdent.startswith(subPageIdent)
- if isActive:
- body.append('%s\t\t<div class="navactive">' %\
- tabs)
- body.append('%s\t\t<a href="%s">%s</a>' %\
- (tabs,
- subPageIdent.getUrl(urlBase = self.urlBase),
- pagelabel))
- if isActive:
- body.append('%s\t\t</div> '
- '<!-- class="navactive" -->' %\
- tabs)
- if indent <= 0:
- body.append('%s\t\t</div>' % tabs)
-
- self.__genNavElem(body, subPageIdent,
- activePageIdent, indent + 2)
-
- body.append('%s\t</div>' % tabs)
+ for pagename, pagelabel, pageprio in subPages:
+ if not pagelabel:
+ continue
+ body.append('%s\t<div class="%s"> '
+ '<!-- %d -->' % (
+ tabs,
+ "navelem" if indent > 0 else "navgroup",
+ pageprio))
+ if indent <= 0:
+ body.append('%s\t\t<div class="navhead">' %\
+ tabs)
+ subPageIdent = CMSPageIdent(basePageIdent + [pagename])
+ isActive = (activePageIdent is not None and
+ activePageIdent.startswith(subPageIdent))
+ if isActive:
+ body.append('%s\t\t<div class="navactive">' %\
+ tabs)
+ body.append('%s\t\t<a href="%s">%s</a>' %\
+ (tabs,
+ subPageIdent.getUrl(urlBase = self.urlBase),
+ pagelabel))
+ if isActive:
+ body.append('%s\t\t</div> '
+ '<!-- class="navactive" -->' %\
+ tabs)
+ if indent <= 0:
+ body.append('%s\t\t</div>' % tabs)
+
+ self._genNavElem(body, subPageIdent,
+ activePageIdent, indent + 2)
+
+ body.append('%s\t</div>' % tabs)
if indent > 0:
body.append('%s</div>' % tabs)
@@ -174,7 +175,7 @@ class CMS(object):
if rootActive:
body.append('\t\t</div> <!-- class="navactive" -->')
body.append('\t\t</div>')
- self.__genNavElem(body, self.__rootPageIdent, pageIdent)
+ self._genNavElem(body, self.__rootPageIdent, pageIdent)
body.append('\t</div>')
body.append('</div>\n')
diff --git a/cms/resolver.py b/cms/resolver.py
index 1f8ee6c..7e82e0d 100644
--- a/cms/resolver.py
+++ b/cms/resolver.py
@@ -484,8 +484,8 @@ class CMSStatementResolver(object): #+cdef
return resolverRet(cons, '<a id="%s" href="%s">%s</a>' %\
(name, anchor.makeUrl(self), text))
- # Statement: $(pagelist BASEPAGE, ...)
- # Returns an <ul>-list of all sub-page names in the page.
+ # Statement: $(pagelist BASEPAGE)
+ # Returns the navigation elements of all sub-page names in the page.
def __stmt_pagelist(self, d, dOffs):
#@cy cdef _ArgParserRet a
#@cy cdef int64_t cons
@@ -493,20 +493,15 @@ class CMSStatementResolver(object): #+cdef
a = self.__parseArguments(d, dOffs, False)
cons, args = a.cons, a.arguments
+ if len(args) < 1:
+ self.__stmtError("PAGELIST: no base page argument")
try:
- basePageIdent = CMSPageIdent(args)
- subPages = self.cms.db.getSubPages(basePageIdent)
+ basePageIdent = CMSPageIdent.parse(args[0])
except CMSException as e:
self.__stmtError("PAGELIST: invalid base page name")
- html = [ '<ul>\n' ]
- for pagename, navlabel, prio in subPages:
- pageIdent = CMSPageIdent(basePageIdent + [pagename])
- pagetitle = self.cms.db.getPageTitle(pageIdent)
- html.append('\t<li><a href="%s">%s</a></li>\n' %\
- (pageIdent.getUrl(urlBase = self.cms.urlBase),
- pagetitle))
- html.append('</ul>')
- return resolverRet(cons, ''.join(html))
+ html = []
+ self.cms._genNavElem(html, basePageIdent, None, 1)
+ return resolverRet(cons, '\n'.join(html))
# Statement: $(random)
# Statement: $(random BEGIN)
diff --git a/example/cms.css b/example/cms.css
index 47dba9f..8ad16c5 100644
--- a/example/cms.css
+++ b/example/cms.css
@@ -1,3 +1,7 @@
+/******************************************************************************/
+/* BASE */
+/******************************************************************************/
+
html {
background: #202020;
}
@@ -51,6 +55,10 @@ h1 a:hover, h2 a:hover, h3 a:hover {
text-decoration: underline;
}
+/******************************************************************************/
+/* TITLE bar */
+/******************************************************************************/
+
.titlebar {
display: block;
padding: 50px 164px 15px 100px;
@@ -72,6 +80,10 @@ h1 a:hover, h2 a:hover, h3 a:hover {
vertical-align: bottom;
}
+/******************************************************************************/
+/* NAVIGATION bar/groups */
+/******************************************************************************/
+
.navbar {
display: block;
font-size: 13pt;
@@ -137,6 +149,10 @@ h1 a:hover, h2 a:hover, h3 a:hover {
color: #F8F8F8;
}
+/******************************************************************************/
+/* NAVIGATION elements */
+/******************************************************************************/
+
.navbar .navgroups .navgroup .navelems {
display: none;
background: #ebebff;
@@ -227,6 +243,48 @@ h1 a:hover, h2 a:hover, h3 a:hover {
background: #5050A0;
}
+/******************************************************************************/
+/* PAGE LISTING */
+/******************************************************************************/
+
+.page-listing .navelems {
+ background: #ebebff;
+ padding: 3px 5px;
+ margin: 0px;
+ font-size: 11pt;
+
+ border-radius: 15px;
+ border: solid #cbcbff;
+ border-width: 1px;
+
+ box-shadow: 0px 0px 25px rgba(0, 0, 0, 0.25);
+ list-style-type: none;
+}
+
+.page-listing .navelems .navelem {
+ padding: 7px 0px;
+ margin: 2px 0px 2px 0px;
+}
+
+.page-listing .navelems .navelem a {
+ padding: 7px 30px;
+ color: #000000;
+ overflow: visible;
+ white-space: nowrap;
+ margin: 2px 0px 2px 0px;
+
+ border-radius: 10px;
+}
+
+.page-listing .navelems .navelem a:hover {
+ color: #FFFFFF;
+ background: #5050A0;
+}
+
+/******************************************************************************/
+/* MAIN content */
+/******************************************************************************/
+
.main {
border: none;
margin-top: 120px;
@@ -278,6 +336,10 @@ h1 a:hover, h2 a:hover, h3 a:hover {
margin-bottom: 40px;
}
+/******************************************************************************/
+/* MISC */
+/******************************************************************************/
+
.footer {
font-size: x-small;
margin-top: 20px;
@@ -311,6 +373,10 @@ pre {
display: inline-block;
}
+/******************************************************************************/
+/* PRINT media */
+/******************************************************************************/
+
@media print {
html {
background: #FFFFFF;
diff --git a/example/db/macros/PAGELIST b/example/db/macros/PAGELIST
index 8824b42..a014f7f 100644
--- a/example/db/macros/PAGELIST
+++ b/example/db/macros/PAGELIST
@@ -1,8 +1,8 @@
-<!--- @PAGELIST((group), (title)) --->
+<!--- @PAGELIST((pageident), (title)) --->
<!-- Begin: Automatic page listing -->
<div class="page-listing">
<h2>$(if $2,$2,$TITLE)</h2>
- $(pagelist $(if $1,$1,$GROUP))
+$(pagelist $(if $1,$1,$PAGEIDENT))
</div>
<!-- End: Automatic page listing -->
bues.ch cgit interface