Converted interpolation to new syntax

This commit is contained in:
Kieran Eglin 2024-12-04 14:48:07 -08:00
parent 482e1793e4
commit bdef153e90
No known key found for this signature in database
GPG key ID: 193984967FCF432D
32 changed files with 149 additions and 127 deletions

View file

@ -41,4 +41,15 @@ defmodule Pinchflat.Utils.StringUtils do
string string
end end
end end
@doc """
Wraps a string in double braces. Useful as a UI helper now that
LiveView 1.0.0 allows `{}` for interpolation so now we can't use braces
directly in the view.
Returns binary()
"""
def double_brace(string) do
"{{ #{string} }}"
end
end end

View file

@ -100,6 +100,7 @@ defmodule PinchflatWeb do
import PinchflatWeb.CustomComponents.TextComponents import PinchflatWeb.CustomComponents.TextComponents
import PinchflatWeb.CustomComponents.TableComponents import PinchflatWeb.CustomComponents.TableComponents
import PinchflatWeb.CustomComponents.ButtonComponents import PinchflatWeb.CustomComponents.ButtonComponents
import Pinchflat.Utils.StringUtils, only: [double_brace: 1]
alias Pinchflat.Settings alias Pinchflat.Settings
alias Pinchflat.Utils.StringUtils alias Pinchflat.Utils.StringUtils

View file

