]>
Commit | Line | Data |
---|---|---|
940227cb MT |
1 | #!/usr/bin/python |
2 | ||
3 | import socket | |
4 | import tornado.web | |
5 | ||
6 | from handlers_base import * | |
7 | ||
8 | class MirrorIndexHandler(BaseHandler): | |
9 | def get(self): | |
10 | mirrors = self.mirrors.list() | |
11 | ||
12 | self.render("mirrors.html", mirrors=mirrors) | |
13 | ||
14 | ||
15 | class MirrorItemHandler(BaseHandler): | |
16 | def get(self, id): | |
17 | mirror = self.mirrors.get(id) | |
18 | if not mirror: | |
19 | raise tornado.web.HTTPError(404) | |
20 | ||
21 | ip = socket.gethostbyname(mirror.hostname) | |
22 | mirror.location = self.geoip.get_all(ip) | |
23 | ||
24 | # Shortcut for coordiantes | |
25 | mirror.coordiantes = "%s,%s" % \ | |
26 | (mirror.location.latitude, mirror.location.longitude) | |
27 | ||
28 | # Nice string for the user | |
29 | mirror.location_str = mirror.location.country_code | |
30 | if mirror.location.city: | |
31 | mirror.location_str = "%s, %s" % \ | |
32 | (mirror.location.city, mirror.location_str) | |
33 | ||
34 | self.render("mirrors-item.html", item=mirror) | |
35 | ||
36 | ||
37 | class MirrorHandler(BaseHandler): | |
38 | def get(self): | |
39 | self.redirect("mirrors/all") | |
40 | ||
41 | ||
42 | class MirrorAllHandler(BaseHandler): | |
43 | def get(self): | |
44 | self.render("downloads-mirrors.html", mirrors=self.mirrors.list()) | |
45 | ||
46 | ||
47 | class MirrorDetailHandler(BaseHandler): | |
48 | def get(self, id): | |
49 | self.render("download-mirror-detail.html", mirror=self.mirrors.get(id)) |