~mika/www.m1kadev.nl

f738f0ea9e0963ecbd92ee9b27f440be9103a859 — m1kadev 7 months ago 69eb063
add thoughts
M bricks/base-header.html => bricks/base-header.html +2 -2
@@ 1,4 1,4 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/index.css">
<script src="/index.js" defer></script>
\ No newline at end of file
<link rel="stylesheet" href="/static/base.css">
<script src="/static/ldbuilddata.js" defer></script>
\ No newline at end of file

M build.exs => build.exs +41 -8
@@ 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)")

    """
    <div class="thought">
    <h3>#{name}</h3>
    <span>#{thought}</span>
    <small> -mika, #{date}</small>
    </div>
    """
  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("<br>")



@@ 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("<hr>")

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")


R src/index.css => static/base.css +0 -0
R src/index.js => static/ldbuilddata.js +0 -0
A static/thoughts.css => static/thoughts.css +21 -0
@@ 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

A templates/thoughts.html => templates/thoughts.html +29 -0
@@ 0,0 1,29 @@
<!DOCTYPE html>
<html lang="en-GB">

<head>

    {{ &base_header }}

    {{ &highlight }}

    <link rel="stylesheet" href="/static/thoughts.css">

    <title>home - m1kadev</title>
</head>

<body>
    <div id="content">
        <main>
            <h1>thoughts :3</h1>
            {{ &fxg_content }}
            <hr>
            {{ &footer }}
        </main>
    </div>

    {{ &navbar }}

</body>

</html>
\ No newline at end of file

A thoughts/colours => thoughts/colours +1 -0
@@ 0,0 1,1 @@
colours are so cool :)) shame i cant use them :((
\ No newline at end of file

A thoughts/web frameworks => thoughts/web frameworks +1 -0
@@ 0,0 1,1 @@
every web framework is the "most loved by developers",, how's that work ?
\ No newline at end of file