-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/show-news
- Loading branch information
Showing
33 changed files
with
295 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
defmodule Pescarte.Storage do | ||
@moduledoc "Módulo que centraliza operações de gerenciamento de arquivos" | ||
|
||
# bucket padrão onde as imagens da parte pública são | ||
# guardadas de forma comprimida, geralmente em formato webp | ||
@public_image_bucket "static" | ||
@public_image_folder "reduced_images" | ||
|
||
@one_year :timer.hours(24) * 365 | ||
|
||
@doc """ | ||
Recupera a URL de uma imagem guardada no Storage (atualmente Supabase), | ||
para renderizar ela na parte pública da plataforma. | ||
## Params | ||
- `path`: O caminho até a imagem a ser renderizada, a desconsiderar o bucket, por exemplo, se o caminho no Supabase Storage é `reduced_images/aplicativos/card_censo.webp` então o argumento dessa função será `aplicativos/card_censo.webp`. | ||
- `expires_in`: Tempo de expiração da URL, opcional, valor padrão de 1 ano. | ||
- `opts`: Argumento opcional de configuração, por exemplo para usar a API de transformação de imagens da Supabase, passando a opção `:transform` onde o valor são parâmetros válidos de `Supabase.Storage.TransformOptions` | ||
- `bucket`: O nome do bucket a ser usado, opcional pois o valor padrão é `static`, já com a pasta `reduced_images` adicionada ao caminho. | ||
## Examples | ||
iex> Pescarte.Storage.get_public_area_image_url("aplicativos/card_censo.webp") | ||
{:ok, "https://supabase-url"} | ||
iex> Pescarte.Storage.get_public_area_image_url("arquivo-nao-existe") | ||
{:error, :file_not_found} | ||
""" | ||
def get_public_area_image_url( | ||
path, | ||
expires_in \\ @one_year, | ||
opts \\ [], | ||
bucket \\ @public_image_bucket | ||
) | ||
when is_binary(path) and is_binary(bucket) do | ||
with {:ok, client} <- Pescarte.Supabase.get_client() do | ||
path = Path.join(@public_image_folder, path) | ||
storage = Supabase.Storage.from(client, bucket) | ||
opts = [{:expires_in, expires_in} | opts] | ||
Supabase.Storage.File.create_signed_url(storage, path, opts) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,15 +27,15 @@ defmodule PescarteWeb.DesignSystem.AuthenticatedNavbar do | |
<DesignSystem.link :for={{menu_name, path, icon} <- @menus} navigate={path}> | ||
<li class={"nav-item #{if should_activate_menu_item(path, @current_path), do: "active"}"}> | ||
<.icon name={icon} class="text-black-60" /> | ||
<.text :if={@open} size="base" color="text-black-60"><%= menu_name %></.text> | ||
<.text :if={@open} size="base" color="text-black-60">{menu_name}</.text> | ||
</li> | ||
</DesignSystem.link> | ||
</ul> | ||
<a class="user-info" href={~p"/app/pesquisa/perfil"} style="cursor: pointer;"> | ||
<Lucideicons.user :if={[email protected]_avatar} class="text-black-60" /> | ||
<img :if={@user.link_avatar} src={@user.link_avatar} class="text-black-60" /> | ||
<.text :if={@open} size="base" color="text-black-80"> | ||
<%= Usuario.build_usuario_name(@user) %> | ||
{Usuario.build_usuario_name(@user)} | ||
</.text> | ||
</a> | ||
</nav> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<PescarteWeb.DesignSystem.Navbar.render current_path="{@current_path}" /> | ||
<main class="w-full h-full z-0"> | ||
<.flash_group flash={@flash} /> <%= @inner_content %> | ||
<.flash_group flash={@flash} /> {@inner_content} | ||
</main> | ||
<.footer /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,6 @@ | |
/> | ||
<main> | ||
<.flash_group flash={@flash} /> | ||
<%= @inner_content %> | ||
{@inner_content} | ||
</main> | ||
<.footer /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.