mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-01-19 22:27:59 +01:00
fix parser, add last page back to pagination
This commit is contained in:
parent
19b54f5f58
commit
eef29910de
3 changed files with 19 additions and 8 deletions
|
@ -1,4 +1,5 @@
|
|||
- params = assigns[:params] || []
|
||||
- last = assigns[:last] || false
|
||||
|
||||
= if @page.total_pages > 1 do
|
||||
nav.pagination
|
||||
|
@ -24,4 +25,6 @@
|
|||
|
||||
= if not last_page?(@page) do
|
||||
= link("Next ›", to: next_page_path(@page, @route, params))
|
||||
/= link("Last »", to: last_page_path(@page, @route, params))
|
||||
|
||||
= if last do
|
||||
= link("Last »", to: last_page_path(@page, @route, params))
|
|
@ -1,4 +1,6 @@
|
|||
- pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @posts, route: fn p -> Routes.forum_topic_path(@conn, :show, @forum, @topic, p) end
|
||||
elixir:
|
||||
route = fn p -> Routes.forum_topic_path(@conn, :show, @forum, @topic, p) end
|
||||
pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @posts, route: route, last: true
|
||||
|
||||
h1 = @topic.title
|
||||
/ Header section
|
||||
|
|
|
@ -192,29 +192,29 @@ defmodule Search.Parser do
|
|||
# Types which do not support ranges
|
||||
|
||||
defp field_type(parser, [{LiteralParser, field_name}, range: :eq, literal: value]),
|
||||
do: {:ok, {%{term: %{field(parser, field_name) => String.trim(value)}}, []}}
|
||||
do: {:ok, {%{term: %{field(parser, field_name) => normalize_value(parser, value)}}, []}}
|
||||
|
||||
defp field_type(parser, [{LiteralParser, field_name}, range: :eq, literal: value, fuzz: fuzz]),
|
||||
do: {:ok, {%{fuzzy: %{field(parser, field_name) => %{value: String.trim(value), fuzziness: fuzz}}}, []}}
|
||||
do: {:ok, {%{fuzzy: %{field(parser, field_name) => %{value: normalize_value(parser, value), fuzziness: fuzz}}}, []}}
|
||||
|
||||
defp field_type(_parser, [{LiteralParser, _field_name}, range: :eq, wildcard: "*"]),
|
||||
do: {:ok, {%{match_all: %{}}, []}}
|
||||
|
||||
defp field_type(parser, [{LiteralParser, field_name}, range: :eq, wildcard: value]),
|
||||
do: {:ok, {%{wildcard: %{field(parser, field_name) => String.trim(value)}}, []}}
|
||||
do: {:ok, {%{wildcard: %{field(parser, field_name) => normalize_value(parser, value)}}, []}}
|
||||
|
||||
|
||||
defp field_type(parser, [{NgramParser, field_name}, range: :eq, literal: value]),
|
||||
do: {:ok, {%{match_phrase: %{field(parser, field_name) => String.trim(value)}}, []}}
|
||||
do: {:ok, {%{match_phrase: %{field(parser, field_name) => normalize_value(parser, value)}}, []}}
|
||||
|
||||
defp field_type(parser, [{NgramParser, field_name}, range: :eq, literal: value, fuzz: _fuzz]),
|
||||
do: {:ok, {%{match_phrase: %{field(parser, field_name) => String.trim(value)}}, []}}
|
||||
do: {:ok, {%{match_phrase: %{field(parser, field_name) => normalize_value(parser, value)}}, []}}
|
||||
|
||||
defp field_type(_parser, [{NgramParser, _field_name}, range: :eq, wildcard: "*"]),
|
||||
do: {:ok, {%{match_all: %{}}, []}}
|
||||
|
||||
defp field_type(parser, [{NgramParser, field_name}, range: :eq, wildcard: value]),
|
||||
do: {:ok, {%{wildcard: %{field(parser, field_name) => String.trim(value)}}, []}}
|
||||
do: {:ok, {%{wildcard: %{field(parser, field_name) => normalize_value(parser, value)}}, []}}
|
||||
|
||||
|
||||
defp field_type(parser, [{BoolParser, field_name}, range: :eq, bool: value]),
|
||||
|
@ -265,4 +265,10 @@ defmodule Search.Parser do
|
|||
defp field(parser, field_name) do
|
||||
parser.aliases[field_name] || field_name
|
||||
end
|
||||
|
||||
defp normalize_value(_parser, value) do
|
||||
value
|
||||
|> String.trim()
|
||||
|> String.downcase()
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue