diff --git a/changelog.md b/changelog.md index 648662d..def4f2d 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,6 @@ +# v0.1.3 +- backlink to other notes in notes + # v0.1.2 - fix more typos - add to faq diff --git a/lib/memex_web/components/note_content.ex b/lib/memex_web/components/note_content.ex new file mode 100644 index 0000000..c2a697a --- /dev/null +++ b/lib/memex_web/components/note_content.ex @@ -0,0 +1,44 @@ +defmodule MemexWeb.Components.NoteContent do + @moduledoc """ + Display the content for a note + """ + use MemexWeb, :component + alias Memex.Notes.Note + alias Phoenix.HTML + + attr :note, Note, required: true + + def note_content(assigns) do + ~H""" +
<%= add_links_to_content(@note.content) %>
" + end + ) + |> HTML.raw() + end +end diff --git a/lib/memex_web/live/note_live/show.ex b/lib/memex_web/live/note_live/show.ex index 65f63b4..4d5863f 100644 --- a/lib/memex_web/live/note_live/show.ex +++ b/lib/memex_web/live/note_live/show.ex @@ -1,6 +1,6 @@ defmodule MemexWeb.NoteLive.Show do use MemexWeb, :live_view - + import MemexWeb.Components.NoteContent alias Memex.{Accounts.User, Notes, Notes.Note} @impl true diff --git a/lib/memex_web/live/note_live/show.html.heex b/lib/memex_web/live/note_live/show.html.heex index 73026b0..690d329 100644 --- a/lib/memex_web/live/note_live/show.html.heex +++ b/lib/memex_web/live/note_live/show.html.heex @@ -5,14 +5,7 @@
<%= if @note.tags, do: @note.tags |> Enum.join(", ") %>
- + <.note_content note={@note} /><%= gettext("Visibility: %{visibility}", visibility: @note.visibility) %> diff --git a/priv/gettext/actions.pot b/priv/gettext/actions.pot index 7404637..c82b0a5 100644 --- a/priv/gettext/actions.pot +++ b/priv/gettext/actions.pot @@ -58,7 +58,7 @@ msgstr "" #: lib/memex_web/live/context_live/index.html.heex:49 #: lib/memex_web/live/context_live/show.html.heex:34 #: lib/memex_web/live/note_live/index.html.heex:49 -#: lib/memex_web/live/note_live/show.html.heex:38 +#: lib/memex_web/live/note_live/show.html.heex:31 #: lib/memex_web/live/pipeline_live/index.html.heex:49 #: lib/memex_web/live/pipeline_live/show.html.heex:43 #: lib/memex_web/live/pipeline_live/show.html.heex:113 @@ -74,7 +74,7 @@ msgstr "" #: lib/memex_web/live/context_live/index.html.heex:38 #: lib/memex_web/live/context_live/show.html.heex:23 #: lib/memex_web/live/note_live/index.html.heex:38 -#: lib/memex_web/live/note_live/show.html.heex:27 +#: lib/memex_web/live/note_live/show.html.heex:20 #: lib/memex_web/live/pipeline_live/index.html.heex:38 #: lib/memex_web/live/pipeline_live/show.html.heex:32 #: lib/memex_web/live/pipeline_live/show.html.heex:102 @@ -133,7 +133,7 @@ msgid "save" msgstr "" #: lib/memex_web/live/context_live/show.html.heex:16 -#: lib/memex_web/live/note_live/show.html.heex:23 +#: lib/memex_web/live/note_live/show.html.heex:16 #: lib/memex_web/live/pipeline_live/show.html.heex:25 #, elixir-autogen, elixir-format msgid "back" diff --git a/priv/gettext/de/LC_MESSAGES/actions.po b/priv/gettext/de/LC_MESSAGES/actions.po index 356c598..956339f 100644 --- a/priv/gettext/de/LC_MESSAGES/actions.po +++ b/priv/gettext/de/LC_MESSAGES/actions.po @@ -59,7 +59,7 @@ msgstr "" #: lib/memex_web/live/context_live/index.html.heex:49 #: lib/memex_web/live/context_live/show.html.heex:34 #: lib/memex_web/live/note_live/index.html.heex:49 -#: lib/memex_web/live/note_live/show.html.heex:38 +#: lib/memex_web/live/note_live/show.html.heex:31 #: lib/memex_web/live/pipeline_live/index.html.heex:49 #: lib/memex_web/live/pipeline_live/show.html.heex:43 #: lib/memex_web/live/pipeline_live/show.html.heex:113 @@ -75,7 +75,7 @@ msgstr "" #: lib/memex_web/live/context_live/index.html.heex:38 #: lib/memex_web/live/context_live/show.html.heex:23 #: lib/memex_web/live/note_live/index.html.heex:38 -#: lib/memex_web/live/note_live/show.html.heex:27 +#: lib/memex_web/live/note_live/show.html.heex:20 #: lib/memex_web/live/pipeline_live/index.html.heex:38 #: lib/memex_web/live/pipeline_live/show.html.heex:32 #: lib/memex_web/live/pipeline_live/show.html.heex:102 @@ -134,7 +134,7 @@ msgid "save" msgstr "" #: lib/memex_web/live/context_live/show.html.heex:16 -#: lib/memex_web/live/note_live/show.html.heex:23 +#: lib/memex_web/live/note_live/show.html.heex:16 #: lib/memex_web/live/pipeline_live/show.html.heex:25 #, elixir-autogen, elixir-format msgid "back" diff --git a/priv/gettext/de/LC_MESSAGES/default.po b/priv/gettext/de/LC_MESSAGES/default.po index a07f668..3dbc6d8 100644 --- a/priv/gettext/de/LC_MESSAGES/default.po +++ b/priv/gettext/de/LC_MESSAGES/default.po @@ -82,7 +82,7 @@ msgid "Uses left" msgstr "" #: lib/memex_web/live/context_live/show.html.heex:11 -#: lib/memex_web/live/note_live/show.html.heex:18 +#: lib/memex_web/live/note_live/show.html.heex:11 #: lib/memex_web/live/pipeline_live/show.html.heex:20 #, elixir-autogen, elixir-format msgid "Visibility: %{visibility}" diff --git a/priv/gettext/de/LC_MESSAGES/prompts.po b/priv/gettext/de/LC_MESSAGES/prompts.po index 6d35305..fe33fab 100644 --- a/priv/gettext/de/LC_MESSAGES/prompts.po +++ b/priv/gettext/de/LC_MESSAGES/prompts.po @@ -140,7 +140,7 @@ msgstr "" #: lib/memex_web/live/context_live/index.html.heex:46 #: lib/memex_web/live/context_live/show.html.heex:31 #: lib/memex_web/live/note_live/index.html.heex:46 -#: lib/memex_web/live/note_live/show.html.heex:35 +#: lib/memex_web/live/note_live/show.html.heex:28 #: lib/memex_web/live/pipeline_live/index.html.heex:46 #: lib/memex_web/live/pipeline_live/show.html.heex:40 #: lib/memex_web/live/pipeline_live/show.html.heex:110 diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot index 9eb2eca..6d7a4c7 100644 --- a/priv/gettext/default.pot +++ b/priv/gettext/default.pot @@ -71,7 +71,7 @@ msgid "Uses left" msgstr "" #: lib/memex_web/live/context_live/show.html.heex:11 -#: lib/memex_web/live/note_live/show.html.heex:18 +#: lib/memex_web/live/note_live/show.html.heex:11 #: lib/memex_web/live/pipeline_live/show.html.heex:20 #, elixir-autogen, elixir-format msgid "Visibility: %{visibility}" diff --git a/priv/gettext/prompts.pot b/priv/gettext/prompts.pot index 58d49f9..b3915a6 100644 --- a/priv/gettext/prompts.pot +++ b/priv/gettext/prompts.pot @@ -139,7 +139,7 @@ msgstr "" #: lib/memex_web/live/context_live/index.html.heex:46 #: lib/memex_web/live/context_live/show.html.heex:31 #: lib/memex_web/live/note_live/index.html.heex:46 -#: lib/memex_web/live/note_live/show.html.heex:35 +#: lib/memex_web/live/note_live/show.html.heex:28 #: lib/memex_web/live/pipeline_live/index.html.heex:46 #: lib/memex_web/live/pipeline_live/show.html.heex:40 #: lib/memex_web/live/pipeline_live/show.html.heex:110 diff --git a/test/memex_web/live/note_live_test.exs b/test/memex_web/live/note_live_test.exs index b4ea767..3a70770 100644 --- a/test/memex_web/live/note_live_test.exs +++ b/test/memex_web/live/note_live_test.exs @@ -3,6 +3,7 @@ defmodule MemexWeb.NoteLiveTest do import Phoenix.LiveViewTest import Memex.NotesFixtures + alias MemexWeb.Endpoint @create_attrs %{ "content" => "some content", @@ -132,4 +133,31 @@ defmodule MemexWeb.NoteLiveTest do refute has_element?(index_live, "#note-#{note.id}") end end + + describe "show with note" do + setup [:register_and_log_in_user] + + setup %{user: user} do + %{slug: note_slug} = note = note_fixture(user) + + [ + note: note, + backlinked_note: + note_fixture(%{content: "example with backlink to [[#{note_slug}]] note"}, user) + ] + end + + test "displays context", %{ + conn: conn, + backlinked_note: %{slug: backlinked_note_slug}, + note: %{slug: note_slug} + } do + {:ok, show_live, html} = + live(conn, Routes.note_show_path(conn, :show, backlinked_note_slug)) + + assert html =~ "context" + assert html =~ Routes.note_show_path(Endpoint, :show, note_slug) + assert has_element?(show_live, "[data-qa=\"note-link-#{note_slug}\"]") + end + end end