Skip to content

Commit

Permalink
Undo line length limitation
Browse files Browse the repository at this point in the history
  • Loading branch information
doughsay committed Dec 4, 2021
1 parent 2ed1fc2 commit 6a8bd46
Show file tree
Hide file tree
Showing 29 changed files with 265 additions and 64 deletions.
6 changes: 4 additions & 2 deletions .credo.exs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@
# You can customize the priority of any check
# Priority values are: `low, normal, high, higher`
#
{Credo.Check.Design.AliasUsage, [priority: :low, if_nested_deeper_than: 2, if_called_more_often_than: 0]},
{Credo.Check.Design.AliasUsage,
[priority: :low, if_nested_deeper_than: 2, if_called_more_often_than: 0]},
# You can also customize the exit_status of each check.
# If you don't want TODO comments to cause `mix credo` to fail, just
# set this value to 0 (zero).
Expand Down Expand Up @@ -158,7 +159,8 @@
{Credo.Check.Warning.UnsafeExec, []},

# moved from "controversial/experimental"
{Credo.Check.Consistency.MultiAliasImportRequireUse, files: %{excluded: ["lib/ambry_web.ex"]}},
{Credo.Check.Consistency.MultiAliasImportRequireUse,
files: %{excluded: ["lib/ambry_web.ex"]}},
{Credo.Check.Consistency.UnusedVariableNames, []},
{Credo.Check.Design.DuplicatedCode, []},
{Credo.Check.Readability.ImplTrue, []},
Expand Down
1 change: 0 additions & 1 deletion .formatter.exs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[
line_length: 120,
import_deps: [:ecto, :phoenix, :surface],
plugins: [Surface.Formatter.Plugin],
inputs: [
Expand Down
3 changes: 2 additions & 1 deletion lib/ambry/file_utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ defmodule Ambry.FileUtils do
def maybe_delete_image(web_path) do
book_count = Repo.one(from b in Book, select: count(b.id), where: b.image_path == ^web_path)

person_count = Repo.one(from p in Person, select: count(p.id), where: p.image_path == ^web_path)
person_count =
Repo.one(from p in Person, select: count(p.id), where: p.image_path == ^web_path)

if book_count + person_count == 0 do
disk_path = Paths.web_to_disk(web_path)
Expand Down
6 changes: 4 additions & 2 deletions lib/ambry/people.ex
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,17 @@ defmodule Ambry.People do
{narrated_books,
[
authors: narrated_book_authors,
series_books: {narrated_book_series_books, series: narrated_book_series_book_series}
series_books:
{narrated_book_series_books, series: narrated_book_series_book_series}
]}},
authors:
{authors,
books:
{authored_books,
[
authors: authored_book_authors,
series_books: {authored_book_series_books, series: authored_book_series_book_series}
series_books:
{authored_book_series_books, series: authored_book_series_book_series}
]}}
],
order_by: [desc: narrated_books.published, desc: authored_books.published]
Expand Down
3 changes: 2 additions & 1 deletion lib/ambry_web/controllers/api/bookmarks_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ defmodule AmbryWeb.API.BookmarkController do
def index(conn, %{"media_id" => media_id} = params) do
offset = offset_from_params(params, @limit)

{bookmarks, has_more?} = Media.list_bookmarks(conn.assigns.api_user.id, media_id, offset, @limit)
{bookmarks, has_more?} =
Media.list_bookmarks(conn.assigns.api_user.id, media_id, offset, @limit)

render(conn, "index.json", bookmarks: bookmarks, has_more?: has_more?)
end
Expand Down
3 changes: 2 additions & 1 deletion lib/ambry_web/controllers/api/player_state_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ defmodule AmbryWeb.API.PlayerStateController do
def index(conn, params) do
offset = offset_from_params(params, @limit)

{player_states, has_more?} = Media.get_recent_player_states(conn.assigns.api_user.id, offset, @limit)
{player_states, has_more?} =
Media.get_recent_player_states(conn.assigns.api_user.id, offset, @limit)

