Skip to content

Commit aa106d0

Browse files
committed
wip
1 parent 5623321 commit aa106d0

File tree

10 files changed

+637
-23
lines changed

10 files changed

+637
-23
lines changed

_presentations/building-websites-with-tableau.md

Lines changed: 598 additions & 0 deletions
Large diffs are not rendered by default.
58.6 KB
Loading
527 KB
Loading
82.3 KB
Loading

extra/images/toc-example.png

174 KB
Loading

flake.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
];
2525
systems = ["x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin"];
2626
agenix-shell = {
27+
# identityPaths = [
28+
# "$HOME/.ssh/id_ed25519"
29+
# "$HOME/.ssh/id_rsa"
30+
# ];
31+
2732
secrets = {
2833
GOODREADS_KEY.file = ./secrets/GOODREADS_KEY.age;
2934
NETLIFY_AUTH_TOKEN.file = ./secrets/NETLIFY_AUTH_TOKEN.age;

lib/blog/extensions/presentation_extension.ex

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ defmodule Blog.PresentationExtension do
3434
pre_convert_body: body
3535
} = entry
3636

37-
slides = extract_slides(body)
37+
slides = extract_slides(body, token.site.config.markdown[:mdex])
3838

3939
for {slide, idx} <- Enum.with_index(slides, 1) do
4040
body = MDEx.to_markdown!(slide)
4141

42-
build(path, front_matter, idx, body, config, fn assigns ->
42+
build(path, front_matter, idx, Enum.count(slides), body, config, fn assigns ->
4343
cols =
44-
for col <- extract_columns(slide) do
44+
for col <- extract_columns(slide, assigns.site.config.markdown[:mdex]) do
4545
separate_header_and_body(col)
4646
end
4747

@@ -106,32 +106,33 @@ defmodule Blog.PresentationExtension do
106106
graph =
107107
Tableau.Graph.insert(
108108
token.graph,
109-
Enum.map(token.presentations, fn page ->
109+
for page <- token.presentations do
110110
%Tableau.Page{
111111
parent: page.layout,
112112
permalink: page.permalink,
113113
template: page.renderer,
114114
opts: page
115115
}
116-
end)
116+
end
117117
)
118118

119119
{:ok, Map.put(token, :graph, graph)}
120120
end
121121

122-
defp build(filename, front_matter, slide, body, presentation_config, renderer) do
122+
defp build(filename, front_matter, slide, length, body, presentation_config, renderer) do
123123
front_matter
124124
|> Map.put(:__tableau_presentation_extension__, true)
125125
|> Map.put(:body, body)
126126
|> Map.put(:slide, slide)
127+
|> Map.put(:length, length)
127128
|> Map.put(:file, filename)
128129
|> Map.put(:renderer, renderer)
129130
|> Map.put(:layout, Module.concat([front_matter[:layout]]))
130131
|> Common.build_permalink(presentation_config)
131132
end
132133

133-
defp extract_slides(body) do
134-
%MDEx.Document{nodes: nodes} = MDEx.parse_document!(body)
134+
defp extract_slides(body, mdex_opts) do
135+
%MDEx.Document{nodes: nodes} = MDEx.parse_document!(body, mdex_opts)
135136

136137
for node <- nodes, reduce: [[]] do
137138
[page | rest] ->
@@ -151,12 +152,12 @@ defmodule Blog.PresentationExtension do
151152
|> Enum.reverse()
152153
end
153154

154-
defp extract_columns(%MDEx.Document{nodes: nodes}) do
155+
defp extract_columns(%MDEx.Document{nodes: nodes}, _mdex_opts) do
155156
for node <- nodes, reduce: [[]] do
156157
[page | rest] ->
157158
case node do
158159
%MDEx.Paragraph{nodes: [%MDEx.Text{literal: "==="}]} ->
159-
[[], MDEx.Document.wrap(Enum.reverse(page)) | rest]
160+
[[], Enum.reverse(page) | rest]
160161

161162
_ ->
162163
[[node | page] | rest]

lib/blog/layouts/post_layout.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ defmodule Blog.PostLayout do
7676

7777
if @page[:book] do
7878
~MD"""
79-
**Title**: [<%= @page.book.title %>](https://goodreads.com/book/show/<%= @page.book.goodreads_id %>)
79+
**Title**: <a href="https://goodreads.com/book/show/<%= @page.book.goodreads_id %>"><%= @page.book.title %></a>
8080
8181
**Author**: <%= @page.book.author %>
8282

lib/blog/layouts/presentation_layout.ex

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@ defmodule Blog.PresentationLayout do
44

55
def template(assigns) do
66
temple do
7-
div class: "h-dvh aspect-video mx-auto overflow-hidden p-8",
7+
div class: "h-dvh mx-auto overflow-hidden p-8",
88
"x-data": "slide",
99
"@keydown.h.window": "previousSlide",
1010
"@keydown.left.window": "previousSlide",
1111
"@keydown.l.window": "nextSlide",
1212
"@keydown.right.window": "nextSlide",
13-
"@keydown.space.window": "nextSlide",
14-
"@keydown.cmd.enter.window": "document.body.requestFullscreen()" do
15-
div id: "slide",
16-
class: "" do
13+
"@keydown.space.window": "nextSlide" do
14+
div id: "slide" do
1715
render(@inner_content)
1816
end
1917
end
@@ -23,7 +21,13 @@ defmodule Blog.PresentationLayout do
2321
document.addEventListener("alpine:init", () => {
2422
Alpine.data("slide", () => ({
2523
init() {
26-
const slide = window.location.toString().split("/")
24+
let slide = window.location.toString()
25+
26+
// in case the url ends with a slash
27+
if (slide.endsWith("/")) {
28+
slide = slide.slice(0, slide.length - 1);
29+
}
30+
slide = slide.split("/")
2731
this.slide = parseInt(slide[slide.length - 1])
2832
this.permalink = slide.slice(0, slide.length - 1).join("/")
2933
@@ -57,13 +61,19 @@ defmodule Blog.PresentationLayout do
5761
// observeMutations: false,
5862
// observeWindow: false
5963
// });
60-
// });
64+
// });
6165
},
6266
nextSlide() {
63-
window.location = `${this.permalink}/${this.slide + 1}`;
67+
let nextSlide = this.slide + 1;
68+
if (nextSlide <= #{@page.length}) {
69+
window.location = `${this.permalink}/${nextSlide}`;
70+
}
6471
},
6572
previousSlide() {
66-
window.location = `${this.permalink}/${Math.max(0, this.slide - 1)}`;
73+
let previousSlide = this.slide - 1;
74+
if (previousSlide >= 1) {
75+
window.location = `${this.permalink}/${previousSlide}`;
76+
}
6777
}
6878
6979
}));

mix.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
%{
2-
"autumn": {:hex, :autumn, "0.4.1", "6a9608af647db187bdf33304d2d4dc8d667583a5e30a1355f049ec80fd249fd7", [:mix], [{:nimble_options, "~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:rustler, "~> 0.29", [hex: :rustler, repo: "hexpm", optional: false]}, {:rustler_precompiled, "~> 0.6", [hex: :rustler_precompiled, repo: "hexpm", optional: false]}], "hexpm", "fa16172c92a2c8e1ac870872e3a51bd0ae41005ff9409dca1092a5228780f2a2"},
2+
"autumn": {:hex, :autumn, "0.5.2", "4aa38276577d8016b71d69401e2ca4219e27ef8fe6a6f5974a1fb4edd42b8aa3", [:mix], [{:nimble_options, "~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:rustler, "~> 0.29", [hex: :rustler, repo: "hexpm", optional: false]}, {:rustler_precompiled, "~> 0.6", [hex: :rustler_precompiled, repo: "hexpm", optional: false]}], "hexpm", "83dd42823f91ff97ea91fba3dac62f1ffce384b2b43c8db3b5a73108d6a8cad3"},
33
"bandit": {:hex, :bandit, "1.7.0", "d1564f30553c97d3e25f9623144bb8df11f3787a26733f00b21699a128105c0c", [:mix], [{:hpax, "~> 1.0", [hex: :hpax, repo: "hexpm", optional: false]}, {:plug, "~> 1.18", [hex: :plug, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:thousand_island, "~> 1.0", [hex: :thousand_island, repo: "hexpm", optional: false]}, {:websock, "~> 0.5", [hex: :websock, repo: "hexpm", optional: false]}], "hexpm", "3e2f7a98c7a11f48d9d8c037f7177cd39778e74d55c7af06fe6227c742a8168a"},
44
"bun": {:hex, :bun, "1.4.2", "1785d50fff1bbb561f1d7d46a39fe091b5eefa00158f6ff6dae52b55e4a5cafe", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}], "hexpm", "834c0965b204b9e28748fbd3596268841fefcf1649b5617a70b379dfe68ad331"},
5-
"castore": {:hex, :castore, "1.0.14", "4582dd7d630b48cf5e1ca8d3d42494db51e406b7ba704e81fbd401866366896a", [:mix], [], "hexpm", "7bc1b65249d31701393edaaac18ec8398d8974d52c647b7904d01b964137b9f4"},
5+
"castore": {:hex, :castore, "1.0.15", "8aa930c890fe18b6fe0a0cff27b27d0d4d231867897bd23ea772dee561f032a3", [:mix], [], "hexpm", "96ce4c69d7d5d7a0761420ef743e2f4096253931a3ba69e5ff8ef1844fe446d3"},
66
"date_time_parser": {:hex, :date_time_parser, "1.2.0", "3d5a816b91967f51e0f94dcb16a34b2cb780f22cd48931779e81d72f7d3eadb1", [:mix], [{:kday, "~> 1.0", [hex: :kday, repo: "hexpm", optional: false]}], "hexpm", "0cf09ada9f42c0b3bfba02dc0ea2e4b4d2f543d9d2bf99b831a29e6b4a4160e5"},
77
"easyxml": {:git, "https://github.com/wojtekmach/easyxml.git", "0cd453116efe395cfe04baaeb9df93ec5cc86d36", [branch: "main"]},
88
"file_system": {:hex, :file_system, "1.1.0", "08d232062284546c6c34426997dd7ef6ec9f8bbd090eb91780283c9016840e8f", [:mix], [], "hexpm", "bfcf81244f416871f2a2e15c1b515287faa5db9c6bcf290222206d120b3d43f6"},
@@ -25,7 +25,7 @@
2525
"poolboy": {:hex, :poolboy, "1.5.2", "392b007a1693a64540cead79830443abf5762f5d30cf50bc95cb2c1aaafa006b", [:rebar3], [], "hexpm", "dad79704ce5440f3d5a3681c8590b9dc25d1a561e8f5a9c995281012860901e3"},
2626
"req": {:hex, :req, "0.4.8", "2b754a3925ddbf4ad78c56f30208ced6aefe111a7ea07fb56c23dccc13eb87ae", [:mix], [{:brotli, "~> 0.3.1", [hex: :brotli, repo: "hexpm", optional: true]}, {:ezstd, "~> 1.0", [hex: :ezstd, repo: "hexpm", optional: true]}, {:finch, "~> 0.9", [hex: :finch, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:mime, "~> 1.6 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:nimble_csv, "~> 1.0", [hex: :nimble_csv, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "7146e51d52593bb7f20d00b5308a5d7d17d663d6e85cd071452b613a8277100c"},
2727
"rustler": {:hex, :rustler, "0.36.2", "6c2142f912166dfd364017ab2bf61242d4a5a3c88e7b872744642ae004b82501", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:toml, "~> 0.7", [hex: :toml, repo: "hexpm", optional: false]}], "hexpm", "93832a6dbc1166739a19cd0c25e110e4cf891f16795deb9361dfcae95f6c88fe"},
28-
"rustler_precompiled": {:hex, :rustler_precompiled, "0.8.2", "5f25cbe220a8fac3e7ad62e6f950fcdca5a5a5f8501835d2823e8c74bf4268d5", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:rustler, "~> 0.23", [hex: :rustler, repo: "hexpm", optional: true]}], "hexpm", "63d1bd5f8e23096d1ff851839923162096364bac8656a4a3c00d1fff8e83ee0a"},
28+
"rustler_precompiled": {:hex, :rustler_precompiled, "0.8.3", "4e741024b0b097fe783add06e53ae9a6f23ddc78df1010f215df0c02915ef5a8", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:rustler, "~> 0.23", [hex: :rustler, repo: "hexpm", optional: true]}], "hexpm", "c23f5f33cb6608542de4d04faf0f0291458c352a4648e4d28d17ee1098cddcc4"},
2929
"schematic": {:hex, :schematic, "0.5.1", "be4b2c03115d5a593459c11a7249a6fbb45855947d9653e9250455dcd7df1d42", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "02f913c97e6e04ccdaa02004679a7a16bb16fe0449583ad647e296d8e8961546"},
3030
"slugify": {:hex, :slugify, "1.3.1", "0d3b8b7e5c1eeaa960e44dce94382bee34a39b3ea239293e457a9c5b47cc6fd3", [:mix], [], "hexpm", "cb090bbeb056b312da3125e681d98933a360a70d327820e4b7f91645c4d8be76"},
3131
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.7", "354c321cf377240c7b8716899e182ce4890c5938111a1296add3ec74cf1715df", [:make, :mix, :rebar3], [], "hexpm", "fe4c190e8f37401d30167c8c405eda19469f34577987c76dde613e838bbc67f8"},

0 commit comments

Comments
 (0)