diff --git a/lib/chiya/notes.ex b/lib/chiya/notes.ex
index d0f8457..e828698 100644
--- a/lib/chiya/notes.ex
+++ b/lib/chiya/notes.ex
@@ -5,7 +5,7 @@ defmodule Chiya.Notes do
import Ecto.Query, warn: false
alias Chiya.Repo
- alias Chiya.Notes.{Note, NoteImage, NoteNote, NoteTag, NoteComment}
+ alias Chiya.Notes.{Note, NoteImage, NoteImageTemp, NoteNote, NoteTag, NoteComment}
@preloads [
:channels,
@@ -262,6 +262,13 @@ defmodule Chiya.Notes do
Note.changeset(note, attrs)
end
+ @doc """
+ Returns an `%Ecto.Changeset{}` for tracking note_image changes.
+ """
+ def change_note_image(%NoteImage{} = note_image, attrs \\ %{}) do
+ NoteImage.update_changeset(note_image, attrs)
+ end
+
@doc """
Gets a single note image.
"""
@@ -296,6 +303,12 @@ defmodule Chiya.Notes do
:ok
end
+ def create_note_image_temp(attrs \\ %{}) do
+ %NoteImageTemp{}
+ |> NoteImageTemp.changeset(attrs)
+ |> Repo.insert()
+ end
+
def get_note_note!(attrs \\ %{}) do
Repo.get_by!(NoteNote, attrs)
end
@@ -314,13 +327,6 @@ defmodule Chiya.Notes do
Repo.delete(note_note)
end
- @doc """
- Returns an `%Ecto.Changeset{}` for tracking note_image changes.
- """
- def change_note_image(%NoteImage{} = note_image, attrs \\ %{}) do
- NoteImage.update_changeset(note_image, attrs)
- end
-
def get_note_tag!(attrs \\ %{}) do
Repo.get_by!(NoteTag, attrs)
end
diff --git a/lib/chiya/notes/note_image_temp.ex b/lib/chiya/notes/note_image_temp.ex
new file mode 100644
index 0000000..49a8294
--- /dev/null
+++ b/lib/chiya/notes/note_image_temp.ex
@@ -0,0 +1,20 @@
+defmodule Chiya.Notes.NoteImageTemp do
+ use Ecto.Schema
+ use Waffle.Ecto.Schema
+ import Ecto.Changeset
+
+ schema "note_images_temp" do
+ field :content, :string, default: ""
+ field :path, ChiyaWeb.Uploaders.NoteImage.Type
+
+ timestamps()
+ end
+
+ @doc false
+ def changeset(note_image, attrs) do
+ note_image
+ |> cast(attrs, [:content])
+ |> cast_attachments(attrs, [:path], allow_paths: true)
+ |> validate_required([:path])
+ end
+end
diff --git a/lib/chiya_web/controllers/page_html.ex b/lib/chiya_web/controllers/page_html.ex
index 5ea69a8..7bd619c 100644
--- a/lib/chiya_web/controllers/page_html.ex
+++ b/lib/chiya_web/controllers/page_html.ex
@@ -16,10 +16,10 @@ defmodule ChiyaWeb.PageHTML do
def do_render_outline(%{text: text, children: children, level: _level}) do
slug = Slugger.slugify_downcase(text)
+
content_tag(:ul, [class: "m-0"],
do: [
- content_tag(:li, do:
- content_tag(:a, text, href: "##{slug}")),
+ content_tag(:li, do: content_tag(:a, text, href: "##{slug}")),
Enum.map(children, &do_render_outline/1)
]
)
diff --git a/lib/chiya_web/controllers/page_html/note.html.heex b/lib/chiya_web/controllers/page_html/note.html.heex
index 06d4c65..faa6167 100644
--- a/lib/chiya_web/controllers/page_html/note.html.heex
+++ b/lib/chiya_web/controllers/page_html/note.html.heex
@@ -3,22 +3,23 @@
<%= @note.name %>
-
+
<%= Markdown.render(@note.content) |> raw %>
<%= if not Enum.empty?(@note.links_to) do %>
-
- <.divider text="" />
- Notes linking here:
-
-
+
+ <.divider text="" /> Notes linking here:
+
+
<% end %>