summaryrefslogtreecommitdiffstats
path: root/web/macros.py
diff options
context:
space:
mode:
Diffstat (limited to 'web/macros.py')
-rw-r--r--web/macros.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/web/macros.py b/web/macros.py
new file mode 100644
index 0000000..a4566fe
--- /dev/null
+++ b/web/macros.py
@@ -0,0 +1,43 @@
1import time
2
3plugins_release = '1.4.16'
4mib_release = '1.0.1'
5page = {
6 "description": "Standard plugins for Nagios and compatible monitoring solutions.",
7 "keywords": "Nagios, Icinga, Shinken, Monitoring, Official, Plugins, Open, Source, Free, Software"
8}
9
10def menu():
11 menu_pages = [p for p in pages if 'menu-position' in p]
12 menu_pages.sort(key=lambda p: int(p['menu-position']))
13 for p in menu_pages:
14 if p.title == page.title:
15 print('<span class="current">%s</span>' % hx(p.title))
16 else:
17 print('<span><a href="%s">%s</a></span>' % (p.url, hx(p.title)))
18
19def breadcrumb():
20 parents = {p.title: (p.url, p.get('parent')) for p in pages}
21 title = page.title
22 output = hx(title)
23 while parents[title][1] is not None:
24 title = parents[title][1]
25 url = parents[title][0]
26 output = '<a href="%s">%s</a> &gt; %s' % (url, hx(title), output)
27 if output == hx(page.title): # Hide breadcrumb if the page has no parent.
28 output = '&nbsp;'
29 return output
30
31def list_kids():
32 kids = [(p.url, p.title) for p in pages if p.get('parent') == page.title]
33 for kid in sorted(kids):
34 print('* [%s](%s)' % (kid[1], kid[0]))
35
36def copyright_years(since=None):
37 this_year = time.gmtime().tm_year
38 if since is not None and int(since) != this_year:
39 return str(since) + '&ndash;' + str(this_year)
40 else:
41 return str(this_year)
42
43# vim:set expandtab softtabstop=4 shiftwidth=4 textwidth=80: