From 62a2f13bb6917faf42dfe72c0e9d322ab8fcf658 Mon Sep 17 00:00:00 2001 From: mdashlw Date: Mon, 10 Jun 2024 17:30:51 +0300 Subject: [PATCH 1/2] feat: bump max source count to 15 --- lib/philomena/images.ex | 2 +- lib/philomena_web/templates/image/_source.html.slime | 2 +- lib/philomena_web/templates/image/new.html.slime | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/philomena/images.ex b/lib/philomena/images.ex index 95788ad5..d68595fb 100644 --- a/lib/philomena/images.ex +++ b/lib/philomena/images.ex @@ -937,7 +937,7 @@ defmodule Philomena.Images do (source.sources ++ target.sources) |> Enum.map(fn s -> %Source{image_id: target.id, source: s.source} end) |> Enum.uniq() - |> Enum.take(10) + |> Enum.take(15) target |> Image.sources_changeset(sources) diff --git a/lib/philomena_web/templates/image/_source.html.slime b/lib/philomena_web/templates/image/_source.html.slime index 8fa32872..48e3c6de 100644 --- a/lib/philomena_web/templates/image/_source.html.slime +++ b/lib/philomena_web/templates/image/_source.html.slime @@ -8,7 +8,7 @@ p 'The page(s) you found this image on. Images may have a maximum of - span.js-max-source-count> 10 + span.js-max-source-count> 15 ' source URLs. Leave any sources you don't want to use blank. = inputs_for f, :sources, [as: "image[old_sources]", skip_hidden: true], fn fs -> diff --git a/lib/philomena_web/templates/image/new.html.slime b/lib/philomena_web/templates/image/new.html.slime index ad596f17..dfb664d9 100644 --- a/lib/philomena_web/templates/image/new.html.slime +++ b/lib/philomena_web/templates/image/new.html.slime @@ -40,7 +40,7 @@ h4 About this image p 'The page(s) you found this image on. Images may have a maximum of - span.js-max-source-count> 10 + span.js-max-source-count> 15 ' source URLs. Leave any sources you don't want to use blank. = inputs_for f, :sources, fn fs -> From 567eaac69725144d4f5b8d1eac759b8ef1572298 Mon Sep 17 00:00:00 2001 From: mdashlw Date: Mon, 10 Jun 2024 17:48:29 +0300 Subject: [PATCH 2/2] image: validate sources length --- lib/philomena/images/image.ex | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/philomena/images/image.ex b/lib/philomena/images/image.ex index d8e791c8..7b808eaa 100644 --- a/lib/philomena/images/image.ex +++ b/lib/philomena/images/image.ex @@ -212,11 +212,13 @@ defmodule Philomena.Images.Image do image |> cast(attrs, []) |> SourceDiffer.diff_input(old_sources, new_sources) + |> validate_length(:sources, max: 15) end def sources_changeset(image, new_sources) do change(image) |> put_assoc(:sources, new_sources) + |> validate_length(:sources, max: 15) end def tag_changeset(image, attrs, old_tags, new_tags, excluded_tags \\ []) do