9 Commits

  1. 19
      CHANGELOG.md
  2. 2
      assets/.babelrc
  3. 1
      assets/js/app.js
  4. 964
      assets/package-lock.json
  5. 2
      assets/package.json
  6. 1
      deploy.sh
  7. 4
      lib/mirage/notes.ex
  8. 6
      lib/mirage_web/controllers/topic_controller.ex
  9. 4
      lib/mirage_web/live/page_live.ex
  10. 37
      lib/mirage_web/live/page_live.html.leex
  11. 2
      lib/mirage_web/live/show_note_live.html.leex
  12. 1
      lib/mirage_web/templates/layout/_user_menu.html.eex
  13. 26
      lib/mirage_web/templates/note/_note.html.eex
  14. 30
      lib/mirage_web/templates/note/index.html.eex
  15. 35
      lib/mirage_web/templates/note/show.html.eex
  16. 2
      lib/mirage_web/templates/setting/index.html.eex
  17. 6
      lib/mirage_web/templates/shared/user_menu.html.eex
  18. 16
      lib/mirage_web/templates/topic/show.html.eex
  19. 11
      lib/mirage_web/templates/user/index.html.eex
  20. 3
      lib/mirage_web/views/shared_view.ex
  21. 2
      mix.exs

19
CHANGELOG.md

