Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d43ec7b73 | ||
|
|
ebd9f7f52c | ||
|
|
f0efa78b89 | ||
|
|
ca905d46aa | ||
|
|
5ea437b9f1 |
No files matched your search
Generated
+149
-682
File diff suppressed because it is too large.
Load diff
+2
-2
@@ -12,11 +12,11 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"autoprefixer": "^10.3.1",
|
"autoprefixer": "^10.3.1",
|
||||||
"esbuild": "^0.21.0",
|
"esbuild": "^0.12.22",
|
||||||
"esbuild-plugin-postcss2": "0.0.9",
|
"esbuild-plugin-postcss2": "0.0.9",
|
||||||
"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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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: {},
|
||||||
|
|||||||
+1
-1
@@ -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
|
||||||
|
|||||||
@@ -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.
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -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>
|
||||||
@@ -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()
|
||||||
|
|||||||
Reference in new issue
Block a user