chore: Format code
This commit is contained in:
parent
3a00fa5487
commit
70e36cd887
6 changed files with 56 additions and 50 deletions
|
@ -1,6 +1,5 @@
|
||||||
# Used by "mix format"
|
# Used by "mix format"
|
||||||
[
|
[
|
||||||
import_deps: [:phoenix_live_view],
|
import_deps: [:phoenix_live_view],
|
||||||
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"],
|
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
|
||||||
locals_without_parens: [config: ]
|
|
||||||
]
|
]
|
||||||
|
|
|
@ -14,8 +14,7 @@ config :tailwind,
|
||||||
config :esbuild,
|
config :esbuild,
|
||||||
version: "0.19.3",
|
version: "0.19.3",
|
||||||
default: [
|
default: [
|
||||||
args:
|
args: ~w(js/app.js --bundle --target=es2016 --outdir=../priv/static/assets/),
|
||||||
~w(js/app.js --bundle --target=es2016 --outdir=../priv/static/assets/),
|
|
||||||
cd: Path.expand("../assets", __DIR__),
|
cd: Path.expand("../assets", __DIR__),
|
||||||
env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)}
|
env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)}
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
defmodule Mix.Tasks.PreDotHn.Ping do
|
defmodule Mix.Tasks.PreDotHn.Ping do
|
||||||
use Mix.Task
|
use Mix.Task
|
||||||
|
|
||||||
@urls [
|
@urls [
|
||||||
"http://google.com/ping?sitemap=%s",
|
"http://google.com/ping?sitemap=%s",
|
||||||
"http://www.bing.com/webmaster/ping.aspx?sitemap=%s"
|
"http://www.bing.com/webmaster/ping.aspx?sitemap=%s"
|
||||||
]
|
]
|
||||||
|
@ -10,7 +10,7 @@ defmodule Mix.Tasks.PreDotHn.Ping do
|
||||||
@urls
|
@urls
|
||||||
|> Enum.map(fn url ->
|
|> Enum.map(fn url ->
|
||||||
ping_url = String.replace(url, "%s", sitemap_url)
|
ping_url = String.replace(url, "%s", sitemap_url)
|
||||||
:httpc.request('#{ping_url}')
|
:httpc.request(~c"#{ping_url}")
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -99,29 +99,33 @@ defmodule PreDotHn do
|
||||||
assigns = %{base: base, posts: posts}
|
assigns = %{base: base, posts: posts}
|
||||||
|
|
||||||
body =
|
body =
|
||||||
EEx.eval_string("""
|
EEx.eval_string(
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
"""
|
||||||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<channel>
|
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||||
<title>pre.hn</title>
|
<channel>
|
||||||
<description>Robert Prehn's personal blog.</description>
|
<title>pre.hn</title>
|
||||||
<link>https://pre.hn</link>
|
<description>Robert Prehn's personal blog.</description>
|
||||||
<atom:link href="https://pre.hn/feed.rss" rel="self" type="application/rss+xml" />
|
<link>https://pre.hn</link>
|
||||||
<atom:link href="https://pre.hn/link-log/feed.rss" rel="self" type="application/rss+xml" />
|
<atom:link href="https://pre.hn/feed.rss" rel="self" type="application/rss+xml" />
|
||||||
|
<atom:link href="https://pre.hn/link-log/feed.rss" rel="self" type="application/rss+xml" />
|
||||||
|
|
||||||
<%= for post <- @posts do %>
|
<%= for post <- @posts do %>
|
||||||
<item>
|
<item>
|
||||||
<title><%= HtmlSanitizeEx.strip_tags(post.title) %></title>
|
<title><%= HtmlSanitizeEx.strip_tags(post.title) %></title>
|
||||||
<description>
|
<description>
|
||||||
<%= Phoenix.HTML.html_escape(post.body) |> elem(1) %>
|
<%= Phoenix.HTML.html_escape(post.body) |> elem(1) %>
|
||||||
</description>
|
</description>
|
||||||
<pubDate><%= rss_date_format.(post.date) %></pubDate>
|
<pubDate><%= rss_date_format.(post.date) %></pubDate>
|
||||||
<guid isPermaLink="true"><%= @base %><%= post.slug %>/</guid>
|
<guid isPermaLink="true"><%= @base %><%= post.slug %>/</guid>
|
||||||
</item>
|
</item>
|
||||||
<% end %>
|
<% end %>
|
||||||
</channel>
|
</channel>
|
||||||
</rss>
|
</rss>
|
||||||
""", assigns: assigns, rss_date_format: &rss_date_format/1)
|
""",
|
||||||
|
assigns: assigns,
|
||||||
|
rss_date_format: &rss_date_format/1
|
||||||
|
)
|
||||||
|
|
||||||
path = Path.join(["priv", "static", "feed.rss"])
|
path = Path.join(["priv", "static", "feed.rss"])
|
||||||
|
|
||||||
|
@ -162,7 +166,9 @@ defmodule PreDotHn do
|
||||||
|
|
||||||
def make_sitemap(posts) do
|
def make_sitemap(posts) do
|
||||||
posts
|
posts
|
||||||
|> Stream.map(&(%Sitemapper.URL{lastmod: (&1[:updated_at] || &1.date), loc: "https://pre.hn/#{&1.slug}/"}))
|
|> Stream.map(
|
||||||
|
&%Sitemapper.URL{lastmod: &1[:updated_at] || &1.date, loc: "https://pre.hn/#{&1.slug}/"}
|
||||||
|
)
|
||||||
|> Sitemapper.generate(sitemap_url: "https://pre.hn/")
|
|> Sitemapper.generate(sitemap_url: "https://pre.hn/")
|
||||||
|> Sitemapper.persist(store: Sitemapper.FileStore, store_config: [path: "priv/static/"])
|
|> Sitemapper.persist(store: Sitemapper.FileStore, store_config: [path: "priv/static/"])
|
||||||
|> Stream.run()
|
|> Stream.run()
|
||||||
|
|
|
@ -24,27 +24,30 @@ defmodule PreDotHn.LinkLog do
|
||||||
assigns = %{links: links}
|
assigns = %{links: links}
|
||||||
|
|
||||||
body =
|
body =
|
||||||
EEx.eval_string("""
|
EEx.eval_string(
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
"""
|
||||||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<channel>
|
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||||
<title>pre.hn - Links</title>
|
<channel>
|
||||||
<description>Robert Prehn's Link Log</description>
|
<title>pre.hn - Links</title>
|
||||||
<link>https://pre.hn</link>
|
<description>Robert Prehn's Link Log</description>
|
||||||
<atom:link href="https://pre.hn/link-log/feed.rss" rel="self" type="application/rss+xml" />
|
<link>https://pre.hn</link>
|
||||||
|
<atom:link href="https://pre.hn/link-log/feed.rss" rel="self" type="application/rss+xml" />
|
||||||
|
|
||||||
<%= for link <- @links do %>
|
<%= for link <- @links do %>
|
||||||
<item>
|
<item>
|
||||||
<title><%= HtmlSanitizeEx.strip_tags(link["name"]) %></title>
|
<title><%= HtmlSanitizeEx.strip_tags(link["name"]) %></title>
|
||||||
<description>
|
<description>
|
||||||
<%= link["summary"] %>
|
<%= link["summary"] %>
|
||||||
</description>
|
</description>
|
||||||
<guid isPermaLink="true"><%= link["url"] %></guid>
|
<guid isPermaLink="true"><%= link["url"] %></guid>
|
||||||
</item>
|
</item>
|
||||||
<% end %>
|
<% end %>
|
||||||
</channel>
|
</channel>
|
||||||
</rss>
|
</rss>
|
||||||
""", assigns: assigns)
|
""",
|
||||||
|
assigns: assigns
|
||||||
|
)
|
||||||
|
|
||||||
path = Path.join(["priv", "static", "link-log", "feed.rss"])
|
path = Path.join(["priv", "static", "link-log", "feed.rss"])
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,6 @@ defmodule PreDotHn.Markdown do
|
||||||
defp highlight([text], lang), do: highlight(text, lang)
|
defp highlight([text], lang), do: highlight(text, lang)
|
||||||
|
|
||||||
defp highlight(text, lang) do
|
defp highlight(text, lang) do
|
||||||
|
|
||||||
{:ok, highlight} = TreeSitter.highlight_html(text, lang || "plain")
|
{:ok, highlight} = TreeSitter.highlight_html(text, lang || "plain")
|
||||||
|
|
||||||
[_preamble, rest] = String.split(highlight, "<table>")
|
[_preamble, rest] = String.split(highlight, "<table>")
|
||||||
|
|
Loading…
Reference in a new issue