mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 21:47:59 +01:00
add explicit list of underscore-safe namespaces (furbooru/philomena#28)
This commit is contained in:
parent
7736cb041f
commit
aefc79eb8e
1 changed files with 14 additions and 5 deletions
|
@ -43,6 +43,14 @@ defmodule Philomena.Tags.Tag do
|
||||||
"video" => "content-fanmade"
|
"video" => "content-fanmade"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@underscore_safe_namespaces [
|
||||||
|
"artist:",
|
||||||
|
"colorist:",
|
||||||
|
"editor:",
|
||||||
|
"oc:",
|
||||||
|
"photographer:"
|
||||||
|
]
|
||||||
|
|
||||||
@derive {Phoenix.Param, key: :slug}
|
@derive {Phoenix.Param, key: :slug}
|
||||||
|
|
||||||
schema "tags" do
|
schema "tags" do
|
||||||
|
@ -211,11 +219,12 @@ defmodule Philomena.Tags.Tag do
|
||||||
defp join_namespace_parts([_namespace, _name], original_name),
|
defp join_namespace_parts([_namespace, _name], original_name),
|
||||||
do: original_name
|
do: original_name
|
||||||
|
|
||||||
defp ununderscore(<<"artist:", _rest::binary>> = name),
|
defp ununderscore(name) do
|
||||||
do: name
|
case String.starts_with?(name, @underscore_safe_namespaces) do
|
||||||
|
true -> name
|
||||||
defp ununderscore(name),
|
false -> String.replace(name, "_", " ")
|
||||||
do: String.replace(name, "_", " ")
|
end
|
||||||
|
end
|
||||||
|
|
||||||
defp put_slug(changeset) do
|
defp put_slug(changeset) do
|
||||||
slug =
|
slug =
|
||||||
|
|
Loading…
Reference in a new issue