@ -82,7 +82,7 @@ defmodule PinchflatWeb.CoreComponents do
</button> </button>
</div> </div>
<div id={"#{@id}-content"}> <div id={"#{@id}-content"}>
<%= render_slot(@inner_block) %> {render_slot(@inner_block)}
</div> </div>
</div> </div>
</div> </div>
@ -126,9 +126,9 @@ defmodule PinchflatWeb.CoreComponents do
]}> ]}>
<main> <main>
<h5 :if={@title} class="mb-2 text-lg font-bold"> <h5 :if={@title} class="mb-2 text-lg font-bold">
<%= @title %> {@title}
</h5> </h5>
<p class="mt-2 text-md leading-5 opacity-80"><%= msg %></p> <p class="mt-2 text-md leading-5 opacity-80">{msg}</p>
</main> </main>
<button <button
type="button" type="button"
@ -208,9 +208,9 @@ defmodule PinchflatWeb.CoreComponents do
def simple_form(assigns) do def simple_form(assigns) do
~H""" ~H"""
<.form :let={f} for={@for} as={@as} {@rest}> <.form :let={f} for={@for} as={@as} {@rest}>
<%= render_slot(@inner_block, f) %> {render_slot(@inner_block, f)}
<div :for={action <- @actions} class="mt-2 flex items-center justify-between gap-6"> <div :for={action <- @actions} class="mt-2 flex items-center justify-between gap-6">
<%= render_slot(action, f) %> {render_slot(action, f)}
</div> </div>
</.form> </.form>
""" """
@ -297,11 +297,11 @@ defmodule PinchflatWeb.CoreComponents do
class={["rounded focus:ring-0", @inputclass]} class={["rounded focus:ring-0", @inputclass]}
{@rest} {@rest}
/> />
<%= @label %> {@label}
<span :if={@label_suffix} class="text-xs text-bodydark"><%= @label_suffix %></span> <span :if={@label_suffix} class="text-xs text-bodydark">{@label_suffix}</span>
</label> </label>
<.help :if={@help}><%= if @html_help, do: Phoenix.HTML.raw(@help), else: @help %></.help> <.help :if={@help}>{if @html_help, do: Phoenix.HTML.raw(@help), else: @help}</.help>
<.error :for={msg <- @errors}><%= msg %></.error> <.error :for={msg <- @errors}>{msg}</.error>
</div> </div>
""" """
end end
@ -310,7 +310,7 @@ defmodule PinchflatWeb.CoreComponents do
~H""" ~H"""
<div phx-feedback-for={@name}> <div phx-feedback-for={@name}>
<.label for={@id}> <.label for={@id}>
<%= @label %><span :if={@label_suffix} class="text-xs text-bodydark"><%= @label_suffix %></span> {@label}<span :if={@label_suffix} class="text-xs text-bodydark">{@label_suffix}</span>
</.label> </.label>
<section class="grid grid-cols-1 gap-2 md:grid-cols-2 max-w-prose mb-4 ml-1"> <section class="grid grid-cols-1 gap-2 md:grid-cols-2 max-w-prose mb-4 ml-1">
<div :for={{option_name, option_value} <- @options} class="flex items-center"> <div :for={{option_name, option_value} <- @options} class="flex items-center">
@ -323,12 +323,12 @@ defmodule PinchflatWeb.CoreComponents do
class={["rounded focus:ring-offset-0 ring-offset-0 focus:ring-0 h-5 w-5 ", @inputclass]} class={["rounded focus:ring-offset-0 ring-offset-0 focus:ring-0 h-5 w-5 ", @inputclass]}
/> />
<label for={"#{@id}-#{option_value}"} class="ml-2 cursor-pointer select-none"> <label for={"#{@id}-#{option_value}"} class="ml-2 cursor-pointer select-none">
<%= option_name %> {option_name}
</label> </label>
</div> </div>
</section> </section>
<.help :if={@help}><%= if @html_help, do: Phoenix.HTML.raw(@help), else: @help %></.help> <.help :if={@help}>{if @html_help, do: Phoenix.HTML.raw(@help), else: @help}</.help>
<.error :for={msg <- @errors}><%= msg %></.error> <.error :for={msg <- @errors}>{msg}</.error>
</div> </div>
""" """
end end
@ -342,8 +342,8 @@ defmodule PinchflatWeb.CoreComponents do
~H""" ~H"""
<div x-data={"{ enabled: #{@checked} }"} class="" phx-update="ignore" id={"#{@id}-wrapper"}> <div x-data={"{ enabled: #{@checked} }"} class="" phx-update="ignore" id={"#{@id}-wrapper"}>
<.label :if={@label} for={@id}> <.label :if={@label} for={@id}>
<%= @label %> {@label}
<span :if={@label_suffix} class="text-xs text-bodydark"><%= @label_suffix %></span> <span :if={@label_suffix} class="text-xs text-bodydark">{@label_suffix}</span>
</.label> </.label>
<div class="relative flex flex-col"> <div class="relative flex flex-col">
<input type="hidden" id={@id} name={@name} x-bind:value="enabled" {@rest} /> <input type="hidden" id={@id} name={@name} x-bind:value="enabled" {@rest} />
@ -359,8 +359,8 @@ defmodule PinchflatWeb.CoreComponents do
> >
</div> </div>
</div> </div>
<.help :if={@help}><%= if @html_help, do: Phoenix.HTML.raw(@help), else: @help %></.help> <.help :if={@help}>{if @html_help, do: Phoenix.HTML.raw(@help), else: @help}</.help>
<.error :for={msg <- @errors}><%= msg %></.error> <.error :for={msg <- @errors}>{msg}</.error>
</div> </div>
</div> </div>
""" """
@ -370,7 +370,7 @@ defmodule PinchflatWeb.CoreComponents do
~H""" ~H"""
<div phx-feedback-for={@name}> <div phx-feedback-for={@name}>
<.label :if={@label} for={@id}> <.label :if={@label} for={@id}>
<%= @label %><span :if={@label_suffix} class="text-xs text-bodydark"><%= @label_suffix %></span> {@label}<span :if={@label_suffix} class="text-xs text-bodydark">{@label_suffix}</span>
</.label> </.label>
<div class="flex"> <div class="flex">
<select <select
@ -385,13 +385,13 @@ defmodule PinchflatWeb.CoreComponents do
multiple={@multiple} multiple={@multiple}
{@rest} {@rest}
> >
<option :if={@prompt} value=""><%= @prompt %></option> <option :if={@prompt} value="">{@prompt}</option>
<%= Phoenix.HTML.Form.options_for_select(@options, @value) %> {Phoenix.HTML.Form.options_for_select(@options, @value)}
</select> </select>
<%= render_slot(@inner_block) %> {render_slot(@inner_block)}
</div> </div>
<.help :if={@help}><%= if @html_help, do: Phoenix.HTML.raw(@help), else: @help %></.help> <.help :if={@help}>{if @html_help, do: Phoenix.HTML.raw(@help), else: @help}</.help>
<.error :for={msg <- @errors}><%= msg %></.error> <.error :for={msg <- @errors}>{msg}</.error>
</div> </div>
""" """
end end
@ -400,7 +400,7 @@ defmodule PinchflatWeb.CoreComponents do
~H""" ~H"""
<div phx-feedback-for={@name}> <div phx-feedback-for={@name}>
<.label for={@id}> <.label for={@id}>
<%= @label %><span :if={@label_suffix} class="text-xs text-bodydark"><%= @label_suffix %></span> {@label}<span :if={@label_suffix} class="text-xs text-bodydark">{@label_suffix}</span>
</.label> </.label>
<textarea <textarea
id={@id} id={@id}
@ -414,8 +414,8 @@ defmodule PinchflatWeb.CoreComponents do
]} ]}
{@rest} {@rest}
><%= Phoenix.HTML.Form.normalize_value("textarea", @value) %></textarea> ><%= Phoenix.HTML.Form.normalize_value("textarea", @value) %></textarea>
<.help :if={@help}><%= if @html_help, do: Phoenix.HTML.raw(@help), else: @help %></.help> <.help :if={@help}>{if @html_help, do: Phoenix.HTML.raw(@help), else: @help}</.help>
<.error :for={msg <- @errors}><%= msg %></.error> <.error :for={msg <- @errors}>{msg}</.error>
</div> </div>
""" """
end end
@ -425,7 +425,7 @@ defmodule PinchflatWeb.CoreComponents do
~H""" ~H"""
<div phx-feedback-for={@name}> <div phx-feedback-for={@name}>
<.label for={@id}> <.label for={@id}>
<%= @label %><span :if={@label_suffix} class="text-xs text-bodydark"><%= @label_suffix %></span> {@label}<span :if={@label_suffix} class="text-xs text-bodydark">{@label_suffix}</span>
</.label> </.label>
<div class="flex items-center"> <div class="flex items-center">
<input <input
@ -442,10 +442,10 @@ defmodule PinchflatWeb.CoreComponents do
]} ]}
{@rest} {@rest}
/> />
<%= render_slot(@input_append) %> {render_slot(@input_append)}
</div> </div>
<.help :if={@help}><%= if @html_help, do: Phoenix.HTML.raw(@help), else: @help %></.help> <.help :if={@help}>{if @html_help, do: Phoenix.HTML.raw(@help), else: @help}</.help>
<.error :for={msg <- @errors}><%= msg %></.error> <.error :for={msg <- @errors}>{msg}</.error>
</div> </div>
""" """
end end
@ -458,7 +458,7 @@ defmodule PinchflatWeb.CoreComponents do
def help(assigns) do def help(assigns) do
~H""" ~H"""
<p class="mt-1 text-sm leading-5"> <p class="mt-1 text-sm leading-5">
<%= render_slot(@inner_block) %> {render_slot(@inner_block)}
</p> </p>
""" """
end end
@ -472,7 +472,7 @@ defmodule PinchflatWeb.CoreComponents do
def label(assigns) do def label(assigns) do
~H""" ~H"""
<label for={@for} class="mt-5 mb-2 inline-block text-md font-medium text-black dark:text-white"> <label for={@for} class="mt-5 mb-2 inline-block text-md font-medium text-black dark:text-white">
<%= render_slot(@inner_block) %> {render_slot(@inner_block)}
</label> </label>
""" """
end end
@ -486,7 +486,7 @@ defmodule PinchflatWeb.CoreComponents do
~H""" ~H"""
<p class="mt-1 mb-5 flex gap-3 text-md leading-6 text-rose-600 phx-no-feedback:hidden"> <p class="mt-1 mb-5 flex gap-3 text-md leading-6 text-rose-600 phx-no-feedback:hidden">
<.icon name="hero-exclamation-circle-mini" class="mt-0.5 h-5 w-5 flex-none" /> <.icon name="hero-exclamation-circle-mini" class="mt-0.5 h-5 w-5 flex-none" />
<%= render_slot(@inner_block) %> {render_slot(@inner_block)}
</p> </p>
""" """
end end
@ -505,13 +505,13 @@ defmodule PinchflatWeb.CoreComponents do
<header class={[@actions != [] && "flex items-center justify-between gap-6", @class]}> <header class={[@actions != [] && "flex items-center justify-between gap-6", @class]}>
<div> <div>
<h1 class="text-lg font-semibold leading-8 text-zinc-800"> <h1 class="text-lg font-semibold leading-8 text-zinc-800">
<%= render_slot(@inner_block) %> {render_slot(@inner_block)}
</h1> </h1>
<p :if={@subtitle != []} class="mt-2 text-sm leading-6 text-zinc-600"> <p :if={@subtitle != []} class="mt-2 text-sm leading-6 text-zinc-600">
<%= render_slot(@subtitle) %> {render_slot(@subtitle)}
</p> </p>
</div> </div>
<div class="flex-none"><%= render_slot(@actions) %></div> <div class="flex-none">{render_slot(@actions)}</div>
</header> </header>
""" """
end end
@ -551,9 +551,9 @@ defmodule PinchflatWeb.CoreComponents do
<table class="w-[40rem] mt-11 sm:w-full"> <table class="w-[40rem] mt-11 sm:w-full">
<thead class="text-sm text-left leading-6 text-zinc-500"> <thead class="text-sm text-left leading-6 text-zinc-500">
<tr> <tr>
<th :for={col <- @col} class="p-0 pb-4 pr-6 font-normal"><%= col[:label] %></th> <th :for={col <- @col} class="p-0 pb-4 pr-6 font-normal">{col[:label]}</th>
<th :if={@action != []} class="relative p-0 pb-4"> <th :if={@action != []} class="relative p-0 pb-4">
<span class="sr-only"><%= gettext("Actions") %></span> <span class="sr-only">{gettext("Actions")}</span>
</th> </th>
</tr> </tr>
</thead> </thead>
@ -571,7 +571,7 @@ defmodule PinchflatWeb.CoreComponents do
<div class="block py-4 pr-6"> <div class="block py-4 pr-6">
<span class="absolute -inset-y-px right-0 -left-4 group-hover:bg-zinc-50 sm:rounded-l-xl" /> <span class="absolute -inset-y-px right-0 -left-4 group-hover:bg-zinc-50 sm:rounded-l-xl" />
<span class={["relative", i == 0 && "font-semibold text-zinc-900"]}> <span class={["relative", i == 0 && "font-semibold text-zinc-900"]}>
<%= render_slot(col, @row_item.(row)) %> {render_slot(col, @row_item.(row))}
</span> </span>
</div> </div>
</td> </td>
@ -579,7 +579,7 @@ defmodule PinchflatWeb.CoreComponents do
<div class="relative whitespace-nowrap py-4 text-right text-sm font-medium"> <div class="relative whitespace-nowrap py-4 text-right text-sm font-medium">
<span class="absolute -inset-y-px -right-4 left-0 group-hover:bg-zinc-50 sm:rounded-r-xl" /> <span class="absolute -inset-y-px -right-4 left-0 group-hover:bg-zinc-50 sm:rounded-r-xl" />
<span :for={action <- @action} class="relative ml-4 font-semibold leading-6 text-zinc-900 hover:text-zinc-700"> <span :for={action <- @action} class="relative ml-4 font-semibold leading-6 text-zinc-900 hover:text-zinc-700">
<%= render_slot(action, @row_item.(row)) %> {render_slot(action, @row_item.(row))}
</span> </span>
</div> </div>
</td> </td>
@ -608,8 +608,8 @@ defmodule PinchflatWeb.CoreComponents do
<div class="mt-2 mb-14"> <div class="mt-2 mb-14">
<dl class="-my-4 divide-y dark:divide-strokedark"> <dl class="-my-4 divide-y dark:divide-strokedark">
<div :for={item <- @item} class="flex gap-4 py-4 text-sm leading-6 sm:gap-8"> <div :for={item <- @item} class="flex gap-4 py-4 text-sm leading-6 sm:gap-8">
<dt class="w-1/4 flex-none dark:text-white"><%= item.title %></dt> <dt class="w-1/4 flex-none dark:text-white">{item.title}</dt>
<dd class="dark:text-white"><%= render_slot(item) %></dd> <dd class="dark:text-white">{render_slot(item)}</dd>
</div> </div>
</dl> </dl>
</div> </div>
@ -644,12 +644,12 @@ defmodule PinchflatWeb.CoreComponents do
~H""" ~H"""
<ul> <ul>
<li :for={{k, v} <- @iterable_attributes} class="mb-2 w-2/3"> <li :for={{k, v} <- @iterable_attributes} class="mb-2 w-2/3">
<strong><%= k %>:</strong> <strong>{k}:</strong>
<code class="inline-block text-sm font-mono text-gray p-0.5 mx-0.5"> <code class="inline-block text-sm font-mono text-gray p-0.5 mx-0.5">
<%= if is_binary(v) && URI.parse(v).scheme && URI.parse(v).scheme =~ "http" do %> <%= if is_binary(v) && URI.parse(v).scheme && URI.parse(v).scheme =~ "http" do %>
<TextComponents.inline_link href={v}><%= v %></TextComponents.inline_link> <TextComponents.inline_link href={v}>{v}</TextComponents.inline_link>
<% else %> <% else %>
<%= v %> {v}
<% end %> <% end %>
</code> </code>
</li> </li>
@ -672,7 +672,7 @@ defmodule PinchflatWeb.CoreComponents do
<div class="mt-16"> <div class="mt-16">
<.link href={@href} class="text-sm font-semibold leading-6 text-zinc-900 hover:text-zinc-700"> <.link href={@href} class="text-sm font-semibold leading-6 text-zinc-900 hover:text-zinc-700">
<.icon name="hero-arrow-left-solid" class="h-3 w-3" /> <.icon name="hero-arrow-left-solid" class="h-3 w-3" />
<%= render_slot(@inner_block) %> {render_slot(@inner_block)}
</.link> </.link>
</div> </div>
""" """

