5 Commits

  1. 17
      CHANGELOG.md
  2. 43
      assets/css/app.scss
  3. 7
      lib/mirage_web/controllers/user_controller.ex
  4. 2
      lib/mirage_web/live/show_note_live.ex
  5. 36
      lib/mirage_web/router.ex
  6. 2
      lib/mirage_web/templates/layout/_user_menu.html.eex
  7. 14
      lib/mirage_web/templates/user/index.html.eex
  8. 3
      lib/mirage_web/views/user_view.ex
  9. 2
      mix.exs

17
CHANGELOG.md

@ -5,6 +5,23 @@ See [Conventional Commits](Https://conventionalcommits.org) for commit guideline
<!-- changelog -->
## [v0.22.0](https://git.inhji.de/inhji/mirage/compare/v0.21.0...v0.22.0) (2021-02-12)
### Features:
* user menu WIP
* add user overview page
### Bug Fixes:
* remove obsolete user layout
* clean up show note live
## [v0.21.0](https://git.inhji.de/inhji/mirage/compare/v0.20.0...v0.21.0) (2021-02-10)

43
assets/css/app.scss

@ -94,6 +94,10 @@ footer {
padding: 2rem;
}
.padding {
padding: 2rem;
}
section:not(.hero) + section,
div + section {
margin-top: 2rem;
@ -130,15 +134,40 @@ nav[role=navigation] {
font-weight: bold;
}
li a {
display: block;
padding: 1rem;
text-decoration: none;
transition: all 0.3s;
li {
a {
display: block;
padding: 1rem;
text-decoration: none;
transition: all 0.3s;
&:hover {
background: #3a3a3a;
}
}
}
}
aside.menu {
ul {
li a:hover {
background: #3a3a3a;
li {
padding-left: 2rem;
margin: 0 -2rem 0 -4rem;
background: $bg-content;
a {
display: inline-block;
width: 100%;
padding: 1rem 2rem;
transition: all 0.3s;
text-decoration: none;
&:hover {
background: #3a3a3a;
}
}
}
}
}

7
lib/mirage_web/controllers/user_controller.ex

@ -0,0 +1,7 @@
defmodule MirageWeb.UserController do
use MirageWeb, :controller
def index(conn, _params) do
render(conn, "index.html")
end
end

2
lib/mirage_web/live/show_note_live.ex

@ -11,7 +11,7 @@ defmodule MirageWeb.ShowNoteLive do
end
@impl true
def handle_params(%{"id" => note_id}, uri, socket) do
def handle_params(%{"id" => note_id}, _uri, socket) do
note =
note_id
|> Notes.get_note!()

36
lib/mirage_web/router.ex

@ -35,6 +35,12 @@ defmodule MirageWeb.Router do
live "/notes/:id", ShowNoteLive
end
scope "/user", MirageWeb do
pipe_through [:browser, :require_authenticated_user]
get "/", UserController, :index
end
# Other scopes may use custom stacks.
# scope "/api", MirageWeb do
# pipe_through :api
@ -64,30 +70,30 @@ defmodule MirageWeb.Router do
scope "/", MirageWeb do
pipe_through [:browser, :redirect_if_user_is_authenticated]
get "/users/register", UserRegistrationController, :new
post "/users/register", UserRegistrationController, :create
get "/users/log_in", UserSessionController, :new
post "/users/log_in", UserSessionController, :create
get "/users/reset_password", UserResetPasswordController, :new
post "/users/reset_password", UserResetPasswordController, :create
get "/users/reset_password/:token", UserResetPasswordController, :edit
put "/users/reset_password/:token", UserResetPasswordController, :update
get "/user/register", UserRegistrationController, :new
post "/user/register", UserRegistrationController, :create
get "/user/log_in", UserSessionController, :new
post "/user/log_in", UserSessionController, :create
get "/user/reset_password", UserResetPasswordController, :new
post "/user/reset_password", UserResetPasswordController, :create
get "/user/reset_password/:token", UserResetPasswordController, :edit
put "/user/reset_password/:token", UserResetPasswordController, :update
end
scope "/", MirageWeb do
pipe_through [:browser, :require_authenticated_user]
get "/users/settings", UserSettingsController, :edit
put "/users/settings", UserSettingsController, :update
get "/users/settings/confirm_email/:token", UserSettingsController, :confirm_email
get "/user/settings", UserSettingsController, :edit
put "/user/settings", UserSettingsController, :update
get "/user/settings/confirm_email/:token", UserSettingsController, :confirm_email
end
scope "/", MirageWeb do
pipe_through [:browser]
delete "/users/log_out", UserSessionController, :delete
get "/users/confirm", UserConfirmationController, :new
post "/users/confirm", UserConfirmationController, :create
get "/users/confirm/:token", UserConfirmationController, :confirm
delete "/user/log_out", UserSessionController, :delete
get "/user/confirm", UserConfirmationController, :new
post "/user/confirm", UserConfirmationController, :create
get "/user/confirm/:token", UserConfirmationController, :confirm
end
end

2
lib/mirage_web/templates/layout/_user_menu.html.eex

@ -1,5 +1,5 @@
<%= if @current_user do %>
<li><%= link @current_user.email, to: Routes.user_settings_path(@conn, :edit) %></li>
<li><%= link @current_user.email, to: Routes.user_path(@conn, :index) %></li>
<li><%= link "Settings", to: Routes.setting_path(@conn, :index) %></li>
<li><%= link "Log out", to: Routes.user_session_path(@conn, :delete), method: :delete %></li>
<% else %>

14
lib/mirage_web/templates/user/index.html.eex

@ -0,0 +1,14 @@
<aside class="menu">
<ul>
<li><%= link "User", to: Routes.user_path(@conn, :index) %></li>
<li><%= link "Settings", to: Routes.setting_path(@conn, :index) %></li>
</ul>
</aside>
<div class="hero">
<h1>User</h1>
</div>
<section>
<p>hello world!</p>
</section>

3
lib/mirage_web/views/user_view.ex

@ -0,0 +1,3 @@
defmodule MirageWeb.UserView do
use MirageWeb, :view
end

2
mix.exs

@ -1,7 +1,7 @@
defmodule Mirage.MixProject do
use Mix.Project
@version "0.21.0"
@version "0.22.0"
def project do
[

Loading…
Cancel
Save