From dd8e3a95fcd837938c6c20a4603cd9492d0980d5 Mon Sep 17 00:00:00 2001 From: Catalin Constantin Mititiuc Date: Mon, 16 Jun 2025 20:18:04 -0700 Subject: [PATCH] WIP: list posts --- ...open-an-iex-shell-from-an-elixir-script.md | 8 +- ...alyzer-with-gui-from-a-docker-container.md | 8 +- ...ming-multiview-projections-to-isometric.md | 8 +- ...erated-html-with-docker-on-digitalocean.md | 8 +- docs/2023-11-15-test-mix-task-file-modify.md | 8 +- ...1-build-static-website-generator-part-1.md | 8 +- index.html | 27 +------ index.md | 24 ------ posts.moon | 80 +++++++++++++++++++ site.moon | 70 +++++++++++++++- templates/index.html | 11 +-- templates/root.html | 1 + templates/wares.html | 2 + 13 files changed, 179 insertions(+), 84 deletions(-) delete mode 100644 index.md create mode 100644 posts.moon diff --git a/docs/2023-09-15-open-an-iex-shell-from-an-elixir-script.md b/docs/2023-09-15-open-an-iex-shell-from-an-elixir-script.md index 2c241cb..f3825cf 100644 --- a/docs/2023-09-15-open-an-iex-shell-from-an-elixir-script.md +++ b/docs/2023-09-15-open-an-iex-shell-from-an-elixir-script.md @@ -1,12 +1,12 @@ +{ + id: "open-an-iex-shell-from-an-elixir-script" +} + --- title: "Open An IEx Shell From An Elixir Script" blurb: "We can run an Elixir script with either the elixir or the iex command. Both will execute the code, but the second command opens an interactive IEx shell afterward. What if, we won't know until runtime whether we want a shell or not? How can we start an IEx session even when we use elixir, instead of iex, to run our script?" ... -{ - id: "open-an-iex-shell-from-an-elixir-script" -} - ## Method 1 Here's a quick test script: diff --git a/docs/2023-10-08-start-erlangs-dialyzer-with-gui-from-a-docker-container.md b/docs/2023-10-08-start-erlangs-dialyzer-with-gui-from-a-docker-container.md index 36ee86c..76079d4 100644 --- a/docs/2023-10-08-start-erlangs-dialyzer-with-gui-from-a-docker-container.md +++ b/docs/2023-10-08-start-erlangs-dialyzer-with-gui-from-a-docker-container.md @@ -1,12 +1,12 @@ +{ + id: "start-erlangs-dialyzer-with-gui-from-a-docker-container" +} + --- title: "Start Erlang's Dialyzer With GUI From A Docker Container" blurb: "Everything in OTP is command-line driven, so using containers during development has been without issue. But, Dialyzer, Erlang's static analysis tool, actually has a Graphical User Interface. How can we still use Dialyzer and its GUI even though Elixir is running inside a container?" ... -{ - id: "start-erlangs-dialyzer-with-gui-from-a-docker-container" -} - I use Docker mostly when working on software projects and I figured out how to get Erlang's Dialyzer GUI working in a Docker container. 1. Start a container with X11 forwarding: diff --git a/docs/2023-10-16-fix-distortion-introduced-when-transforming-multiview-projections-to-isometric.md b/docs/2023-10-16-fix-distortion-introduced-when-transforming-multiview-projections-to-isometric.md index d95bcfa..5f26c52 100644 --- a/docs/2023-10-16-fix-distortion-introduced-when-transforming-multiview-projections-to-isometric.md +++ b/docs/2023-10-16-fix-distortion-introduced-when-transforming-multiview-projections-to-isometric.md @@ -1,11 +1,11 @@ ---- -blurb: "One thing we learned from a week of trying to make isometric vector drawings." -... - { id: "fix-distortion-introduced-when-transforming-multiview-projections-to-isometric" } +--- +blurb: "One thing we learned from a week of trying to make isometric vector drawings." +... + ## Objective Construct an isometric vector image of an object from top, front, and side view projections (like [this](https://workforce.libretexts.org/Bookshelves/Drafting_and_Design_Technology/Introduction_to_Drafting_and_AutoCAD_3D_(Baumback)/02%3A_Part_2/2.01%3A_Module_7-_Visualizing_Multiview_Drawings), but using Inkscape instead of AutoCAD). diff --git a/docs/2023-11-01-deploy-elixir-generated-html-with-docker-on-digitalocean.md b/docs/2023-11-01-deploy-elixir-generated-html-with-docker-on-digitalocean.md index 249b0f1..e7e69ad 100644 --- a/docs/2023-11-01-deploy-elixir-generated-html-with-docker-on-digitalocean.md +++ b/docs/2023-11-01-deploy-elixir-generated-html-with-docker-on-digitalocean.md @@ -1,12 +1,12 @@ +{ + id: "deploy-elixir-generated-html-with-docker-on-digitalocean" +} + --- title: "Deploy Elixir-Generated HTML With Docker On DigitalOcean" blurb: "This is a simple proof of concept where we create a boilerplate HTML file with Elixir, containerize our build process with Docker, and deploy our markup live with DigitalOcean's hosting service." ... -{ - id: "deploy-elixir-generated-html-with-docker-on-digitalocean" -} - ## Introduction DigitalOcean has this [App Platform](https://www.digitalocean.com/products/app-platform) service that can host a static website, as well as build it from a Docker image, if provided a `Dockerfile`. We thought a static website built by an Elixir app could be an instructive project. To explore if the idea is viable, we wrote a small Elixir application that generates a simple `index.html` file and deployed it live on DigitalOcean's service. diff --git a/docs/2023-11-15-test-mix-task-file-modify.md b/docs/2023-11-15-test-mix-task-file-modify.md index fc4a5d4..c3720d7 100644 --- a/docs/2023-11-15-test-mix-task-file-modify.md +++ b/docs/2023-11-15-test-mix-task-file-modify.md @@ -1,12 +1,12 @@ +{ + id: "test-mix-task-file-modify" +} + --- title: "Temporary Directories For Testing Mix Tasks That Modify Files" blurb: "Writing a test for a simple Mix task gets surprisingly complex. Application environment variables, temporary test directories, and IO capture are all involved." ... -{ - id: "test-mix-task-file-modify" -} - ## Intro Last time, we added a Mix task to our project that writes an HTML file to a directory `/public` in the container's filesystem. Today, we will write a test for that task. diff --git a/docs/2023-12-01-build-static-website-generator-part-1.md b/docs/2023-12-01-build-static-website-generator-part-1.md index 5b75a2e..3d76a1a 100644 --- a/docs/2023-12-01-build-static-website-generator-part-1.md +++ b/docs/2023-12-01-build-static-website-generator-part-1.md @@ -1,12 +1,12 @@ +{ + id: "build-static-website-generator-part-1" +} + --- title: "Build A Static-Website Generator With Elixir, Part 1" blurb: "We take the first steps in designing and implementing the \"world's simplest static-website generator\". Building on tools and knowledge we acquired previously, and utilizing an incremental and iterative development process, we go through the entire software life-cycle from creating the initial project files to deploying to production. We spare nothing, from spelling out every command, to ensuring application integrity with tests, and even updating the README file. Grab a drink and some snacks, and dive right in!" ... -{ - id: "build-static-website-generator-part-1" -} - ::: info This post was originally intended to be the first in a multi-part series. However, the deeper we got into this project, the more we realized we were diff --git a/index.html b/index.html index 8dc0ba8..a03fad9 100644 --- a/index.html +++ b/index.html @@ -7,30 +7,7 @@ $render{"templates/wares"} - -$render{"moon-test"} - - -$render{"home"} -