View file

@ -37,7 +37,7 @@ defmodule PinchflatWeb.CustomComponents.ButtonComponents do
disabled={@disabled} disabled={@disabled}
{@rest} {@rest}
> >
<%= render_slot(@inner_block) %> {render_slot(@inner_block)}
</button> </button>
""" """
end end
@ -66,7 +66,7 @@ defmodule PinchflatWeb.CustomComponents.ButtonComponents do
"font-medium text-white hover:bg-opacity-95" "font-medium text-white hover:bg-opacity-95"
]} ]}
> >
<%= @text %> {@text}
<CoreComponents.icon <CoreComponents.icon
name="hero-chevron-down" name="hero-chevron-down"
class="fill-current duration-200 ease-linear mt-1" class="fill-current duration-200 ease-linear mt-1"
@ -81,7 +81,7 @@ defmodule PinchflatWeb.CustomComponents.ButtonComponents do
<ul class="flex flex-col"> <ul class="flex flex-col">
<li :for={option <- @option}> <li :for={option <- @option}>
<span class="flex px-5 py-2 font-medium text-bodydark2 hover:text-white cursor-pointer"> <span class="flex px-5 py-2 font-medium text-bodydark2 hover:text-white cursor-pointer">
<%= render_slot(option) %> {render_slot(option)}
</span> </span>
</li> </li>
</ul> </ul>
@ -126,7 +126,7 @@ defmodule PinchflatWeb.CustomComponents.ButtonComponents do
> >
<span class="border-light absolute -top-1 left-1/2 -z-10 h-2 w-2 -translate-x-1/2 rotate-45 rounded-sm bg-meta-4"> <span class="border-light absolute -top-1 left-1/2 -z-10 h-2 w-2 -translate-x-1/2 rotate-45 rounded-sm bg-meta-4">
</span> </span>
<span><%= @tooltip %></span> <span>{@tooltip}</span>
</div> </div>
</div> </div>
""" """

View file

@ -34,16 +34,16 @@ defmodule PinchflatWeb.CustomComponents.TabComponents do
x-bind:class={"openTab === '#{tab.id}' ? activeClasses : inactiveClasses"} x-bind:class={"openTab === '#{tab.id}' ? activeClasses : inactiveClasses"}
class="border-b-2 py-4 w-full sm:w-fit text-sm font-medium hover:text-meta-5 md:text-base" class="border-b-2 py-4 w-full sm:w-fit text-sm font-medium hover:text-meta-5 md:text-base"
> >
<span class="text-xl"><%= tab.title %></span> <span class="text-xl">{tab.title}</span>
</a> </a>
</div> </div>
<div class="mx-4 my-4 lg:my-0 flex gap-5 sm:gap-10 items-center"> <div class="mx-4 my-4 lg:my-0 flex gap-5 sm:gap-10 items-center">
<%= render_slot(@tab_append) %> {render_slot(@tab_append)}
</div> </div>
</header> </header>
<div class="mt-4 min-h-60"> <div class="mt-4 min-h-60">
<div :for={tab <- @tab} x-show={"openTab === '#{tab.id}'"} class="font-medium leading-relaxed"> <div :for={tab <- @tab} x-show={"openTab === '#{tab.id}'"} class="font-medium leading-relaxed">
<%= render_slot(tab) %> {render_slot(tab)}
</div> </div>
</div> </div>
</div> </div>

