Skip to content

Commit

Permalink
upgrade deps and cleanup unused pages (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
benvp authored Nov 21, 2021
1 parent d1a6ce6 commit 8857eb5
Show file tree
Hide file tree
Showing 21 changed files with 1,343 additions and 2,086 deletions.
28 changes: 14 additions & 14 deletions apps/toniefy/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
},
"dependencies": {
"@fortawesome/fontawesome-free": "^5.15.2",
"@tailwindcss/forms": "^0.2.1",
"@tailwindcss/forms": "^0.3.4",
"alpinejs": "^2.8.0",
"nprogress": "^0.2.0",
"phoenix": "file:../deps/phoenix",
"phoenix_html": "file:../deps/phoenix_html",
"phoenix_live_view": "file:../deps/phoenix_live_view",
"tailwindcss": "^2.0.0",
"tailwindcss": "^2.2.19",
"tiny-invariant": "^1.1.0"
},
"devDependencies": {
Expand All @@ -28,27 +28,27 @@
"@types/spotify-web-playback-sdk": "^0.1.7",
"@typescript-eslint/eslint-plugin": "^4.11.0",
"@typescript-eslint/parser": "^4.11.0",
"autoprefixer": "^10.1.0",
"babel-loader": "^8.2.2",
"autoprefixer": "^10.4.0",
"babel-loader": "^8.2.3",
"babel-plugin-module-resolver": "^4.1.0",
"copy-webpack-plugin": "^7.0.0",
"css-loader": "^5.0.1",
"css-minimizer-webpack-plugin": "^1.1.5",
"css-loader": "^6.5.1",
"css-minimizer-webpack-plugin": "^3.1.4",
"eslint": "^7.16.0",
"eslint-config-prettier": "^7.1.0",
"eslint-import-resolver-babel-module": "^5.2.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-prettier": "^3.3.0",
"hard-source-webpack-plugin": "^0.13.1",
"mini-css-extract-plugin": "^1.3.3",
"postcss": "^8.2.1",
"postcss-import": "^14.0.0",
"postcss-loader": "^4.1.0",
"postcss-preset-env": "^6.7.0",
"mini-css-extract-plugin": "^2.4.5",
"postcss": "^8.3.11",
"postcss-import": "^14.0.2",
"postcss-loader": "^6.2.0",
"postcss-preset-env": "^7.0.1",
"prettier": "^2.2.1",
"terser-webpack-plugin": "^2.3.2",
"terser-webpack-plugin": "^5.2.5",
"typescript": "^4.1.3",
"webpack": "^5.11.0",
"webpack-cli": "^4.3.0"
"webpack": "^5.64.2",
"webpack-cli": "^4.9.1"
}
}
4 changes: 2 additions & 2 deletions apps/toniefy/assets/static/robots.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
#
# To ban all spiders from the entire site uncomment the next two lines:
# User-agent: *
# Disallow: /
User-agent: *
Disallow: /
2,905 changes: 1,248 additions & 1,657 deletions apps/toniefy/assets/yarn.lock

Large diffs are not rendered by default.

12 changes: 0 additions & 12 deletions apps/toniefy/lib/toniex_web/controllers/page_controller.ex
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
defmodule ToniexWeb.PageController do
use ToniexWeb, :controller

def privacy(conn, _params) do
render(conn, "privacy.html")
end

def donate(conn, _params) do
render(conn, "donate.html")
end

def donate_success(conn, _params) do
render(conn, "donate_success.html")
end
end

This file was deleted.

2 changes: 1 addition & 1 deletion apps/toniefy/lib/toniex_web/endpoint.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ defmodule ToniexWeb.Endpoint do
at: "/",
from: :toniex,
gzip: false,
only: ~w(css webfonts fonts images js favicon.ico robots.txt privacy.html)
only: ~w(css webfonts fonts images js favicon.ico robots.txt)

# Code reloading can be explicitly enabled under the
# :code_reloader configuration of your endpoint.
Expand Down
2 changes: 1 addition & 1 deletion apps/toniefy/lib/toniex_web/live/library/index.html.leex
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@

<h2 class="mt-6 heading-2"><%= @playlist.title %></h2>

<%= live_component @socket, PlaylistComponent, tracks: @playlist.tracks %>
<%= live_component PlaylistComponent, tracks: @playlist.tracks %>

