-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add file watcher for development with live reload (#7)
* Add file watcher for development with live reload * add linter (credo) * upgrade Erlang and Elixir versions in CI
- Loading branch information
1 parent
767b6d4
commit f1a2b0a
Showing
17 changed files
with
201 additions
and
165 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
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
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,6 +1,6 @@ | ||
--- | ||
title: "<%= @app_name %>" | ||
layout: "default" | ||
layout: "default.html" | ||
--- | ||
|
||
Quick static site generation with Elixir templates 🧡 |
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
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,32 @@ | ||
defmodule GriffinSSG.Filesystem.Watcher do | ||
@moduledoc """ | ||
Module for non-named GenServer responsible for watching for changes. | ||
Executes a generic callback when file changes are detected. | ||
Used for the LiveReload HTTPServer that is launched as part of `mix grf.server`. | ||
""" | ||
use GenServer | ||
|
||
@swap_file_extnames [".swp", ".swx"] | ||
|
||
def start_link([directories, callback]) do | ||
GenServer.start_link(__MODULE__, {directories, callback}) | ||
end | ||
|
||
def init({directories, callback}) do | ||
{:ok, pid} = FileSystem.start_link(dirs: directories) | ||
FileSystem.subscribe(pid) | ||
{:ok, %{callback: callback}} | ||
end | ||
|
||
def handle_info({:file_event, _watcher_pid, {file_path, [:modified, :closed]}}, state) do | ||
unless Path.extname(file_path) in @swap_file_extnames do | ||
state.callback.() | ||
end | ||
|
||
{:noreply, state} | ||
end | ||
|
||
def handle_info({:file_event, _, _}, 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 was deleted.
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
Oops, something went wrong.