mirror of
https://github.com/sileht/bird-lg.git
synced 2024-12-22 20:44:43 +01:00
Add some link
This commit is contained in:
parent
3776c8bf34
commit
cd4b763523
5
lg.py
5
lg.py
|
@ -29,13 +29,16 @@ def add_links(text):
|
|||
|
||||
ret_text = []
|
||||
for line in text:
|
||||
# Some heuristic to create link
|
||||
if line.strip().startswith("BGP.as_path:") or \
|
||||
line.strip().startswith("Neighbor AS:") :
|
||||
ret_text.append(re.sub(r'(\d+)',r'<a href="/whois/\1" class="whois">\1</a>',line))
|
||||
else:
|
||||
line = re.sub(r'([a-zA-Z0-9\-]*\.([a-zA-Z]{2,3}){1,2})(\s|$)', r'<a href="/whois/\1" class="whois">\1</a>',line)
|
||||
line = re.sub(r'([a-zA-Z0-9\-]*\.([a-zA-Z]{2,3}){1,2})(\s|$)', r'<a href="/whois/\1" class="whois">\1</a>\2',line)
|
||||
line = re.sub(r'AS(\d+)', r'<a href="/whois/\1" class="whois">AS\1</a>',line)
|
||||
line = re.sub(r'(\d+\.\d+\.\d+\.\d+)', r'<a href="/whois/\1" class="whois">\1</a>',line)
|
||||
hosts = "/".join(request.path.split("/")[2:])
|
||||
line = re.sub(r'\[(\w+)\s+((|\d\d\d\d-\d\d-\d\d\s)(|\d\d:)\d\d:\d\d|\w\w\w\d\d)\]', r'[<a href="/detail/%s?q=\1">\1</a> \2]' % hosts, line)
|
||||
ret_text.append(line)
|
||||
return "\n".join(ret_text)
|
||||
|
||||
|
|
Loading…
Reference in a new issue