]> git.ipfire.org Git - ipfire.org.git/commitdiff
dbl: Move the sources to the main page
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 8 Feb 2026 16:26:46 +0000 (16:26 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 8 Feb 2026 16:26:46 +0000 (16:26 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/templates/dbl/lists/show.html
src/templates/dbl/lists/sources.html [deleted file]
src/templates/dbl/modules/sources.html [new file with mode: 0644]
src/web/__init__.py
src/web/dbl.py

index a19acbaf6cb8dbb2db3563a0c98c17a70a06d378..b4954ae19554508b16e8e89fcd1b2f54402e06db 100644 (file)
@@ -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
index a5c68f20eace8abed5ee862bb3811e1f5a6c9abf..4d0151c96a5ad88fca75b19d094036b2832c7f51 100644 (file)
                                        </span>
                                </a>
 
-                               <a class="button" href="/dbl/lists/{{ list.slug }}/sources">
-                                       <span class="icon is-small">
-                                               <i class="fas fa-code-pull-request" aria-hidden="true"></i>
-                                       </span>
-
-                                       <span>{{ _("Sources") }}</span>
-                               </a>
-
                                <a class="button" href="/dbl/lists/{{ list.slug }}/history">
                                        <span class="icon is-small">
                                                <i class="fas fa-list-check" aria-hidden="true"></i>
                        </div>
                </div>
        </section>
+
+       {# Sources #}
+       {% if sources %}
+               <section class="section" id="sources">
+                       <div class="container">
+                               <h4 class="title is-4">
+                                       {{ _("Sources") }}
+                               </h4>
+
+                               {% module DBLSources(sources) %}
+                       </div>
+               </section>
+       {% end %}
 {% end block %}
diff --git a/src/templates/dbl/lists/sources.html b/src/templates/dbl/lists/sources.html
deleted file mode 100644 (file)
index efd5295..0000000
+++ /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 %}
-       <section class="hero is-dark">
-               <div class="hero-body">
-                       <div class="container">
-                               <nav class="breadcrumb" aria-label="breadcrumbs">
-                                       <ul>
-                                               <li>
-                                                       <a href="/dbl">
-                                                               {{ _("IPFire DBL") }}
-                                                       </a>
-                                               </li>
-
-                                               <li>
-                                                       <a href="/dbl/lists">
-                                                               {{ _("Lists") }}
-                                                       </a>
-                                               </li>
-
-                                               <li>
-                                                       <a href="/dbl/lists/{{ list.slug }}">
-                                                               {{ list }}
-                                                       </a>
-                                               </li>
-
-                                               <li class="is-active">
-                                                       <a href="#" aria-current="page">{{ _("Sources") }}</a>
-                                               </li>
-                                       </ul>
-                               </nav>
-
-                               <h1 class="title">
-                                       {{ _("Sources: %s") % list }}
-                               </h1>
-                       </div>
-               </div>
-       </section>
-
-       <section class="section">
-               <div class="container">
-                       <h5 class="title is-5">{{ _("Sources") }}</h5>
-
-                       <table class="table is-fullwidth is-striped is-hoverable is-narrow">
-                               <thead>
-                                       <tr>
-                                               <th>
-                                                       {{ _("Name") }}
-                                               </th>
-
-                                               <th class="has-text-right">
-                                                       {{ _("Last Update") }}
-                                               </th>
-
-                                               <th class="has-text-right">
-                                                       {{ _("Listed Domains") }}
-                                               </th>
-
-                                               <th class="has-text-right">
-                                                       {{ _("False Positives") }}
-                                               </th>
-
-                                               <th class="has-text-right">
-                                                       {{ _("Dead Domains") }}
-                                               </th>
-                                       </tr>
-                               </thead>
-
-                               <tbody>
-                                       {% for source in sorted(sources) %}
-                                               <tr>
-                                                       <td>
-                                                               <a href="{{ source.url }}" target="_blank">
-                                                                       {{ source.name }}
-                                                               </a>
-
-                                                               <br>
-
-                                                               <small class="has-text-grey">
-                                                                       {{ source.license }}
-                                                               </small>
-                                                       </td>
-
-                                                       <td class="has-text-right">
-                                                               {{ locale.format_date(source.updated_at, shorter=True) }}
-                                                       </td>
-
-                                                       {# Total Domains #}
-                                                       <td class="has-text-right">
-                                                               {{ format_number(source.total_domains) }}
-                                                       </td>
-
-                                                       {# False Positives #}
-                                                       <td class="has-text-right">
-                                                               {{ format_number(source.false_positives) }}
-                                                       </td>
-
-                                                       {# Dead Domains #}
-                                                       <td class="has-text-right">
-                                                               {% if source.total_domains and source.dead_domains %}
-                                                                       {{ format_percent(source.dead_domains / source.total_domains) }}
-                                                               {% else %}
-                                                                       <span class="has-text-grey">
-                                                                               {{ _("N/A") }}
-                                                                       </span>
-                                                               {% end %}
-                                                       </td>
-                                               </tr>
-                                       {% end %}
-                               </tbody>
-                       </table>
-               </div>
-       </section>
-{% end block %}
diff --git a/src/templates/dbl/modules/sources.html b/src/templates/dbl/modules/sources.html
new file mode 100644 (file)
index 0000000..98513d7
--- /dev/null
@@ -0,0 +1,68 @@
+<table class="table is-fullwidth is-striped is-hoverable is-narrow">
+       <thead>
+               <tr>
+                       <th>
+                               {{ _("Name") }}
+                       </th>
+
+                       <th class="has-text-right">
+                               {{ _("Last Update") }}
+                       </th>
+
+                       <th class="has-text-right">
+                               {{ _("Listed Domains") }}
+                       </th>
+
+                       <th class="has-text-right">
+                               {{ _("False Positives") }}
+                       </th>
+
+                       <th class="has-text-right">
+                               {{ _("Dead Domains") }}
+                       </th>
+               </tr>
+       </thead>
+
+       <tbody>
+               {% for source in sorted(sources) %}
+                       <tr>
+                               <td>
+                                       <a href="{{ source.url }}" target="_blank">
+                                               {{ source.name }}
+                                       </a>
+
+                                       <br>
+
+                                       <small class="has-text-grey">
+                                               {{ source.license }}
+                                       </small>
+                               </td>
+
+                               <td class="has-text-right">
+                                       {{ locale.format_date(source.updated_at, shorter=True) }}
+                               </td>
+
+                               {# Total Domains #}
+                               <td class="has-text-right">
+                                       {{ format_number(source.total_domains) }}
+                               </td>
+
+                               {# False Positives #}
+                               <td class="has-text-right">
+                                       {{ format_number(source.false_positives) }}
+                               </td>
+
+                               {# Dead Domains #}
+                               <td class="has-text-right">
+                                       {% if source.total_domains and source.dead_domains %}
+                                               {{ format_percent(source.dead_domains / source.total_domains) }}
+                                       {% else %}
+                                               <span class="has-text-grey">
+                                                       {{ _("N/A") }}
+                                               </span>
+                                       {% end %}
+                               </td>
+                       </tr>
+               {% end %}
+       </tbody>
+</table>
index 065e9bfddfdc8c4ca9a24bb3859ca967ae8b0756..064b12a65f7d1871488e7124cac2a6e4852882e2 100644 (file)
@@ -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),
index e1b56fc54ff5fb5647a1a4d92e161bf79e463169..122f152212d83c9f12ecc52c9c4bd4b9cb0fae70 100644 (file)
@@ -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 = {