mix format
This commit is contained in:
parent
ef3ec699a2
commit
e87fa125bb
14 changed files with 86 additions and 90 deletions
|
@ -43,15 +43,14 @@ config :tailwind,
|
|||
]
|
||||
|
||||
# Configures Elixir's Logger
|
||||
config :logger, :default_handler,
|
||||
level: :debug
|
||||
config :logger, :default_handler, level: :debug
|
||||
|
||||
config :logger, :default_formatter,
|
||||
format: "$time $metadata[$level] $message\n"
|
||||
config :logger, :default_formatter, format: "$time $metadata[$level] $message\n"
|
||||
|
||||
config :chiya, :logger, [
|
||||
{:handler, :file_log, :logger_std_h, %{
|
||||
level: :info,
|
||||
{:handler, :file_log, :logger_std_h,
|
||||
%{
|
||||
level: :info,
|
||||
config: %{
|
||||
file: ~c"chiya.log",
|
||||
filesync_repeat_interval: 5000,
|
||||
|
|
|
@ -67,8 +67,7 @@ config :chiya, dev_routes: true
|
|||
|
||||
# Do not include metadata nor timestamps in development logs
|
||||
# config :logger, :console, format: "[$level] $message\n"
|
||||
config :logger, :default_formatter,
|
||||
format: "[$level] $message\n"
|
||||
config :logger, :default_formatter, format: "[$level] $message\n"
|
||||
|
||||
# Set a higher stacktrace during development. Avoid configuring such
|
||||
# in production as building large stacktraces may be expensive.
|
||||
|
|
|
@ -16,8 +16,7 @@ config :swoosh, api_client: Swoosh.ApiClient.Finch, finch_name: Chiya.Finch
|
|||
|
||||
# Do not print debug messages in production
|
||||
# config :logger, level: :debug
|
||||
config :logger, :default_handler,
|
||||
level: :info
|
||||
config :logger, :default_handler, level: :info
|
||||
|
||||
config :cors_plug,
|
||||
origin: ["app://obsidian.md"],
|
||||
|
|
|
@ -31,8 +31,7 @@ config :swoosh, :api_client, false
|
|||
|
||||
# Print only warnings and errors during test
|
||||
# config :logger, level: :warning
|
||||
config :logger, :default_handler,
|
||||
level: :warning
|
||||
config :logger, :default_handler, level: :warning
|
||||
|
||||
# Initialize plugs at runtime for faster test compilation
|
||||
config :phoenix, :plug_init_mode, :runtime
|
||||
|
|
|
@ -118,11 +118,13 @@ defmodule ChiyaWeb do
|
|||
alias Phoenix.LiveView.JS
|
||||
|
||||
# Custom functions
|
||||
import ChiyaWeb.Format, only: [
|
||||
from_now: 1,
|
||||
pretty_date: 1,
|
||||
datetime: 1
|
||||
]
|
||||
import ChiyaWeb.Format,
|
||||
only: [
|
||||
from_now: 1,
|
||||
pretty_date: 1,
|
||||
datetime: 1
|
||||
]
|
||||
|
||||
alias ChiyaWeb.Markdown
|
||||
|
||||
# Routes generation with the ~p sigil
|
||||
|
|
|
@ -239,32 +239,32 @@ defmodule ChiyaWeb.PublicComponents do
|
|||
</figure>
|
||||
"""
|
||||
|
||||
3 ->
|
||||
assigns =
|
||||
assigns
|
||||
|> assign(:first, Enum.at(images, 0))
|
||||
|> assign(:second, Enum.at(images, 1))
|
||||
|> assign(:third, Enum.at(images, 2))
|
||||
3 ->
|
||||
assigns =
|
||||
assigns
|
||||
|> assign(:first, Enum.at(images, 0))
|
||||
|> assign(:second, Enum.at(images, 1))
|
||||
|> assign(:third, Enum.at(images, 2))
|
||||
|
||||
~H"""
|
||||
<figure class="flex gap-1">
|
||||
<img
|
||||
src={ChiyaWeb.Helpers.image_url(assigns.first, :thumb)}
|
||||
class="flex-1 w-full rounded-l"
|
||||
title={assigns.first.content}
|
||||
/>
|
||||
<img
|
||||
src={ChiyaWeb.Helpers.image_url(assigns.second, :thumb)}
|
||||
class="flex-1 w-full"
|
||||
title={assigns.second.content}
|
||||
/>
|
||||
<img
|
||||
src={ChiyaWeb.Helpers.image_url(assigns.third, :thumb)}
|
||||
class="flex-1 w-full rounded-r"
|
||||
title={assigns.third.content}
|
||||
/>
|
||||
</figure>
|
||||
"""
|
||||
~H"""
|
||||
<figure class="flex gap-1">
|
||||
<img
|
||||
src={ChiyaWeb.Helpers.image_url(assigns.first, :thumb)}
|
||||
class="flex-1 w-full rounded-l"
|
||||
title={assigns.first.content}
|
||||
/>
|
||||
<img
|
||||
src={ChiyaWeb.Helpers.image_url(assigns.second, :thumb)}
|
||||
class="flex-1 w-full"
|
||||
title={assigns.second.content}
|
||||
/>
|
||||
<img
|
||||
src={ChiyaWeb.Helpers.image_url(assigns.third, :thumb)}
|
||||
class="flex-1 w-full rounded-r"
|
||||
title={assigns.third.content}
|
||||
/>
|
||||
</figure>
|
||||
"""
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -3,11 +3,12 @@
|
|||
<:subtitle>Use this form to manage note records in your database.</:subtitle>
|
||||
</.header>
|
||||
|
||||
<.note_form
|
||||
changeset={@changeset}
|
||||
action={~p"/admin/notes"}
|
||||
channels={@channels}
|
||||
tags={@tags}
|
||||
selected_channels={@selected_channels} />
|
||||
<.note_form
|
||||
changeset={@changeset}
|
||||
action={~p"/admin/notes"}
|
||||
channels={@channels}
|
||||
tags={@tags}
|
||||
selected_channels={@selected_channels}
|
||||
/>
|
||||
|
||||
<.back navigate={~p"/admin/notes"}>Back to notes</.back>
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
</section>
|
||||
|
||||
<%= if @note do %>
|
||||
<section class="mx-auto mt-8 prose prose-gruvbox md:prose-lg lg:prose-xl | p-summary e-content">
|
||||
<%= Markdown.render(@note.content) |> raw %>
|
||||
</section>
|
||||
<section class="mx-auto mt-8 prose prose-gruvbox md:prose-lg lg:prose-xl | p-summary e-content">
|
||||
<%= Markdown.render(@note.content) |> raw %>
|
||||
</section>
|
||||
<% end %>
|
||||
</article>
|
||||
</article>
|
||||
|
|
|
@ -18,7 +18,9 @@
|
|||
<time class="font-semibold | dt-published"><%= pretty_date(@note.published_at) %></time>
|
||||
<.dot />
|
||||
<span>Last Updated</span>
|
||||
<time class="font-semibold" datetime={datetime(@note.updated_at)}><%= pretty_date(@note.updated_at) %></time>
|
||||
<time class="font-semibold" datetime={datetime(@note.updated_at)}>
|
||||
<%= pretty_date(@note.updated_at) %>
|
||||
</time>
|
||||
<%= if not Enum.empty?(@note.tags) do %>
|
||||
<.dot />
|
||||
<span>Tags</span>
|
||||
|
|
|
@ -27,12 +27,7 @@
|
|||
label="Default Channel"
|
||||
options={@channels}
|
||||
/>
|
||||
<.input
|
||||
field={f[:wiki_channel_id]}
|
||||
type="select"
|
||||
label="Wiki Channel"
|
||||
options={@channels}
|
||||
/>
|
||||
<.input field={f[:wiki_channel_id]} type="select" label="Wiki Channel" options={@channels} />
|
||||
<:actions>
|
||||
<.button>Save Setting</.button>
|
||||
</:actions>
|
||||
|
|
|
@ -31,16 +31,17 @@ defmodule ChiyaWeb.AdminHomeLive do
|
|||
|
||||
case Chiya.Notes.create_note(params) do
|
||||
{:ok, note} ->
|
||||
{:noreply, socket
|
||||
|> put_flash(:info, "Note created!")
|
||||
|> push_navigate(to: ~p"/note/#{note.slug}")}
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(:info, "Note created!")
|
||||
|> push_navigate(to: ~p"/note/#{note.slug}")}
|
||||
|
||||
{:error, %Ecto.Changeset{} = changeset} ->
|
||||
IO.inspect(changeset)
|
||||
|
||||
{:noreply,
|
||||
socket
|
||||
|> put_flash(:error, "Could not create note!")
|
||||
socket
|
||||
|> put_flash(:error, "Could not create note!")
|
||||
|> assign(form: to_form(changeset))}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,15 +7,14 @@ defmodule ChiyaWeb.Markdown do
|
|||
|
||||
import Ecto.Changeset, only: [get_change: 2, put_change: 3]
|
||||
|
||||
defp options() do
|
||||
%Earmark.Options{
|
||||
def options(),
|
||||
do: %Earmark.Options{
|
||||
code_class_prefix: "lang- language-",
|
||||
footnotes: true,
|
||||
breaks: true,
|
||||
escape: false,
|
||||
registered_processors: processors()
|
||||
}
|
||||
end
|
||||
|
||||
@doc """
|
||||
Renders markdown with Earmark.
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
defmodule Chiya.NoteTest do
|
||||
use Chiya.DataCase
|
||||
alias Chiya.Notes.Note
|
||||
use Chiya.DataCase
|
||||
alias Chiya.Notes.Note
|
||||
|
||||
@content1 "This is a short title"
|
||||
@content2 "This is a title that is a lot longer than the first and does not contain a dot"
|
||||
@content3 "This is a title. It contains dots and should be cut at the first of the dots."
|
||||
@content4 "This used to be some funny title"
|
||||
@content1 "This is a short title"
|
||||
@content2 "This is a title that is a lot longer than the first and does not contain a dot"
|
||||
@content3 "This is a title. It contains dots and should be cut at the first of the dots."
|
||||
@content4 "This used to be some funny title"
|
||||
|
||||
describe "note_title" do
|
||||
test "returns a short text completely" do
|
||||
assert Note.note_title(@content1) == @content1
|
||||
end
|
||||
describe "note_title" do
|
||||
test "returns a short text completely" do
|
||||
assert Note.note_title(@content1) == @content1
|
||||
end
|
||||
|
||||
test "returns a longer text until 7 words " do
|
||||
title = Note.note_title(@content2)
|
||||
assert title == "This is a title that is a"
|
||||
test "returns a longer text until 7 words " do
|
||||
title = Note.note_title(@content2)
|
||||
assert title == "This is a title that is a"
|
||||
|
||||
title = Note.note_title(@content4)
|
||||
assert title == "This used to be some funny title"
|
||||
end
|
||||
title = Note.note_title(@content4)
|
||||
assert title == "This used to be some funny title"
|
||||
end
|
||||
|
||||
test "returns a longer text until the first dot" do
|
||||
title = Note.note_title(@content3)
|
||||
assert title == "This is a title"
|
||||
end
|
||||
end
|
||||
end
|
||||
test "returns a longer text until the first dot" do
|
||||
title = Note.note_title(@content3)
|
||||
assert title == "This is a title"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ defmodule Chiya.TagUpdaterTest do
|
|||
assert Enum.count(note.tags) == 1
|
||||
end
|
||||
|
||||
test "with a list of new tags replaces exisiting tags"do
|
||||
test "with a list of new tags replaces exisiting tags" do
|
||||
note = note_fixture()
|
||||
|
||||
assert note.tags == []
|
||||
|
|
Loading…
Reference in a new issue