From 69eb0636b9856aeaeed063dfdcf43eac59f7b8a1 Mon Sep 17 00:00:00 2001 From: m1kadev <67912368+m1kadev@users.noreply.github.com> Date: Sun, 21 Dec 2025 19:58:06 +0100 Subject: [PATCH] move templates to separate directory --- build.exs | 12 +++++++----- src/index.html => templates/base.html | 0 {src => templates/pages}/colophon.html | 0 {pastes => templates}/paste.html | 0 4 files changed, 7 insertions(+), 5 deletions(-) rename src/index.html => templates/base.html (100%) rename {src => templates/pages}/colophon.html (100%) rename {pastes => templates}/paste.html (100%) diff --git a/build.exs b/build.exs index 1f6e2418405533e926119247442941f1fe08919d..a1c8da10e3eca5b437ecb9c5ff0421851be21d1f 100644 --- a/build.exs +++ b/build.exs @@ -81,7 +81,10 @@ defmodule Builders do end def fxg(input_path, template, bricks) do - own_template = input_path |> String.replace_suffix("fxg", "html") + own_template = + input_path + |> String.replace_prefix("src", "templates/pages") + |> String.replace_suffix("fxg", "html") case File.read(own_template) do {:ok, ctemplate} -> _fxg(input_path, ctemplate, bricks) @@ -134,7 +137,7 @@ end defmodule FileX do def created(path) do {:ok, %File.Stat{mtime: {{y, m, d}, _}}} = File.stat(path, time: :local) - Integer.to_string(d) <> "/" <> Integer.to_string(m) <> "/" <> Integer.to_string(y) + "#{d}/#{m}/#{y}" end def sanitised_name(path) do @@ -167,7 +170,7 @@ bricks = Path.wildcard("bricks/*.html") |> Map.new(fn x -> {FileX.sanitised_name(x), File.read!(x)} end) -{:ok, main_template} = File.read("src/index.html") +{:ok, main_template} = File.read("templates/base.html") Path.wildcard("src/**/*.css") |> Task.async_stream(fn file -> Builders.css(file) end) @@ -187,11 +190,10 @@ Path.wildcard("static/**/*") File.mkdir_p("build/pastes") -{:ok, paste_template} = File.read("pastes/paste.html") +{:ok, paste_template} = File.read("templates/paste.html") pastes = Path.wildcard("pastes/**/*") - |> Enum.filter(fn x -> x != "pastes/paste.html" end) pastes |> Task.async_stream(fn file -> Builders.paste(file, paste_template, bricks) end) diff --git a/src/index.html b/templates/base.html similarity index 100% rename from src/index.html rename to templates/base.html diff --git a/src/colophon.html b/templates/pages/colophon.html similarity index 100% rename from src/colophon.html rename to templates/pages/colophon.html diff --git a/pastes/paste.html b/templates/paste.html similarity index 100% rename from pastes/paste.html rename to templates/paste.html