From f738f0ea9e0963ecbd92ee9b27f440be9103a859 Mon Sep 17 00:00:00 2001 From: m1kadev <67912368+m1kadev@users.noreply.github.com> Date: Sun, 21 Dec 2025 22:48:53 +0100 Subject: [PATCH] add thoughts --- bricks/base-header.html | 4 +-- build.exs | 49 ++++++++++++++++++++++----- src/index.css => static/base.css | 0 src/index.js => static/ldbuilddata.js | 0 static/thoughts.css | 21 ++++++++++++ templates/thoughts.html | 29 ++++++++++++++++ thoughts/colours | 1 + thoughts/web frameworks | 1 + 8 files changed, 95 insertions(+), 10 deletions(-) rename src/index.css => static/base.css (100%) rename src/index.js => static/ldbuilddata.js (100%) create mode 100644 static/thoughts.css create mode 100644 templates/thoughts.html create mode 100644 thoughts/colours create mode 100644 thoughts/web frameworks diff --git a/bricks/base-header.html b/bricks/base-header.html index a16aa4b2f25d000d27f0de5c43456062e241d5ac..977000f158b7d804481dab457017febd06e55186 100644 --- a/bricks/base-header.html +++ b/bricks/base-header.html @@ -1,4 +1,4 @@ - - \ No newline at end of file + + \ No newline at end of file diff --git a/build.exs b/build.exs index a1c8da10e3eca5b437ecb9c5ff0421851be21d1f..5638fbd72b2dd54dfcabcbe37432c55cca4c0292 100644 --- a/build.exs +++ b/build.exs @@ -100,7 +100,7 @@ defmodule Builders do lang = Path.extname(input_path) |> String.slice(1..-1//1) file = Path.basename(input_path) - time = FileX.created(input_path) + time = FileX.createdf(input_path) result = Mustache.render( @@ -132,14 +132,34 @@ defmodule Builders do output = Mustache.render(template, Map.merge(%{fxg_content: content}, bricks)) File.write(output_path, output) end + + def thought(path, unix) do + thought = File.read!(path) + name = String.replace_prefix(path, "thoughts/", "") + + date = DateTime.from_unix!(unix) |> Calendar.strftime("%d/%m/%y (%H:%M)") + + """ +
+

#{name}

+ #{thought} + -mika, #{date} +
+ """ + end end defmodule FileX do - def created(path) do + def createdf(path) do {:ok, %File.Stat{mtime: {{y, m, d}, _}}} = File.stat(path, time: :local) "#{d}/#{m}/#{y}" end + def created(path) do + {:ok, %File.Stat{mtime: x}} = File.stat(path, time: :posix) + x + end + def sanitised_name(path) do Path.basename(path) |> String.trim_trailing(".html") @@ -162,10 +182,6 @@ case File.mkdir_p("build/static") do _ -> raise "Couldn't create the build file structure (/build/static)" end -# Path.wildcard("src/**/*.html") -# |> Task.async_stream(fn file -> Builders.html(file) end) -# |> Enum.to_list() - bricks = Path.wildcard("bricks/*.html") |> Map.new(fn x -> {FileX.sanitised_name(x), File.read!(x)} end) @@ -194,14 +210,16 @@ File.mkdir_p("build/pastes") pastes = Path.wildcard("pastes/**/*") + |> Enum.map(fn x -> {x, FileX.created(x)} end) + |> Enum.sort_by(fn {_, t} -> t end, :desc) + |> Enum.map(fn {x, _} -> x end) pastes |> Task.async_stream(fn file -> Builders.paste(file, paste_template, bricks) end) |> Enum.to_list() -# i cant test this :)) hope it works paste_data = - Map.new(pastes, fn x -> {x, FileX.created(x)} end) + Map.new(pastes, fn x -> {x, FileX.createdf(x)} end) |> Enum.map(fn {x, y} -> Templates.pastelink(x, x, y) end) |> Enum.join("
") @@ -221,6 +239,21 @@ paste_index = File.write("build/pastes/index.html", paste_index) +File.mkdir_p("build/thoughts") + +thoughts_template = File.read!("templates/thoughts.html") + +thoughts = + Path.wildcard("thoughts/**/*") + |> Enum.map(fn path -> {path, FileX.created(path)} end) + |> Enum.sort_by(fn {_, t} -> t end, :desc) + |> Enum.map(fn {path, date} -> Builders.thought(path, date) end) + |> Enum.join("
") + +thoughts_html = Mustache.render(thoughts_template, Map.merge(bricks, %{fxg_content: thoughts})) + +File.write("build/thoughts/index.html", thoughts_html) + {:ok, date} = DateTime.now("Europe/Amsterdam") build_time = Calendar.strftime(date, "%H:%M:%S %d/%m/%y") diff --git a/src/index.css b/static/base.css similarity index 100% rename from src/index.css rename to static/base.css diff --git a/src/index.js b/static/ldbuilddata.js similarity index 100% rename from src/index.js rename to static/ldbuilddata.js diff --git a/static/thoughts.css b/static/thoughts.css new file mode 100644 index 0000000000000000000000000000000000000000..d30ac624f82a47c4a309eb28ee82fb2759baae00 --- /dev/null +++ b/static/thoughts.css @@ -0,0 +1,21 @@ +.thought { + display: block; + /*background-color: #00000050;*/ + padding-left: 1em; + padding-right: 1em; +} + +.thought>h3 { + padding-top: .2em; +} + +.thought>span { + display: block; + padding-left: .5em; + font-style: italic; +} + +.thought>small { + text-align: right; + display: block; +} \ No newline at end of file diff --git a/templates/thoughts.html b/templates/thoughts.html new file mode 100644 index 0000000000000000000000000000000000000000..919d5d63a69392daf01525e1fc10da16e9f080c8 --- /dev/null +++ b/templates/thoughts.html @@ -0,0 +1,29 @@ + + + + + + {{ &base_header }} + + {{ &highlight }} + + + + home - m1kadev + + + +
+
+

thoughts :3

+ {{ &fxg_content }} +
+ {{ &footer }} +
+
+ + {{ &navbar }} + + + + \ No newline at end of file diff --git a/thoughts/colours b/thoughts/colours new file mode 100644 index 0000000000000000000000000000000000000000..52f5907527f041d8e8b47327389782d6348a21a6 --- /dev/null +++ b/thoughts/colours @@ -0,0 +1 @@ +colours are so cool :)) shame i cant use them :(( \ No newline at end of file diff --git a/thoughts/web frameworks b/thoughts/web frameworks new file mode 100644 index 0000000000000000000000000000000000000000..3f4cda97c2e7c739975ab067ddccb24980dbf3b4 --- /dev/null +++ b/thoughts/web frameworks @@ -0,0 +1 @@ +every web framework is the "most loved by developers",, how's that work ? \ No newline at end of file