render(conn, "index.json", player_states: player_states, has_more?: has_more?)
end
Expand Down
14 changes: 12 additions & 2 deletions lib/ambry_web/live/admin/audit_live/index.sface
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@
{file.path}
</div>
<a data-confirm="Are you sure?" href="#" :on-click="delete-file" :values={id: file.id}>
<svg xmlns="http://www.w3.org/2000/svg" class="text-red-600 h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
<svg
xmlns="http://www.w3.org/2000/svg"
class="text-red-600 h-5 w-5"
viewBox="0 0 20 20"
fill="currentColor"
>
<path
fill-rule="evenodd"
d="M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z"
Expand Down Expand Up @@ -83,7 +88,12 @@
{folder.path}
</div>
<a data-confirm="Are you sure?" href="#" :on-click="delete-folder" :values={id: folder.id}>
<svg xmlns="http://www.w3.org/2000/svg" class="text-red-600 h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
<svg
xmlns="http://www.w3.org/2000/svg"
class="text-red-600 h-5 w-5"
viewBox="0 0 20 20"
fill="currentColor"
>
<path
fill-rule="evenodd"
d="M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z"
Expand Down
3 changes: 2 additions & 1 deletion lib/ambry_web/live/admin/book_live/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ defmodule AmbryWeb.Admin.BookLive.Index do
socket = maybe_update_books(socket, %{"filter" => query, "page" => "1"})
list_opts = get_list_opts(socket)

{:noreply, push_patch(socket, to: Routes.admin_book_index_path(socket, :index, patch_opts(list_opts)))}
{:noreply,
push_patch(socket, to: Routes.admin_book_index_path(socket, :index, patch_opts(list_opts)))}
end

defp list_books(opts) do
Expand Down
19 changes: 16 additions & 3 deletions lib/ambry_web/live/admin/book_live/index.sface
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
<h1 class="text-4xl mb-4">Books</h1>

