import email.utils import os.path import time plugins_release = '1.5' mib_release = '1.0.1' page = { "description": "Standard plugins for Nagios and compatible monitoring solutions.", "keywords": "Nagios, Icinga, Shinken, Monitoring, Official, Plugins, Open, Source, Free, Software" } release_notes = 'doc/release-notes/' + plugins_release.replace('.', '-') + '.html' _RSS = """ %s %s %s en-us webmaster@nagios-plugins.org %s %s Poole http://blogs.law.harvard.edu/tech/rss %s """ _RSS_ITEM = """ %s %s %s %s %s """ def hook_postconvert_rss(): items = [] posts = [p for p in pages if 'post' in p] posts.sort(key=lambda p: p.date, reverse=True) for p in posts: title = p.post link = '%s/%s' % (options.base_url.rstrip('/'), p.url) desc = hx(p.html) date = time.mktime(time.strptime('%s 12' % p.date, '%Y-%m-%d %H')) date = email.utils.formatdate(date) items.append(_RSS_ITEM % (title, link, desc, link, date)) items = ''.join(items) title = 'Nagios Plugins' link = '%s/news/index.html' % options.base_url.rstrip('/') desc = 'Announcements published by the Nagios Plugins Development Team.' date = email.utils.formatdate() rss = _RSS % (title, link, desc, date, date, items) fp = open(os.path.join(output, 'rss.xml'), 'w') fp.write(rss) fp.close() def list_posts(max_posts=-1): posts = [p for p in pages if 'post' in p] posts.sort(key=lambda p: p.date, reverse=True) if max_posts == -1: max_posts = len(posts) for p in posts[:max_posts]: date = time.strftime('%B %d, %Y', time.strptime(p['date'], '%Y-%m-%d')) print '* **[%s](%s)** (%s)' % (p.post, p.url, date) def list_kids(): kids = [(p.url, p.title) for p in pages if p.get('parent') == page.title] for kid in sorted(kids): print('* [%s](%s)' % (kid[1], kid[0])) def menu(): menu_pages = [p for p in pages if 'menu-position' in p] menu_pages.sort(key=lambda p: int(p['menu-position'])) for p in menu_pages: if p.title == page.title: print('%s' % hx(p.title)) else: print('%s' % (p.url, hx(p.title))) def breadcrumb(): stable = 'Stable release: %s' \ % (release_notes, plugins_release) parents = {p.title: (p.url, p.get('parent')) for p in pages} title = page.title crumbs = hx(title) while parents[title][1] is not None: title = parents[title][1] url = parents[title][0] crumbs = '%s » %s' % (url, hx(title), crumbs) if crumbs == hx(page.title): crumbs = ' ' + stable return crumbs def copyright_years(since=None): this_year = time.gmtime().tm_year if since is not None and int(since) != this_year: return str(since) + '–' + str(this_year) else: return str(this_year) # vim:set expandtab softtabstop=4 shiftwidth=4 textwidth=80: