]> git.ipfire.org Git - ipfire.org.git/commitdiff
mirrors: Move into download section
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 27 Nov 2020 19:36:00 +0000 (19:36 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 27 Nov 2020 19:36:00 +0000 (19:36 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/static/js/maps.js
src/templates/base.html
src/templates/download/mirror.html [new file with mode: 0644]
src/templates/download/mirrors.html [new file with mode: 0644]
src/templates/mirrors/index.html [deleted file]
src/templates/mirrors/mirror.html [deleted file]
src/web/__init__.py
src/web/download.py
src/web/mirrors.py [deleted file]

index 39c9534615a20843efb84dbb88b1f900ff048a98..e956c7d0d2bcec88c45ab98e92eb84ae3901a468 100644 (file)
@@ -90,7 +90,6 @@ web_PYTHON = \
        src/web/handlers.py \
        src/web/iuse.py \
        src/web/location.py \
-       src/web/mirrors.py \
        src/web/nopaste.py \
        src/web/people.py \
        src/web/ui_modules.py \
@@ -193,6 +192,8 @@ templates_donate_messages_DATA = \
 templates_donate_messagesdir = $(templates_donatedir)/messages
 
 templates_download_DATA = \
+       src/templates/download/mirror.html \
+       src/templates/download/mirrors.html \
        src/templates/download/release.html \
        src/templates/download/thank-you.html
 
@@ -234,12 +235,6 @@ templates_messages_DATA = \
 
 templates_messagesdir = $(templatesdir)/messages
 
-templates_mirrors_DATA = \
-       src/templates/mirrors/index.html \
-       src/templates/mirrors/mirror.html
-
-templates_mirrorsdir = $(templatesdir)/mirrors
-
 templates_modules_DATA = \
        src/templates/modules/christmas-banner.html \
        src/templates/modules/map.html \
index 94b8ff32c1d38e602b76de05d51a57a72d842555..82a2520036e07f94f95fdafaa21bbb4b7f402aea 100644 (file)
@@ -3,7 +3,7 @@ $(function() {
                var map = L.map(this);
 
                // Add the map provider
-               var layer = L.tileLayer("https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png", {
+               var layer = L.tileLayer("https://a.tile.openstreetmap.org/{z}/{x}/{y}.png", {
                        attribution: "&copy; <a href=\"https://osm.org/copyright\">OpenStreetMap</a> contributors"
                }).addTo(map);
 
index 466688f5304f9a5c66bf6fcda020a8f187cb1255..d49e6c1caa00dc34ff102bf31bbd636b0054cd2f 100644 (file)
@@ -35,8 +35,6 @@
                                                        {{ _("Fireinfo") }}
                                                {% elif hostname == "location.ipfire.org" %}
                                                        {{ _("Location") }}
-                                               {% elif hostname == "mirrors.ipfire.org" %}
-                                                       {{ _("Mirrors") }}
                                                {% elif hostname == "wiki.ipfire.org" %}
                                                        {{ _("Wiki") }}
                                                {% end %}
diff --git a/src/templates/download/mirror.html b/src/templates/download/mirror.html
new file mode 100644 (file)
index 0000000..4912277
--- /dev/null
@@ -0,0 +1,76 @@
+{% extends "../base.html" %}
+
+{% block title %}{{ _("Mirror %s") % mirror }}{% end block %}
+
+{% block container %}
+       <div class="header">
+               <div class="container">
+                       <h1>{{ mirror }}</h1>
+
+                       <p class="text-muted">
+                               {% if mirror.owner %}
+                                       {{ _("by %s") % mirror.owner }}
+                               {% end %}
+
+                               {% if mirror.country %}                         
+                                       {{ _("in %s") % mirror.country.name }}
+                               {% end %}
+                       </p>
+               </div>
+       </div>
+
+       <div class="container">
+               <section>
+                       <div class="row justify-content-center">
+                               <div class="col-12 col-lg-10">
+                                       <div class="card mb-4">
+                                               <div class="card-img-top">
+                                                       {% module Map(mirror.country.name) %}
+                                               </div>
+
+                                               {% if mirror.asn %}
+                                                       <div class="card-body">
+                                                               <dl class="mb-0">
+                                                                       <dt>{{ _("Autonomous System") }}</dt>
+                                                                       <dd>{{ mirror.address.autonomous_system or "AS%s" % mirror.asn }}</dd>
+                                                               </dl>
+                                                       </div>
+                                               {% end %}
+
+                                               <ul class="list-group list-group-flush">
+                                                       {% if mirror.state == "UP" %}
+                                                               <li class="list-group-item list-group-item-success flex-column align-items-start">
+                                                                       <p class="mb-1">{{ _("The mirror is up") }}</p>
+
+                                                                       <small class="text-muted">
+                                                                               {{ _("Last updated %s") % locale.format_date(mirror.last_update) }}
+                                                                       </small>
+                                                               </li>
+                                                       {% elif mirror.state == "DOWN" %}
+                                                               <li class="list-group-item list-group-item-danger flex-column align-items-start">
+                                                                       <p class="mb-1">{{ _("The mirror is down") }}</p>
+
+                                                                       <small class="text-muted">
+                                                                               {{ _("Last updated %s") % locale.format_date(mirror.last_update) }}
+                                                                       </small>
+                                                               </li>
+                                                       {% elif mirror.state == "OUTOFSYNC" %}
+                                                               <li class="list-group-item list-group-item-warning flex-column align-items-start">
+                                                                       <p class="mb-1">{{ _("The mirror is out of sync") }}</p>
+
+                                                                       <small class="text-muted">
+                                                                               {{ _("Last updated %s") % locale.format_date(mirror.last_update) }}
+                                                                       </small>
+                                                               </li>
+                                                       {% end %}
+                                               </ul>
+                                       </div>
+
+                                       <a class="btn btn-primary btn-block" href="{{ mirror.url }}">
+                                               {{ _("Browse Mirror") }} <span class="fas fa-external-link-alt ml-2"></span>
+                                       </a>
+                               </div>
+                       </div>
+               </section>
+       </div>
+{% end block %}
diff --git a/src/templates/download/mirrors.html b/src/templates/download/mirrors.html
new file mode 100644 (file)
index 0000000..ba4cdf0
--- /dev/null
@@ -0,0 +1,55 @@
+{% extends "../base.html" %}
+
+{% block title %}{{ _("Mirrors") }}{% end block %}
+
+{% block container %}
+       {% set total = sum((len(m) for c, m in mirrors.items())) %}
+
+       <div class="header">
+               <div class="container">
+                       <h1>{{ _("Mirrors") }}</h1>
+               </div>
+       </div>
+
+       <div class="container">
+               <section>
+                       <h4 class="text-center">
+                               {{ _("We are currently running %s mirror servers worldwide") % total }}
+                       </h4>
+               </section>
+
+               <section>
+                       <div class="row justify-content-center">
+                               <div class="col-12 col-lg-6">
+                                       {% for country in sorted(mirrors, key=lambda c: c.name) %}
+                                               <a name="{{ country.alpha2 }}"></a>
+                                               <div class="my-4 d-flex justify-content-between">
+                                                       <div>
+                                                               <h4 class="mb-0">{{ country.name }}</h4>
+                                                               <span class="small text-muted">
+                                                                       {{ _("One Mirror", "%(num)s Mirrors", len(mirrors[country])) % { "num" : len(mirrors[country]) } }}
+                                                               </span>
+                                                       </div>
+
+                                                       <h4 class="flag-icon flag-icon-{{ country.alpha2.lower() }}"></h4>
+                                               </div>
+
+                                               <div class="list-group">
+                                                       {% for m in mirrors[country] %}
+                                                               <a href="/download/mirrors/{{ m.hostname }}" class="list-group-item list-group-item-action
+                                                                               list-group-item-{% if m.state == "UP" %}success{% elif m.state == "DOWN" %}danger{% else %}warning{% end %}
+                                                                               flex-column align-items-start">
+                                                                       <h5 class="mb-1">{{ m.hostname }}</h5>
+
+                                                                       {% if m.owner %}
+                                                                               <p class="mb-0 text-truncate text-muted">{{ m.owner }}</p>
+                                                                       {% end %}
+                                                               </a>
+                                                       {% end %}
+                                               </div>
+                                       {% end %}
+                               </div>
+                       </div>
+               </section>
+       </div>
+{% end block %}
diff --git a/src/templates/mirrors/index.html b/src/templates/mirrors/index.html
deleted file mode 100644 (file)
index ad358c7..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-{% extends "../base.html" %}
-
-{% block title %}{{ _("Mirrors") }}{% end block %}
-
-{% block content %}
-       {% set total = sum((len(m) for c, m in mirrors.items())) %}
-
-       <h4 class="my-5 text-muted text-center">
-               {{ _("We are currently running %s mirror servers") % total }}
-       </h4>
-
-       {% set countries = sorted(mirrors, key=lambda c: c.name) %}
-
-       <div class="row justify-content-center">
-               <div class="col-12 col-md-6">
-                       {% for country in countries %}
-                               <a name="{{ country.alpha2 }}"></a>
-                               <div class="my-4 d-flex justify-content-between ">
-                                       <div>
-                                               <h4 class="mb-0">{{ country.name }}</h4>
-                                               <span class="small text-muted">
-                                                       {{ _("One Mirror", "%(num)s Mirrors", len(mirrors[country])) % { "num" : len(mirrors[country]) } }}
-                                               </span>
-                                       </div>
-
-                                       <h4 class="flag-icon flag-icon-{{ country.alpha2.lower() }}"></h4>
-                               </div>
-
-                               <div class="list-group">
-                                       {% for m in mirrors[country] %}
-                                               <a href="/mirrors/{{ m.hostname }}" class="list-group-item list-group-item-action
-                                                               list-group-item-{% if m.state == "UP" %}success{% elif m.state == "DOWN" %}danger{% else %}warning{% end %}
-                                                               flex-column align-items-start">
-                                                       <h5 class="mb-1">{{ m.hostname }}</h5>
-
-                                                       {% if m.owner %}
-                                                               <p class="mb-0 text-truncate text-muted">{{ m.owner }}</p>
-                                                       {% end %}
-                                               </a>
-                                       {% end %}
-                               </div>
-                       {% end %}
-               </div>
-       </div>
-{% end block %}
diff --git a/src/templates/mirrors/mirror.html b/src/templates/mirrors/mirror.html
deleted file mode 100644 (file)
index 71c31d8..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-{% extends "../base.html" %}
-
-{% block title %}{{ _("Mirror %s") % mirror }}{% end block %}
-
-{% block content %}
-       <section>
-               <div class="container">
-                       <h1 class="mb-0">{{ mirror }}</h1>
-
-                       {% if mirror.owner %}
-                               <p>{{ _("by %s") % mirror.owner }}</p>
-                       {% end %}
-               </div>
-       </section>
-
-       <div class="row justify-content-center">
-               <div class="col-12 col-md-6">
-                       <div class="card mb-4">
-                               {# <div class="card-img-top">
-                                       {% module Map() %}
-                               </div> #}
-
-                               <div class="card-body">
-                                       <dl class="mb-0">
-                                               {% if mirror.asn %}
-                                                       <dt>{{ _("Autonomous System") }}</dt>
-                                                       <dd>{{ mirror.address.autonomous_system or "AS%s" % mirror.asn }}</dd>
-                                               {% end %}
-
-                                               <dt>{{ _("Country") }}</dt>
-                                               <dd>{{ mirror.country.name }}</dd>
-                                       </dl>
-                               </div>
-
-                               <ul class="list-group list-group-flush">
-                                       {% if mirror.state == "UP" %}
-                                               <li class="list-group-item list-group-item-success flex-column align-items-start">
-                                                       <p class="mb-1">{{ _("The mirror is up") }}</p>
-
-                                                       <small class="text-muted">
-                                                               {{ _("Last updated %s") % locale.format_date(mirror.last_update) }}
-                                                       </small>
-                                               </li>
-                                       {% elif mirror.state == "DOWN" %}
-                                               <li class="list-group-item list-group-item-danger flex-column align-items-start">
-                                                       <p class="mb-1">{{ _("The mirror is down") }}</p>
-
-                                                       <small class="text-muted">
-                                                               {{ _("Last updated %s") % locale.format_date(mirror.last_update) }}
-                                                       </small>
-                                               </li>
-                                       {% elif mirror.state == "OUTOFSYNC" %}
-                                               <li class="list-group-item list-group-item-warning flex-column align-items-start">
-                                                       <p class="mb-1">{{ _("The mirror is out of sync") }}</p>
-
-                                                       <small class="text-muted">
-                                                               {{ _("Last updated %s") % locale.format_date(mirror.last_update) }}
-                                                       </small>
-                                               </li>
-                                       {% end %}
-                               </ul>
-                       </div>
-
-                       <a class="btn btn-primary btn-block" href="{{ mirror.url }}">
-                               {{ _("Browse Mirror") }} <span class="fas fa-external-link-alt ml-2"></span>
-                       </a>
-               </div>
-       </div>
-{% end block %}
index 651d4de7f984408f61feafba7e0570b469f2378e..32bade619944e1dd37b1dc6e04c8dbae42443b3c 100644 (file)
@@ -22,7 +22,6 @@ from . import download
 from . import fireinfo
 from . import iuse
 from . import location
-from . import mirrors
 from . import nopaste
 from . import people
 from . import ui_modules
@@ -133,6 +132,8 @@ class Application(tornado.web.Application):
                        # Download sites
                        (r"/downloads", tornado.web.RedirectHandler, { "url" : "/download" }),
                        (r"/download", download.IndexHandler),
+                       (r"/download/mirrors", download.MirrorsHandler),
+                       (r"/download/mirrors/([0-9a-z\-\.]+)", download.MirrorHandler),
                        (r"/download/thank-you", download.ThankYouHandler),
                        (r"/download/([0-9a-z\-\.]+)", download.ReleaseHandler),
 
@@ -180,9 +181,9 @@ class Application(tornado.web.Application):
                ])
 
                # mirrors.ipfire.org
-               self.add_handlers(r"^mirrors\.ipfire\.rocks", [
-                       (r"/", mirrors.IndexHandler),
-                       (r"/mirrors/(.*)", mirrors.MirrorHandler),
+               self.add_handlers(r"^mirrors\.ipfire\.org", [
+                       (r"/", tornado.web.RedirectHandler, { "url" : "https://www.ipfire.org/download/mirrors" }),
+                       (r"/mirrors/(.*)", tornado.web.RedirectHandler, { "url" : "https://www.ipfire.org/download/mirrors/{0}" }),
                ])
 
                # planet.ipfire.org
index 3f58579aa66a6efe372cd6fab42295a63626f7a6..26a1a9683933ca940f63c7eb1b8c31f55c99d5f5 100644 (file)
@@ -18,6 +18,24 @@ class IndexHandler(base.BaseHandler):
                self.redirect("/download/%s" % release.slug)
 
 
+class MirrorsHandler(base.BaseHandler):
+       def get(self):
+               mirrors = self.backend.mirrors.get_by_countries()
+               if not mirrors:
+                       raise tornado.web.HTTPError(404)
+
+               self.render("download/mirrors.html", mirrors=mirrors)
+
+
+class MirrorHandler(base.BaseHandler):
+       def get(self, hostname):
+               mirror = self.backend.mirrors.get_by_hostname(hostname)
+               if not mirror:
+                       raise tornado.web.HTTPError(404, "Could not find %s" % hostname)
+
+               self.render("download/mirror.html", mirror=mirror)
+
+
 class ReleaseHandler(base.BaseHandler):
        def get(self, slug):
                release = self.backend.releases.get_by_sname(slug)
diff --git a/src/web/mirrors.py b/src/web/mirrors.py
deleted file mode 100644 (file)
index 6c7c273..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/usr/bin/python
-
-import tornado.web
-
-from . import base
-
-class IndexHandler(base.BaseHandler):
-       def get(self):
-               mirrors = self.backend.mirrors.get_by_countries()
-               if not mirrors:
-                       raise tornado.web.HTTPError(404)
-
-               self.render("mirrors/index.html", mirrors=mirrors)
-
-
-class MirrorHandler(base.BaseHandler):
-       def get(self, hostname):
-               mirror = self.mirrors.get_by_hostname(hostname)
-               if not mirror:
-                       raise tornado.web.HTTPError(404, "Could not find %s" % hostname)
-
-               self.render("mirrors/mirror.html", mirror=mirror)