View file

@ -32,7 +32,7 @@ defmodule PinchflatWeb.CustomComponents.TableComponents do
<thead> <thead>
<tr class="text-left bg-meta-4"> <tr class="text-left bg-meta-4">
<th :for={col <- @col} class="px-4 py-4 font-medium text-white xl:pl-11"> <th :for={col <- @col} class="px-4 py-4 font-medium text-white xl:pl-11">
<%= col[:label] %> {col[:label]}
</th> </th>
</tr> </tr>
</thead> </thead>
@ -45,7 +45,7 @@ defmodule PinchflatWeb.CustomComponents.TableComponents do
col[:class] col[:class]
]} ]}
> >
<%= render_slot(col, @row_item.(row)) %> {render_slot(col, @row_item.(row))}
</td> </td>
</tr> </tr>
</tbody> </tbody>

View file

@ -12,7 +12,7 @@ defmodule PinchflatWeb.CustomComponents.TextComponents do
def inline_code(assigns) do def inline_code(assigns) do
~H""" ~H"""
<code class="inline-block text-sm font-mono text-gray bg-boxdark rounded-md p-0.5 mx-0.5 text-nowrap"> <code class="inline-block text-sm font-mono text-gray bg-boxdark rounded-md p-0.5 mx-0.5 text-nowrap">
<%= render_slot(@inner_block) %> {render_slot(@inner_block)}
</code> </code>
""" """
end end
@ -26,7 +26,7 @@ defmodule PinchflatWeb.CustomComponents.TextComponents do
def inline_link(assigns) do def inline_link(assigns) do
~H""" ~H"""
<.link href={@href} target="_blank" class="text-blue-500 hover:text-blue-300"> <.link href={@href} target="_blank" class="text-blue-500 hover:text-blue-300">
<%= render_slot(@inner_block) %> {render_slot(@inner_block)}
</.link> </.link>
""" """
end end
@ -41,7 +41,7 @@ defmodule PinchflatWeb.CustomComponents.TextComponents do
def subtle_link(assigns) do def subtle_link(assigns) do
~H""" ~H"""
<.link href={@href} target={@target} class="underline decoration-bodydark decoration-1 hover:decoration-white"> <.link href={@href} target={@target} class="underline decoration-bodydark decoration-1 hover:decoration-white">
<%= render_slot(@inner_block) %> {render_slot(@inner_block)}
</.link> </.link>
""" """
end end
@ -82,7 +82,7 @@ defmodule PinchflatWeb.CustomComponents.TextComponents do
assigns = Map.put(assigns, :text, formatted_text) assigns = Map.put(assigns, :text, formatted_text)
~H""" ~H"""
<span><%= @text %></span> <span>{@text}</span>
""" """
end end
@ -98,7 +98,7 @@ defmodule PinchflatWeb.CustomComponents.TextComponents do
assigns = Map.put(assigns, :timezone, timezone) assigns = Map.put(assigns, :timezone, timezone)
~H""" ~H"""
<time><%= Calendar.strftime(Timex.Timezone.convert(@datetime, @timezone), @format) %></time> <time>{Calendar.strftime(Timex.Timezone.convert(@datetime, @timezone), @format)}</time>
""" """
end end
@ -109,7 +109,7 @@ defmodule PinchflatWeb.CustomComponents.TextComponents do
def localized_number(assigns) do def localized_number(assigns) do
~H""" ~H"""
<span x-data x-text={"Intl.NumberFormat().format(#{@number})"}><%= @number %></span> <span x-data x-text={"Intl.NumberFormat().format(#{@number})"}>{@number}</span>
""" """
end end
@ -122,7 +122,7 @@ defmodule PinchflatWeb.CustomComponents.TextComponents do
def pluralize(assigns) do def pluralize(assigns) do
~H""" ~H"""
<%= @word %><%= if @count == 1, do: "", else: @suffix %> {@word}{if @count == 1, do: "", else: @suffix}
""" """
end end
end end

View file

@ -61,7 +61,7 @@ defmodule PinchflatWeb.Layouts do
x-on:click="selected = !selected" x-on:click="selected = !selected"
> >
<span class="flex items-center gap-2.5"> <span class="flex items-center gap-2.5">
<.icon name={@icon} /> <%= @text %> <.icon name={@icon} /> {@text}
</span> </span>
<span class="text-bodydark2"> <span class="text-bodydark2">
<.icon name="hero-chevron-down" x-bind:class="{ 'rotate-180': selected }" /> <.icon name="hero-chevron-down" x-bind:class="{ 'rotate-180': selected }" />
@ -103,7 +103,7 @@ defmodule PinchflatWeb.Layouts do
@class @class
]} ]}
> >
<.icon :if={@icon} name={@icon} /> <%= @text %> <.icon :if={@icon} name={@icon} /> {@text}
</.link> </.link>
""" """
end end

View file

@ -6,7 +6,7 @@
<main> <main>
<div class="mx-auto max-w-screen-2xl p-4 md:p-6 2xl:p-10"> <div class="mx-auto max-w-screen-2xl p-4 md:p-6 2xl:p-10">
<.flash_group flash={@flash} /> <.flash_group flash={@flash} />
<%= @inner_content %> {@inner_content}
</div> </div>
</main> </main>
</div> </div>

View file

@ -11,7 +11,7 @@
<main> <main>
<div class="mx-auto max-w-screen-2xl p-4 md:p-6 2xl:p-10"> <div class="mx-auto max-w-screen-2xl p-4 md:p-6 2xl:p-10">
<.flash_group flash={@flash} /> <.flash_group flash={@flash} />
<%= @inner_content %> {@inner_content}
</div> </div>
</main> </main>
</div> </div>

View file

@ -67,7 +67,7 @@
class="group relative flex items-center gap-2.5 px-4 pt-2 text-sm" class="group relative flex items-center gap-2.5 px-4 pt-2 text-sm"
x-on:click={"markVersionAsSeen('#{Application.spec(:pinchflat)[:vsn]}')"} x-on:click={"markVersionAsSeen('#{Application.spec(:pinchflat)[:vsn]}')"}
> >
<span>Pinchflat <%= Application.spec(:pinchflat)[:vsn] %></span> <span>Pinchflat {Application.spec(:pinchflat)[:vsn]}</span>
<a <a
href="https://github.com/kieraneglin/pinchflat/releases" href="https://github.com/kieraneglin/pinchflat/releases"
target="_blank" target="_blank"
@ -79,7 +79,7 @@
</a> </a>
</span> </span>
<span class="group relative flex items-center gap-2.5 px-4 pt-2 text-sm"> <span class="group relative flex items-center gap-2.5 px-4 pt-2 text-sm">
yt-dlp <%= Settings.get!(:yt_dlp_version) %> yt-dlp {Settings.get!(:yt_dlp_version)}
</span> </span>
</li> </li>
</ul> </ul>