<div class="mt-4 mr-1 text-right">
<button data-confirm="Bist du dir sicher?" phx-click="delete-playlist" type="button" class="link-secondary">
Expand Down
29 changes: 29 additions & 0 deletions apps/toniefy/lib/toniex_web/live/live_auth.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
defmodule ToniexWeb.LiveAuth do
import Phoenix.LiveView

alias Toniex.Accounts

def on_mount(:default, _params, session, socket) do
{:cont, fetch_current_user(socket, session)}
end

def on_mount(:require_authenticated_user, _params, session, socket) do
socket = fetch_current_user(socket, session)

if socket.assigns.current_user do
{:cont, socket}
else
{:halt, socket}
end
end

defp fetch_current_user(socket, session) do
if user_token = session["user_token"] do
assign_new(socket, :current_user, fn ->
Accounts.get_user_by_session_token(user_token)
end)
else
assign(socket, current_user: nil)
end
end
end
29 changes: 5 additions & 24 deletions apps/toniefy/lib/toniex_web/live/page_live.ex
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
defmodule ToniexWeb.PageLive do
use ToniexWeb, :live_view

alias Toniex.Waitlist

@impl true
def mount(_params, session, socket) do
socket =
assign_defaults(session, socket)
|> assign(
message: nil,
waitlist_changeset: Waitlist.change_entry(%Waitlist.Entry{})
)
socket = assign_defaults(session, socket)

if socket.assigns.current_user do
socket = push_redirect(socket, to: Routes.library_index_path(socket, :index))
Expand All @@ -21,21 +14,9 @@ defmodule ToniexWeb.PageLive do
end

@impl true
def handle_params(_params, uri, socket) do
{:noreply, assign(socket, uri: URI.parse(uri))}
end

@impl true
def handle_event("join_waitlist", %{"entry" => %{"email" => email}}, socket) do
case Waitlist.join(email) do
{:ok, _entry} ->
{:noreply,
assign(socket,
message: "Prima. Wir kontaktieren dich, sobald dein Zugang freigeschaltet wurde."
)}

{:error, changeset} ->
{:noreply, assign(socket, waitlist_changeset: changeset)}
end
def render(assigns) do
~L"""
<div></div>
"""
end
end
52 changes: 0 additions & 52 deletions apps/toniefy/lib/toniex_web/live/page_live.html.leex

This file was deleted.

6 changes: 2 additions & 4 deletions apps/toniefy/lib/toniex_web/live/review_session_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ defmodule ToniexWeb.ReviewSessionLive do
socket
|> put_flash(
:success,
"#{Enum.count(socket.assigns.session.tracks)} songs have been added to playlist \"#{
playlist.title
}\"."
"#{Enum.count(socket.assigns.session.tracks)} songs have been added to playlist \"#{playlist.title}\"."
)
|> push_redirect(to: Routes.library_index_path(socket, :index))

Expand Down Expand Up @@ -72,7 +70,7 @@ defmodule ToniexWeb.ReviewSessionLive do
</p>
<div class="mt-4">
<%= live_component @socket, PlaylistComponent, tracks: @session.tracks %>
<%= live_component PlaylistComponent, tracks: @session.tracks %>
</div>
<div class="card mt-12">
Expand Down
35 changes: 17 additions & 18 deletions apps/toniefy/lib/toniex_web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@ defmodule ToniexWeb.Router do
scope "/", ToniexWeb do
pipe_through :browser

live "/", PageLive, :index

get "/record", RecordController, :index
get "/privacy", PageController, :privacy
get "/piggy-bank", PageController, :donate
get "/piggy-bank/thank-you", PageController, :donate_success
end

scope "/", ToniexWeb do
Expand Down Expand Up @@ -60,8 +55,8 @@ defmodule ToniexWeb.Router do
pipe_through [:browser, :redirect_if_user_is_authenticated]

# we disable registration for now
get "/register", UserRegistrationController, :new
post "/register", UserRegistrationController, :create
# get "/register", UserRegistrationController, :new
# post "/register", UserRegistrationController, :create

get "/login", UserSessionController, :new
post "/login", UserSessionController, :create
Expand All @@ -71,19 +66,23 @@ defmodule ToniexWeb.Router do
put "/reset-password/:token", UserResetPasswordController, :update
end

scope "/", ToniexWeb do
pipe_through [:browser, :require_authenticated_user]
live_session :authenticated, on_mount: [{ToniexWeb.LiveAuth, :require_authenticated_user}] do
scope "/", ToniexWeb do
pipe_through [:browser, :require_authenticated_user]

