Compare commits

..

8 Commits

Author SHA1 Message Date
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
f0efa78b89
feat(menu): use a dropdown menu
Signed-off-by: SphericalKat <amolele@gmail.com>
2024-05-09 19:13:26 +05:30
ca905d46aa
fix(web): remove deprecated options
Signed-off-by: SphericalKat <amolele@gmail.com>
2024-05-09 18:41:47 +05:30
5ea437b9f1
fix(phoenix): remove deprecated items
Signed-off-by: SphericalKat <amolele@gmail.com>
2024-05-09 18:39:59 +05:30
4554b672af
fix(pastes): update schema with timestamps macro
Signed-off-by: Sphericalkat <amolele@gmail.com>
2024-05-07 01:16:52 +05:30
5eb22fdb9c
feat: add timestamps to paste table
Signed-off-by: Sphericalkat <amolele@gmail.com>
2024-05-07 01:06:18 +05:30
e1f66f9895
fix(config): increase concurrency limit
Signed-off-by: Sphericalkat <amolele@gmail.com>
2024-02-02 15:54:53 +05:30
8eed2f1423
fix(layout): update personal site link 2023-10-04 02:11:18 +05:30
14 changed files with 117 additions and 55 deletions

View File

@ -16,14 +16,15 @@
"fs-extra": "^10.0.0", "fs-extra": "^10.0.0",
"postcss": "^8.3.6", "postcss": "^8.3.6",
"postcss-import": "^15.0.0", "postcss-import": "^15.0.0",
"tailwindcss": "^3.0.0" "tailwindcss": "^3.4.3"
} }
}, },
"../deps/phoenix": { "../deps/phoenix": {
"version": "0.0.1" "version": "1.6.16",
"license": "MIT"
}, },
"../deps/phoenix_html": { "../deps/phoenix_html": {
"version": "0.0.1" "version": "3.3.1"
}, },
"node_modules/@alloc/quick-lru": { "node_modules/@alloc/quick-lru": {
"version": "5.2.0", "version": "5.2.0",
@ -281,9 +282,9 @@
} }
}, },
"node_modules/caniuse-lite": { "node_modules/caniuse-lite": {
"version": "1.0.30001338", "version": "1.0.30001617",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001338.tgz", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001617.tgz",
"integrity": "sha512-1gLHWyfVoRDsHieO+CaeYe7jSo/MT7D7lhaXUiwwbuR5BwQxORs0f1tAwUSQr3YbxRXJvxHM/PA5FfPQRnsPeQ==", "integrity": "sha512-mLyjzNI9I+Pix8zwcrpxEbGlfqOkF9kM3ptzmKNw5tizSyYwMe+nGLTqMK9cO+0E+Bh6TsBxNAaHWEM8xwSsmA==",
"dev": true, "dev": true,
"funding": [ "funding": [
{ {
@ -293,6 +294,10 @@
{ {
"type": "tidelift", "type": "tidelift",
"url": "https://tidelift.com/funding/github/npm/caniuse-lite" "url": "https://tidelift.com/funding/github/npm/caniuse-lite"
},
{
"type": "github",
"url": "https://github.com/sponsors/ai"
} }
] ]
}, },
@ -509,9 +514,9 @@
} }
}, },
"node_modules/fast-glob": { "node_modules/fast-glob": {
"version": "3.2.12", "version": "3.3.2",
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz",
"integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==", "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.stat": "^2.0.2",
@ -525,9 +530,9 @@
} }
}, },
"node_modules/fastq": { "node_modules/fastq": {
"version": "1.13.0", "version": "1.17.1",
"resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz",
"integrity": "sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw==", "integrity": "sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"reusify": "^1.0.4" "reusify": "^1.0.4"
@ -894,9 +899,9 @@
"dev": true "dev": true
}, },
"node_modules/jiti": { "node_modules/jiti": {
"version": "1.18.2", "version": "1.21.0",
"resolved": "https://registry.npmjs.org/jiti/-/jiti-1.18.2.tgz", "resolved": "https://registry.npmjs.org/jiti/-/jiti-1.21.0.tgz",
"integrity": "sha512-QAdOptna2NYiSSpv0O/BwoHBSmz4YhpzJHyi+fnMRTXFjp7B8i/YG5Z8IfusxB1ufjcD2Sre1F3R+nX3fvy7gg==", "integrity": "sha512-gFqAIbuKyyso/3G2qhiO2OM6shY6EPP/R0+mkDbyspxKazh8BXDC5FiFsUjlczgdNz/vfra0da2y+aHrusLG/Q==",
"dev": true, "dev": true,
"bin": { "bin": {
"jiti": "bin/jiti.js" "jiti": "bin/jiti.js"
@ -1832,9 +1837,9 @@
} }
}, },
"node_modules/tailwindcss": { "node_modules/tailwindcss": {
"version": "3.3.2", "version": "3.4.3",
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.3.2.tgz", "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.3.tgz",
"integrity": "sha512-9jPkMiIBXvPc2KywkraqsUfbfj+dHDb+JPWtSJa9MLFdrPyazI7q6WX2sUrm7R9eVR7qqv3Pas7EvQFzxKnI6w==", "integrity": "sha512-U7sxQk/n397Bmx4JHbJx/iSOOv5G+II3f1kpLpY2QeUv5DcPdcTsYLlusZfq1NthHS1c1cZoyFmmkex1rzke0A==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@alloc/quick-lru": "^5.2.0", "@alloc/quick-lru": "^5.2.0",
@ -1842,10 +1847,10 @@
"chokidar": "^3.5.3", "chokidar": "^3.5.3",
"didyoumean": "^1.2.2", "didyoumean": "^1.2.2",
"dlv": "^1.1.3", "dlv": "^1.1.3",
"fast-glob": "^3.2.12", "fast-glob": "^3.3.0",
"glob-parent": "^6.0.2", "glob-parent": "^6.0.2",
"is-glob": "^4.0.3", "is-glob": "^4.0.3",
"jiti": "^1.18.2", "jiti": "^1.21.0",
"lilconfig": "^2.1.0", "lilconfig": "^2.1.0",
"micromatch": "^4.0.5", "micromatch": "^4.0.5",
"normalize-path": "^3.0.0", "normalize-path": "^3.0.0",
@ -1857,7 +1862,6 @@
"postcss-load-config": "^4.0.1", "postcss-load-config": "^4.0.1",
"postcss-nested": "^6.0.1", "postcss-nested": "^6.0.1",
"postcss-selector-parser": "^6.0.11", "postcss-selector-parser": "^6.0.11",
"postcss-value-parser": "^4.2.0",
"resolve": "^1.22.2", "resolve": "^1.22.2",
"sucrase": "^3.32.0" "sucrase": "^3.32.0"
}, },
@ -2163,9 +2167,9 @@
"dev": true "dev": true
}, },
"caniuse-lite": { "caniuse-lite": {
"version": "1.0.30001338", "version": "1.0.30001617",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001338.tgz", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001617.tgz",
"integrity": "sha512-1gLHWyfVoRDsHieO+CaeYe7jSo/MT7D7lhaXUiwwbuR5BwQxORs0f1tAwUSQr3YbxRXJvxHM/PA5FfPQRnsPeQ==", "integrity": "sha512-mLyjzNI9I+Pix8zwcrpxEbGlfqOkF9kM3ptzmKNw5tizSyYwMe+nGLTqMK9cO+0E+Bh6TsBxNAaHWEM8xwSsmA==",
"dev": true "dev": true
}, },
"chokidar": { "chokidar": {
@ -2332,9 +2336,9 @@
} }
}, },
"fast-glob": { "fast-glob": {
"version": "3.2.12", "version": "3.3.2",
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz",
"integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==", "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==",
"dev": true, "dev": true,
"requires": { "requires": {
"@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.stat": "^2.0.2",
@ -2345,9 +2349,9 @@
} }
}, },
"fastq": { "fastq": {
"version": "1.13.0", "version": "1.17.1",
"resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz",
"integrity": "sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw==", "integrity": "sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==",
"dev": true, "dev": true,
"requires": { "requires": {
"reusify": "^1.0.4" "reusify": "^1.0.4"
@ -2629,9 +2633,9 @@
"dev": true "dev": true
}, },
"jiti": { "jiti": {
"version": "1.18.2", "version": "1.21.0",
"resolved": "https://registry.npmjs.org/jiti/-/jiti-1.18.2.tgz", "resolved": "https://registry.npmjs.org/jiti/-/jiti-1.21.0.tgz",
"integrity": "sha512-QAdOptna2NYiSSpv0O/BwoHBSmz4YhpzJHyi+fnMRTXFjp7B8i/YG5Z8IfusxB1ufjcD2Sre1F3R+nX3fvy7gg==", "integrity": "sha512-gFqAIbuKyyso/3G2qhiO2OM6shY6EPP/R0+mkDbyspxKazh8BXDC5FiFsUjlczgdNz/vfra0da2y+aHrusLG/Q==",
"dev": true "dev": true
}, },
"jsonfile": { "jsonfile": {
@ -3267,9 +3271,9 @@
"dev": true "dev": true
}, },
"tailwindcss": { "tailwindcss": {
"version": "3.3.2", "version": "3.4.3",
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.3.2.tgz", "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.3.tgz",
"integrity": "sha512-9jPkMiIBXvPc2KywkraqsUfbfj+dHDb+JPWtSJa9MLFdrPyazI7q6WX2sUrm7R9eVR7qqv3Pas7EvQFzxKnI6w==", "integrity": "sha512-U7sxQk/n397Bmx4JHbJx/iSOOv5G+II3f1kpLpY2QeUv5DcPdcTsYLlusZfq1NthHS1c1cZoyFmmkex1rzke0A==",
"dev": true, "dev": true,
"requires": { "requires": {
"@alloc/quick-lru": "^5.2.0", "@alloc/quick-lru": "^5.2.0",
@ -3277,10 +3281,10 @@
"chokidar": "^3.5.3", "chokidar": "^3.5.3",
"didyoumean": "^1.2.2", "didyoumean": "^1.2.2",
"dlv": "^1.1.3", "dlv": "^1.1.3",
"fast-glob": "^3.2.12", "fast-glob": "^3.3.0",
"glob-parent": "^6.0.2", "glob-parent": "^6.0.2",
"is-glob": "^4.0.3", "is-glob": "^4.0.3",
"jiti": "^1.18.2", "jiti": "^1.21.0",
"lilconfig": "^2.1.0", "lilconfig": "^2.1.0",
"micromatch": "^4.0.5", "micromatch": "^4.0.5",
"normalize-path": "^3.0.0", "normalize-path": "^3.0.0",
@ -3292,7 +3296,6 @@
"postcss-load-config": "^4.0.1", "postcss-load-config": "^4.0.1",
"postcss-nested": "^6.0.1", "postcss-nested": "^6.0.1",
"postcss-selector-parser": "^6.0.11", "postcss-selector-parser": "^6.0.11",
"postcss-value-parser": "^4.2.0",
"resolve": "^1.22.2", "resolve": "^1.22.2",
"sucrase": "^3.32.0" "sucrase": "^3.32.0"
}, },

View File

@ -17,6 +17,6 @@
"fs-extra": "^10.0.0", "fs-extra": "^10.0.0",
"postcss": "^8.3.6", "postcss": "^8.3.6",
"postcss-import": "^15.0.0", "postcss-import": "^15.0.0",
"tailwindcss": "^3.0.0" "tailwindcss": "^3.4.3"
} }
} }