View file

@ -25,6 +25,6 @@
into the text box and press the button. into the text box and press the button.
</p> </p>
<%= live_render(@conn, Pinchflat.UpgradeButtonLive) %> {live_render(@conn, Pinchflat.UpgradeButtonLive)}
</section> </section>
</.modal> </.modal>

View file

@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="csrf-token" content={get_csrf_token()} /> <meta name="csrf-token" content={get_csrf_token()} />
<.live_title> <.live_title>
<%= assigns[:page_title] || "Pinchflat" %> {assigns[:page_title] || "Pinchflat"}
</.live_title> </.live_title>
<link phx-track-static rel="stylesheet" href={~p"/assets/app.css"} /> <link phx-track-static rel="stylesheet" href={~p"/assets/app.css"} />
<link rel="icon" type="image/x-icon" href={~p"/favicon.ico?cachebust=2024-03-20"} /> <link rel="icon" type="image/x-icon" href={~p"/favicon.ico?cachebust=2024-03-20"} />
@ -21,7 +21,7 @@
class="dark text-bodydark bg-boxdark-2" class="dark text-bodydark bg-boxdark-2"
data-socket-path={Path.join(Application.get_env(:pinchflat, :base_route_path), "/live")} data-socket-path={Path.join(Application.get_env(:pinchflat, :base_route_path), "/live")}
> >
<%= @inner_content %> {@inner_content}
<.donate_modal conn={@conn} /> <.donate_modal conn={@conn} />
<template x-if="!proEnabled && !onboarding"> <template x-if="!proEnabled && !onboarding">

View file

@ -1,6 +1,6 @@
<div class="mb-6 flex gap-3 flex-row items-center"> <div class="mb-6 flex gap-3 flex-row items-center">
<h2 class="text-title-md2 font-bold text-black dark:text-white ml-4"> <h2 class="text-title-md2 font-bold text-black dark:text-white ml-4">
Editing "<%= StringUtils.truncate(@media_item.title, 35) %>" Editing "{StringUtils.truncate(@media_item.title, 35)}"
</h2> </h2>
</div> </div>

View file

@ -4,7 +4,7 @@
<.icon name="hero-arrow-left" class="w-10 h-10 hover:dark:text-white" /> <.icon name="hero-arrow-left" class="w-10 h-10 hover:dark:text-white" />
</.link> </.link>
<h2 class="text-title-md2 font-bold text-black dark:text-white ml-4"> <h2 class="text-title-md2 font-bold text-black dark:text-white ml-4">
<%= StringUtils.truncate(@media_item.title, 35) %> {StringUtils.truncate(@media_item.title, 35)}
</h2> </h2>
</div> </div>
@ -31,8 +31,8 @@
<.media_preview media_item={@media_item} /> <.media_preview media_item={@media_item} />
</div> </div>
<aside class="mt-4"> <aside class="mt-4">
<h2 class="text-xl mb-2"><%= @media_item.title %></h2> <h2 class="text-xl mb-2">{@media_item.title}</h2>
<div>Uploaded: <%= DateTime.to_date(@media_item.uploaded_at) %></div> <div>Uploaded: {DateTime.to_date(@media_item.uploaded_at)}</div>
<div> <div>
<span :if={URI.parse(@media_item.original_url).scheme =~ "http"}> <span :if={URI.parse(@media_item.original_url).scheme =~ "http"}>
<.subtle_link href={@media_item.original_url} target="_blank">Open Original</.subtle_link> <.subtle_link href={@media_item.original_url} target="_blank">Open Original</.subtle_link>
@ -58,7 +58,7 @@
<section> <section>
<strong>Source:</strong> <strong>Source:</strong>
<.subtle_link href={~p"/sources/#{@media_item.source_id}"}> <.subtle_link href={~p"/sources/#{@media_item.source_id}"}>
<%= @media_item.source.custom_name %> {@media_item.source.custom_name}
</.subtle_link> </.subtle_link>
<.list_items_from_map map={Map.from_struct(@media_item)} /> <.list_items_from_map map={Map.from_struct(@media_item)} />
</section> </section>
@ -68,10 +68,10 @@
<%= if match?([_|_], @media_item.tasks) do %> <%= if match?([_|_], @media_item.tasks) do %>
<.table rows={@media_item.tasks} table_class="text-black dark:text-white"> <.table rows={@media_item.tasks} table_class="text-black dark:text-white">
<:col :let={task} label="Worker"> <:col :let={task} label="Worker">
<%= task.job.worker %> {task.job.worker}
</:col> </:col>
<:col :let={task} label="State"> <:col :let={task} label="State">
<%= task.job.state %> {task.job.state}
</:col> </:col>
<:col :let={task} label="Scheduled At"> <:col :let={task} label="Scheduled At">
<.datetime_in_zone datetime={task.job.scheduled_at} /> <.datetime_in_zone datetime={task.job.scheduled_at} />

View file

@ -3,7 +3,7 @@
<.icon name="hero-arrow-left" class="w-10 h-10 hover:dark:text-white" /> <.icon name="hero-arrow-left" class="w-10 h-10 hover:dark:text-white" />
</.link> </.link>
<h2 class="text-title-md2 font-bold text-black dark:text-white ml-4"> <h2 class="text-title-md2 font-bold text-black dark:text-white ml-4">
Editing "<%= @media_profile.name %>" Editing "{@media_profile.name}"
</h2> </h2>
</div> </div>

View file

@ -16,11 +16,11 @@
<.table rows={@media_profiles} table_class="text-black dark:text-white"> <.table rows={@media_profiles} table_class="text-black dark:text-white">
<:col :let={media_profile} label="Name"> <:col :let={media_profile} label="Name">
<.subtle_link href={~p"/media_profiles/#{media_profile.id}"}> <.subtle_link href={~p"/media_profiles/#{media_profile.id}"}>
<%= media_profile.name %> {media_profile.name}
</.subtle_link> </.subtle_link>
</:col> </:col>
<:col :let={media_profile} label="Preferred Resolution"> <:col :let={media_profile} label="Preferred Resolution">
<%= media_profile.preferred_resolution %> {media_profile.preferred_resolution}
</:col> </:col>
<:col :let={media_profile} label="Sources"> <:col :let={media_profile} label="Sources">
<.subtle_link href={~p"/media_profiles/#{media_profile.id}/#tab-sources"}> <.subtle_link href={~p"/media_profiles/#{media_profile.id}/#tab-sources"}>

View file