get "/me", UserSettingsController, :edit
put "/me/change-password", UserSettingsController, :update
put "/me/change-email", UserSettingsController, :update
get "/me/confirm-email/:token", UserSettingsController, :confirm_email
delete "/me/disconnect-service", UserSettingsController, :disconnect_service
live "/", PageLive, :index

live "/library", LibraryLive.Index, :index
live "/library/record", RecorderLive
live "/library/record/review", ReviewSessionLive
live "/library/:id", LibraryLive.Index, :show
get "/me", UserSettingsController, :edit
put "/me/change-password", UserSettingsController, :update
put "/me/change-email", UserSettingsController, :update
get "/me/confirm-email/:token", UserSettingsController, :confirm_email
delete "/me/disconnect-service", UserSettingsController, :disconnect_service

live "/library", LibraryLive.Index, :index
live "/library/record", RecorderLive
live "/library/record/review", ReviewSessionLive
live "/library/:id", LibraryLive.Index, :show
end
end

scope "/", ToniexWeb do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<li><%= link "Settings", to: Routes.user_settings_path(@conn, :edit) %></li>
<li><%= link "Log out", to: Routes.user_session_path(@conn, :delete), method: :delete %></li>
<% else %>
<li><%= link "Register", to: Routes.user_registration_path(@conn, :new) %></li>
<li><%= link "Log in", to: Routes.user_session_path(@conn, :new) %></li>
<% end %>
</ul>
3 changes: 0 additions & 3 deletions apps/toniefy/lib/toniex_web/templates/layout/app.html.eex
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<div class="space-x-8">
<%= if @current_user do %>
<%= live_patch "Meine Bibliothek", to: Routes.library_index_path(@conn, :index), class: active_class(@conn.request_path, Routes.library_index_path(@conn, :index), "header__nav-link", "header__nav-link--active") %>
<%= link "Henris Spardose", to: Routes.page_path(@conn, :donate), class: active_class(@conn.request_path, Routes.page_path(@conn, :donate), "header__nav-link", "header__nav-link--active") %>
<%= link "Einstellungen", to: Routes.user_settings_path(@conn, :edit), class: active_class(@conn.request_path, Routes.user_settings_path(@conn, :edit), "header__nav-link", "header__nav-link--active") %>
<%= link "Logout", to: Routes.user_session_path(@conn, :delete), method: :delete, class: "header__nav-link" %>
<% else %>
Expand All @@ -20,7 +19,5 @@
<%= @inner_content %>
</main>
<footer class="flex justify-center sm:justify-end items-end px-4 py-6 mt-8 mx-auto space-x-6 max-w-screen-md">
<p class="text-sm"><%= link "Datenschutz", to: Routes.page_path(@conn, :privacy), class: "footer__link" %></p>
<p class="text-sm"><%= link "Kontakt", to: "mailto:hi@toniefy.me?subject=Toniefy Kontakt", class: "footer__link" %></p>
<p class="font-semibold text-sm text-gray-400">toniefy <span class="text-primary-main">|</span> 2021</p>
</footer>
3 changes: 0 additions & 3 deletions apps/toniefy/lib/toniex_web/templates/layout/live.html.leex
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<div class="space-x-8">
<%= if @current_user do %>
<%= live_patch "Meine Bibliothek", to: Routes.library_index_path(@socket, :index), class: active_class(@uri.path, Routes.library_index_path(@socket, :index), "header__nav-link", "header__nav-link--active") %>
<%= link "Henris Spardose", to: Routes.page_path(@socket, :donate), class: active_class(@uri.path, Routes.page_path(@socket, :donate), "header__nav-link", "header__nav-link--active") %>
<%= link "Einstellungen", to: Routes.user_settings_path(@socket, :edit), class: "header__nav-link" %>
<%= link "Logout", to: Routes.user_session_path(@socket, :delete), method: :delete, class: "header__nav-link" %>
<% else %>
Expand All @@ -20,7 +19,5 @@
<%= @inner_content %>
</main>
<footer class="flex justify-center sm:justify-end items-end px-4 py-6 mt-8 mx-auto space-x-6 max-w-screen-md">
<p class="text-sm"><%= link "Datenschutz", to: Routes.page_path(@socket, :privacy), class: "footer__link" %></p>
<p class="text-sm"><%= link "Kontakt", to: "mailto:hi@toniefy.me?subject=Toniefy Kontakt", class: "footer__link" %></p>
<p class="font-semibold text-sm text-gray-400">toniefy <span class="text-primary-main">|</span> 2021</p>
</footer>
Loading

0 comments on commit 8857eb5

Please sign in to comment.