From: Michael Tremer Date: Sun, 8 Feb 2026 16:26:46 +0000 (+0000) Subject: dbl: Move the sources to the main page X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=212b12eece9abe14d2709d1ab19a0f40a908365b;p=ipfire.org.git dbl: Move the sources to the main page Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index a19acbaf..b4954ae1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -202,13 +202,13 @@ templates_dbl_lists_DATA = \ src/templates/dbl/lists/domain.html \ src/templates/dbl/lists/history.html \ src/templates/dbl/lists/reports.html \ - src/templates/dbl/lists/sources.html \ src/templates/dbl/lists/show.html templates_dbl_listsdir = $(templates_dbldir)/lists templates_dbl_modules_DATA = \ src/templates/dbl/modules/lists.html \ + src/templates/dbl/modules/sources.html \ src/templates/dbl/modules/submit-report.html templates_dbl_modulesdir = $(templates_dbldir)/modules diff --git a/src/templates/dbl/lists/show.html b/src/templates/dbl/lists/show.html index a5c68f20..4d0151c9 100644 --- a/src/templates/dbl/lists/show.html +++ b/src/templates/dbl/lists/show.html @@ -91,14 +91,6 @@ - - - - - - {{ _("Sources") }} - - @@ -109,4 +101,17 @@ + + {# Sources #} + {% if sources %} +
+
+

+ {{ _("Sources") }} +

+ + {% module DBLSources(sources) %} +
+
+ {% end %} {% end block %} diff --git a/src/templates/dbl/lists/sources.html b/src/templates/dbl/lists/sources.html deleted file mode 100644 index efd52956..00000000 --- a/src/templates/dbl/lists/sources.html +++ /dev/null @@ -1,123 +0,0 @@ -{% extends "../../base.html" %} - -{% block head %} - {% module OpenGraph( - title=_("IPFire DBL - %s - Sources") % list, - description=list.description, - ) %} -{% end block %} - -{% block title %}{{ _("IPFire DBL") }} - {{ list }} - {{ _("Sources") }}{% end block %} - -{% block container %} -
- -
- -
-
-
{{ _("Sources") }}
- - - - - - - - - - - - - - - - - - {% for source in sorted(sources) %} - - - - - - {# Total Domains #} - - - {# False Positives #} - - - {# Dead Domains #} - - - {% end %} - -
- {{ _("Name") }} - - {{ _("Last Update") }} - - {{ _("Listed Domains") }} - - {{ _("False Positives") }} - - {{ _("Dead Domains") }} -
- - {{ source.name }} - - -
- - - {{ source.license }} - -
- {{ locale.format_date(source.updated_at, shorter=True) }} - - {{ format_number(source.total_domains) }} - - {{ format_number(source.false_positives) }} - - {% if source.total_domains and source.dead_domains %} - {{ format_percent(source.dead_domains / source.total_domains) }} - {% else %} - - {{ _("N/A") }} - - {% end %} -
-
-
-{% end block %} diff --git a/src/templates/dbl/modules/sources.html b/src/templates/dbl/modules/sources.html new file mode 100644 index 00000000..98513d79 --- /dev/null +++ b/src/templates/dbl/modules/sources.html @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + {% for source in sorted(sources) %} + + + + + + {# Total Domains #} + + + {# False Positives #} + + + {# Dead Domains #} + + + {% end %} + +
+ {{ _("Name") }} + + {{ _("Last Update") }} + + {{ _("Listed Domains") }} + + {{ _("False Positives") }} + + {{ _("Dead Domains") }} +
+ + {{ source.name }} + + +
+ + + {{ source.license }} + +
+ {{ locale.format_date(source.updated_at, shorter=True) }} + + {{ format_number(source.total_domains) }} + + {{ format_number(source.false_positives) }} + + {% if source.total_domains and source.dead_domains %} + {{ format_percent(source.dead_domains / source.total_domains) }} + {% else %} + + {{ _("N/A") }} + + {% end %} +
diff --git a/src/web/__init__.py b/src/web/__init__.py index 065e9bfd..064b12a6 100644 --- a/src/web/__init__.py +++ b/src/web/__init__.py @@ -86,6 +86,7 @@ class Application(tornado.web.Application): # DBL "DBLLists" : dbl.ListsModule, + "DBLSources" : dbl.SourcesModule, "DBLSubmitReport" : dbl.SubmitReportModule, # Docs @@ -224,7 +225,6 @@ class Application(tornado.web.Application): (r"/dbl/lists/([\w\-]+)/domains/(.*)", dbl.ListDomainHandler), (r"/dbl/lists/([\w\-]+)/history", dbl.ListHistoryHandler), (r"/dbl/lists/([\w\-]+)/reports", dbl.ListReportsHandler), - (r"/dbl/lists/([\w\-]+)/sources", dbl.ListSourcesHandler), (r"/dbl/report", dbl.SubmitReportHandler), (r"/dbl/reports/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})", dbl.ReportHandler), (r"/dbl/search", dbl.SearchHandler), diff --git a/src/web/dbl.py b/src/web/dbl.py index e1b56fc5..122f1522 100644 --- a/src/web/dbl.py +++ b/src/web/dbl.py @@ -42,8 +42,11 @@ class ListHandler(base.AnalyticsMixin, BaseHandler): if not list: raise tornado.web.HTTPError(404, "Could not find list '%s'" % slug) + # Fetch the sources + sources = await list.get_sources() + # Render the page - self.render("dbl/lists/show.html", list=list) + self.render("dbl/lists/show.html", list=list, sources=sources) class ListHistoryHandler(base.AnalyticsMixin, BaseHandler): @@ -77,20 +80,6 @@ class ListReportsHandler(base.AnalyticsMixin, BaseHandler): self.render("dbl/lists/reports.html", list=list, reports=reports) -class ListSourcesHandler(base.AnalyticsMixin, BaseHandler): - async def get(self, slug): - # Fetch the list - list = await self.backend.dbl.get_list(slug) - if not list: - raise tornado.web.HTTPError(404, "Could not find list '%s'" % slug) - - # Fetch the sources - sources = await list.get_sources() - - # Render the page - self.render("dbl/lists/sources.html", list=list, sources=sources) - - class ListDomainHandler(base.AnalyticsMixin, BaseHandler): async def get(self, slug, name): # Fetch the list @@ -209,6 +198,11 @@ class ListsModule(ui_modules.UIModule): return self.render_string("dbl/modules/lists.html", lists=lists) +class SourcesModule(ui_modules.UIModule): + def render(self, sources): + return self.render_string("dbl/modules/sources.html", sources=sources) + + class SubmitReportModule(ui_modules.UIModule): def render(self, name, blocked=False, list=None): args = {