$FILENAME
+ $FILEMETA +
+$CODE
+
+ + +
From f9828cfefe705805de898a10289ff2bcc0b9c9f4 Mon Sep 17 00:00:00 2001
From: m1kadev <67912368+m1kadev@users.noreply.github.com>
Date: Thu, 18 Dec 2025 21:59:28 +0100
Subject: [PATCH] add pastes folder
---
.gitignore | 13 +-
LICENSE | 21 +
build.exs | 126 ++-
pastes/paste.html | 54 ++
pull-hljs.sh | 17 +
src/colophon.fxg | 5 +
src/colophon.html | 48 ++
src/index.css | 4 +
src/{template.html => index.html} | 15 +-
src/index.js | 19 +-
src/projects.fxg | 2 +-
static/highlight.min.js | 1242 -----------------------------
12 files changed, 283 insertions(+), 1283 deletions(-)
create mode 100644 LICENSE
create mode 100644 pastes/paste.html
create mode 100755 pull-hljs.sh
create mode 100644 src/colophon.fxg
create mode 100644 src/colophon.html
rename src/{template.html => index.html} (65%)
delete mode 100644 static/highlight.min.js
diff --git a/.gitignore b/.gitignore
index ae31546b785ff945a7281e3c859cff26dcfe359a..179e94922d46db2c6d455a80091d4938ea52e344 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,11 +1,4 @@
-/_build/
-/cover/
-/deps/
-/doc/
-/tmp/
-erl_crash.dump
-*.ez
-www-*.tar
-/.elixir_ls
-/_build/
/build
+/static/highlight.min.js
+/static/rust.min.js
+/static/html.min.js
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000000000000000000000000000000000000..92fbc069755047dcf1da1499944017400c16cbae
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2025 mika
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
\ No newline at end of file
diff --git a/build.exs b/build.exs
index 72d81c0dac328a1ee7aefe10b5a8ddbe82bb4cd2..bec6346f7a5472ed39aeeb4574f03fe0f9a9d234 100644
--- a/build.exs
+++ b/build.exs
@@ -7,11 +7,41 @@ Mix.install([
Calendar.put_time_zone_database(Tzdata.TimeZoneDatabase)
-defmodule Builders do
+defmodule Templates do
binfo_template = """
- commit=<%= commit %>lightningcss=<%= lightningcss %>html_minifer_next=<%= html_minifier_next %>uglifyjs=<%= uglifyjs %>build_time=<%= build_time %>
+ commit=<%= commit %>lightningcss=<%= lightningcss %>html_minifier_next=<%= html_minifier_next %>uglifyjs=<%= uglifyjs %>build_time=<%= build_time %>
+ """
+
+ pastelink_template = """
+ <%= name %> | <%= date %>
"""
+ EEx.function_from_string(
+ :def,
+ :build_info,
+ binfo_template,
+ [
+ :commit,
+ :lightningcss,
+ :html_minifier_next,
+ :uglifyjs,
+ :build_time
+ ]
+ )
+
+ EEx.function_from_string(
+ :def,
+ :pastelink,
+ pastelink_template,
+ [
+ :location,
+ :name,
+ :date
+ ]
+ )
+end
+
+defmodule Builders do
def html(input_path) do
output_path = String.replace_prefix(input_path, "src", "build")
@@ -50,27 +80,55 @@ defmodule Builders do
end
def fxg(input_path, template) do
+ own_template = input_path |> String.replace_suffix("fxg", "html")
+
+ case File.read(own_template) do
+ {:ok, ctemplate} -> _fxg(input_path, ctemplate)
+ _ -> _fxg(input_path, template)
+ end
+ end
+
+ def paste(input_path, template) do
+ {:ok, rcode} = File.read(input_path)
+
+ output = "build/" <> input_path <> ".html"
+
+ code =
+ rcode
+ |> String.replace("&", "&")
+ |> String.replace("<", "<")
+ |> String.replace(">", ">")
+
+ lang = Path.extname(input_path) |> String.slice(1..-1//1)
+ file = Path.basename(input_path)
+ {:ok, %File.Stat{mtime: mtime}} = File.stat(input_path, time: :posix)
+
+ result =
+ template
+ |> String.replace("$LANG", lang)
+ |> String.replace("$CODE", code)
+ |> String.replace("$FILENAME", input_path)
+ |> String.replace("$FILEMETA", "Created on " <> Integer.to_string(mtime))
+
+ :ok = File.write(output, result)
+ end
+
+ defp _fxg(input_path, template) do
output_path =
String.replace_prefix(input_path, "src", "build")
|> String.replace_suffix("fxg", "html")
{output, 0} = System.cmd("fxg", [input_path])
- output = String.replace(template, "
")
+
+pastes_header = """
+
random code snippets i found useful or wanted to save :))
+" <> paste_data <> "
") + +File.write("build/pastes/index.html", paste_index) + {:ok, date} = DateTime.now("Europe/Amsterdam") build_time = Calendar.strftime(date, "%H:%M:%S %d/%m/%y") File.write( "build/info.txt", - Builders.build_info(commit, lightningcss, html_minifier_next, uglifyjs, build_time) + Templates.build_info( + commit, + lightningcss |> String.split_at(13) |> elem(1), + html_minifier_next, + uglifyjs |> String.split_at(10) |> elem(1), + build_time + ) ) diff --git a/pastes/paste.html b/pastes/paste.html new file mode 100644 index 0000000000000000000000000000000000000000..34e0a062a74dbbf8aa6fc7004b3ee34e32533e63 --- /dev/null +++ b/pastes/paste.html @@ -0,0 +1,54 @@ + + + + + + +
+$CODE
+
+