forked from ccheever/bunny1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sean Reifschneider
committed
Feb 9, 2011
1 parent
015d8aa
commit 610ba50
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env python | ||
|
||
from bottle import redirect | ||
from cony import rich_help | ||
|
||
|
||
@rich_help('--help') | ||
def cmd_wikipedia(term): | ||
'''Wikipedia page search.''' | ||
|
||
template = """ | ||
<p />Search Wikipedia for the given term. If no term is specified, | ||
the home page is opened. Otherwise, the term is searched for on | ||
Wikipedia, which may result in a redirect to an exact page match, | ||
or to a list of search results. | ||
</p> | ||
<p>If the term "slash" (/) followed by one of the language-specific | ||
Wikipedia sub-sites, such as "/en" or "/ru", go directly to that | ||
page.</p> | ||
%rebase layout title = 'Wikipedia Help' | ||
""" | ||
|
||
if term == '--help' or term == '?' or term == '-?': | ||
return dict(template = template) | ||
elif not term: | ||
redirect('http://www.wikipedia.org/') | ||
elif term[0] == '/' and len(term) == 3: | ||
redirect('http://%s.wikipedia.org/' % term[1:]) | ||
else: | ||
redirect('http://www.wikipedia.org/w/index.php?search=%s' | ||
% term.replace(' ', '+')) |