~mika/www.m1kadev.nl

c6b023f3c0a8b2bbbb652550522969c74b1ec1cd — m1kadev 6 months ago dfb336b
proper title handling:)) finally
M .gitignore => .gitignore +2 -1
@@ 1,2 1,3 @@
/build
/static/*.min.*
\ No newline at end of file
/static/*.min.*
TODO
\ No newline at end of file

M build.exs => build.exs +25 -8
@@ 114,7 114,7 @@ defmodule Builders do
        template,
        Map.merge(
          %{
            filename: input_path,
            filename: file,
            about_paste: "Created on " <> time,
            language: "<script src=\"static/" <> lang <> ".min.js\"></script>",
            codetag: "<pre><code class=\"language-" <> lang <> "\">",


@@ 134,9 134,15 @@ defmodule Builders do
      String.replace_prefix(input_path, "pages", "build")
      |> String.replace_suffix("fxg", "html")

    name =
      case Path.basename(input_path) |> Path.rootname() do
        "index" -> "home"
        x -> x
      end

    {content, 0} = System.cmd("fxg", [input_path])

    output = Mustache.render(template, Map.merge(%{fxg_content: content}, bricks))
    output = Mustache.render(template, Map.merge(%{fxg_content: content, location: name}, bricks))
    IO.inspect(output_path)
    :ok = File.write(output_path, output)
  end


@@ 246,7 252,10 @@ pastes_header = """
paste_index =
  Mustache.render(
    main_template,
    Map.merge(bricks, %{fxg_content: pastes_header <> "<p>" <> paste_data <> "</p>"})
    Map.merge(bricks, %{
      fxg_content: pastes_header <> "<p>" <> paste_data <> "</p>",
      location: "pastes"
    })
  )

File.write("build/pastes/index.html", paste_index)


@@ 266,13 275,21 @@ thoughts = Enum.map(thought_paths, fn {path, date} -> Builders.thought(path, dat
thoughts_html =
  Mustache.render(
    thoughts_template,
    Map.merge(bricks, %{fxg_content: Enum.join(thoughts, "<hr>")})
    Map.merge(bricks, %{fxg_content: Enum.join(thoughts, "<hr>"), location: "thoughts"})
  )

for {thought, {path, _}} <- Enum.zip(thoughts, thought_paths) do
  output_path = "build/thoughts/" <> FileX.sanitised_name(path) <> ".html"
  IO.inspect(output_path)
  thought_html = Mustache.render(thought_template, Map.merge(bricks, %{fxg_content: thought}))
for {thought, {path, time}} <- Enum.zip(thoughts, thought_paths) do
  thought = FileX.sanitised_name(path)
  output_path = "build/thoughts/" <> thought <> ".html"

  when_said = DateTime.from_unix!(time) |> Calendar.strftime("%H:%M, %d/%m/%y")

  thought_html =
    Mustache.render(
      thought_template,
      Map.merge(bricks, %{fxg_content: File.read!(path), thought: thought, date: when_said})
    )

  File.write(output_path, thought_html)
end


M styles/thought.css => styles/thought.css +3 -5
@@ 1,17 1,15 @@
.thought>h3 {
    font-size: xx-large;
h2 {
    margin: 0px;
    padding-top: .1em;
    padding-bottom: .5em;
}

.thought>span {
#thought {
    display: block;
    padding-left: 1.5em;
    font-style: italic;
}

.thought>small {
small {
    text-align: right;
    display: block;
}
\ No newline at end of file

M templates/base.html => templates/base.html +1 -1
@@ 7,7 7,7 @@

    {{ &highlight }}

    <title>home - m1kadev</title>
    <title>{{ location }} - m1kadev</title>
</head>

<body>

M templates/pages/colophon.html => templates/pages/colophon.html +1 -1
@@ 5,7 5,7 @@

    {{ &base_header }}

    <title>colophon - m1kadev.nl</title>
    <title> {{ location }} - m1kadev.nl</title>

</head>


M templates/pages/index.html => templates/pages/index.html +1 -1
@@ 11,7 11,7 @@
    <script src="/scripts/showMotd.js" defer></script>
    <link rel="stylesheet" href="/styles/index.css">

    <title>home - m1kadev</title>
    <title>{{ location }} - m1kadev</title>
</head>

<body>

M templates/paste.html => templates/paste.html +2 -0
@@ 6,6 6,8 @@

    {{ &language }}
    {{ &highlight }}

    <title>{{ filename }} - m1kadev</title>
</head>

<body>

M templates/thought.html => templates/thought.html +6 -2
@@ 7,7 7,7 @@

    <link rel="stylesheet" href="/styles/thought.css">

    <title>home - m1kadev</title>
    <title> {{ thought }} - m1kadev</title>
</head>

<body>


@@ 16,7 16,11 @@

    <div id="content">
        <main>
            {{ &fxg_content }}
            <h2> {{ thought }} </h2>
            <span id="thought">
                {{ &fxg_content }}
            </span>
            <small>-mika, {{ date }}</small>
            <hr>
            {{ &footer }}
        </main>

M templates/thoughts.html => templates/thoughts.html +1 -1
@@ 9,7 9,7 @@

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

    <title>home - m1kadev</title>
    <title> {{ location }} - m1kadev</title>
</head>

<body>