]> de.git.xonotic.org Git - xonotic/xonstat.git/blob - xonstat/util.py
Move page_url() to util.
[xonotic/xonstat.git] / xonstat / util.py
1 import re
2
3 def strip_colors(str=None):
4     str = re.sub(r'\^x\w\w\w', '', str)
5     str = re.sub(r'\^\d', '', str)
6     return str
7
8 def html_colors(str=None):
9     orig = str
10     str = re.sub(r'\^x(\w)(\w)(\w)', 
11             "<span style='color:#\g<1>\g<1>\g<2>\g<2>\g<3>\g<3>'>", str)
12     str = re.sub(r'\^1', "<span style='color:#FF9900'>", str)
13     str = re.sub(r'\^2', "<span style='color:#33FF00'>", str)
14     str = re.sub(r'\^3', "<span style='color:#FFFF00'>", str)
15     str = re.sub(r'\^4', "<span style='color:#3366FF'>", str)
16     str = re.sub(r'\^5', "<span style='color:#33FFFF'>", str)
17     str = re.sub(r'\^6', "<span style='color:#FF3366'>", str)
18     str = re.sub(r'\^7', "<span style='color:#FFFFFF'>", str)
19     str = re.sub(r'\^8', "<span style='color:#999999'>", str)
20     str = re.sub(r'\^9', "<span style='color:#666666'>", str)
21     str = re.sub(r'\^0', "<span style='color:#333333'>", str)
22
23     for span in range(len(re.findall(r'\^x\w\w\w|\^\d', orig))):
24         str += "</span>"
25
26     return str
27
28 def page_url(page):
29     return current_route_url(request, page=page, _query=request.GET)