@ -6,7 +6,9 @@
<ul class="list-disc list-inside ml-2 md:ml-5"> <ul class="list-disc list-inside ml-2 md:ml-5">
<li> <li>
Liquid-style: Liquid-style:
<.inline_code>/&lbrace;&lbrace; channel &rbrace;&rbrace;/&lbrace;&lbrace; title &rbrace;&rbrace; - &lbrace;&lbrace; id &rbrace;&rbrace;.&lbrace;&lbrace; ext &rbrace;&rbrace;</.inline_code> <.inline_code>
{"/#{double_brace("channel")}/#{double_brace("title")} - #{double_brace("id")}.#{double_brace("ext")}"}
</.inline_code>
</li> </li>
<li> <li>
<code class="text-sm">yt-dlp</code>-style <code class="text-sm">yt-dlp</code>-style
@ -17,7 +19,7 @@
</li> </li>
<li> <li>
Any bare words: Any bare words:
<.inline_code>/videos/1080p/&lbrace;&lbrace; id &rbrace;&rbrace;.&lbrace;&lbrace; ext &rbrace;&rbrace;</.inline_code> <.inline_code>{"/videos/1080p/#{double_brace("id")}.#{double_brace("ext")}"}</.inline_code>
</li> </li>
</ul> </ul>
<p class="my-2"> <p class="my-2">
@ -25,7 +27,7 @@
<em>any</em> <em>any</em>
single-word <code class="text-sm">yt-dlp</code> single-word <code class="text-sm">yt-dlp</code>
option can be used as liquid-style and it's automatically made filepath-safe. For example, the option can be used as liquid-style and it's automatically made filepath-safe. For example, the
<.inline_code>&lbrace;&lbrace; duration &rbrace;&rbrace;</.inline_code> <.inline_code>{double_brace("duration")}</.inline_code>
option is translated to option is translated to
<.inline_code>%(duration)S</.inline_code> <.inline_code>%(duration)S</.inline_code>
</p> </p>
@ -33,12 +35,14 @@
<strong>Major 🔑:</strong> <strong>Major 🔑:</strong>
these syntaxes can be mixed and matched freely! I prefer to use liquid-style and bare words these syntaxes can be mixed and matched freely! I prefer to use liquid-style and bare words
but I'll include <code class="text-sm">yt-dlp</code>-style when I need more control. For example: but I'll include <code class="text-sm">yt-dlp</code>-style when I need more control. For example:
<.inline_code>/1080p/&lbrace;&lbrace; channel &rbrace;&rbrace;/&lbrace;&lbrace; title &rbrace;&rbrace;-(%(subtitles.en.-1.ext)s).&lbrace;&lbrace; ext &rbrace;&rbrace;</.inline_code> <.inline_code>
{"/1080p/#{double_brace("channel")}/#{double_brace("title")}-(%(subtitles.en.-1.ext)s).#{double_brace("ext")}"}
</.inline_code>
</p> </p>
<p class="my-2"> <p class="my-2">
<strong>NOTE:</strong> <strong>NOTE:</strong>
Your template <em>must</em> Your template <em>must</em>
end with an extension option (<.inline_code>.&lbrace;&lbrace; ext &rbrace;&rbrace;</.inline_code> end with an extension option (<.inline_code>.{double_brace("ext")}</.inline_code>
or or
<.inline_code>.%(ext)S</.inline_code>). <.inline_code>.%(ext)S</.inline_code>).
Downloading won't work as expected without it. Downloading won't work as expected without it.
@ -59,21 +63,21 @@
<h3 class="text-lg font-bold my-2">Media Center Custom Aliases</h3> <h3 class="text-lg font-bold my-2">Media Center Custom Aliases</h3>
<ul class="list-disc list-inside mb-4 ml-2 md:ml-5 max-w-prose"> <ul class="list-disc list-inside mb-4 ml-2 md:ml-5 max-w-prose">
<li :for={{k, v} <- media_center_custom_output_template_options()} class="mt-1"> <li :for={{k, v} <- media_center_custom_output_template_options()} class="mt-1">
<.inline_code>&lbrace;&lbrace; <%= k %> &rbrace;&rbrace;</.inline_code> <.inline_code>{double_brace(k)}</.inline_code>
<span :if={v}>- <%= html_escape({:safe, v}) %></span> <span :if={v}>- {html_escape({:safe, v})}</span>
</li> </li>
</ul> </ul>
<h3 class="text-lg font-bold mb-2">Other Custom Aliases</h3> <h3 class="text-lg font-bold mb-2">Other Custom Aliases</h3>
<ul class="list-disc list-inside mb-4 ml-2 md:ml-5 max-w-prose"> <ul class="list-disc list-inside mb-4 ml-2 md:ml-5 max-w-prose">
<li :for={{k, v} <- other_custom_output_template_options()} class="mt-1"> <li :for={{k, v} <- other_custom_output_template_options()} class="mt-1">
<.inline_code>&lbrace;&lbrace; <%= k %> &rbrace;&rbrace;</.inline_code> <.inline_code>{double_brace(k)}</.inline_code>
<span :if={v}>- <%= html_escape({:safe, v}) %></span> <span :if={v}>- {html_escape({:safe, v})}</span>
</li> </li>
</ul> </ul>
<h3 class="text-lg font-bold mb-2">Common Options</h3> <h3 class="text-lg font-bold mb-2">Common Options</h3>
<ul class="list-disc list-inside ml-2 md:ml-5"> <ul class="list-disc list-inside ml-2 md:ml-5">
<li :for={opt <- common_output_template_options()} class="mt-1"> <li :for={opt <- common_output_template_options()} class="mt-1">
<.inline_code>&lbrace;&lbrace; <%= opt %> &rbrace;&rbrace;</.inline_code> <.inline_code>{double_brace(opt)}</.inline_code>
</li> </li>
</ul> </ul>
</section> </section>

View file

@ -4,7 +4,7 @@
<.icon name="hero-arrow-left" class="w-10 h-10 hover:dark:text-white" /> <.icon name="hero-arrow-left" class="w-10 h-10 hover:dark:text-white" />
</.link> </.link>
<h2 class="text-title-md2 font-bold text-black dark:text-white ml-2"> <h2 class="text-title-md2 font-bold text-black dark:text-white ml-2">
<%= @media_profile.name %> {@media_profile.name}
</h2> </h2>
</div> </div>
@ -33,10 +33,10 @@
<.table rows={@sources} table_class="text-black dark:text-white"> <.table rows={@sources} table_class="text-black dark:text-white">
<:col :let={source} label="Name"> <:col :let={source} label="Name">
<.subtle_link href={~p"/sources/#{source.id}"}> <.subtle_link href={~p"/sources/#{source.id}"}>
<%= source.custom_name || source.collection_name %> {source.custom_name || source.collection_name}
</.subtle_link> </.subtle_link>
</:col> </:col>
<:col :let={source} label="Type"><%= source.collection_type %></:col> <:col :let={source} label="Type">{source.collection_type}</:col>
<:col :let={source} label="Should Download?"> <:col :let={source} label="Should Download?">
<.icon name={if source.download_media, do: "hero-check", else: "hero-x-mark"} /> <.icon name={if source.download_media, do: "hero-check", else: "hero-x-mark"} />
</:col> </:col>

View file

