src/web/handlers_mirrors.py \
src/web/handlers_nopaste.py \
src/web/handlers_talk.py \
+ src/web/location.py \
src/web/ui_modules.py
webdir = $(backenddir)/web
templates_blog_modulesdir = $(templates_blogdir)/modules
+templates_location_DATA = \
+ src/templates/location/lookup.html
+
+templates_locationdir = $(templatesdir)/location
+
templates_modules_DATA = \
+ src/templates/modules/map.html \
src/templates/modules/menu.html
templates_modulesdir = $(templatesdir)/modules
+++ /dev/null
-{% extends "../base.html" %}
-
-{% block title %}{{ _("GeoIP for %s") % addr }}{% end block %}
-
-{% block body %}
-<div class="container">
- <section class="features-content col-12">
- <h2 class="display-2 text-center">{{ _("GeoIP for %s") % addr }}</h2>
-
- {% if peer %}
- <div class="row">
- <div class="col-lg-4 col-md-4">
- <dl>
- {% if peer.asn %}
- <dt>{{ _("Autonomous System") }}</dt>
- <dd>{{ peer.asn }}</dd>
- {% end %}
-
- <dt>{{ _("Country") }}</dt>
- <dd>
- {% if peer.country_name %}
- {{ peer.country_name }} ({{ peer.country }})
- {% else %}
- {{ peer.country_name }}
- {% end %}
- </dd>
-
- {% if peer.city %}
- <dt>{{ _("City") }}</dt>
- <dd>{{ peer.city }}</dd>
-
- {% if peer.postal_code %}
- <dt>{{ _("Postal Code") }}</dt>
- <dd>{{ peer.postal_code }}</dd>
- {% end %}
- {% end %}
- </dl>
-
- {% if mirrors %}
- <h4>{{ _("Preferred Mirrors") }}</h4>
-
- <ul>
- {% for mirror in mirrors %}
- <li>
- <a href="https://mirrors.ipfire.org/mirror/{{ mirror.hostname }}">
- {{ mirror.hostname }}
- </a>
- <span class="pull-right">
- {{ _("%.0f km") % mirror.distance_to(peer) }}
- </span>
- </li>
- {% end %}
- </ul>
- {% end %}
- </div>
-
- <div class="col-lg-8 col-md-8">
- {% module Map(peer.latitude, peer.longitude) %}
- </div>
- </div>
- {% else %}
- <div class="alert alert-info">
- <p>{{ _("No GeoIP information could be found for the IP address '%s'.") % addr }}</p>
- </div>
- {% end %}
- </section>
-</div>
-
-{% end block %}
--- /dev/null
+{% extends "../base.html" %}
+
+{% block title %}{{ _("Location of %s") % address }}{% end block %}
+
+{% block content %}
+ <h1 class="text-center mt-5 mb-5">{{ _("Location of %s") % address }}</h1>
+
+ <div class="row justify-content-center">
+ <div class="col-12 col-md-6">
+ <div class="card">
+ {% if peer and peer.latitude and peer.longitude %}
+ <div class="card-img-top">
+ {% module Map(peer.latitude, peer.longitude) %}
+ </div>
+ {% end %}
+
+ <div class="card-body">
+ <dl>
+ <dt>{{ _("Country") }}</dt>
+ <dd>
+ {% if peer %}
+ {% if peer.country_name %}
+ {{ peer.country_name }} ({{ peer.country }})
+ {% else %}
+ {{ peer.country_name }}
+ {% end %}
+ {% else %}
+ <span class="text-muted">{{ _("Unkown") }}</span>
+ {% end %}
+ </dd>
+
+ {% if peer and peer.asn %}
+ <dt>{{ _("Autonomous System") }}</dt>
+ <dd>{{ peer.asn }}</dd>
+ {% end %}
+ </dl>
+ </div>
+ </div>
+ </div>
+ </div>
+{% end block %}
-<iframe width="100%" height="500" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"
- src="https://www.openstreetmap.org/export/embed.html?bbox={{ longitude - 4 }},{{ latitude - 4 }},{{ longitude + 4 }},{{ latitude + 4 }}&layer=mapquest&marker={{ latitude }},{{ longitude }}" style="border: 1px solid black">
+<iframe width="100%" height="400" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"
+ src="https://www.openstreetmap.org/export/embed.html?bbox={{ longitude - 4 }},{{ latitude - 4 }},{{ longitude + 4 }},{{ latitude + 4 }}&layer=mapquest&marker={{ latitude }},{{ longitude }}">
</iframe>
-<p>
- <a href="https://www.openstreetmap.org/?lat={{ latitude }}&lon={{ longitude }}&zoom=8&layers=M&mlat={{ latitude }}&mlon={{ longitude }}" target="_blank">{{ _("View larger map") }}</a>
- -
- © <a href="https://www.openstreetmap.org/" target="_blank">OpenStreetMap</a> contributors, CC-BY-SA
- <span class="pull-right">
- {% if latitude >= 0 %}
- {{ latitude }} N,
- {% else %}
- {{ -latitude }} S,
- {% end %}
- {% if longitude >= 0 %}
- {{ longitude }} E
- {% else %}
- {{ -longitude }} W
- {% end %}
- </span>
-</p>
from ui_modules import *
from . import blog
+from . import location
BASEDIR = os.path.join(os.path.dirname(__file__), "..")
"format_month_name" : self.format_month_name,
},
"ui_modules" : {
+ # Blog
"BlogHistoryNavigation": blog.HistoryNavigationModule,
"BlogList" : blog.ListModule,
"BlogPost" : blog.PostModule,
"BlogPosts" : blog.PostsModule,
+ # Location
+ "Map" : MapModule,
+
# Old modules
"Advertisement" : AdvertisementModule,
"DonationBox" : DonationBoxModule,
"DonationInputBox" : DonationInputBoxModule,
"DownloadButton" : DownloadButtonModule,
"LanguageName" : LanguageNameModule,
- "Map" : MapModule,
"Menu" : MenuModule,
"MirrorItem" : MirrorItemModule,
"MirrorsTable" : MirrorsTableModule,
(r"/view/(.*)", NopasteViewHandler),
] + authentication_handlers)
+ # location.ipfire.org
+ self.add_handlers(r"location(\.dev)?\.ipfire\.org", [
+ (r"/", location.IndexHandler),
+ (r"/lookup/(.+)", location.LookupHandler),
+ ])
+
# geoip.ipfire.org
self.add_handlers(r"geoip(\.dev)?\.ipfire\.org", [
- (r"/", GeoIPHandler),
+ (r"/", tornado.web.RedirectHandler, { "url" : "https://location.ipfire.org/" }),
])
# talk.ipfire.org
latest_release=latest_release,
fireinfo_country=self.fireinfo.get_random_country_penetration())
-class GeoIPHandler(BaseHandler):
- def get_address(self):
- addr = self.get_argument("addr", None)
-
- if not addr:
- addr = self.get_remote_ip()
-
- return addr
-
- def get(self):
- addr = self.get_address()
-
- peer = self.geoip.get_all(addr)
- if peer:
- peer["country_name"] = self.geoip.get_country_name(peer.country)
-
- mirrors = self.mirrors.get_for_location(peer)
-
- self.render("geoip/index.html", addr=addr, peer=peer, mirrors=mirrors)
-
class DonateHandler(BaseHandler):
def get(self):
--- /dev/null
+
+#!/usr/bin/python
+
+import tornado.web
+
+import handlers_base as base
+
+class IndexHandler(base.BaseHandler):
+ def get(self):
+ self.redirect("/lookup/%s" % self.get_remote_ip())
+
+
+class LookupHandler(base.BaseHandler):
+ def get(self, address):
+ peer = self.geoip.get_all(address)
+ if peer:
+ peer["country_name"] = self.geoip.get_country_name(peer.country)
+
+ self.render("location/lookup.html", address=address, peer=peer)