merge base project into memex
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2023-02-26 01:47:26 -05:00
39 changed files with 1604 additions and 243 deletions

View File

@ -11,7 +11,8 @@
phx-value-sort-key={key}
phx-target={@myself}
>
<span><%= label %></span>
<i class="w-0 float-right fas fa-sm fa-chevron-up opacity-0"></i>
<span class={if @last_sort_key == key, do: "underline"}><%= label %></span>
<%= if @last_sort_key == key do %>
<%= case @sort_mode do %>
<% :asc -> %>
@ -25,7 +26,7 @@
</span>
</th>
<% else %>
<th class={["p-2", column[:class]]}>
<th class={["p-2 cursor-not-allowed", column[:class]]}>
<%= label %>
</th>
<% end %>

View File

@ -82,7 +82,6 @@ defmodule MemexWeb.Components.Topbar do
<%= @current_user.email %>
</.link>
</li>
<li class="mx-2 my-1">
<.link
href={Routes.user_session_path(Endpoint, :delete)}
@ -92,7 +91,6 @@ defmodule MemexWeb.Components.Topbar do
<i class="fas fa-sign-out-alt"></i>
</.link>
</li>
<li
:if={
@current_user.role == :admin and function_exported?(Routes, :live_dashboard_path, 2)
@ -109,7 +107,7 @@ defmodule MemexWeb.Components.Topbar do
<% else %>
<li :if={Accounts.allow_registration?()} class="mx-2 my-1">
<.link
navigate={Routes.user_registration_path(Endpoint, :new)}
href={Routes.user_registration_path(Endpoint, :new)}
class="text-primary-400 text-primary-400 hover:underline truncate"
>
<%= dgettext("actions", "register") %>
@ -118,7 +116,7 @@ defmodule MemexWeb.Components.Topbar do
<li class="mx-2 my-1">
<.link
navigate={Routes.user_session_path(Endpoint, :new)}
href={Routes.user_session_path(Endpoint, :new)}
class="text-primary-400 text-primary-400 hover:underline truncate"
>
<%= dgettext("actions", "log in") %>

View File

@ -4,6 +4,10 @@ defmodule MemexWeb.Components.UserCard do
"""
use MemexWeb, :component
alias Memex.Accounts.User
attr :user, User, required: true
slot(:inner_block, required: true)
def user_card(assigns) do
~H"""

View File

@ -2,7 +2,7 @@ defmodule MemexWeb.UserRegistrationController do
use MemexWeb, :controller
import MemexWeb.Gettext
alias Memex.{Accounts, Accounts.Invites}
alias MemexWeb.{Endpoint, HomeLive}
alias MemexWeb.HomeLive
def new(conn, %{"invite" => invite_token}) do
if Invites.valid_invite_token?(invite_token) do

View File

@ -5,7 +5,7 @@ defmodule MemexWeb.HomeLive do
use MemexWeb, :live_view
alias Memex.Accounts
alias MemexWeb.{Endpoint, FaqLive}
alias MemexWeb.FaqLive
@version Mix.Project.config()[:version]

View File

@ -18,13 +18,16 @@
<%= changeset_errors(@changeset) %>
</div>
<%= label(f, :name, gettext("Name"), class: "title text-lg text-primary-400") %>
<%= label(f, :name, gettext("name"), class: "title text-lg text-primary-400") %>
<%= text_input(f, :name, class: "input input-primary col-span-2") %>
<%= error_tag(f, :name, "col-span-3") %>
<%= label(f, :uses_left, gettext("Uses left"), class: "title text-lg text-primary-400") %>
<%= label(f, :uses_left, gettext("uses left"), class: "title text-lg text-primary-400") %>
<%= number_input(f, :uses_left, min: 0, class: "input input-primary col-span-2") %>
<%= error_tag(f, :uses_left, "col-span-3") %>
<span class="col-span-3 text-primary-500 italic text-center">
<%= gettext(~s/Leave "Uses left" blank to make invite unlimited/) %>
</span>
<%= submit(dgettext("actions", "Save"),
class: "mx-auto btn btn-primary col-span-3",

View File

@ -7,7 +7,7 @@ defmodule MemexWeb.InviteLive.Index do
import MemexWeb.Components.{InviteCard, UserCard}
alias Memex.Accounts
alias Memex.Accounts.{Invite, Invites}
alias MemexWeb.{Endpoint, HomeLive}
alias MemexWeb.HomeLive
alias Phoenix.LiveView.JS
@impl true

View File

@ -8,7 +8,7 @@
<%= gettext("no invites 😔") %>
</h1>
<.link patch={Routes.invite_index_path(Endpoint, :new)} class="btn btn-primary ml-auto">
<.link patch={Routes.invite_index_path(Endpoint, :new)} class="btn btn-primary">
<%= dgettext("actions", "invite someone new!") %>
</.link>
<% end %>
@ -87,7 +87,7 @@
<hr class="hr" />
<h1 class="title text-xl text-primary-400">
<%= gettext("Admins") %>
<%= gettext("admins") %>
</h1>
<div class="flex flex-col justify-center items-stretch space-y-4">
@ -100,7 +100,7 @@
data-confirm={
dgettext(
"prompts",
"are you sure you want to delete %{email}? This action is permanent!",
"are you sure you want to delete %{email}? this action is permanent!",
email: admin.email
)
}
@ -128,7 +128,7 @@
data-confirm={
dgettext(
"prompts",
"are you sure you want to delete %{email}? This action is permanent!",
"are you sure you want to delete %{email}? this action is permanent!",
email: user.email
)
}

View File

@ -28,8 +28,8 @@ defmodule MemexWeb.LiveHelpers do
def modal(assigns) do
~H"""
<.link
patch={@return_to}
id="modal-bg"
patch={@return_to}
class="fade-in fixed z-10 left-0 top-0
w-full h-full overflow-hidden
p-8 flex flex-col justify-center items-center cursor-auto"
@ -42,7 +42,7 @@ defmodule MemexWeb.LiveHelpers do
<div
id="modal"
class="fixed z-10 left-0 top-0 pointer-events-none
w-screen h-screen overflow-hidden
w-full h-full overflow-hidden
p-4 sm:p-8 flex flex-col justify-center items-center"
>
<div

View File

@ -11,9 +11,9 @@
<script defer type="text/javascript" src="/js/app.js">
</script>
</head>
<body class="m-0 p-0 w-full h-full bg-primary-800 text-primary-400 subpixel-antialiased">
<body class="pb-8 m-0 p-0 w-full h-full bg-primary-800 text-primary-400 subpixel-antialiased">
<header>
<.topbar current_user={assigns[:current_user]}></.topbar>
<.topbar current_user={assigns[:current_user]} />
</header>
<div class="pb-8 w-full flex flex-col justify-center items-center text-center">

View File

@ -1,6 +1,6 @@
<main role="main" class="min-h-full min-w-full">
<header>
<.topbar current_user={assigns[:current_user]}></.topbar>
<.topbar current_user={assigns[:current_user]} />
<div class="mx-8 my-2 flex flex-col space-y-4 text-center">
<p :if={get_flash(@conn, :info)} class="alert alert-info" role="alert">

View File

@ -1,6 +1,6 @@
<main class="pb-8 min-w-full">
<header>
<.topbar current_user={assigns[:current_user]}></.topbar>
<.topbar current_user={assigns[:current_user]} />
<div class="mx-8 my-2 flex flex-col space-y-4 text-center">
<p

View File

@ -9,7 +9,7 @@
action={Routes.user_confirmation_path(@conn, :create)}
class="flex flex-col space-y-4 sm:space-y-0 sm:grid sm:grid-cols-3 sm:gap-4 justify-center items-center"
>
<%= label(f, :email, class: "title text-lg text-primary-400") %>
<%= label(f, :email, gettext("Email"), class: "title text-lg text-primary-400") %>
<%= email_input(f, :email, required: true, class: "input input-primary col-span-2") %>
<%= submit(dgettext("actions", "Resend confirmation instructions"),

View File

@ -17,11 +17,11 @@
<%= hidden_input(f, :invite_token, value: @invite_token) %>
<% end %>
<%= label(f, :email, class: "title text-lg text-primary-400") %>
<%= label(f, :email, gettext("email"), class: "title text-lg text-primary-400") %>
<%= email_input(f, :email, required: true, class: "input input-primary col-span-2") %>
<%= error_tag(f, :email, "col-span-3") %>
<%= label(f, :password, class: "title text-lg text-primary-400") %>
<%= label(f, :password, gettext("password"), class: "title text-lg text-primary-400") %>
<%= password_input(f, :password, required: true, class: "input input-primary col-span-2") %>
<%= error_tag(f, :password, "col-span-3") %>

View File

@ -9,17 +9,15 @@
action={Routes.user_reset_password_path(@conn, :update, @token)}
class="flex flex-col space-y-4 sm:space-y-0 sm:grid sm:grid-cols-3 sm:gap-4 justify-center items-center"
>
<div :if={@changeset.action && not @changeset.valid?()} class="alert alert-danger col-span-3">
<p>
<%= dgettext("errors", "Oops, something went wrong! Please check the errors below.") %>
</p>
</div>
<p :if={@changeset.action && not @changeset.valid?()} class="alert alert-danger col-span-3">
<%= dgettext("errors", "oops, something went wrong! please check the errors below.") %>
</p>
<%= label(f, :password, "new password", class: "title text-lg text-primary-400") %>
<%= label(f, :password, gettext("new password"), class: "title text-lg text-primary-400") %>
<%= password_input(f, :password, required: true, class: "input input-primary col-span-2") %>
<%= error_tag(f, :password, "col-span-3") %>
<%= label(f, :password_confirmation, "Confirm new password",
<%= label(f, :password_confirmation, gettext("confirm new password"),
class: "title text-lg text-primary-400"
) %>
<%= password_input(f, :password_confirmation,

View File

@ -9,7 +9,7 @@
action={Routes.user_reset_password_path(@conn, :create)}
class="flex flex-col space-y-4 sm:space-y-0 sm:grid sm:grid-cols-3 sm:gap-4 justify-center items-center"
>
<%= label(f, :email, class: "title text-lg text-primary-400") %>
<%= label(f, :email, gettext("email"), class: "title text-lg text-primary-400") %>
<%= email_input(f, :email, required: true, class: "input input-primary col-span-2") %>
<%= submit(dgettext("actions", "send instructions to reset password"),

View File

@ -10,19 +10,17 @@
as="user"
class="flex flex-col space-y-4 sm:space-y-0 sm:grid sm:grid-cols-3 sm:gap-4 justify-center items-center"
>
<div :if={@error_message} class="alert alert-danger col-span-3">
<p>
<%= @error_message %>
</p>
</div>
<p :if={@error_message} class="alert alert-danger col-span-3">
<%= @error_message %>
</p>
<%= label(f, :email, class: "title text-lg text-primary-400") %>
<%= label(f, :email, gettext("email"), class: "title text-lg text-primary-400") %>
<%= email_input(f, :email, required: true, class: "input input-primary col-span-2") %>
<%= label(f, :password, class: "title text-lg text-primary-400") %>
<%= label(f, :password, gettext("password"), class: "title text-lg text-primary-400") %>
<%= password_input(f, :password, required: true, class: "input input-primary col-span-2") %>
<%= label(f, :remember_me, gettext("Keep me logged in for 60 days"),
<%= label(f, :remember_me, gettext("keep me logged in for 60 days"),
class: "title text-lg text-primary-400"
) %>
<%= checkbox(f, :remember_me, class: "checkbox col-span-2") %>

View File

@ -19,7 +19,7 @@
:if={@email_changeset.action && not @email_changeset.valid?()}
class="alert alert-danger col-span-3"
>
<%= dgettext("errors", "oops, something went wrong! Please check the errors below") %>
<%= dgettext("errors", "oops, something went wrong! please check the errors below") %>
</div>
<%= hidden_input(f, :action, name: "action", value: "update_email") %>
@ -57,12 +57,12 @@
<%= dgettext("actions", "change password") %>
</h3>
<div
<p
:if={@password_changeset.action && not @password_changeset.valid?()}
class="alert alert-danger col-span-3"
>
<%= dgettext("errors", "Oops, something went wrong! Please check the errors below.") %>
</div>
<%= dgettext("errors", "oops, something went wrong! please check the errors below.") %>
</p>
<%= hidden_input(f, :action, name: "action", value: "update_password") %>
@ -115,7 +115,7 @@
:if={@locale_changeset.action && not @locale_changeset.valid?()}
class="alert alert-danger col-span-3"
>
<%= dgettext("errors", "oops, something went wrong! Please check the errors below") %>
<%= dgettext("errors", "oops, something went wrong! please check the errors below") %>
</div>
<%= hidden_input(f, :action, name: "action", value: "update_locale") %>

View File

@ -1,13 +1,13 @@
defmodule MemexWeb.LayoutView do
use MemexWeb, :view
import MemexWeb.{Components.Topbar, Gettext}
import MemexWeb.Components.Topbar
alias MemexWeb.HomeLive
# Phoenix LiveDashboard is available only in development by default,
# so we instruct Elixir to not warn if the dashboard route is missing.
@compile {:no_warn_undefined, {Routes, :live_dashboard_path, 2}}
def get_title(%{assigns: %{title: title}}) do
def get_title(%{assigns: %{title: title}}) when title not in [nil, ""] do
gettext("memEx | %{title}", title: title)
end