Author SHA1 Message Date
renovate[bot] 9d43ec7b73 chore(deps): update dependency autoprefixer to v10.4.19 2024-05-09 13:59:53 +00:00
sphericalkat ebd9f7f52c feat(pastes): add new page to show owned pastes
Signed-off-by: SphericalKat <amolele@gmail.com>
2024-05-09 19:29:13 +05:30
sphericalkat f0efa78b89 feat(menu): use a dropdown menu
Signed-off-by: SphericalKat <amolele@gmail.com>
2024-05-09 19:13:26 +05:30
sphericalkat ca905d46aa fix(web): remove deprecated options
Signed-off-by: SphericalKat <amolele@gmail.com>
2024-05-09 18:41:47 +05:30
sphericalkat 5ea437b9f1 fix(phoenix): remove deprecated items
Signed-off-by: SphericalKat <amolele@gmail.com>
2024-05-09 18:39:59 +05:30
10 changed files with 209 additions and 695 deletions

No files matched your search

+149 -682
View File
File diff suppressed because it is too large. Load diff
+2 -2
View File
@@ -12,11 +12,11 @@
},
"devDependencies": {
"autoprefixer": "^10.3.1",
"esbuild": "^0.21.0",
"esbuild": "^0.12.22",
"esbuild-plugin-postcss2": "0.0.9",
"fs-extra": "^10.0.0",
"postcss": "^8.3.6",
"postcss-import": "^15.0.0",
"tailwindcss": "^3.0.0"
"tailwindcss": "^3.4.3"
}
}
+6 -6
View File
@@ -1,19 +1,19 @@
module.exports = {
purge: [
content: [
"../lib/**/*.ex",
"../lib/**/*.leex",
"../lib/**/*.eex",
"../lib/**/*.heex",
"./js/**/*.js",
],
darkMode: false, // or 'media' or 'class'
darkMode: 'media', // or 'media' or 'class'
theme: {
extend: {
colors: {
amber: '#ff9800',
'light-grey': '#212121',
colors: {
amber: "#ff9800",
"light-grey": "#212121",
},
},
},
},
variants: {
extend: {},
+1 -1
View File
@@ -1,4 +1,4 @@
use Mix.Config
import Config
# Only in tests, remove the complexity from the password hashing algorithm
config :bcrypt_elixir, :log_rounds, 1
+4
View File
@@ -21,6 +21,10 @@ defmodule Ketbin.Pastes do
Repo.all(Paste)
end
def list_pastes_by_user(user_id) do
Repo.all(from(p in Paste, where: p.belongs_to == ^user_id))
end
@doc """
Gets a single paste.
@@ -134,4 +134,9 @@ defmodule KetbinWeb.PageController do
render(conn, "edit.html", paste: paste, changeset: changeset)
end
end
def pastes(%{assigns: %{current_user: current_user}} = conn, _params) do
pastes = Pastes.list_pastes_by_user(current_user.id)
render(conn, "pastes.html", pastes: pastes)
end
end
+7
View File
@@ -18,6 +18,13 @@ defmodule KetbinWeb.Router do
plug :fetch_current_user
end
# scope to ensure user is authenticated
scope "/", KetbinWeb do
pipe_through [:browser, :require_authenticated_user]
get "/pastes", PageController, :pastes
end
scope "/", KetbinWeb do
pipe_through :browser
@@ -1,8 +1,28 @@
<script>
function toggleDropdown() {
const dropdown = document.querySelector('#dropdown');
const dropdownLabel = document.querySelector('#dropdown-label');
if (dropdown.classList.contains('hidden')) {
dropdown.classList.remove('hidden');
dropdown.classList.add('absolute');
dropdownLabel.innerHTML = dropdownLabel.innerHTML.replace('▼', '▲');
} else {
dropdown.classList.add('hidden');
dropdown.classList.remove('absolute');
dropdownLabel.innerHTML = dropdownLabel.innerHTML.replace('▲', '▼');
}
}
</script>
<ul>
<%= if @current_user do %>
<li><%= @current_user.email %></li>
<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>
<div class="relative">
<li id="dropdown-label" onclick="toggleDropdown()" class="text-[#ff9800] cursor-pointer select-none"><%= @current_user.email %> ▼</li>
<div id="dropdown" class="hidden right-0 z-50 bg-[#313131] px-4 py-2">
<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>
<li><%= link "My Pastes", to: Routes.page_path(@conn, :pastes) %></li>
</div>
</div>
<% else %>
<li><%= link "Register", to: Routes.user_registration_path(@conn, :new) %></li>
<li><%= link "Log in", to: Routes.user_session_path(@conn, :new) %></li>
@@ -0,0 +1,11 @@
<div class="flex relative flex-col w-full h-full">
<ul class="break-word py-4 h-full w-full overflow-y-auto">
<%= for paste <- @pastes do %>
<li class="flex flex-row items-center justify-between">
<a href={ Routes.page_path(@conn, :show, paste) } class="">
https://katb.in/v/<%= paste.id %>
</a>
</li>
<% end %>
</ul>
</div>
+1 -1
View File
@@ -7,7 +7,7 @@ defmodule Ketbin.MixProject do
version: "0.1.0",
elixir: "~> 1.12",
elixirc_paths: elixirc_paths(Mix.env()),
compilers: [:phoenix, :gettext] ++ Mix.compilers(),
compilers: [:phoenix] ++ Mix.compilers(),
start_permanent: Mix.env() == :prod,
aliases: aliases(),
deps: deps()