View File

@ -1,19 +1,19 @@
module.exports = { module.exports = {
purge: [ content: [
"../lib/**/*.ex", "../lib/**/*.ex",
"../lib/**/*.leex", "../lib/**/*.leex",
"../lib/**/*.eex", "../lib/**/*.eex",
"../lib/**/*.heex", "../lib/**/*.heex",
"./js/**/*.js", "./js/**/*.js",
], ],
darkMode: false, // or 'media' or 'class' darkMode: 'media', // or 'media' or 'class'
theme: { theme: {
extend: { extend: {
colors: { colors: {
amber: '#ff9800', amber: "#ff9800",
'light-grey': '#212121', "light-grey": "#212121",
}, },
}, },
}, },
variants: { variants: {
extend: {}, extend: {},

View File

@ -1,4 +1,4 @@
use Mix.Config import Config
# Only in tests, remove the complexity from the password hashing algorithm # Only in tests, remove the complexity from the password hashing algorithm
config :bcrypt_elixir, :log_rounds, 1 config :bcrypt_elixir, :log_rounds, 1

View File

@ -25,8 +25,8 @@ processes = []
script_checks = [] script_checks = []
[services.concurrency] [services.concurrency]
hard_limit = 25 hard_limit = 10000
soft_limit = 20 soft_limit = 6000
type = "connections" type = "connections"
[[services.ports]] [[services.ports]]

View File

@ -21,6 +21,10 @@ defmodule Ketbin.Pastes do
Repo.all(Paste) Repo.all(Paste)
end end
def list_pastes_by_user(user_id) do
Repo.all(from(p in Paste, where: p.belongs_to == ^user_id))
end
@doc """ @doc """
Gets a single paste. Gets a single paste.

View File

@ -9,6 +9,8 @@ defmodule Ketbin.Pastes.Paste do
field :content, :string field :content, :string
field :is_url, :boolean, default: false field :is_url, :boolean, default: false
field :belongs_to, :id field :belongs_to, :id
timestamps()
end end
@doc false @doc false

View File

@ -134,4 +134,9 @@ defmodule KetbinWeb.PageController do
render(conn, "edit.html", paste: paste, changeset: changeset) render(conn, "edit.html", paste: paste, changeset: changeset)
end end
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 end

View File

@ -18,6 +18,13 @@ defmodule KetbinWeb.Router do
plug :fetch_current_user plug :fetch_current_user
end end
# scope to ensure user is authenticated
scope "/", KetbinWeb do
pipe_through [:browser, :require_authenticated_user]
get "/pastes", PageController, :pastes
end
scope "/", KetbinWeb do scope "/", KetbinWeb do
pipe_through :browser pipe_through :browser

View File

@ -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> <ul>
<%= if @current_user do %> <%= if @current_user do %>
<li><%= @current_user.email %></li> <div class="relative">
<li><%= link "Settings", to: Routes.user_settings_path(@conn, :edit) %></li> <li id="dropdown-label" onclick="toggleDropdown()" class="text-[#ff9800] cursor-pointer select-none"><%= @current_user.email %> ▼</li>
<li><%= link "Log out", to: Routes.user_session_path(@conn, :delete), method: :delete %></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 %> <% else %>
<li><%= link "Register", to: Routes.user_registration_path(@conn, :new) %></li> <li><%= link "Register", to: Routes.user_registration_path(@conn, :new) %></li>
<li><%= link "Log in", to: Routes.user_session_path(@conn, :new) %></li> <li><%= link "Log in", to: Routes.user_session_path(@conn, :new) %></li>

View File

@ -88,7 +88,7 @@
</main> </main>
<footer class="font-bold"> <footer class="font-bold">
<div class="flex px-4 py-1 text-xs sm:text-base justify-between text-amber" style="background: #1a1a1a; font-family: JetbrainsMono"> <div class="flex px-4 py-1 text-xs sm:text-base justify-between text-amber" style="background: #1a1a1a; font-family: JetbrainsMono">
<a href="https://sphericalk.at"> <a href="https://kat.bio">
© <%= DateTime.utc_now().year %> SphericalKat © <%= DateTime.utc_now().year %> SphericalKat
</a> </a>
<a href="https://github.com/sphericalkat/katbin"> <a href="https://github.com/sphericalkat/katbin">

View File

@ -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>

View File

@ -7,7 +7,7 @@ defmodule Ketbin.MixProject do
version: "0.1.0", version: "0.1.0",
elixir: "~> 1.12", elixir: "~> 1.12",
elixirc_paths: elixirc_paths(Mix.env()), elixirc_paths: elixirc_paths(Mix.env()),
compilers: [:phoenix, :gettext] ++ Mix.compilers(), compilers: [:phoenix] ++ Mix.compilers(),
start_permanent: Mix.env() == :prod, start_permanent: Mix.env() == :prod,
aliases: aliases(), aliases: aliases(),
deps: deps() deps: deps()
@ -39,7 +39,7 @@ defmodule Ketbin.MixProject do
{:ecto_sql, "~> 3.7"}, {:ecto_sql, "~> 3.7"},
{:postgrex, ">= 0.0.0"}, {:postgrex, ">= 0.0.0"},
{:phoenix_html, "~> 3.0"}, {:phoenix_html, "~> 3.0"},
{:phoenix_live_view, "~> 0.20.0"}, {:phoenix_live_view, "~> 0.18.0"},
{:phoenix_live_reload, "~> 1.3", only: :dev}, {:phoenix_live_reload, "~> 1.3", only: :dev},
{:phoenix_live_dashboard, "~> 0.5"}, {:phoenix_live_dashboard, "~> 0.5"},
{:telemetry_metrics, "~> 0.6"}, {:telemetry_metrics, "~> 0.6"},

View File

@ -0,0 +1,10 @@
defmodule Ketbin.Repo.Migrations.AddTimestampsPastes do
use Ecto.Migration
def change do
alter table(:pastes) do
add :inserted_at, :naive_datetime, null: false, default: fragment("CURRENT_TIMESTAMP")
add :updated_at, :naive_datetime, null: false, default: fragment("CURRENT_TIMESTAMP")
end
end
end