-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from andyleclair/feat/dev_server
add dev server + post
- Loading branch information
Showing
21 changed files
with
859 additions
and
499 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
defmodule Mix.Tasks.Build do | ||
use Mix.Task | ||
|
||
@impl Mix.Task | ||
def run(_args) do | ||
{micro, :ok} = | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,12 +56,12 @@ defmodule Personal do | |
<body class="bg-nor-easter text-smurf-blood"> | ||
<div class="flex h-60 min-h-screen flex-col items-center"> | ||
<header class="bg-bludacris p-10 my-4 lg:mt-10 lg:mb-14"> | ||
<h1>[email protected]$><span class="blink">_</span></h1> | ||
<h1><a href={url()}>[email protected]</a>$><span class="blink">_</span></h1> | ||
</header> | ||
<main class="relative grow min-h-96 flex-1 p-4"> | ||
<%= render_slot(@inner_block) %> | ||
</main> | ||
<footer class="mt-10 bg-bludacris p-4 text-center"> | ||
<footer class="mt-24 bg-bludacris p-4 text-center"> | ||
© Andy LeClair 2024 | <a href="/atom.xml">Atom</a> | <a href="/feed.xml">RSS</a> | ||
</footer> | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
defmodule Personal.Router do | ||
use Plug.Router | ||
plug :match | ||
plug :dispatch | ||
|
||
get "/drafts" do | ||
send_resp(conn, 200, "drafts") | ||
end | ||
|
||
match _ do | ||
send_resp(conn, 404, "oops") | ||
end | ||
end | ||
|
||
defmodule Personal.DevServer do | ||
use Plug.Builder | ||
|
||
plug Plug.Static.IndexHtml, at: "/" | ||
|
||
plug Plug.Static, | ||
at: "/", | ||
from: "./output" | ||
|
||
plug Personal.Router | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
defmodule Personal.Watcher do | ||
require Logger | ||
use GenServer | ||
|
||
def start_link(args) do | ||
GenServer.start_link(__MODULE__, args) | ||
end | ||
|
||
def init(args) do | ||
{:ok, watcher_pid} = FileSystem.start_link(args) | ||
FileSystem.subscribe(watcher_pid) | ||
{:ok, %{watcher_pid: watcher_pid}} | ||
end | ||
|
||
# These emit a LOT of events, [:modified] is fine | ||
def handle_info( | ||
{:file_event, watcher_pid, {path, [:modified]}}, | ||
%{watcher_pid: watcher_pid} = state | ||
) do | ||
Mix.shell().info(["File modified: #{path}"]) | ||
Mix.shell().info(["Site Rebuilding"]) | ||
# Currently, we're just recompiling the entire site | ||
# TODO: make this fancier based on the path | ||
System.cmd("mix", ["site.build"]) | ||
Mix.shell().info([:green, "Site rebuilt"]) | ||
{:noreply, state} | ||
end | ||
|
||
def handle_info( | ||
{:file_event, watcher_pid, {_path, _events}}, | ||
%{watcher_pid: watcher_pid} = state | ||
) do | ||
{:noreply, state} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,13 +14,15 @@ | |
<body class="bg-nor-easter text-smurf-blood"> | ||
<div class="flex h-60 min-h-screen flex-col items-center"> | ||
<header class="bg-bludacris p-10 my-4 lg:mt-10 lg:mb-14"> | ||
<h1>[email protected]$><span class="blink">_</span></h1> | ||
<h1><a href="https://andyleclair.dev/">[email protected]</a>$><span class="blink">_</span></h1> | ||
</header> | ||
<main class="relative grow min-h-96 flex-1 p-4"> | ||
|
||
<h2 class="text-xl">Blog!</h2> | ||
<ul> | ||
<li> | ||
2024-12-31 - <a href="posts/2024/12-31-dev-server.html">Dev Server</a> | ||
</li><li> | ||
2024-12-30 - <a href="posts/2024/12-30-adding-rss-to-a-static-site.html">Adding RSS to a static site</a> | ||
</li><li> | ||
2024-11-15 - <a href="posts/2024/11-15-how-to-do-a-preload-good.html">How To Do A Preload Good</a> | ||
|
@@ -40,7 +42,7 @@ <h2 class="text-xl">Blog!</h2> | |
</ul> | ||
|
||
</main> | ||
<footer class="bg-bludacris p-4 text-center"> | ||
<footer class="mt-24 bg-bludacris p-4 text-center"> | ||
© Andy LeClair 2024 | <a href="/atom.xml">Atom</a> | <a href="/feed.xml">RSS</a> | ||
</footer> | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
<body class="bg-nor-easter text-smurf-blood"> | ||
<div class="flex h-60 min-h-screen flex-col items-center"> | ||
<header class="bg-bludacris p-10 my-4 lg:mt-10 lg:mb-14"> | ||
<h1>[email protected]$><span class="blink">_</span></h1> | ||
<h1><a href="https://andyleclair.dev/">[email protected]</a>$><span class="blink">_</span></h1> | ||
</header> | ||
<main class="relative grow min-h-96 flex-1 p-4"> | ||
|
||
|
@@ -36,7 +36,7 @@ <h3><a href="https://www.youtube.com/watch?v=wVrSXeRXSWE">Related Listening</a>< | |
</article> | ||
|
||
</main> | ||
<footer class="bg-bludacris p-4 text-center"> | ||
<footer class="mt-24 bg-bludacris p-4 text-center"> | ||
© Andy LeClair 2024 | <a href="/atom.xml">Atom</a> | <a href="/feed.xml">RSS</a> | ||
</footer> | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
<body class="bg-nor-easter text-smurf-blood"> | ||
<div class="flex h-60 min-h-screen flex-col items-center"> | ||
<header class="bg-bludacris p-10 my-4 lg:mt-10 lg:mb-14"> | ||
<h1>[email protected]$><span class="blink">_</span></h1> | ||
<h1><a href="https://andyleclair.dev/">[email protected]</a>$><span class="blink">_</span></h1> | ||
</header> | ||
<main class="relative grow min-h-96 flex-1 p-4"> | ||
|
||
|
@@ -45,7 +45,7 @@ <h3><a href="https://www.youtube.com/watch?v=9q4mVEcedSo">Related Listening</a>< | |
</article> | ||
|
||
</main> | ||
<footer class="bg-bludacris p-4 text-center"> | ||
<footer class="mt-24 bg-bludacris p-4 text-center"> | ||
© Andy LeClair 2024 | <a href="/atom.xml">Atom</a> | <a href="/feed.xml">RSS</a> | ||
</footer> | ||
</div> | ||
|
Oops, something went wrong.