--- /dev/null
+{% extends "../base.html" %}
+
+{% block head %}
+ {% module OpenGraph(
+ title=_("IPFire DBL - Search Results For: %s") % q,
+ ) %}
+{% end block %}
+
+{% block title %}{{ _("Search Results For: %s") % q }}{% end block %}
+
+{% block container %}
+ <section class="hero is-fullheight-with-navbar">
+ <div class="hero-body">
+ <div class="container">
+ <h1 class="title">
+ {{ _("Sorry, we could not find anything for %s") % q }}
+ </h1>
+
+ {# Suggest to report if it is a valid domain #}
+ {% if valid_fqdn %}
+ {% module DBLSubmitReport(q) %}
+ {% end %}
+ </div>
+ </div>
+ </section>
+{% end block %}
{% block title %}{{ _("Search Results For: %s") % q }}{% end block %}
{% block container %}
- <section class="hero is-dark">
+ <section class="hero is-fullheight-with-navbar">
<div class="hero-body">
<div class="container">
- <h1 class="title">
- {{ _("Search Results For: %s") % q }}
- </h1>
- </div>
- </div>
- </section>
+ <div class="columns is-centered">
+ <div class="column is-half">
+ <article class="panel is-primary">
+ <p class="panel-heading">
+ {{ format_domain(q) }}
+ </p>
- <section class="section">
- <div class="container">
- {# Show any results #}
- {% if results %}
- {% for list, result in sorted(results.items()) %}
- <div class="block">
- <h5 class="title is-5">
- <a href="/dbl/lists/{{ list.slug }}">
- {{ list }}
- </a>
- </h5>
+ {% for list in sorted(lists) %}
+ {% set result = results.get(list) %}
- <div class="content">
- {% if result.status == "ALLOWED" %}
- <p>
- <span class="icon-text">
- <span class="icon has-text-success">
- <i class="fas fa-check"></i>
- </span>
- <span>
- <a href="/dbl/lists/{{ list.slug }}/domains/{{ result.domain }}">
- {{ _("%s is currently allowed") % format_domain(result.domain) }}
- </a>
+ <a class="panel-block is-justify-content-space-between" href="/dbl/lists/{{ list.slug }}/domains/{{ q }}">
+ {{ list }}
+
+ {% if result is None %}
+ <span class="tag">
+ {{ _("Not Listed") }}
</span>
- </span>
- </p>
- {% elif result.status == "BLOCKED" %}
- <p>
- <span class="icon-text">
- <span class="icon has-text-danger">
- <i class="fas fa-x"></i>
+
+ {% elif result.status == "ALLOWED" %}
+ <span class="tag is-success">
+ {{ _("Allowed") }}
</span>
- <span>
- <a href="/dbl/lists/{{ list.slug }}/domains/{{ result.domain }}">
- {{ _("%s is currently blocked") % format_domain(result.domain) }}
- </a>
+ {% elif result.status == "BLOCKED" %}
+ <span class="tag is-danger">
+ {{ _("Blocked") }}
</span>
- </span>
- </p>
+ {% end %}
+ </a>
{% end %}
- </div>
+ </article>
</div>
- {% end %}
-
- {# Show a note if there has been no results #}
- {% else %}
- <div class="content has-text-centered">
- <p>
- {{ _("There are no matches for '%s'") % q }}
- </p>
</div>
-
- {# If the query has been a valid FQDN, we encourage users to report it #}
- {% if results == {} %}
- {% module DBLSubmitReport(name=q) %}
- {% end %}
- {% end %}
+ </div>
</div>
</section>
{% end block %}
try:
results = await self.backend.dbl.search(q)
+ # Raise an exception if nothing was found
+ if not results:
+ raise FileNotFoundError(q)
+
# ValueError is raised if the query has not been a valid FQDN
except ValueError as e:
- results = None
+ self.render("dbl/search-not-found.html", q=q, valid_fqdn=False)
+
+ # FileNotFoundError is raised if nothing was found
+ except FileNotFoundError as e:
+ self.render("dbl/search-not-found.html", q=q, valid_fqdn=True)
# Render the page
- self.render("dbl/search.html", q=q, results=results)
+ else:
+ # Fetch all lists
+ lists = await self.backend.dbl.get_lists()
+
+ self.render("dbl/search.html", q=q, lists=lists, results=results)
class ListsModule(ui_modules.UIModule):