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