From: Michael Tremer Date: Wed, 22 Jan 2025 18:23:52 +0000 (+0000) Subject: mirrors: Add filter to show the name of an ASN X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7dba43b913e6e6b7475a40a0b87b2ece8c6525db;p=pbs.git mirrors: Add filter to show the name of an ASN Signed-off-by: Michael Tremer --- diff --git a/src/templates/mirrors/show.html b/src/templates/mirrors/show.html index 3c1f29ec..f9194b46 100644 --- a/src/templates/mirrors/show.html +++ b/src/templates/mirrors/show.html @@ -48,7 +48,7 @@

{{ _("Autonomous System") }}

- {{ mirror.asn }} + {{ mirror.asn | format_asn }}

diff --git a/src/web/base.py b/src/web/base.py index 58715242..1cc9bc53 100644 --- a/src/web/base.py +++ b/src/web/base.py @@ -282,6 +282,7 @@ class BaseHandler(tornado.web.RequestHandler): "email_name" : filters.email_name, "enumerate" : filters._enumerate, "file_mode" : filters.file_mode, + "format_asn" : filters.format_asn, "format_date" : filters.format_date, "format_day" : filters.format_day, "format_time" : filters.format_time, diff --git a/src/web/filters.py b/src/web/filters.py index 8bcf3082..b7f39acb 100644 --- a/src/web/filters.py +++ b/src/web/filters.py @@ -61,6 +61,15 @@ def file_mode(mode): """ return stat.filemode(mode) +@jinja2.pass_context +def format_asn(ctx, asn): + backend = ctx.get("backend") + + # Lookup the Autonomous System + o = backend.mirrors.location.get_as(asn) + + return "%s" % (o or asn) + @jinja2.pass_context def format_date(ctx, *args, **kwargs): # Fetch locale