diff --git a/config/config.exs b/config/config.exs index ea10c90..742b3c1 100644 --- a/config/config.exs +++ b/config/config.exs @@ -102,7 +102,7 @@ config :tailwind, # Configures Elixir's Logger config :logger, :console, - format: "$time $metadata[$level] $message\n", + format: "$date $time $metadata[$level] | $message\n", metadata: [:request_id] # Use Jason for JSON parsing in Phoenix diff --git a/docker/docker-run.dev.sh b/docker/docker-run.dev.sh index ddae66f..8ebb1a8 100755 --- a/docker/docker-run.dev.sh +++ b/docker/docker-run.dev.sh @@ -2,12 +2,12 @@ set -e -# Ensure the app's deps are installed +echo "\nInstalling Elixir deps..." mix deps.get -# Install JS deps -echo "\nInstalling JS..." -cd assets && yarn install +# Install both project-level and assets-level JS dependencies +echo "\nInstalling JS deps..." +yarn install && cd assets && yarn install cd .. # Potentially Set up the database diff --git a/lib/pinchflat_web/controllers/sources/source_controller.ex b/lib/pinchflat_web/controllers/sources/source_controller.ex index 2df192f..d11dd08 100644 --- a/lib/pinchflat_web/controllers/sources/source_controller.ex +++ b/lib/pinchflat_web/controllers/sources/source_controller.ex @@ -41,13 +41,30 @@ defmodule PinchflatWeb.Sources.SourceController do render(conn, :index, sources: Repo.all(source_query)) end - def new(conn, _params) do - changeset = Sources.change_source(%Source{}) + def new(conn, params) do + # This lets me preload the settings from another source for more efficient creation + cs_struct = + case to_string(params["template_id"]) do + "" -> %Source{} + template_id -> Repo.get(Source, template_id) || %Source{} + end render(conn, :new, - changeset: changeset, media_profiles: media_profiles(), - layout: get_onboarding_layout() + layout: get_onboarding_layout(), + # Most of these don't actually _need_ to be nullified at this point, + # but if I don't do it now I know it'll bite me + changeset: + Sources.change_source(%Source{ + cs_struct + | id: nil, + uuid: nil, + custom_name: nil, + collection_name: nil, + collection_id: nil, + collection_type: nil, + original_url: nil + }) ) end diff --git a/lib/pinchflat_web/controllers/sources/source_html.ex b/lib/pinchflat_web/controllers/sources/source_html.ex index bf61720..b47e7f7 100644 --- a/lib/pinchflat_web/controllers/sources/source_html.ex +++ b/lib/pinchflat_web/controllers/sources/source_html.ex @@ -9,6 +9,7 @@ defmodule PinchflatWeb.Sources.SourceHTML do attr :changeset, Ecto.Changeset, required: true attr :action, :string, required: true attr :media_profiles, :list, required: true + attr :method, :string, required: true def source_form(assigns) diff --git a/lib/pinchflat_web/controllers/sources/source_html/actions_dropdown.html.heex b/lib/pinchflat_web/controllers/sources/source_html/actions_dropdown.html.heex index ab5b7c1..43b4c22 100644 --- a/lib/pinchflat_web/controllers/sources/source_html/actions_dropdown.html.heex +++ b/lib/pinchflat_web/controllers/sources/source_html/actions_dropdown.html.heex @@ -26,6 +26,11 @@ <.icon name="hero-check" class="ml-2 h-4 w-4" /> + <:option> + <.link href={~p"/sources/new?template_id=#{@source}"} method="get"> + Use as Template + + <:option>
diff --git a/lib/pinchflat_web/controllers/sources/source_html/edit.html.heex b/lib/pinchflat_web/controllers/sources/source_html/edit.html.heex index 680d2e3..e85cf1e 100644 --- a/lib/pinchflat_web/controllers/sources/source_html/edit.html.heex +++ b/lib/pinchflat_web/controllers/sources/source_html/edit.html.heex @@ -10,7 +10,12 @@