Add miscellaneous stuff

This commit is contained in:
Thelonius Kort
2023-03-15 10:56:30 +01:00
parent 61253f301a
commit 43f3ea193f
5 changed files with 10 additions and 3 deletions

View File

@ -3,7 +3,6 @@ alias Outlook.HtmlPreparations.HtmlPreparation
alias Outlook.InternalTree.{Html,InternalNode,TranslationUnit} alias Outlook.InternalTree.{Html,InternalNode,TranslationUnit}
alias Outlook.InternalTree alias Outlook.InternalTree
alias Outlook.Articles alias Outlook.Articles
alias Outlook.Artikel
alias Outlook.Accounts alias Outlook.Accounts
alias Outlook.Articles.Article alias Outlook.Articles.Article
alias Outlook.Authors alias Outlook.Authors

View File

@ -39,7 +39,7 @@ defmodule Outlook.Authors do
def get_author_with_articles!(id) do def get_author_with_articles!(id) do
Repo.get!(Author, id) Repo.get!(Author, id)
|> Repo.preload([:articles]) |> Repo.preload([articles: :translations])
end end
@doc """ @doc """

View File

@ -9,7 +9,7 @@ defmodule Outlook.Authors.Author do
field :homepage_name, :string field :homepage_name, :string
field :homepage_url, :string field :homepage_url, :string
field :name, :string field :name, :string
has_many :articles, Article has_many :articles, Article, on_delete: :delete_all
timestamps() timestamps()
end end

View File

@ -54,10 +54,12 @@ defmodule Outlook.Translators.Deepl do
) )
response = Jason.decode!(response_raw.body, keys: :atoms) response = Jason.decode!(response_raw.body, keys: :atoms)
require Logger
case response do case response do
%{status: "done"} -> %{status: "done"} ->
response response
%{status: status} -> %{status: status} ->
Logger.debug "Deepl response: #{response |> inspect}"
steps = Map.get(response, :seconds_remaining, 1) * 5 steps = Map.get(response, :seconds_remaining, 1) * 5
for n <- 0..steps do for n <- 0..steps do
send(pid, {:progress, %{progress: 100 * n / steps, status: status}}) send(pid, {:progress, %{progress: 100 * n / steps, status: status}})

View File

@ -12,4 +12,10 @@ defmodule OutlookWeb.ViewHelpers do
def tidy_raw(whatever) do def tidy_raw(whatever) do
whatever whatever
end end
# TODO: implement (and use) the following function
@doc "Strip <a> tags to prevent broken html (or 'breaking') from user input."
def strip_links(html) do
raise "Yet to be implemented!"
end
end end