X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=geekigeeki.py;h=b52d3522c88d0b5b11a5e6c46463b70a1f92ca52;hb=84d4dd63eb79f68bec2e6172a9c701575b502243;hp=b8aeee89402cddc8bfe65b947e63c12d550cad27;hpb=3089b2bdb284cce0870999cfa21c060759b94ae4;p=geekigeeki.git
diff --git a/geekigeeki.py b/geekigeeki.py
index b8aeee8..b52d352 100755
--- a/geekigeeki.py
+++ b/geekigeeki.py
@@ -161,24 +161,24 @@ def send_title(name, text="Limbo", msg_text=None, msg_type='error', writable=Fal
# Navbar
print('
')
- print link_tag('FrontPage', site_icon or 'Home', 'navlink')
+ print link_tag('FrontPage', site_icon or 'Home', cssclass='navlink')
if name:
- print('
' + link_tag('?fullsearch=' + name, text, 'navlink') + ' ')
+ print('
' + link_tag('?fullsearch=' + name, text, cssclass='navlink') + ' ')
else:
print('
' + text + ' ')
- print(' | ' + link_tag('FindPage', 'Find Page', 'navlink'))
+ print(' | ' + link_tag('FindPage', 'Find Page', cssclass='navlink'))
if 'history_url' in globals():
print(' |
Recent Changes')
if name:
print(' |
Page History')
if name:
- print(' | ' + link_tag('?raw=' + name, 'Raw Text', 'navlink'))
+ print(' | ' + link_tag('?raw=' + name, 'Raw Text', cssclass='navlink'))
if privileged_url is not None:
if writable:
- print(' | ' + link_tag('?a=edit&q=' + name, 'Edit', 'navlink', privileged=True))
+ print(' | ' + link_tag('?a=edit&q=' + name, 'Edit', cssclass='navlink', privileged=True))
else:
- print(' | ' + link_tag(name, 'Login', 'navlink', privileged=True))
+ print(' | ' + link_tag(name, 'Login', cssclass='navlink', privileged=True))
else:
print(' |
Immutable Page')
@@ -194,33 +194,34 @@ def send_httperror(status="403 Not Found", query=""):
send_title(None, msg_text=("%s: on query '%s'" % (status, query)))
send_footer()
-def link_tag(params, text=None, link_class=None, privileged=False, **kvargs):
+def link_tag(dest, text=None, privileged=False, **kvargs):
if text is None:
- text = humanlink(params)
+ text = humanlink(dest)
elif img_re.match(text):
text = '
'
+ link_class = kvargs.get('class', kvargs.get('cssclass', None))
if not link_class:
- if is_external_url(params):
+ if is_external_url(dest):
link_class = 'external'
- elif file_re.match(params) and Page(params).exists():
+ elif file_re.match(dest) and Page(dest).exists():
link_class = 'wikilink'
else:
- params = nonexist_pfx + params
+ text = nonexist_pfx + text
link_class = 'nonexistent'
- classattr = 'class="%s" ' % link_class
# Prevent crawlers from following links potentially added by spammers or to generated pages
+ nofollow = ''
if link_class == 'external' or link_class == 'navlink':
- classattr += 'rel="nofollow"'
+ nofollow = 'rel="nofollow" '
- return '
%s' % (classattr, relative_url(params, privileged=privileged), text)
+ return '
%s' % (link_class, nofollow, relative_url(dest, privileged=privileged), text)
def link_inline(name, descr=None, kvargs={}):
if not descr: descr = humanlink(name)
url = relative_url(name)
if video_re.match(name):
- return '
' % url
+ return '
' % url
elif img_re.match(name):
return '
' % (url, url + url_args(kvargs), descr)
elif file_re.match(name) and not ext_re.search(name): # FIXME: this guesses a wiki page