@ -17,7 +17,7 @@ defmodule PinchflatWeb.Pages.PageHTML do
}) })
~H""" ~H"""
<.localized_number number={@num} /> <%= @suffix %> <.localized_number number={@num} /> {@suffix}
""" """
end end
end end

View file

@ -30,21 +30,21 @@ defmodule Pinchflat.Pages.HistoryTableLive do
<.table rows={@records} table_class="text-white"> <.table rows={@records} table_class="text-white">
<:col :let={media_item} label="Title"> <:col :let={media_item} label="Title">
<.subtle_link href={~p"/sources/#{media_item.source_id}/media/#{media_item}"}> <.subtle_link href={~p"/sources/#{media_item.source_id}/media/#{media_item}"}>
<%= StringUtils.truncate(media_item.title, 35) %> {StringUtils.truncate(media_item.title, 35)}
</.subtle_link> </.subtle_link>
</:col> </:col>
<:col :let={media_item} label="Upload Date"> <:col :let={media_item} label="Upload Date">
<%= DateTime.to_date(media_item.uploaded_at) %> {DateTime.to_date(media_item.uploaded_at)}
</:col> </:col>
<:col :let={media_item} label="Indexed At"> <:col :let={media_item} label="Indexed At">
<%= format_datetime(media_item.inserted_at) %> {format_datetime(media_item.inserted_at)}
</:col> </:col>
<:col :let={media_item} label="Downloaded At"> <:col :let={media_item} label="Downloaded At">
<%= format_datetime(media_item.media_downloaded_at) %> {format_datetime(media_item.media_downloaded_at)}
</:col> </:col>
<:col :let={media_item} label="Source"> <:col :let={media_item} label="Source">
<.subtle_link href={~p"/sources/#{media_item.source_id}"}> <.subtle_link href={~p"/sources/#{media_item.source_id}"}>
<%= StringUtils.truncate(media_item.source.custom_name, 35) %> {StringUtils.truncate(media_item.source.custom_name, 35)}
</.subtle_link> </.subtle_link>
</:col> </:col>
</.table> </.table>

View file

@ -42,13 +42,13 @@
<div class="rounded-sm border shadow-default border-strokedark bg-boxdark mt-4 p-5"> <div class="rounded-sm border shadow-default border-strokedark bg-boxdark mt-4 p-5">
<span class="text-2xl font-medium mb-4">Media History</span> <span class="text-2xl font-medium mb-4">Media History</span>
<section class="mt-6"> <section class="mt-6">
<%= live_render(@conn, Pinchflat.Pages.HistoryTableLive) %> {live_render(@conn, Pinchflat.Pages.HistoryTableLive)}
</section> </section>
</div> </div>
<div class="rounded-sm border shadow-default border-strokedark bg-boxdark mt-4 p-5"> <div class="rounded-sm border shadow-default border-strokedark bg-boxdark mt-4 p-5">
<span class="text-2xl font-medium mb-4">Active Tasks</span> <span class="text-2xl font-medium mb-4">Active Tasks</span>
<section class="mt-6 min-h-80"> <section class="mt-6 min-h-80">
<%= live_render(@conn, Pinchflat.Pages.JobTableLive) %> {live_render(@conn, Pinchflat.Pages.JobTableLive)}
</section> </section>
</div> </div>

View file

@ -19,18 +19,18 @@ defmodule Pinchflat.Pages.JobTableLive do
<div class="max-w-full overflow-x-auto"> <div class="max-w-full overflow-x-auto">
<.table rows={@tasks} table_class="text-white"> <.table rows={@tasks} table_class="text-white">
<:col :let={task} label="Task"> <:col :let={task} label="Task">
<%= worker_to_task_name(task.job.worker) %> {worker_to_task_name(task.job.worker)}
</:col> </:col>
<:col :let={task} label="Subject"> <:col :let={task} label="Subject">
<.subtle_link href={task_to_link(task)}> <.subtle_link href={task_to_link(task)}>
<%= StringUtils.truncate(task_to_record_name(task), 35) %> {StringUtils.truncate(task_to_record_name(task), 35)}
</.subtle_link> </.subtle_link>
</:col> </:col>
<:col :let={task} label="Attempt No."> <:col :let={task} label="Attempt No.">
<%= task.job.attempt %> {task.job.attempt}
</:col> </:col>
<:col :let={task} label="Started At"> <:col :let={task} label="Started At">
<%= format_datetime(task.job.attempted_at) %> {format_datetime(task.job.attempted_at)}
</:col> </:col>
</.table> </.table>
</div> </div>

View file

@ -14,7 +14,7 @@ defmodule PinchflatWeb.Searches.SearchHTML do
~H""" ~H"""
<%= for fragment <- @split_string do %> <%= for fragment <- @split_string do %>
<%= render_fragment(fragment) %> {render_fragment(fragment)}
<% end %> <% end %>
""" """
end end

View file

@ -1,6 +1,6 @@
<div class="mb-6 flex gap-3 flex-row items-center justify-between"> <div class="mb-6 flex gap-3 flex-row items-center justify-between">
<h2 class="text-title-md2 font-bold text-black dark:text-white"> <h2 class="text-title-md2 font-bold text-black dark:text-white">
Results for "<%= StringUtils.truncate(@search_term, 50) %>" Results for "{StringUtils.truncate(@search_term, 50)}"
</h2> </h2>
</div> </div>
@ -11,7 +11,7 @@
<.table rows={@search_results} table_class="text-black dark:text-white"> <.table rows={@search_results} table_class="text-black dark:text-white">
<:col :let={result} label="Title"> <:col :let={result} label="Title">
<.subtle_link href={~p"/sources/#{result.source_id}/media/#{result.id}"}> <.subtle_link href={~p"/sources/#{result.source_id}/media/#{result.id}"}>
<%= StringUtils.truncate(result.title, 35) %> {StringUtils.truncate(result.title, 35)}
</.subtle_link> </.subtle_link>
</:col> </:col>
<:col :let={result} label="Excerpt"> <:col :let={result} label="Excerpt">

View file

@ -19,11 +19,11 @@
</span> </span>
</section> </section>
<%= live_render( {live_render(
@conn, @conn,
Pinchflat.Settings.AppriseServerLive, Pinchflat.Settings.AppriseServerLive,
session: %{"value" => f[:apprise_server].value} session: %{"value" => f[:apprise_server].value}
) %> )}
</section> </section>
<section class="mt-8"> <section class="mt-8">

View file

@ -3,7 +3,7 @@
<.icon name="hero-arrow-left" class="w-10 h-10 hover:dark:text-white" /> <.icon name="hero-arrow-left" class="w-10 h-10 hover:dark:text-white" />
</.link> </.link>
<h2 class="text-title-md2 font-bold text-black dark:text-white ml-4"> <h2 class="text-title-md2 font-bold text-black dark:text-white ml-4">
Editing "<%= @source.custom_name %>" Editing "{@source.custom_name}"
</h2> </h2>
</div> </div>

View file

