- text = params # default
- classattr = ''
- if ss_class:
- classattr += 'class="%s" ' % ss_class
- # Prevent crawlers from following links potentially added by spammers or to generated pages
- if ss_class == 'external' or ss_class == 'navlink':
- classattr += 'rel="nofollow" '
- if authentication:
- path = privileged_path()
+ text = humanlink(dest)
+ elif image_re.match(text):
+ text = '<img border="0" src="' + relative_url(text) + '" alt="' + text + '" />'
+
+ link_class = kvargs.get('class', kvargs.get('cssclass', None))
+ if not link_class:
+ if is_external_url(dest):
+ link_class = 'external'
+ elif file_re.match(dest) and Page(dest).exists():
+ link_class = 'wikilink'
+ else:
+ text = nonexist_pfx + text
+ link_class = 'nonexistent'
+
+ # Prevent crawlers from following links potentially added by spammers or to generated pages
+ nofollow = ''
+ if link_class == 'external' or link_class == 'navlink':
+ nofollow = 'rel="nofollow" '
+
+ return '<a class="%s" %shref="%s">%s</a>' % (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 '<video controls="1" src="%s">Your browser does not support the HTML5 video tag</video>' % url
+ elif image_re.match(name):
+ return '<a href="%s"><img border="0" src="%s" alt="%s" /></a>' % (url, url + url_args(kvargs), descr)
+ elif file_re.match(name) and not ext_re.search(name): # FIXME: this guesses a wiki page
+ return Page(name).send_naked()