Files
Claper/lib/claper/embeds/embed.ex
Alex Lion 5bd4793b6e Version 2.4.0
## ⚠️ Breaking changes

- S3 variables are now named: S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY, S3_REGION and S3_BUCKET
- Users now have roles. Refer to the `roles` table and assign a role to a user with the `role_id` column in the `users` table.

## Features

- Add Admin Panel to manage users and presentations
- Add user roles: user, admin
- Add `LANGUAGES` setting to configure available languages in the app
- Add hideable presenter attendee count (#183 #155)
- Add Hungarian translation (#161)
- Add Latvian translation (#163)
- Add custom S3 endpoint with `S3_SCHEME`, `S3_HOST`, `S3_PORT` and `S3_PUBLIC_URL`

## Fixes and improvements

- Upgrade JS dependencies
- Upgrade Elixir dependencies, including Phoenix Live View to 1.0.17
- Upgrade to Tailwind 4+
- Refactor view templates to use {} instead of <%= %>
- Fix event name validation to be required
- Docker image is now using Ubuntu instead of Alpine for better dependencies support
- Fix scrollbar not showing in event manager when no presentation file (#164) (@aryel780)
- Fix settings scroll for small screen (#168)
- Fix duplicate key quiz when duplicate (#182)
- Fix email change confirmation (#172)
- Fix italian translation (#179)
- Fix random poll choices (#184)
2025-12-26 14:46:16 +01:00

106 lines
3.1 KiB
Elixir

defmodule Claper.Embeds.Embed do
use Ecto.Schema
import Ecto.Changeset
use Gettext, backend: ClaperWeb.Gettext
@type t :: %__MODULE__{
id: integer(),
title: String.t(),
content: String.t(),
provider: String.t(),
enabled: boolean(),
position: integer() | nil,
attendee_visibility: boolean() | nil,
presentation_file_id: integer() | nil,
inserted_at: NaiveDateTime.t(),
updated_at: NaiveDateTime.t()
}
@derive {Jason.Encoder, only: [:title, :content, :position, :attendee_visibility]}
schema "embeds" do
field :title, :string
field :content, :string
field :provider, :string
field :enabled, :boolean, default: true
field :position, :integer, default: 0
field :attendee_visibility, :boolean, default: false
belongs_to :presentation_file, Claper.Presentations.PresentationFile
timestamps()
end
@doc false
def changeset(embed, attrs \\ %{}) do
embed
|> cast(attrs, [
:enabled,
:title,
:content,
:provider,
:presentation_file_id,
:position,
:attendee_visibility
])
|> validate_required([
:title,
:content,
:provider,
:presentation_file_id,
:position,
:attendee_visibility
])
|> validate_inclusion(:provider, ["youtube", "vimeo", "canva", "googleslides", "custom"])
|> validate_provider_url()
end
defp validate_provider_url(changeset) do
case get_field(changeset, :provider) do
"youtube" ->
changeset
|> validate_format(:content, ~r/^https?:\/\/.+$/,
message: gettext("Please enter a valid link starting with http:// or https://")
)
|> validate_format(:content, ~r/(youtu\.be)|(youtube\.com)/,
message: gettext("Please enter a valid %{provider} link", provider: "YouTube")
)
"canva" ->
changeset
|> validate_format(:content, ~r/^https?:\/\/.+$/,
message: gettext("Please enter a valid link starting with http:// or https://")
)
|> validate_format(:content, ~r/canva\.com/,
message: gettext("Please enter a valid %{provider} link", provider: "Canva")
)
"googleslides" ->
changeset
|> validate_format(:content, ~r/^https?:\/\/.+$/,
message: gettext("Please enter a valid link starting with http:// or https://")
)
|> validate_format(:content, ~r/google\.com/,
message: gettext("Please enter a valid %{provider} link", provider: "Google Slides")
)
"vimeo" ->
changeset
|> validate_format(:content, ~r/^https?:\/\/.+$/,
message: gettext("Please enter a valid link starting with http:// or https://")
)
|> validate_format(:content, ~r/vimeo\.com/,
message: gettext("Please enter a valid %{provider} link", provider: "Vimeo")
)
"custom" ->
changeset
|> validate_format(:content, ~r/<iframe.*?<\/iframe>/s,
message: gettext("Please enter valid HTML content with an iframe tag")
)
_ ->
changeset
end
end
end