10 Commits

  1. 29
      CHANGELOG.md
  2. 2
      assets/css/_navigation.scss
  3. 10
      assets/css/app.scss
  4. 712
      assets/package-lock.json
  5. 11
      lib/mirage/notes.ex
  6. 2
      lib/mirage_web/controllers/user_controller.ex
  7. 8
      lib/mirage_web/live/note_live/index.ex
  8. 48
      lib/mirage_web/live/note_live/index.html.leex
  9. 5
      lib/mirage_web/templates/layout/_sidebar.html.eex
  10. 2
      lib/mirage_web/templates/setting/index.html.eex
  11. 5
      lib/mirage_web/templates/shared/user_menu.html.eex
  12. 8
      lib/mirage_web/templates/topic/edit.html.eex
  13. 7
      lib/mirage_web/templates/topic/form.html.eex
  14. 15
      lib/mirage_web/templates/user/index.html.eex
  15. 2
      mix.exs
  16. 2
      priv/repo/migrations/20210215183316_migrate_links_to_join_table.exs
  17. 1
      priv/repo/migrations/20210227074240_create_lists.exs

29
CHANGELOG.md

@ -5,6 +5,35 @@ See [Conventional Commits](Https://conventionalcommits.org) for commit guideline
<!-- changelog -->
## [v0.62.0](https://git.inhji.de/inhji/mirage/compare/v0.61.0...v0.62.0) (2021-02-27)
### Chores:
* mix format
* update npm deps
### Features:
* finally make proper tag form
* remove user_menu
* revamp note index, add most viewed
* show most viewed notes
* add active styles for sidebar
### Bug Fixes:
* small fixed for sidebar
* correct width for logged in layout
## [v0.61.0](https://git.inhji.de/inhji/mirage/compare/v0.60.0...v0.61.0) (2021-02-27)

2
assets/css/_navigation.scss

@ -85,7 +85,7 @@ aside#sidebar {
width: 100%;
transition: all 0.3s;
&:hover {
&:hover, &.active {
@include color-assign(background-color, primary);
@include color-assign(color, on-primary);
}

10
assets/css/app.scss

@ -119,8 +119,14 @@ a {
.flex-3 {flex: 3;}
.flex-4 {flex: 4;}
body.logged-in #wrapper {
margin-left: $width-sidebar;
body.logged-in {
.container {
max-width: 60rem + $width-sidebar;
}
#wrapper {
margin-left: $width-sidebar;
}
}
main[role=main] {

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

11
lib/mirage/notes.ex

@ -77,6 +77,17 @@ defmodule Mirage.Notes do
Repo.all(q)
end
def list_notes(:most_viewed) do
q =
from n in Note,
limit: 3,
select: n,
order_by: [desc: n.views],
preload: ^@note_preloads
Repo.all(q)
end
def list_notes(:unlinked) do
q =
from n in Note,

2
lib/mirage_web/controllers/user_controller.ex

@ -2,7 +2,6 @@ defmodule MirageWeb.UserController do
use MirageWeb, :controller
def index(conn, _params) do
last_edited = Mirage.Notes.list_notes(:last_edited)
unlinked = Mirage.Notes.list_notes(:unlinked)
untagged = Mirage.Notes.list_notes(:untagged)
at = Mirage.Notes.list_notes(:at)
@ -12,7 +11,6 @@ defmodule MirageWeb.UserController do
notes: %{
today: today,
at: at,
last_edited: last_edited,
untagged: untagged,
unlinked: unlinked
}

8
lib/mirage_web/live/note_live/index.ex

@ -6,9 +6,15 @@ defmodule MirageWeb.NoteLive.Index do
@impl true
def mount(_params, session, socket) do
last_edited = Mirage.Notes.list_notes(:last_edited)
most_viewed = Mirage.Notes.list_notes(:most_viewed)
{:ok,
socket
|> assign(:notes, list_notes())
|> assign(:notes, %{
last_edited: last_edited,
most_viewed: most_viewed
})
|> with_user(session)}
end

48
lib/mirage_web/live/note_live/index.html.leex

@ -4,7 +4,6 @@
<header class="hero">
<h1>Listing Notes</h1>
<p><%= Enum.count(@notes) %> Notes</p>
<%= if @current_user do %>
<span><%= live_patch "New Note", to: Routes.note_index_path(@socket, :new), class: "button" %></span>
<% end %>
@ -19,33 +18,28 @@
return_to: Routes.note_index_path(@socket, :index) %>
<% end %>
<section class="notes">
<%= for note <- @notes do %>
<article class="note" id="note-<%= note.id %>">
<%= live_patch to: Routes.note_show_path(@socket, :show, note) do %>
<header class="width-full">
<h2 class="title">
<%= note.title %>
</h2>
</header>
<% end %>
<section class="bg-content width-full">
<h3>✒️ Last Edited</h3>
<section>
<div class="content html width-full bg-content">
<%= raw note.content_html %>
</div>
</section>
<div class="grid cards">
<%= for note <- @notes.last_edited do %>
<%= link to: Routes.note_show_path(@socket, :show, note), class: "col card" do %>
<strong><%= note.title %></strong>
<p><%= note.content |> String.slice(0..50) %></p>
<% end %>
<% end %>
</div>
</section>
<section class="bg-content width-full">
<h3>🕶️ Most Viewed</h3>
<footer class="width-full bg-content">
<time datetime="<%= note.inserted_at %>"><%= Timex.from_now(note.inserted_at) %></time>
<span class="tags">
<%= for topic <- note.topics do %>
<span class="tag"><%= topic.text %></span>
<% end %>
</span>
</footer>
</article>
<div class="grid cards">
<%= for note <- @notes.most_viewed do %>
<%= link to: Routes.note_show_path(@socket, :show, note), class: "col card" do %>
<strong><%= note.title %></strong>
<p><%= note.content |> String.slice(0..50) %></p>
<% end %>
<% end %>
</div>
</section>

5
lib/mirage_web/templates/layout/_sidebar.html.eex

@ -3,9 +3,8 @@
<li>
<a>&nbsp;</a>
</li>
<li>
<%= active_link(@conn, "Inbox", to: Routes.user_path(@conn, :index), wrap_tag: :li) %>
</li>
<%= active_link(@conn, "Inbox", to: Routes.user_path(@conn, :index), wrap_tag: :li) %>
<li class="spacer"></li>
<%= active_link(@conn, "Notes", to: "/notes", wrap_tag: :li) %>
<%= active_link(@conn, "Links", to: "/links", wrap_tag: :li) %>
<%= active_link(@conn, "Topics", to: "/topics", wrap_tag: :li) %>

2
lib/mirage_web/templates/setting/index.html.eex

@ -2,8 +2,6 @@
<h1>Listing Settings</h1>
</header>
<%= render MirageWeb.SharedView, "user_menu.html", assigns %>
<div class="width-full bg-content">
<%= for setting <- @settings do %>
<%= link setting.name, to: Routes.setting_path(@conn, :show, setting), class: "button" %>

5
lib/mirage_web/templates/shared/user_menu.html.eex

@ -1,5 +0,0 @@
<aside class="menu">
<ul>
<li><%= link "Settings", to: Routes.setting_path(@conn, :index) %></li>
</ul>
</aside>

8
lib/mirage_web/templates/topic/edit.html.eex

@ -1,5 +1,7 @@
<h1>Edit Note topic</h1>
<header class="hero">
<h1>Edit Note topic</h1>
</header>
<section class="bg-content width-full">
<%= render "form.html", Map.put(assigns, :action, Routes.topic_path(@conn, :update, @topic)) %>
<span><%= link "Back", to: Routes.topic_path(@conn, :index) %></span>
</section>

7
lib/mirage_web/templates/topic/form.html.eex

@ -5,9 +5,10 @@
</div>
<% end %>
<%= label f, :text %>
<%= text_input f, :text %>
<%= error_tag f, :text %>
<fieldset>
<%= text_input f, :text %>
<%= error_tag f, :text %>
</fieldset>
<div>
<%= submit "Save" %>

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

@ -2,8 +2,6 @@
<h1>Inbox</h1>
</header>
<%= render MirageWeb.SharedView, "user_menu.html", assigns %>
<section class="bg-content width-full">
<h3>📆 Todays Note</h3>
@ -17,19 +15,6 @@
</div>
</section>
<section class="bg-content width-full">
<h3>✒️ Last Edited</h3>
<div class="grid cards">
<%= for note <- @notes.last_edited do %>
<%= link to: Routes.note_show_path(@conn, :show, note), class: "col card" do %>
<strong><%= note.title %></strong>
<p><%= note.content |> String.slice(0..50) %></p>
<% end %>
<% end %>
</div>
</section>
<%= if not Enum.empty?(@notes.unlinked) do %>
<section class="bg-content width-full">
<h3>🔗 Unlinked</h3>

2
mix.exs

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

2
priv/repo/migrations/20210215183316_migrate_links_to_join_table.exs

@ -6,7 +6,7 @@ defmodule Mirage.Repo.Migrations.MigrateLinksToJoinTable do
alter table(:links) do
add :domain, :string
end
execute(&link_join_up/0, &link_join_down/0)
end

1
priv/repo/migrations/20210227074240_create_lists.exs

@ -8,6 +8,5 @@ defmodule Mirage.Repo.Migrations.CreateLists do
timestamps()
end
end
end
Loading…
Cancel
Save