mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-02-01 03:46:44 +01:00
validation fixes, make navigate endpoint use * as query if none given
This commit is contained in:
parent
537b2e7e66
commit
ef0eee0105
3 changed files with 17 additions and 3 deletions
|
@ -193,7 +193,7 @@ defmodule Philomena.Users.User do
|
|||
|> propagate_tag_list(:watched_tag_list, :watched_tag_ids)
|
||||
|> validate_inclusion(:theme, ~W(default dark red))
|
||||
|> validate_inclusion(:images_per_page, 15..50)
|
||||
|> validate_inclusion(:comments_per_page, 15..50)
|
||||
|> validate_inclusion(:comments_per_page, 15..100)
|
||||
|> validate_search(:watched_images_query_str, user, true)
|
||||
|> validate_search(:watched_images_exclude_str, user, true)
|
||||
end
|
||||
|
|
|
@ -62,8 +62,16 @@ defmodule PhilomenaWeb.Image.NavigateController do
|
|||
defp compile_query(conn) do
|
||||
user = conn.assigns.current_user
|
||||
|
||||
{:ok, query} = Query.compile(user, conn.params["q"] || "")
|
||||
{:ok, query} = Query.compile(user, match_all_if_blank(conn.params["q"]))
|
||||
|
||||
query
|
||||
end
|
||||
|
||||
defp match_all_if_blank(nil), do: "*"
|
||||
defp match_all_if_blank(input) do
|
||||
case String.trim(input) == "" do
|
||||
true -> "*"
|
||||
false -> input
|
||||
end
|
||||
end
|
||||
end
|
|
@ -21,6 +21,7 @@ h1 Content Settings
|
|||
.field
|
||||
= label f, :watched_tag_list, "Tags to watch"
|
||||
= render PhilomenaWeb.TagView, "_tag_editor.html", f: f, name: :watched_tag_list, type: :edit, conn: @conn
|
||||
= error_tag f, :watched_tag_list
|
||||
|
||||
h4 Watchlist queries and filtering
|
||||
p
|
||||
|
@ -31,9 +32,11 @@ h1 Content Settings
|
|||
.field
|
||||
= label f, :watched_images_query_str, "Watch list search string (images found by this search are added to your watched images list)"
|
||||
= textarea f, :watched_images_query_str, class: "input input--wide", autocapitalize: "none"
|
||||
= error_tag f, :watched_images_query_str
|
||||
.field
|
||||
= label f, :watched_images_exclude_str, "Watch list filter string (any images found by this search are removed from your watched images list)"
|
||||
= textarea f, :watched_images_exclude_str, class: "input input--wide", autocapitalize: "none"
|
||||
= error_tag f, :watched_images_exclude_str
|
||||
.field
|
||||
=> checkbox f, :no_spoilered_in_watched, class: "checkbox"
|
||||
=> label f, :no_spoilered_in_watched, "Hide images spoilered by filter in watchlist"
|
||||
|
@ -59,13 +62,15 @@ h1 Content Settings
|
|||
.field
|
||||
=> label f, :images_per_page
|
||||
=> number_input f, :images_per_page, min: 15, max: 50, step: 1, class: "input"
|
||||
= error_tag f, :images_per_page
|
||||
.fieldlabel
|
||||
i
|
||||
' This is the number of images per page that are displayed on image listings and searches, up to a maximum of 50.
|
||||
' For 1080p monitors, try 24.
|
||||
.field
|
||||
=> label f, :comments_per_page
|
||||
=> number_input f, :comments_per_page, min: 15, max: 50, step: 1, class: "input"
|
||||
=> number_input f, :comments_per_page, min: 15, max: 100, step: 1, class: "input"
|
||||
= error_tag f, :comments_per_page
|
||||
.fieldlabel: i This is the number of comments per page that are displayed on image pages.
|
||||
.field
|
||||
=> label f, :scale_large_images
|
||||
|
@ -74,6 +79,7 @@ h1 Content Settings
|
|||
.field
|
||||
=> label f, :theme
|
||||
=> select f, :theme, theme_options(@conn), class: "input"
|
||||
= error_tag f, :theme
|
||||
.fieldlabel: i Preview themes by selecting one from the dropdown. Saving sets the currently selected theme.
|
||||
|
||||
.block__tab.hidden.flex.flex--maybe-wrap data-tab="metadata"
|
||||
|
|
Loading…
Reference in a new issue