Skip to content

Commit

Permalink
Add pages
Browse files Browse the repository at this point in the history
  • Loading branch information
drakeerv committed Nov 1, 2024
1 parent 47be1e0 commit ec336eb
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 11 deletions.
4 changes: 2 additions & 2 deletions plugins/providers.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ kinds = ["sear"]
pagination = "1"

[wiby.extra]
url = "https://wiby.me/json?q={query}&page={page}"
url = "https://wiby.me/json?q={query}&p={page}"
url_key = "URL"
title_key = "Title"
snippet_key = "Snippet"
Expand Down Expand Up @@ -157,5 +157,5 @@ name = "Yahoo"
description = "A search engine"
kinds = ["sear"]
[yahoo.features]
pagination = "0"
pagination = "1"
safe_search = "multilevel"
1 change: 0 additions & 1 deletion views/components/search_bar.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
transition: all 0.2s ease;
margin-left: 4px;
vertical-align: middle;
/* horizontal align content */
display: inline-block;
text-align: center;
}
Expand Down
3 changes: 0 additions & 3 deletions views/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@
{% endblock head %}

{% block content %}
<div>

</div>
<table id="lead" cellspacing="0">
<tr>
<td rowspan="2">
Expand Down
45 changes: 40 additions & 5 deletions views/results.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
margin-right: 10px;
}

#kinds a#current {
#kinds a#current-category {
color: #98db7c;
font-weight: bold;
}
Expand Down Expand Up @@ -77,8 +77,19 @@
vertical-align: middle;
}

#bottom {
padding: 10px;
.page-button {
padding: 5px 10px;
margin-right: 5px;
border-radius: 5px;
background-color: #363636;
color: #CDCDCD;
text-decoration: none;
transition: all 0.3s;
}

.page-button#current-page {
background-color: #98db7c;
color: #363636;
}

#ferris {
Expand Down Expand Up @@ -157,7 +168,8 @@ <h3>Searched</h3>
<tr>
<td colspan="3" id="kinds">
{% for i in range(end=kind_ids | length) %}
<a href="?q={{ query.query }}&k={{ kind_ids[i] }}" id="{% if kind == kind_ids[i] %}current{% endif %}">{{
<a href="?q={{ query.query }}&p={{ query.page }}&k={{ kind_ids[i] }}"
id="{% if kind == kind_ids[i] %}current-category{% endif %}">{{
kind_names[i] }}</a>
{% endfor %}
</td>
Expand All @@ -173,6 +185,29 @@ <h3>Searched</h3>
{{ result_view::generate_content(result=result) }}
{% endfor %}
<div id="bottom">
<!-- {% set page_start = query.page - 5 %}
{% set page_end = query.page + 5 %}
{% if page_start < 0 %}
{% set diff = 0 - page_start %}
{% set page_start = 0 %}
{% set page_end = page_end + diff %}
{% endif %} -->
<!-- query.page first page is 1 -->
{% set page_start = query.page - 5 %}
{% set page_end = query.page + 5 %}
{% if page_start < 1 %}
{% set page_end = page_end + (1 - page_start) %}
{% set page_start = 1 %}
{% endif %}

{% if query.page > 1 %}
<a href="?q={{ query.query }}&k={{ kind }}&p={{ query.page - 1 }}" class="page-button">&#x276E;&#xFE0E;</a>
{% endif %}
{% for i in range(start=page_start, end=page_end) %}
<a href="?q={{ query.query }}&k={{ kind }}&p={{ i }}" class="page-button" id="{% if i == query.page %}current-page{% endif %}">{{ i }}</a>
{% endfor %}
<a href="?q={{ query.query }}&k={{ kind }}&p={{ query.page + 1 }}" class="page-button">&#x276F;&#xFE0E;</a>

<p>Found {{ results | length }} results in {{ search_time }} ms</p>
</div>
{% else %}
Expand Down Expand Up @@ -204,4 +239,4 @@ <h1>No results found</h1>
}, 3000);
});
</script>
{% endblock body %}
{% endblock body %}

0 comments on commit ec336eb

Please sign in to comment.