diff --git a/lib/outlook/translations/translation.ex b/lib/outlook/translations/translation.ex index c5489ac..2b35889 100644 --- a/lib/outlook/translations/translation.ex +++ b/lib/outlook/translations/translation.ex @@ -4,7 +4,7 @@ defmodule Outlook.Translations.Translation do alias Outlook.Accounts.User alias Outlook.Articles.Article - alias Outlook.Translations.{TranslationUnitsMap,Translation} + alias Outlook.Translations.TranslationUnitsMap schema "translations" do field :content, TranslationUnitsMap @@ -32,30 +32,4 @@ defmodule Outlook.Translations.Translation do name: :article_id_lang_unique_index) |> foreign_key_constraint(:article_id) end - - def translate_unicode(str) do - mapping = %{"Ä" => "Ae", - "Ö" => "Oe", - "Ü" => "Ue", - "ä" => "ae", - "ö" => "oe", - "ü" => "ue", - "ß" => "ss"} - {:ok, re} = "[#{Map.keys(mapping) |> Enum.join}]" |> Regex.compile("u") - Regex.replace(re, str, fn(c) -> mapping[c] end) - end - - def spit_title(title) do - title - |> translate_unicode() - # |> String.replace(~r/[^-0-9A-Za-z ]/u, "_") - |> String.replace(~r/[^\w\s-]/u, "") - |> String.replace(~r/(\s|-)+/u, "-") - end - - defimpl Phoenix.Param, for: Translation do - def to_param(%{id: id, title: title}) do - "#{Translation.spit_title(title)}--#{Integer.to_string(id, 36) |> String.downcase()}" - end - end end diff --git a/lib/outlook_web/components/public_components.ex b/lib/outlook_web/components/public_components.ex index 1205a8e..f52a953 100644 --- a/lib/outlook_web/components/public_components.ex +++ b/lib/outlook_web/components/public_components.ex @@ -13,7 +13,7 @@ defmodule OutlookWeb.PublicComponents do def autor(assigns) do ~H""" - +
<%= @autor.name %>
<%= @autor.description |> tidy_raw %>
diff --git a/lib/outlook_web/live/article_live/show.html.heex b/lib/outlook_web/live/article_live/show.html.heex index e694cfe..3026a18 100644 --- a/lib/outlook_web/live/article_live/show.html.heex +++ b/lib/outlook_web/live/article_live/show.html.heex @@ -16,7 +16,7 @@ -<.table id="translations" rows={@article.translations} row_click={&JS.navigate(~p"/translations/#{(&1).id}")}> +<.table id="translations" rows={@article.translations} row_click={&JS.navigate(~p"/translations/#{&1}")}> <:col :let={translation} label="Language"><%= translation.language %> <:col :let={translation} label="Title"><%= translation.title %> <:col :let={translation} label="Teaser"><%= translation.teaser |> tidy_raw %> @@ -24,9 +24,9 @@ <:col :let={translation} label="Public"><%= translation.public %> <:action :let={translation}>
- <.link navigate={~p"/translations/#{translation.id}"}>Show + <.link navigate={~p"/translations/#{translation}"}>Show
- <.link navigate={~p"/translations/#{translation.id}/edit"}>Edit + <.link navigate={~p"/translations/#{translation}/edit"}>Edit <:action :let={translation}> <.link phx-click={JS.push("delete_translation", value: %{id: translation.id})} data-confirm="Are you sure?"> diff --git a/lib/outlook_web/live/translation_live/index.html.heex b/lib/outlook_web/live/translation_live/index.html.heex index 4d4537b..30731e1 100644 --- a/lib/outlook_web/live/translation_live/index.html.heex +++ b/lib/outlook_web/live/translation_live/index.html.heex @@ -2,7 +2,7 @@ Listing Translations -<.table id="translations" rows={@translations} row_click={&JS.navigate(~p(/translations/#{(&1).id}))}> +<.table id="translations" rows={@translations} row_click={&JS.navigate(~p(/translations/#{&1}))}> <:col :let={translation} label="Language"><%= translation.language %> <:col :let={translation} label="Title"><%= translation.title %> <:col :let={translation} label="Teaser"><%= translation.teaser |> tidy_raw %> @@ -12,9 +12,9 @@ <:col :let={translation} label="Unauthorized"><%= translation.unauthorized %> <:action :let={translation}>
- <.link navigate={~p"/translations/#{translation.id}"}>Show + <.link navigate={~p"/translations/#{translation}"}>Show
- <.link navigate={~p"/translations/#{translation.id}/edit"}>Edit + <.link navigate={~p"/translations/#{translation}/edit"}>Edit <:action :let={translation}> <.link phx-click={JS.push("delete", value: %{id: translation.id})} data-confirm="Are you sure?"> diff --git a/lib/outlook_web/live/translation_live/show.html.heex b/lib/outlook_web/live/translation_live/show.html.heex index 16f6f92..af472bc 100644 --- a/lib/outlook_web/live/translation_live/show.html.heex +++ b/lib/outlook_web/live/translation_live/show.html.heex @@ -2,7 +2,7 @@ Translation <%= @translation.id %> <:subtitle>This is a translation record from your database. <:actions> - <.link navigate={~p"/translations/#{@translation.id}/edit"} phx-click={JS.push_focus()}> + <.link navigate={~p"/translations/#{@translation}/edit"} phx-click={JS.push_focus()}> <.button>Edit translation