7 Commits

  1. 19
      CHANGELOG.md
  2. 353
      assets/css/_ok.css
  3. 22
      assets/css/app.css
  4. 1311
      assets/package-lock.json
  5. 9
      assets/package.json
  6. 10
      lib/mirage/accounts.ex
  7. 7
      lib/mirage/accounts/user.ex
  8. 16
      lib/mirage_web/controllers/user_settings_controller.ex
  9. 12
      lib/mirage_web/live/about_live.ex
  10. 1
      lib/mirage_web/live/about_live.html.leex
  11. 2
      lib/mirage_web/live/blog_live.html.leex
  12. 13
      lib/mirage_web/live/note_live/show.html.leex
  13. 22
      lib/mirage_web/templates/user_settings/edit.html.eex
  14. 2
      mix.exs
  15. 9
      priv/repo/migrations/20210328144534_add_name_to_user.exs

19
CHANGELOG.md

@ -5,6 +5,25 @@ See [Conventional Commits](Https://conventionalcommits.org) for commit guideline
<!-- changelog -->
## [v0.93.0](https://git.inhji.de/inhji/mirage/compare/v0.92.0...v0.93.0) (2021-03-28)
### Chores:
* update npm dependencies
### Features:
* mf2 for note show page
* show username on about
* add normalize.css
* add username to user
## [v0.92.0](https://git.inhji.de/inhji/mirage/compare/v0.91.0...v0.92.0) (2021-03-28)

353
assets/css/_ok.css

@ -1,356 +1,3 @@
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
/* Document
========================================================================== */
/**
* 1. Correct the line height in all browsers.
* 2. Prevent adjustments of font size after orientation changes in iOS.
*/
html {
line-height: 1.15; /* 1 */
-webkit-text-size-adjust: 100%; /* 2 */
}
/* Sections
========================================================================== */
/**
* Remove the margin in all browsers.
*/
body {
margin: 0;
}
/**
* Render the `main` element consistently in IE.
*/
main {
display: block;
}
/**
* Correct the font size and margin on `h1` elements within `section` and
* `article` contexts in Chrome, Firefox, and Safari.
*/
h1 {
font-size: 2em;
margin: 0.67em 0;
}
/* Grouping content
========================================================================== */
/**
* 1. Add the correct box sizing in Firefox.
* 2. Show the overflow in Edge and IE.
*/
hr {
box-sizing: content-box; /* 1 */
height: 0; /* 1 */
overflow: visible; /* 2 */
}
/**
* 1. Correct the inheritance and scaling of font size in all browsers.
* 2. Correct the odd `em` font sizing in all browsers.
*/
pre {
font-family: monospace, monospace; /* 1 */
font-size: 1em; /* 2 */
}
/* Text-level semantics
========================================================================== */
/**
* Remove the gray background on active links in IE 10.
*/
a {
background-color: transparent;
}
/**
* 1. Remove the bottom border in Chrome 57-
* 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
*/
abbr[title] {
border-bottom: none; /* 1 */
text-decoration: underline; /* 2 */
-webkit-text-decoration: underline dotted;
text-decoration: underline dotted; /* 2 */
}
/**
* Add the correct font weight in Chrome, Edge, and Safari.
*/
b,
strong {
font-weight: bolder;
}
/**
* 1. Correct the inheritance and scaling of font size in all browsers.
* 2. Correct the odd `em` font sizing in all browsers.
*/
code,
kbd,
samp {
font-family: monospace, monospace; /* 1 */
font-size: 1em; /* 2 */
}
/**
* Add the correct font size in all browsers.
*/
small {
font-size: 80%;
}
/**
* Prevent `sub` and `sup` elements from affecting the line height in
* all browsers.
*/
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sub {
bottom: -0.25em;
}
sup {
top: -0.5em;
}
/* Embedded content
========================================================================== */
/**
* Remove the border on images inside links in IE 10.
*/
img {
border-style: none;
}
/* Forms
========================================================================== */
/**
* 1. Change the font styles in all browsers.
* 2. Remove the margin in Firefox and Safari.
*/
button,
input,
optgroup,
select,
textarea {
font-family: inherit; /* 1 */
font-size: 100%; /* 1 */
line-height: 1.15; /* 1 */
margin: 0; /* 2 */
}
/**
* Show the overflow in IE.
* 1. Show the overflow in Edge.
*/
button,
input {
/* 1 */
overflow: visible;
}
/**
* Remove the inheritance of text transform in Edge, Firefox, and IE.
* 1. Remove the inheritance of text transform in Firefox.
*/
button,
select {
/* 1 */
text-transform: none;
}
/**
* Correct the inability to style clickable types in iOS and Safari.
*/
button,
[type="button"],
[type="reset"],
[type="submit"] {
-webkit-appearance: button;
}
/**
* Remove the inner border and padding in Firefox.
*/
button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner {
border-style: none;
padding: 0;
}
/**
* Restore the focus styles unset by the previous rule.
*/
button:-moz-focusring,
[type="button"]:-moz-focusring,
[type="reset"]:-moz-focusring,
[type="submit"]:-moz-focusring {
outline: 1px dotted ButtonText;
}
/**
* Correct the padding in Firefox.
*/
fieldset {
padding: 0.35em 0.75em 0.625em;
}
/**
* 1. Correct the text wrapping in Edge and IE.
* 2. Correct the color inheritance from `fieldset` elements in IE.
* 3. Remove the padding so developers are not caught out when they zero out
* `fieldset` elements in all browsers.
*/
legend {
box-sizing: border-box; /* 1 */
color: inherit; /* 2 */
display: table; /* 1 */
max-width: 100%; /* 1 */
padding: 0; /* 3 */
white-space: normal; /* 1 */
}
/**
* Add the correct vertical alignment in Chrome, Firefox, and Opera.
*/
progress {
vertical-align: baseline;
}
/**
* Remove the default vertical scrollbar in IE 10+.
*/
textarea {
overflow: auto;
}
/**
* 1. Add the correct box sizing in IE 10.
* 2. Remove the padding in IE 10.
*/
[type="checkbox"],
[type="radio"] {
box-sizing: border-box; /* 1 */
padding: 0; /* 2 */
}
/**
* Correct the cursor style of increment and decrement buttons in Chrome.
*/
[type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button {
height: auto;
}
/**
* 1. Correct the odd appearance in Chrome and Safari.
* 2. Correct the outline style in Safari.
*/
[type="search"] {
-webkit-appearance: textfield; /* 1 */
outline-offset: -2px; /* 2 */
}
/**
* Remove the inner padding in Chrome and Safari on macOS.
*/
[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
/**
* 1. Correct the inability to style clickable types in iOS and Safari.
* 2. Change font properties to `inherit` in Safari.
*/
::-webkit-file-upload-button {
-webkit-appearance: button; /* 1 */
font: inherit; /* 2 */
}
/* Interactive
========================================================================== */
/*
* Add the correct display in Edge, IE 10+, and Firefox.
*/
details {
display: block;
}
/*
* Add the correct display in all browsers.
*/
summary {
display: list-item;
}
/* Misc
========================================================================== */
/**
* Add the correct display in IE 10+.
*/
template {
display: none;
}
/**
* Add the correct display in IE 10.
*/
[hidden] {
display: none;
}
:root {
/* CONSTANTS */
/* ================================== */

22
assets/css/app.css

@ -1,3 +1,4 @@
@import "normalize.css/normalize.css";
@import "easymde/dist/easymde.min.css";
@import "@yaireo/tagify/dist/tagify.css";
@import "bootstrap-icons/font/bootstrap-icons.css";
@ -27,7 +28,7 @@ Variables
--gray-dark: #343a40;
--gray-light: #cccccc;
--primary: rebeccapurple;
--primary: var(--blue);
--secondary: var(--gray);
--success: var(--green);
--info: var(--teal);
@ -36,6 +37,7 @@ Variables
--light: var(--white);
--dark: var(--gray-dark);
--color-link: var(--blue);
--background-navigation: var(--dark);
--color-navigation: var(--light);
--width-sidebar: 15rem;
@ -66,6 +68,10 @@ body {
}
}
a, a:visited {
color: var(--color-link);
}
main {
padding-top: 4rem;
}
@ -77,6 +83,7 @@ main {
margin: auto;
left: var(--width-sidebar);
top: 0;
z-index: 1000;
background: var(--dark);
color: var(--light);
@ -88,6 +95,11 @@ main {
a {
color: var(--light);
font-weight: 400;
&:first-child {
font-weight: 600;
}
}
@media (--smol) {
@ -134,6 +146,14 @@ nav#sidebar {
Elements and Components
========================================================================== */
article {
footer {
a, a:visited {
color: var(--ok-tc-1);
}
}
}
.tag a {
background: var(--gray-light);
padding: 0.5rem;

1311
assets/package-lock.json
File diff suppressed because it is too large
View File

9
assets/package.json

@ -5,13 +5,10 @@
"watch": "webpack --mode development --watch"
},
"dependencies": {
"@codemirror/basic-setup": "^0.18",
"@codemirror/lang-markdown": "^0.18",
"@codemirror/theme-one-dark": "^0.18",
"@yaireo/tagify": "^3.22.3",
"bootstrap-icons": "^1.4.0",
"easymde": "^2.14.0",
"minireset.css": "^0.0.7",
"normalize.css": "^8.0.1",
"nprogress": "^0.2.0",
"phoenix": "file:../deps/phoenix",
"phoenix_html": "file:../deps/phoenix_html",
@ -22,7 +19,7 @@
"devDependencies": {
"@babel/core": "^7.x",
"@babel/preset-env": "^7.x",
"autoprefixer": "^9.8.6",
"autoprefixer": "^10.x",
"babel-loader": "^8.x",
"babel-plugin-prismjs": "^2.0.1",
"copy-webpack-plugin": "^8.x",
@ -31,7 +28,7 @@
"file-loader": "^6.x",
"mini-css-extract-plugin": "^1.3.6",
"postcss": "^8.2.8",
"postcss-custom-media": "^7.0.8",
"postcss-custom-media": "^8.x",
"postcss-loader": "^5.2.0",
"postcss-nested": "^5.0.5",
"postcss-preset-env": "^6.7.0",

10
lib/mirage/accounts.ex

@ -121,6 +121,16 @@ defmodule Mirage.Accounts do
User.email_changeset(user, attrs)
end
def change_user_profile(user, attrs \\ %{}) do
User.profile_changeset(user, attrs)
end
def update_user_profile(user, attrs \\ %{}) do
user
|> User.profile_changeset(attrs)
|> Repo.update()
end
@doc """
Emulates that the email will change without actually changing
it in the database.

7
lib/mirage/accounts/user.ex

@ -5,6 +5,7 @@ defmodule Mirage.Accounts.User do
@derive {Inspect, except: [:password]}
schema "users" do
field :email, :string
field :name, :string
field :password, :string, virtual: true
field :hashed_password, :string
field :confirmed_at, :naive_datetime
@ -68,6 +69,12 @@ defmodule Mirage.Accounts.User do
end
end
def profile_changeset(changeset, attrs) do
changeset
|> cast(attrs, [:name])
|> validate_required([:name])
end
@doc """
A user changeset for changing the email.

16
lib/mirage_web/controllers/user_settings_controller.ex

@ -34,6 +34,21 @@ defmodule MirageWeb.UserSettingsController do
end
end
def update(conn, %{"action" => "update_profile"} = params) do
%{"user" => user_params} = params
user = conn.assigns.current_user
case Accounts.update_user_profile(user, user_params) do
{:ok, user} ->
conn
|> put_flash(:info, "Profile updated successfully.")
|> redirect(to: Routes.user_settings_path(conn, :edit))
{:error, changeset} ->
render(conn, "edit.html", password_changeset: changeset)
end
end
def update(conn, %{"action" => "update_password"} = params) do
%{"current_password" => password, "user" => user_params} = params
user = conn.assigns.current_user
@ -70,5 +85,6 @@ defmodule MirageWeb.UserSettingsController do
conn
|> assign(:email_changeset, Accounts.change_user_email(user))
|> assign(:password_changeset, Accounts.change_user_password(user))
|> assign(:profile_changeset, Accounts.change_user_profile(user))
end
end

12
lib/mirage_web/live/about_live.ex

@ -9,6 +9,16 @@ defmodule MirageWeb.AboutLive do
def mount(_params, session, socket) do
about_note = Mirage.Notes.get_note_by_title("@about")
{:ok, assign(socket, %{about_note: about_note}) |> with_user(session)}
user =
if Mirage.Accounts.has_user?() do
Mirage.Accounts.get_user!(1)
else
nil
end
{:ok,
socket
|> assign(%{about_note: about_note, user: user})
|> with_user(session)}
end
end

1
lib/mirage_web/live/about_live.html.leex

@ -1,5 +1,6 @@
<header class="hero">
<h1>About</h1>
<h2><%= @user.name %></h2>
</header>
<%= if @about_note do %>

2
lib/mirage_web/live/blog_live.html.leex

@ -25,7 +25,7 @@
<% end %>
</header>
<footer>
<time datetime="<%= note.inserted_at %>" class="dt-published">Created <%= note.inserted_at |> Timex.from_now() %></time><span class="muted"> </span><time datetime="<%= note.updated_at %>" class="dt-updated">Last Edited <%= note.updated_at |> Timex.from_now() %></time>
<time datetime="<%= note.inserted_at %>" class="dt-published">Created <%= note.inserted_at |> Timex.from_now() %></time><span class="muted"> * </span><time datetime="<%= note.updated_at %>" class="dt-updated">Last Edited <%= note.updated_at |> Timex.from_now() %></time>
</footer>
</article>
<% end %>

13
lib/mirage_web/live/note_live/show.html.leex

@ -7,26 +7,27 @@
return_to: Routes.note_show_path(@socket, :show, @note) %>
<% end %>
<article>
<article class="h-entry">
<header>
<h1><%= @note.title %></h1>
<h1 class="p-name">
<%= @note.title %>
</h1>
<div class="tags">
<%= for topic <- @note.topics do %>
<span class="tag">
<%= link topic.text, to: Routes.topic_path(MirageWeb.Endpoint, :show, topic) %>
<%= link topic.text, to: Routes.topic_path(MirageWeb.Endpoint, :show, topic), class: "p-category" %>
</span>
<% end %>
</div>
</header>
<section class="content html">
<section class="content html e-content">
<%= raw @note.content_html %>
</section>
<footer>
<time datetime="<%= @note.inserted_at %>">Created <%= Timex.from_now(@note.inserted_at) %></time>
<time datetime="<%= @note.updated_at %>">Last edited <%= Timex.from_now(@note.updated_at) %></time>
<a href="/about">By Inhji</a> * <time datetime="<%= @note.inserted_at %>">Created <%= Timex.from_now(@note.inserted_at) %></time> * <time datetime="<%= @note.updated_at %>">Last edited <%= Timex.from_now(@note.updated_at) %></time> * <a href="<%= Routes.note_show_path(@socket, :show, @note) %>" class="u-url u-uid">Permalink</a>
</footer>
<hr>

22
lib/mirage_web/templates/user_settings/edit.html.eex

@ -2,6 +2,28 @@
<h1>Edit User</h1>
</header>
<h3>Change profile</h3>
<%= form_for @profile_changeset, Routes.user_settings_path(@conn, :update), fn f -> %>
<%= if @profile_changeset.action do %>
<div class="alert alert-danger">
<p>Oops, something went wrong! Please check the errors below.</p>
</div>
<% end %>
<%= hidden_input f, :action, name: "action", value: "update_profile" %>
<fieldset>
<%= label f, :name %>
<%= text_input f, :name, required: true %>
<%= error_tag f, :name %>
</fieldset>
<div>
<%= submit "Change Profile" %>
</div>
<% end %>
<h3>Change email</h3>
<%= form_for @email_changeset, Routes.user_settings_path(@conn, :update), fn f -> %>

2
mix.exs

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

9
priv/repo/migrations/20210328144534_add_name_to_user.exs

@ -0,0 +1,9 @@
defmodule Mirage.Repo.Migrations.AddNameToUser do
use Ecto.Migration
def change do
alter table(:users) do
add :name, :string, default: "Inhji"
end
end
end
Loading…
Cancel
Save