Posts

-$each{posts, "post"}[[ -
-

- - $post - -

- - - — blurb here - - Read post → - -
-]] - -$markdown{[[ -#### [View more posts]($root/posts/) -]]} + +$render{"posts"} diff --git a/index.md b/index.md deleted file mode 100644 index fdf449e..0000000 --- a/index.md +++ /dev/null @@ -1,24 +0,0 @@ -{ - date: "Thu May 08 2025 19:41:30.000000000" -} - -## where is this?? - -$(

asdfasdf

) - -$markdown{[[ -- this is markdown -- also, sparta -]]} - -$if{"val"}[[

just some straight up text

]] - -$render{"templates/wares"} - -$render{"moon-test"} - -## Posts - -- [recursive]($root/posts/2023-08-03-recursively-list-all-files-in-a-directory-with-elixir.html) - -#### [View more posts]($root/posts/) diff --git a/posts.moon b/posts.moon new file mode 100644 index 0000000..3e24b13 --- /dev/null +++ b/posts.moon @@ -0,0 +1,80 @@ +-- html -> +-- +-- posts = [{ +-- id: p.meta.id +-- target: p.meta.target +-- source: p.source +-- } for _, p in pairs site.pages when p.meta.template == "blog"] +-- +-- require("moon").p posts +-- div { "this is a post" } +-- div { "this anoter post" } + +-- date = require "date" +-- return { +-- format: "markdown" +-- title: "My Site's Title" +-- { +-- title: "The First Post" +-- date: date 2011, 11, 26 +-- link: "/my-post" +-- description: [[ +-- The things I did. +-- +-- * ordered pizza +-- * ate it +-- ]] +-- } +-- } + +--
+--

+-- +-- Publish Markdown Documents As Static Web Pages with Pandoc and Phoenix +-- +--

+-- +-- +-- — We thought we wanted a static website generator. It turns out what we really wanted was Phoenix, with an option to convert markdown to HTML. Here is our implementation of a solution, using our very own, recently-released, Pandoc Hex package! +-- +-- Read post → +-- +--
+date = require "date" +date! +-- return { +-- format: "markdown" +-- title: "My Site's Title" +-- { +-- title: "The First Post" +-- date: date 2011, 11, 26 + +-- require("moon").p tostring(date(2011, 11, 26)) +path = require "sitegen.path" +moon = require("moon") +common = require("sitegen.common") + +get_date = (str) -> str + +html -> + posts = [{ + id: p.meta.id + target: p.meta.target + source: p.source + } for _, p in pairs page.site.pages when p.meta.template == "blog"] + + [tag["section"] { + tag["h3"] { tag["a"] { href: p.target .. ".html", p.id }} + tag["time"] { + -- p.source + -- tostring(date(2011, 11, 26)) + -- one = string.match(path.filename(p.source), "%d+%-%d%d%-%d%d%-") + -- r = string.gsub(one, "%-", " ") + -- r + get_date string.match(path.filename(p.source), "%d+%-%d%d%-%d%d") + -- common.slugify path.filename(p.target) + } + "— blurb here" + tag["a"] { class: "read-post-link", href: p.target .. ".html", "Read post →"} + } for _, p in ipairs posts] + diff --git a/site.moon b/site.moon index ebb1e39..b496047 100644 --- a/site.moon +++ b/site.moon @@ -19,18 +19,84 @@ posts = (path=".") -> {join(path, file), target(file, "/posts") for _, file in ipairs files} -- Change output dir to what Openresty prefers -site = site! +-- site = site! site.config.out_dir = "html/" css = tools.system_command "cat < %s > %s", "css" +ps = posts("docs") + +-- require("moon").p ps + +files = [file for file in lfs.dir "docs" when file != "." and file != ".."] + +-- sf = require("sitegen.site_file") + +-- require("moon").p sf + +-- for file in lfs.dir "docs" -- when file != "." and file != ".." + -- print rootname(last(split path)) + -- print file + +at = (one, two) -> + print "ANOTHER TEST" + require("moon").p two + +html = require("sitegen.html") + +one = () -> + html.build -> + tag.a { href: "momo", "yayaya" } + tag.a { href: "momo", "yayaya" } + sitegen.create => @title = "WebDevCat.me · Catalin Mititiuc" @app_name = "stasis" @version = "0.2.12" @val = "yes" + @posts = (page) -> + -- require("moon").p [key for key in pairs page.site.pages[1]] + -- require("moon").p [key for key in pairs page.site] + -- posts = [{ + -- id: p.meta.id + -- target: p.meta.target + -- source: p.source + -- } for _, p in pairs page.site.pages when p.meta.template == "blog"] + -- pages = [key for key, _ in pairs page for _, page in ipairs page.site.pages] - add "index.md" + -- posts = [{ + -- id: p.meta.id + -- target: p.meta.target + -- source: p.source + -- } for _, p in pairs page.site.pages when p.meta.template == "blog"] + + -- require("moon").p posts + -- posts + -- require("moon").p [key for key in pairs page.site] + -- require("moon").p [k for k,v in pairs page for _, page in ipairs pages] + -- require("moon").p [{page.meta, page.source} for _, page in ipairs pages when page.meta.template == "blog"] + -- require("moon").p [{dv} for k, dv in pairs(v) for _, v in pairs pages] + -- require("moon").p [k,v for key, v in pairs pages] + -- require("moon").p site.target + + -- require("moon").p get_site + @test = (page) -> {{"b": 1, "c": 2}, {"d": 3, "e": 4}} + @what = (page) -> + -- require("moon").p [{ln, lv} for ln, lv in pairs debug.getlocal(2, idx)] + -- require("moon").p + "what?" + + -- require("moon").p @ + + -- require("moon").p @site + + add "index.html", o: one add path, target: out, template: "blog" for path, out in pairs posts "docs" + -- add "test.html", id: "test" + -- feed "posts.moon", "feed.xml" + + -- require("moon").p site build css, "app.css" + +-- require("moon").p site diff --git a/templates/index.html b/templates/index.html index 534b3d2..4ea2b20 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,9 +1,7 @@ +

templates/index.html

+ $wrap{"root"} -

spacing guild

- -$([[

hi

]]) -

Hi, I'm Catalin Mititiuc

@@ -11,11 +9,6 @@ $([[

hi

]])

Hiring? Reach me by email.

- -$markdown{[[ -**We can embed markdown directly into an HTML file!** -]]} -
$body diff --git a/templates/root.html b/templates/root.html index 1a4131b..1bccef3 100644 --- a/templates/root.html +++ b/templates/root.html @@ -14,6 +14,7 @@ +

templates/root.html

Web Dev Solutions

diff --git a/templates/wares.html b/templates/wares.html index da20b02..ec36544 100644 --- a/templates/wares.html +++ b/templates/wares.html @@ -1,3 +1,5 @@ +

templates/wares.html

+

Wares