@ -5,6 +5,25 @@ See [Conventional Commits](Https://conventionalcommits.org) for commit guideline
<!-- changelog -->
## [v0.23.0](https://git.inhji.de/inhji/mirage/compare/v0.22.0...v0.23.0) (2021-02-12)
### Features:
* show tagged notes
* add special handling for @home note
* add user menu
### Bug Fixes:
* spacing in note index
* no syntax highlight in note show
## [v0.22.0](https://git.inhji.de/inhji/mirage/compare/v0.21.0...v0.22.0) (2021-02-12)

2
assets/.babelrc

@ -4,7 +4,7 @@
],
"plugins": [
["prismjs", {
"languages": ["javascript", "css", "markup", "markdown", "elixir", "bash", "sql", "visual-basic"],
"languages": ["javascript", "css", "markup", "markdown", "elixir", "bash", "sql", "vbnet"],
"plugins": [],
"theme": "tomorrow",
"css": true

1
assets/js/app.js

@ -41,3 +41,4 @@ if (document.querySelector(element)) {
}
Prism.highlightAll();

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

2
assets/package.json

@ -8,7 +8,7 @@
"@codemirror/basic-setup": "^0.17.1",
"@codemirror/lang-markdown": "^0.17.2",
"@codemirror/theme-one-dark": "^0.17.5",
"minireset.css": "0.0.6",
"minireset.css": "^0.0.7",
"nprogress": "^0.2.0",
"phoenix": "file:../deps/phoenix",
"phoenix_html": "file:../deps/phoenix_html",

1
deploy.sh

@ -4,6 +4,7 @@ echo ""
echo "Pushing changes..."
echo "--------------------------"
git push origin main
git push gh main
echo ""
echo "Build starting!"
echo "--------------------------"

4
lib/mirage/notes.ex

@ -9,7 +9,7 @@ defmodule Mirage.Notes do
alias Mirage.Notes.{Note, Topic, NoteNote, NoteLink}
@note_preloads [:links, :topics, :backlinks]
@topic_preloads [:notes]
@topic_preloads [notes: @note_preloads]
@doc """
Returns the list of notes.
@ -46,6 +46,8 @@ defmodule Mirage.Notes do
def get_note(id), do: Repo.get(Note, id)
def get_note_by_title(title), do: Repo.get_by(Note, title: title)
def preload_note(note), do: Repo.preload(note, @note_preloads)
@doc """

6
lib/mirage_web/controllers/topic_controller.ex

@ -29,7 +29,11 @@ defmodule MirageWeb.TopicController do
end
def show(conn, %{"id" => id}) do
topic = Notes.get_topic!(id)
topic =
id
|> Notes.get_topic!()
|> Notes.preload_topic()
render(conn, "show.html", topic: topic)
end

4
lib/mirage_web/live/page_live.ex

@ -3,7 +3,9 @@ defmodule MirageWeb.PageLive do
@impl true
def mount(_params, _session, socket) do
home_note = Mirage.Notes.get_note_by_title("@home")
settings = Mirage.Settings.list_settings_as_map()
{:ok, assign(socket, _s: settings)}
{:ok, assign(socket, %{_s: settings, home_note: home_note})}
end
end

37
lib/mirage_web/live/page_live.html.leex

@ -3,31 +3,12 @@
<p><%= raw @_s.user_tagline.value_html %></p>
</section>
<section class="grid width-full bg-content">
<div class="col">
<h2>Profiles</h2>
<ul>
<li>
<a href="https://chaos.social/@inhji" target="_blank">Mastodon</a>
</li>
<li>
<a href="https://www.openstreetmap.org/user/inhji" target="_blank">OpenStreetMap</a>
</li>
<li>
<a href="https://listenbrainz.org/user/inhji" target="_blank">Listenbrainz</a>
</li>
</ul>
</div>
<div class="col">
<h2>Hosted</h2>
<ul>
<li>
<a href="https://git.inhji.de" target="_blank">Gitea Instance</a>
</li>
<li>
<a href="https://reader.inhji.de" target="_blank">Miniflux RSS</a>
</li>
</li>
</ul>
</div>
</section>
<%= if @home_note do %>
<section class="width-full bg-content">
<%= raw @home_note.content_html %>
</section>
<% else %>
<section class="width-full bg-content">
Looks like you did not create a home note yet. Just name it <code>@home</code> and it will show up here.
</section>
<% end %>

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

@ -9,7 +9,7 @@
</div>
<div class="width-full bg-content">
<article>
<article phx-update="ignore" id="note-<%= @note.id %>">
<div class="content html">
<%= raw @note.content_html %>
</div>

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

@ -1,6 +1,5 @@
<%= if @current_user do %>
<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 %>
<%= if not Mirage.Accounts.has_user? do %>

26
lib/mirage_web/templates/note/_note.html.eex

@ -0,0 +1,26 @@
<article>
<%= link to: Routes.live_path(@conn, MirageWeb.ShowNoteLive, @note) do %>
<header class="width-full bg-content">
<h2 class="title">
<span class="id"><%= "##{@note.id}" %></span> <%= @note.title %>
</h2>
</header>
<% end %>
<section>
<div class="content html width-full bg-content">
<%= raw @note.content_html %>
</div>
</section>
<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 class="width-full bg-content">
</article>

30
lib/mirage_web/templates/note/index.html.eex

@ -1,34 +1,10 @@
<div class="hero">
<section class="hero">
<h1>Listing Notes</h1>
</div>
</section>
<section class="notes">
<%= for note <- @notes do %>
<article>
<%= link to: Routes.live_path(@conn, MirageWeb.ShowNoteLive, note) do %>
<header class="width-full bg-content">
<h2 class="title">
<span class="id"><%= "##{note.id}" %></span> <%= note.title %>
</h2>
</header>
<% end %>
<section>
<div class="content html width-full bg-content">
<%= raw note.content_html %>
</div>
</section>
<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 class="width-full bg-content">
</article>
<%= render "_note.html", assigns |> Map.put(:note, note) %>
<% end %>
</section>

35
lib/mirage_web/templates/note/show.html.eex

@ -1,35 +0,0 @@
<div class="hero">
<h1><span class="id"><%= "##{@note.id}" %></span> <%= @note.title %></h1>
<p><time datetime="<%= @note.inserted_at %>"><%= Timex.from_now(@note.inserted_at) %></time> / <time datetime="<%= @note.updated_at %>"><%= Timex.from_now(@note.updated_at) %></time></p>
<p class="tags">
<%= for topic <- @note.topics do %>
<span class="tag"><%= topic.text %></span>
<% end %>
</p>
</div>
<div class="width-full bg-content">
<article>
<div class="content html">
<%= raw @note.content_html %>
</div>
</article>
</div>
<%= if not Enum.empty?(@note.backlinks) do %>
<section class="backlinks">
<h4>Backlinks</h4>
<%= for backlink <- @note.backlinks do %>
<%= link backlink.title, to: Routes.live_path(@conn, MirageWeb.ShowNoteLive, backlink), class: "backlink bg-content" %>
<% end %>
</section>
<% end %>
<%= if @current_user do %>
<div class="buttons">
<span><%= link "Edit", to: Routes.note_path(@conn, :edit, @note), class: "button" %></span>
<span><%= link "Back", to: Routes.note_path(@conn, :index), class: "button" %></span>
<span><%= link "Delete", to: Routes.note_path(@conn, :delete, @note), method: :delete, data: [confirm: "Are you sure?"], class: "button" %></span>
</div>
<% end %>

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

@ -1,3 +1,5 @@
<%= render MirageWeb.SharedView, "user_menu.html", assigns %>
<div class="hero">
<h1>Listing Settings</h1>
</div>

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

@ -0,0 +1,6 @@
<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>

16
lib/mirage_web/templates/topic/show.html.eex

@ -1,7 +1,15 @@
<div class="hero">
<section class="hero">
<h1>Topic <%= @topic.text %></h1>
</div>
</section>
<section>
<% IO.inspect @topic %>
<%= for note <- @topic.notes do %>
<%= render MirageWeb.NoteView, "_note.html", assigns |> Map.put(:note, note) %>
<% end %>
</section>
<span><%= link "Edit", to: Routes.topic_path(@conn, :edit, @topic) %></span>
<span><%= link "Back", to: Routes.topic_path(@conn, :index) %></span>
<div class="buttons">
<%= link "Edit", to: Routes.topic_path(@conn, :edit, @topic), class: "button" %>
<%= link "Back", to: Routes.topic_path(@conn, :index), class: "button" %>
</div>

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

@ -1,9 +1,4 @@
<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>
<%= render MirageWeb.SharedView, "user_menu.html", assigns %>
<div class="hero">
<h1>User</h1>
@ -12,3 +7,7 @@
<section>
<p>hello world!</p>
</section>
<div class="buttons">
<%= link "Edit User", to: Routes.user_settings_path(@conn, :edit), class: "button" %>
</div>

3
lib/mirage_web/views/shared_view.ex

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

2
mix.exs

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

Loading…
Cancel
Save