Back to index

moin  1.9.0~rc2
LikePages.py
Go to the documentation of this file.
00001 # -*- coding: iso-8859-1 -*-
00002 """
00003     MoinMoin - Create list of LikePages
00004 
00005     @copyright: 2004 Johannes Berg <johannes@sipsolutions.de>
00006     @license: GNU GPL, see COPYING for details.
00007 """
00008 
00009 Dependencies = ['namespace']
00010 
00011 from MoinMoin.action import LikePages
00012 
00013 def macro_LikePages(macro, text=u'(none)'):
00014     request = macro.request
00015     # we don't want to spend much CPU for spiders requesting nonexisting pages
00016     if not request.isSpiderAgent:
00017         pagename = macro.formatter.page.page_name
00018 
00019         # Get matches
00020         start, end, matches = LikePages.findMatches(pagename, request)
00021 
00022         # Render matches
00023         if matches and not isinstance(matches, (str, unicode)):
00024             return request.redirectedOutput(LikePages.showMatches, pagename, request, start, end, matches, False)
00025         else:
00026             # if we did not find any similar pages, we just render the text we got as argument:
00027             return request.formatter.text(text)
00028     # bots get nothing:
00029     return ''
00030