{#if @live_action in [:new, :edit]}
<Modal id={@book.id || :new} return_to={Routes.admin_book_index_path(@socket, :index, patch_opts(@list_opts))}>
<Modal
id={@book.id || :new}
return_to={Routes.admin_book_index_path(@socket, :index, patch_opts(@list_opts))}
>
<FormComponent
id={@book.id || :new}
title={@page_title}
Expand Down Expand Up @@ -75,7 +78,12 @@
</LivePatch>
</div>
<LivePatch to={Routes.admin_book_index_path(@socket, :edit, book, patch_opts(@list_opts))}>
<svg xmlns="http://www.w3.org/2000/svg" class="text-lime-500 h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
<svg
xmlns="http://www.w3.org/2000/svg"
class="text-lime-500 h-5 w-5"
viewBox="0 0 20 20"
fill="currentColor"
>
<path d="M17.414 2.586a2 2 0 00-2.828 0L7 10.172V13h2.828l7.586-7.586a2 2 0 000-2.828z" />
<path
fill-rule="evenodd"
Expand All @@ -85,7 +93,12 @@
</svg>
</LivePatch>
<a data-confirm="Are you sure?" href="#" :on-click="delete" :values={id: book.id}>
<svg xmlns="http://www.w3.org/2000/svg" class="text-red-600 h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
<svg
xmlns="http://www.w3.org/2000/svg"
class="text-red-600 h-5 w-5"
viewBox="0 0 20 20"
fill="currentColor"
>
<path
fill-rule="evenodd"
d="M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z"
Expand Down
3 changes: 2 additions & 1 deletion lib/ambry_web/live/admin/media_live/form_component.ex
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ defmodule AmbryWeb.Admin.MediaLive.FormComponent do

@impl Phoenix.LiveComponent
def update(%{media: media} = assigns, socket) do
changeset = Media.change_media(media, init_media_param(media), for: changeset_action(assigns.action))
changeset =
Media.change_media(media, init_media_param(media), for: changeset_action(assigns.action))

socket =
if assigns.action == :edit do
Expand Down
3 changes: 2 additions & 1 deletion lib/ambry_web/live/admin/media_live/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ defmodule AmbryWeb.Admin.MediaLive.Index do
socket = maybe_update_media(socket, %{"filter" => query, "page" => "1"})
list_opts = get_list_opts(socket)

{:noreply, push_patch(socket, to: Routes.admin_media_index_path(socket, :index, patch_opts(list_opts)))}
{:noreply,
push_patch(socket, to: Routes.admin_media_index_path(socket, :index, patch_opts(list_opts)))}
end

defp list_media(opts) do
Expand Down
26 changes: 22 additions & 4 deletions lib/ambry_web/live/admin/media_live/index.sface
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
{/if}

{#if @live_action == :chapters}
<Modal id={@selected_media.id} return_to={Routes.admin_media_index_path(@socket, :index, patch_opts(@list_opts))}>
<Modal
id={@selected_media.id}
return_to={Routes.admin_media_index_path(@socket, :index, patch_opts(@list_opts))}
>
<ChaptersComponent
id={@selected_media.id}
title={@page_title}
Expand Down Expand Up @@ -104,7 +107,12 @@
</LivePatch>
</div>
<LivePatch to={Routes.admin_media_index_path(@socket, :chapters, media, patch_opts(@list_opts))}>
<svg xmlns="http://www.w3.org/2000/svg" class="text-lime-500 h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
<svg
xmlns="http://www.w3.org/2000/svg"
class="text-lime-500 h-5 w-5"
viewBox="0 0 20 20"
fill="currentColor"
>
<path
fill-rule="evenodd"
d="M3 4a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm0 4a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm0 4a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm0 4a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1z"
Expand All @@ -113,7 +121,12 @@
</svg>
</LivePatch>
<LivePatch to={Routes.admin_media_index_path(@socket, :edit, media, patch_opts(@list_opts))}>
<svg xmlns="http://www.w3.org/2000/svg" class="text-lime-500 h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
<svg
xmlns="http://www.w3.org/2000/svg"
class="text-lime-500 h-5 w-5"
viewBox="0 0 20 20"
fill="currentColor"
>
<path d="M17.414 2.586a2 2 0 00-2.828 0L7 10.172V13h2.828l7.586-7.586a2 2 0 000-2.828z" />
<path
fill-rule="evenodd"
Expand All @@ -123,7 +136,12 @@
</svg>
</LivePatch>
<a data-confirm="Are you sure?" href="#" :on-click="delete" :values={id: media.id}>
<svg xmlns="http://www.w3.org/2000/svg" class="text-red-600 h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
<svg
xmlns="http://www.w3.org/2000/svg"
class="text-red-600 h-5 w-5"
viewBox="0 0 20 20"
fill="currentColor"
>
<path
fill-rule="evenodd"
d="M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z"
Expand Down
3 changes: 2 additions & 1 deletion lib/ambry_web/live/admin/person_live/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ defmodule AmbryWeb.Admin.PersonLive.Index do
socket = maybe_update_people(socket, %{"filter" => query, "page" => "1"})
list_opts = get_list_opts(socket)

{:noreply, push_patch(socket, to: Routes.admin_person_index_path(socket, :index, patch_opts(list_opts)))}
{:noreply,
push_patch(socket, to: Routes.admin_person_index_path(socket, :index, patch_opts(list_opts)))}
end

defp list_people(opts) do
Expand Down
19 changes: 16 additions & 3 deletions lib/ambry_web/live/admin/person_live/index.sface
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
<h1 class="text-4xl mb-4">People</h1>

{#if @live_action in [:new, :edit]}
<Modal id={@person.id || :new} return_to={Routes.admin_person_index_path(@socket, :index, patch_opts(@list_opts))}>
<Modal
id={@person.id || :new}
return_to={Routes.admin_person_index_path(@socket, :index, patch_opts(@list_opts))}
>
<FormComponent
id={@person.id || :new}
title={@page_title}
Expand Down Expand Up @@ -69,7 +72,12 @@
</LivePatch>
</div>
<LivePatch to={Routes.admin_person_index_path(@socket, :edit, person, patch_opts(@list_opts))}>
<svg xmlns="http://www.w3.org/2000/svg" class="text-lime-500 h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
<svg
xmlns="http://www.w3.org/2000/svg"
class="text-lime-500 h-5 w-5"
viewBox="0 0 20 20"
fill="currentColor"
>
<path d="M17.414 2.586a2 2 0 00-2.828 0L7 10.172V13h2.828l7.586-7.586a2 2 0 000-2.828z" />
<path
fill-rule="evenodd"
Expand All @@ -79,7 +87,12 @@
</svg>
</LivePatch>
<a data-confirm="Are you sure?" href="#" :on-click="delete" :values={id: person.id}>
<svg xmlns="http://www.w3.org/2000/svg" class="text-red-600 h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
<svg
xmlns="http://www.w3.org/2000/svg"
class="text-red-600 h-5 w-5"
viewBox="0 0 20 20"
fill="currentColor"
>
<path
fill-rule="evenodd"
d="M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z"
Expand Down
3 changes: 2 additions & 1 deletion lib/ambry_web/live/admin/series_live/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ defmodule AmbryWeb.Admin.SeriesLive.Index do
socket = maybe_update_series(socket, %{"filter" => query, "page" => "1"})
list_opts = get_list_opts(socket)

{:noreply, push_patch(socket, to: Routes.admin_series_index_path(socket, :index, patch_opts(list_opts)))}
{:noreply,
push_patch(socket, to: Routes.admin_series_index_path(socket, :index, patch_opts(list_opts)))}
end

defp list_series(opts) do
Expand Down
14 changes: 12 additions & 2 deletions lib/ambry_web/live/admin/series_live/index.sface
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@
</LivePatch>
</div>
<LivePatch to={Routes.admin_series_index_path(@socket, :edit, series, patch_opts(@list_opts))}>
<svg xmlns="http://www.w3.org/2000/svg" class="text-lime-500 h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
<svg
xmlns="http://www.w3.org/2000/svg"
class="text-lime-500 h-5 w-5"
viewBox="0 0 20 20"
fill="currentColor"
>
<path d="M17.414 2.586a2 2 0 00-2.828 0L7 10.172V13h2.828l7.586-7.586a2 2 0 000-2.828z" />
<path
fill-rule="evenodd"
Expand All @@ -82,7 +87,12 @@
</svg>
</LivePatch>
<a data-confirm="Are you sure?" href="#" :on-click="delete" :values={id: series.id}>
<svg xmlns="http://www.w3.org/2000/svg" class="text-red-600 h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
<svg
xmlns="http://www.w3.org/2000/svg"
class="text-red-600 h-5 w-5"
viewBox="0 0 20 20"
fill="currentColor"
>
<path
fill-rule="evenodd"
d="M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z"
Expand Down
5 changes: 4 additions & 1 deletion lib/ambry_web/live/book_live/header.sface
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@

{#for series_book <- Enum.sort_by(@book.series_books, & &1.series.name)}
<p class="text-gray-400">
<LiveRedirect to={Routes.series_show_path(Endpoint, :show, series_book.series)} class="hover:underline">
<LiveRedirect
to={Routes.series_show_path(Endpoint, :show, series_book.series)}
class="hover:underline"
>
{series_book.series.name} #{series_book.book_number}
</LiveRedirect>
</p>
Expand Down
5 changes: 4 additions & 1 deletion lib/ambry_web/live/components/book_tiles.sface
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@

{#for series_book <- Enum.sort_by(book.series_books, & &1.series.name)}
<p class="text-sm text-gray-400">
<LiveRedirect to={Routes.series_show_path(Endpoint, :show, series_book.series)} class="hover:underline">
<LiveRedirect
to={Routes.series_show_path(Endpoint, :show, series_book.series)}
class="hover:underline"
>
{series_book.series.name}
#{series_book.book_number}
</LiveRedirect>
Expand Down
8 changes: 7 additions & 1 deletion lib/ambry_web/live/components/chevron_down.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ defmodule AmbryWeb.Components.ChevronDown do
@impl Surface.Component
def render(assigns) do
~F"""
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
</svg>
"""
Expand Down
8 changes: 7 additions & 1 deletion lib/ambry_web/live/components/chevron_up.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ defmodule AmbryWeb.Components.ChevronUp do
@impl Surface.Component
def render(assigns) do
~F"""
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 15l7-7 7 7" />
</svg>
"""
Expand Down
7 changes: 6 additions & 1 deletion lib/ambry_web/live/components/modal.sface
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<div id={@id} :on-window-keydown="close" phx-key="escape" class="fixed z-50 inset-0 overflow-y-auto">
<div
id={@id}
:on-window-keydown="close"
phx-key="escape"
class="fixed z-50 inset-0 overflow-y-auto"
>
<div class="flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0">
<div :on-capture-click="close" class="fixed inset-0 bg-gray-500 bg-opacity-75" />

Expand Down
Loading

0 comments on commit 6a8bd46

Please sign in to comment.