2 Commits

  1. 9
      CHANGELOG.md
  2. 2
      lib/mirage/markdown.ex
  3. 2
      lib/mirage/settings.ex
  4. 4
      lib/mirage_web/live/page_live.html.leex
  5. 2
      lib/mirage_web/templates/layout/_footer.html.eex
  6. 2
      lib/mirage_web/templates/layout/_header.html.eex
  7. 2
      lib/mirage_web/templates/layout/root.html.leex
  8. 14
      lib/mirage_web/views/layout_view.ex
  9. 2
      mix.exs
  10. 24
      priv/repo/migrations/20210207200506_add_settings_data_3.exs

9
CHANGELOG.md

@ -5,6 +5,15 @@ See [Conventional Commits](Https://conventionalcommits.org) for commit guideline
<!-- changelog -->
## [v0.16.0](https://git.inhji.de/inhji/mirage/compare/v0.15.0...v0.16.0) (2021-02-07)
### Features:
* add emoji favicon \o/
## [v0.15.0](https://git.inhji.de/inhji/mirage/compare/v0.14.0...v0.15.0) (2021-02-07)

2
lib/mirage/markdown.ex

@ -1,6 +1,6 @@
defmodule Mirage.Markdown do
import Phoenix.HTML.Link, only: [link: 2]
import Phoenix.HTML, only: [raw: 1, safe_to_string: 1]
import Phoenix.HTML, only: [safe_to_string: 1]
import Ecto.Changeset, only: [get_change: 2, put_change: 3]
def maybe_render_markdown(changeset, markdown_field, html_field) do

2
lib/mirage/settings.ex

@ -24,7 +24,7 @@ defmodule Mirage.Settings do
def list_settings_as_map do
list_settings()
|> Enum.map(fn s ->
{String.to_atom(s.name), s.value_html}
{String.to_atom(s.name), s}
end)
|> Map.new()
end

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

@ -1,6 +1,6 @@
<section class="hero">
<h1><%= raw @_s.user_title %></h1>
<p><%= raw @_s.user_tagline %></p>
<h1><%= raw @_s.user_title.value_html %></h1>
<p><%= raw @_s.user_tagline.value_html %></p>
</section>
<section class="grid width-full bg-content">

2
lib/mirage_web/templates/layout/_footer.html.eex

@ -1,5 +1,5 @@
<footer>
<p>
<%= raw @_s.footer_text %>
<%= raw @_s.footer_text.value_html %>
</p>
</footer>

2
lib/mirage_web/templates/layout/_header.html.eex

@ -2,7 +2,7 @@
<nav role="navigation">
<ul>
<li class="brand">
<a href="/"><%= raw @_s.header_title %></a>
<a href="/"><%= raw @_s.header_title.value_html %></a>
</li>
<li>
<a href="/notes">Notes</a>

2
lib/mirage_web/templates/layout/root.html.leex

@ -6,6 +6,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<%= csrf_meta_tag() %>
<%= live_title_tag assigns[:page_title] || "Inhji.de", suffix: " · Mirage" %>
<link rel="icon" href='<%= set_favicon(@_s.favicon.value) %>'>
<link phx-track-static rel="stylesheet" href="<%= Routes.static_path(@conn, "/css/app.css") %>"/>
<script defer phx-track-static type="text/javascript" src="<%= Routes.static_path(@conn, "/js/app.js") %>"></script>
</head>

14
lib/mirage_web/views/layout_view.ex

@ -1,3 +1,17 @@
defmodule MirageWeb.LayoutView do
use MirageWeb, :view
def set_favicon(icon) do
"data:image/svg+xml,#{favicon(icon) |> safe_to_string}"
end
def favicon(icon) do
~E"""
<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22>
<text y=%22.9em%22 font-size=%2290%22>
<%= icon %>
</text>
</svg>
"""
end
end

2
mix.exs

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

24
priv/repo/migrations/20210207200506_add_settings_data_3.exs

@ -0,0 +1,24 @@
defmodule Mirage.Repo.Migrations.AddSettingsData3 do
use Ecto.Migration
alias Mirage.Settings.Setting
alias Ecto.Multi
import Ecto.Query, warn: false
@settings ["favicon"]
def up do
Multi.new()
|> Multi.insert(:header_title, %Setting{
name: "favicon",
value: "😀",
value_html: "😀"
})
|> repo().transaction()
end
def down do
from(s in Setting, where: s.name in @settings)
|> repo().delete_all()
end
end
Loading…
Cancel
Save