Onboarding improvements (#76)
* Disabled pro modal during onboarding * Restructured the way onboarding changes settings * Added better upload date template placeholder
This commit is contained in:
@@ -30,7 +30,7 @@ defmodule Pinchflat.Profiles.MediaProfile do
|
|||||||
field :name, :string
|
field :name, :string
|
||||||
|
|
||||||
field :output_path_template, :string,
|
field :output_path_template, :string,
|
||||||
default: "/{{ source_custom_name }}/{{ title }}/{{ title }} [{{ id }}].{{ ext }}"
|
default: "/{{ source_custom_name }}/{{ upload_yyyy_mm_dd }} {{ title }}/{{ title }} [{{ id }}].{{ ext }}"
|
||||||
|
|
||||||
field :download_subs, :boolean, default: true
|
field :download_subs, :boolean, default: true
|
||||||
field :download_auto_subs, :boolean, default: true
|
field :download_auto_subs, :boolean, default: true
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ defmodule Pinchflat.Profiles.OutputPathBuilder do
|
|||||||
# Individual parts of the upload date
|
# Individual parts of the upload date
|
||||||
"upload_year" => "%(upload_date>%Y)S",
|
"upload_year" => "%(upload_date>%Y)S",
|
||||||
"upload_month" => "%(upload_date>%m)S",
|
"upload_month" => "%(upload_date>%m)S",
|
||||||
"upload_day" => "%(upload_date>%d)S"
|
"upload_day" => "%(upload_date>%d)S",
|
||||||
|
"upload_yyyy_mm_dd" => "%(upload_date>%Y)S-%(upload_date>%m)S-%(upload_date>%d)S"
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -13,13 +13,17 @@
|
|||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body
|
<body
|
||||||
x-data={"{ sidebarVisible: false, proEnabled: #{Settings.get!(:pro_enabled)} }"}
|
x-data={"{
|
||||||
|
sidebarVisible: false,
|
||||||
|
proEnabled: #{Settings.get!(:pro_enabled)},
|
||||||
|
onboarding: #{Settings.get!(:onboarding)}
|
||||||
|
}"}
|
||||||
class="dark text-bodydark bg-boxdark-2"
|
class="dark text-bodydark bg-boxdark-2"
|
||||||
>
|
>
|
||||||
<%= @inner_content %>
|
<%= @inner_content %>
|
||||||
|
|
||||||
<.donate_modal conn={@conn} />
|
<.donate_modal conn={@conn} />
|
||||||
<template x-if="!proEnabled">
|
<template x-if="!proEnabled && !onboarding">
|
||||||
<.upgrade_modal conn={@conn} />
|
<.upgrade_modal conn={@conn} />
|
||||||
</template>
|
</template>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ defmodule PinchflatWeb.MediaProfiles.MediaProfileHTML do
|
|||||||
upload_day: nil,
|
upload_day: nil,
|
||||||
upload_month: nil,
|
upload_month: nil,
|
||||||
upload_year: nil,
|
upload_year: nil,
|
||||||
|
upload_yyyy_mm_dd: "the upload date in the format YYYY-MM-DD",
|
||||||
source_custom_name: "the name of the sources that use this profile",
|
source_custom_name: "the name of the sources that use this profile",
|
||||||
source_collection_type: "the collection type of the sources that use this profile. Either 'channel' or 'playlist'"
|
source_collection_type: "the collection type of the sources that use this profile. Either 'channel' or 'playlist'"
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -19,7 +19,7 @@
|
|||||||
type="text"
|
type="text"
|
||||||
inputclass="font-mono"
|
inputclass="font-mono"
|
||||||
label="Output path template"
|
label="Output path template"
|
||||||
help="Must end with .{{ ext }}. See below for more details. I promise the default is good for most cases (required)"
|
help="Must end with .{{ ext }}. See below for more details. The default is good for most cases (required)"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<h3 class="mt-8 text-2xl text-black dark:text-white">
|
<h3 class="mt-8 text-2xl text-black dark:text-white">
|
||||||
|
|||||||
@@ -8,38 +8,34 @@ defmodule PinchflatWeb.Pages.PageController do
|
|||||||
alias Pinchflat.Profiles.MediaProfile
|
alias Pinchflat.Profiles.MediaProfile
|
||||||
|
|
||||||
def home(conn, params) do
|
def home(conn, params) do
|
||||||
force_onboarding = params["onboarding"]
|
done_onboarding = params["onboarding"] == "0"
|
||||||
media_profiles_exist = Repo.exists?(MediaProfile)
|
force_onboarding = params["onboarding"] == "1"
|
||||||
sources_exist = Repo.exists?(Source)
|
|
||||||
|
|
||||||
if !force_onboarding && media_profiles_exist && sources_exist do
|
if done_onboarding, do: Settings.set!(:onboarding, false)
|
||||||
render_home_page(conn)
|
|
||||||
|
if force_onboarding || Settings.get!(:onboarding) do
|
||||||
|
render_onboarding_page(conn)
|
||||||
else
|
else
|
||||||
render_onboarding_page(conn, media_profiles_exist, sources_exist)
|
render_home_page(conn)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp render_home_page(conn) do
|
defp render_home_page(conn) do
|
||||||
Settings.set!(:onboarding, false)
|
|
||||||
media_profile_count = Repo.aggregate(MediaProfile, :count, :id)
|
|
||||||
source_count = Repo.aggregate(Source, :count, :id)
|
|
||||||
media_item_count = Repo.aggregate(MediaItem, :count, :id)
|
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> render(:home,
|
|> render(:home,
|
||||||
media_profile_count: media_profile_count,
|
media_profile_count: Repo.aggregate(MediaProfile, :count, :id),
|
||||||
source_count: source_count,
|
source_count: Repo.aggregate(Source, :count, :id),
|
||||||
media_item_count: media_item_count
|
media_item_count: Repo.aggregate(MediaItem, :count, :id)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp render_onboarding_page(conn, media_profiles_exist, sources_exist) do
|
defp render_onboarding_page(conn) do
|
||||||
Settings.set!(:onboarding, true)
|
Settings.set!(:onboarding, true)
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> render(:onboarding_checklist,
|
|> render(:onboarding_checklist,
|
||||||
media_profiles_exist: media_profiles_exist,
|
media_profiles_exist: Repo.exists?(MediaProfile),
|
||||||
sources_exist: sources_exist,
|
sources_exist: Repo.exists?(Source),
|
||||||
layout: {Layouts, :onboarding}
|
layout: {Layouts, :onboarding}
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
</p>
|
</p>
|
||||||
<p class="text-md text-bodydark">Feel free to add more Media Profiles or Sources in the meantime!</p>
|
<p class="text-md text-bodydark">Feel free to add more Media Profiles or Sources in the meantime!</p>
|
||||||
<div class="mt-8">
|
<div class="mt-8">
|
||||||
<.link href={~p"/"}>
|
<.link href={~p"/?onboarding=0"}>
|
||||||
<.button color="bg-primary" rounding="rounded-full" disabled={not @sources_exist}>
|
<.button color="bg-primary" rounding="rounded-full" disabled={not @sources_exist}>
|
||||||
Let's Go <span class="font-bold mx-2">🚀</span>
|
Let's Go <span class="font-bold mx-2">🚀</span>
|
||||||
</.button>
|
</.button>
|
||||||
|
|||||||
@@ -1,51 +1,31 @@
|
|||||||
defmodule PinchflatWeb.PageControllerTest do
|
defmodule PinchflatWeb.PageControllerTest do
|
||||||
use PinchflatWeb.ConnCase
|
use PinchflatWeb.ConnCase
|
||||||
|
|
||||||
import Pinchflat.ProfilesFixtures
|
|
||||||
import Pinchflat.SourcesFixtures
|
|
||||||
|
|
||||||
alias Pinchflat.Settings
|
alias Pinchflat.Settings
|
||||||
|
|
||||||
describe "GET / when testing onboarding" do
|
describe "GET / when testing onboarding" do
|
||||||
test "sets the onboarding session to true when onboarding", %{conn: conn} do
|
test "sets the onboarding setting to true when onboarding", %{conn: conn} do
|
||||||
_conn = get(conn, ~p"/")
|
_conn = get(conn, ~p"/")
|
||||||
assert Settings.get!(:onboarding)
|
assert Settings.get!(:onboarding)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "displays the onboarding page when no media profiles exist", %{conn: conn} do
|
|
||||||
conn = get(conn, ~p"/")
|
|
||||||
assert html_response(conn, 200) =~ "Welcome to Pinchflat"
|
|
||||||
end
|
|
||||||
|
|
||||||
test "displays the onboarding page when no sources exist", %{conn: conn} do
|
|
||||||
_ = media_profile_fixture()
|
|
||||||
|
|
||||||
conn = get(conn, ~p"/")
|
|
||||||
assert html_response(conn, 200) =~ "Welcome to Pinchflat"
|
|
||||||
end
|
|
||||||
|
|
||||||
test "displays the onboarding page when onboarding is forced", %{conn: conn} do
|
test "displays the onboarding page when onboarding is forced", %{conn: conn} do
|
||||||
_ = media_profile_fixture()
|
Settings.set!(:onboarding, false)
|
||||||
_ = source_fixture()
|
|
||||||
|
|
||||||
conn = get(conn, ~p"/?onboarding=1")
|
conn = get(conn, ~p"/?onboarding=1")
|
||||||
assert html_response(conn, 200) =~ "Welcome to Pinchflat"
|
assert html_response(conn, 200) =~ "Welcome to Pinchflat"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "sets the onboarding session to false when not onboarding", %{conn: conn} do
|
test "sets the onboarding setting to false if you pass the corrent query param", %{conn: conn} do
|
||||||
conn = get(conn, ~p"/")
|
conn = get(conn, ~p"/")
|
||||||
assert Settings.get!(:onboarding)
|
assert Settings.get!(:onboarding)
|
||||||
|
|
||||||
_ = media_profile_fixture()
|
_conn = get(conn, ~p"/?onboarding=0")
|
||||||
_ = source_fixture()
|
|
||||||
|
|
||||||
_conn = get(conn, ~p"/")
|
|
||||||
refute Settings.get!(:onboarding)
|
refute Settings.get!(:onboarding)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "displays the home page when not onboarding", %{conn: conn} do
|
test "displays the home page when not onboarding", %{conn: conn} do
|
||||||
_ = media_profile_fixture()
|
Settings.set!(:onboarding, false)
|
||||||
_ = source_fixture()
|
|
||||||
|
|
||||||
conn = get(conn, ~p"/")
|
conn = get(conn, ~p"/")
|
||||||
assert html_response(conn, 200) =~ "MENU"
|
assert html_response(conn, 200) =~ "MENU"
|
||||||
|
|||||||
Reference in New Issue
Block a user