@ -12,7 +12,7 @@
<div class="rounded-sm border border-stroke bg-white shadow-default dark:border-strokedark dark:bg-boxdark"> <div class="rounded-sm border border-stroke bg-white shadow-default dark:border-strokedark dark:bg-boxdark">
<div class="max-w-full overflow-x-auto"> <div class="max-w-full overflow-x-auto">
<div class="flex flex-col gap-10 min-w-max"> <div class="flex flex-col gap-10 min-w-max">
<%= live_render(@conn, PinchflatWeb.Sources.IndexTableLive) %> {live_render(@conn, PinchflatWeb.Sources.IndexTableLive)}
</div> </div>
</div> </div>
</div> </div>

View file

@ -13,7 +13,7 @@ defmodule PinchflatWeb.Sources.IndexTableLive do
<.table rows={@sources} table_class="text-white"> <.table rows={@sources} table_class="text-white">
<:col :let={source} label="Name"> <:col :let={source} label="Name">
<.subtle_link href={~p"/sources/#{source.id}"}> <.subtle_link href={~p"/sources/#{source.id}"}>
<%= StringUtils.truncate(source.custom_name || source.collection_name, 35) %> {StringUtils.truncate(source.custom_name || source.collection_name, 35)}
</.subtle_link> </.subtle_link>
</:col> </:col>
<:col :let={source} label="Pending"> <:col :let={source} label="Pending">
@ -36,7 +36,7 @@ defmodule PinchflatWeb.Sources.IndexTableLive do
</:col> </:col>
<:col :let={source} label="Media Profile"> <:col :let={source} label="Media Profile">
<.subtle_link href={~p"/media_profiles/#{source.media_profile_id}"}> <.subtle_link href={~p"/media_profiles/#{source.media_profile_id}"}>
<%= source.media_profile.name %> {source.media_profile.name}
</.subtle_link> </.subtle_link>
</:col> </:col>
<:col :let={source} label="Enabled?"> <:col :let={source} label="Enabled?">

View file

@ -48,14 +48,14 @@ defmodule PinchflatWeb.Sources.MediaItemTableLive do
<.table rows={@records} table_class="text-white"> <.table rows={@records} table_class="text-white">
<:col :let={media_item} label="Title"> <:col :let={media_item} label="Title">
<.subtle_link href={~p"/sources/#{@source.id}/media/#{media_item.id}"}> <.subtle_link href={~p"/sources/#{@source.id}/media/#{media_item.id}"}>
<%= StringUtils.truncate(media_item.title, 50) %> {StringUtils.truncate(media_item.title, 50)}
</.subtle_link> </.subtle_link>
</:col> </:col>
<:col :let={media_item} :if={@media_state == "other"} label="Manually Ignored?"> <:col :let={media_item} :if={@media_state == "other"} label="Manually Ignored?">
<.icon name={if media_item.prevent_download, do: "hero-check", else: "hero-x-mark"} /> <.icon name={if media_item.prevent_download, do: "hero-check", else: "hero-x-mark"} />
</:col> </:col>
<:col :let={media_item} label="Upload Date"> <:col :let={media_item} label="Upload Date">
<%= DateTime.to_date(media_item.uploaded_at) %> {DateTime.to_date(media_item.uploaded_at)}
</:col> </:col>
<:col :let={media_item} label="" class="flex justify-end"> <:col :let={media_item} label="" class="flex justify-end">
<.icon_link href={~p"/sources/#{@source.id}/media/#{media_item.id}/edit"} icon="hero-pencil-square" class="mr-4" /> <.icon_link href={~p"/sources/#{@source.id}/media/#{media_item.id}/edit"} icon="hero-pencil-square" class="mr-4" />

View file

@ -4,7 +4,7 @@
<.icon name="hero-arrow-left" class="w-10 h-10 hover:dark:text-white" /> <.icon name="hero-arrow-left" class="w-10 h-10 hover:dark:text-white" />
</.link> </.link>
<h2 class="text-title-md2 font-bold text-black dark:text-white ml-4"> <h2 class="text-title-md2 font-bold text-black dark:text-white ml-4">
<%= @source.custom_name %> {@source.custom_name}
</h2> </h2>
</div> </div>
@ -29,7 +29,7 @@
<section> <section>
<strong>Media Profile:</strong> <strong>Media Profile:</strong>
<.subtle_link href={~p"/media_profiles/#{@source.media_profile_id}"}> <.subtle_link href={~p"/media_profiles/#{@source.media_profile_id}"}>
<%= @source.media_profile.name %> {@source.media_profile.name}
</.subtle_link> </.subtle_link>
</section> </section>
@ -37,34 +37,34 @@
</div> </div>
</:tab> </:tab>
<:tab title="Pending" id="pending"> <:tab title="Pending" id="pending">
<%= live_render( {live_render(
@conn, @conn,
PinchflatWeb.Sources.MediaItemTableLive, PinchflatWeb.Sources.MediaItemTableLive,
session: %{"source_id" => @source.id, "media_state" => "pending"} session: %{"source_id" => @source.id, "media_state" => "pending"}
) %> )}
</:tab> </:tab>
<:tab title="Downloaded" id="downloaded"> <:tab title="Downloaded" id="downloaded">
<%= live_render( {live_render(
@conn, @conn,
PinchflatWeb.Sources.MediaItemTableLive, PinchflatWeb.Sources.MediaItemTableLive,
session: %{"source_id" => @source.id, "media_state" => "downloaded"} session: %{"source_id" => @source.id, "media_state" => "downloaded"}
) %> )}
</:tab> </:tab>
<:tab title="Other" id="other"> <:tab title="Other" id="other">
<%= live_render( {live_render(
@conn, @conn,
PinchflatWeb.Sources.MediaItemTableLive, PinchflatWeb.Sources.MediaItemTableLive,
session: %{"source_id" => @source.id, "media_state" => "other"} session: %{"source_id" => @source.id, "media_state" => "other"}
) %> )}
</:tab> </:tab>
<:tab title="Tasks" id="tasks"> <:tab title="Tasks" id="tasks">
<%= if match?([_|_], @pending_tasks) do %> <%= if match?([_|_], @pending_tasks) do %>
<.table rows={@pending_tasks} table_class="text-black dark:text-white"> <.table rows={@pending_tasks} table_class="text-black dark:text-white">
<:col :let={task} label="Worker"> <:col :let={task} label="Worker">
<%= task.job.worker %> {task.job.worker}
</:col> </:col>
<:col :let={task} label="State"> <:col :let={task} label="State">
<%= task.job.state %> {task.job.state}
</:col> </:col>
<:col :let={task} label="Scheduled At"> <:col :let={task} label="Scheduled At">
<.datetime_in_zone datetime={task.job.scheduled_at} /> <.datetime_in_zone datetime={task.job.scheduled_at} />

View file

@ -41,4 +41,10 @@ defmodule Pinchflat.Utils.StringUtilsTest do
assert StringUtils.truncate("hello", 10) == "hello" assert StringUtils.truncate("hello", 10) == "hello"
end end
end end
describe "double_brace/1" do
test "wraps a string in double braces" do
assert StringUtils.double_brace("hello") == "{{ hello }}"
end
end
end end