Skip to content

Commit

Permalink
Add subdefinition videos and definitions in auslan
Browse files Browse the repository at this point in the history
  • Loading branch information
r-tae committed Aug 2, 2024
1 parent 3ca573c commit e67f25e
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 19 deletions.
2 changes: 1 addition & 1 deletion lib/signbank/dictionary.ex
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ defmodule Signbank.Dictionary do
{:ok, %Postgrex.Result{rows: rows}} ->
results =
rows
|> Enum.group_by(fn [_id_gloss, kw, _regions, published] -> kw end)
|> Enum.group_by(fn [_id_gloss, kw, _regions, _published] -> kw end)
|> Enum.map(fn {kw, matches} ->
similarity = matches |> Enum.at(0) |> Enum.at(3)

Expand Down
8 changes: 6 additions & 2 deletions lib/signbank/dictionary/definition.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ defmodule Signbank.Dictionary.Definition do

field :text, :string
field :pos, :integer
field :url, :string

field :role, Ecto.Enum,
values: [
Expand All @@ -18,13 +19,16 @@ defmodule Signbank.Dictionary.Definition do
:noun,
:verb,
:modifier,
:augment,
:pointing_sign,
:question,
:interactive,
# TODO: move this field to notes table
:augment,
# TODO: move this field to notes table
:popular_explanation,
# TODO: move this field to notes table
:note,
# TODO: move to text field
# TODO: move this field to notes table (or maybe text field on Sign)
:editor_note
]

Expand Down
7 changes: 5 additions & 2 deletions lib/signbank_web/components/core_components.ex
Original file line number Diff line number Diff line change
Expand Up @@ -672,8 +672,8 @@ defmodule SignbankWeb.CoreComponents do
end

@role_order [
:general,
:auslan,
:general,
:noun,
:verb,
:modifier,
Expand Down Expand Up @@ -702,7 +702,7 @@ defmodule SignbankWeb.CoreComponents do
end

defp definition_role_to_string(:general), do: SignbankWeb.Gettext.gettext("General Definition")
defp definition_role_to_string(:auslan), do: SignbankWeb.Gettext.gettext("Auslan Definition")
defp definition_role_to_string(:auslan), do: SignbankWeb.Gettext.gettext("Definition in Auslan")
defp definition_role_to_string(:noun), do: SignbankWeb.Gettext.gettext("As a Noun")
defp definition_role_to_string(:verb), do: SignbankWeb.Gettext.gettext("As a Verb or Adjective")
defp definition_role_to_string(:modifier), do: SignbankWeb.Gettext.gettext("As Modifier")
Expand Down Expand Up @@ -754,6 +754,9 @@ defmodule SignbankWeb.CoreComponents do
<ol class="definition__senses">
<li :for={definition <- definitions}>
<Heroicons.eye_slash :if={not definition.published} class="icon--small" /><%= definition.text %>
<video :if={definition.url} controls muted width="200">
<source src={"#{Application.fetch_env!(:signbank, :media_url)}/#{definition.url}"} />
</video>
</li>
</ol>
</div>
Expand Down
17 changes: 4 additions & 13 deletions lib/signbank_web/components/layouts/root.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,23 @@
end %>
</li>
<li>
<.link
href={~p"/users/settings"}
>
<.link href={~p"/users/settings"}>
Settings
</.link>
</li>
<li>
<.link
href={~p"/users/log_out"}
method="delete"
>
<.link href={~p"/users/log_out"} method="delete">
Log out
</.link>
</li>
<% else %>
<li>
<.link
href={~p"/users/register"}
>
<.link href={~p"/users/register"}>
Register
</.link>
</li>
<li>
<.link
href={~p"/users/log_in"}
>
<.link href={~p"/users/log_in"}>
Log in
</.link>
</li>
Expand Down
2 changes: 1 addition & 1 deletion lib/signbank_web/live/entry_live/basic_view.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@
</div>
<div class="entry-page__column">
<%!-- TODO: inherit definitions (but not notes) from the citation form --%>
<.definitions type={:basic} definitions={@sign.definitions} />
<.definitions
:if={@sign.citation}
type={:basic}
definitions={Map.get(@sign.citation, :definitions, [])}
/>
<.definitions type={:basic} definitions={@sign.definitions} />
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
defmodule Signbank.Repo.Migrations.AddUrlFieldToDefinitions do
use Ecto.Migration

def change do
alter table(:definitions) do
add :url, :text, null: true
end
end
end

0 comments on commit e67f25e

Please sign in to comment.