Skip to content

Commit 99085c5

Browse files
committed
Incremental builds and asset watchers
1 parent 8fa63ae commit 99085c5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+536
-216
lines changed

.formatter.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Used by "mix format"
22
[
33
import_deps: [:plug],
4-
inputs: ["{mix,.formatter}.exs", "{config,lib}/**/*.{ex,exs}"]
4+
inputs: ["{mix,.formatter}.exs", "{config,lib}/**/*.{ex,exs}", "test/tableau/**/*.exs"]
55
]

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ tableau-*.tar
2525
# Temporary files, for example, from tests.
2626
/tmp/
2727

28-
/test/support/tab_demo/_site
28+
/example/_site
2929

3030

31-
/test/support/tab_demo/priv/static
31+
/example/priv/static

README.md

Lines changed: 111 additions & 8 deletions

_site/posts/hello-world!/index.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<div>
2+
<h1>
3+
Yo!</h1>
4+
<p>
5+
This is a post</p>
6+
7+
</div>

config/config.exs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import Config
2+
3+
import_config "#{Mix.env()}.exs"

config/dev.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import Config

config/test.exs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import Config
2+
3+
config :logger, level: :warn
File renamed without changes.
File renamed without changes.

test/support/tab_demo/_posts/first-post.md renamed to example/_posts/first-post.md

Lines changed: 1 addition & 0 deletions

example/config/config.exs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import Config
2+
3+
config :tableau, :reloader, dirs: ["./lib/app.ex", "./lib/pages/", "./_posts", "./_site/css"]
4+
5+
config :tableau, :assets,
6+
npx: [
7+
"tailwindcss",
8+
"-o",
9+
"_site/css/site.css",
10+
"--watch",
11+
]
12+
13+
import_config "#{Mix.env()}.exs"

example/config/dev.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import Config

example/config/prod.exs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import Config
2+
3+
config :tableau, :assets,
4+
npx: [
5+
"tailwindcss",
6+
"-o",
7+
"_site/css/site.css",
8+
env: [{"NODE_ENV", "production"}]
9+
]

example/config/test.exs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import Config
2+
3+
config :logger, level: :warn

test/support/tab_demo/lib/layouts/app.ex renamed to example/lib/layouts/app.ex

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ defmodule TabDemo.Layouts.App do
1515
"data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20100%20100%22%3E%3Ctext%20y%3D%22.9em%22%20font-size%3D%2290%22%3E%E2%98%80%EF%B8%8F%3C%2Ftext%3E%3C%2Fsvg%3E",
1616
type: "image/svg+xml"
1717

18-
script(src: "https://unpkg.com/tailwindcss-jit-cdn")
18+
link rel: "stylesheet", href: "/css/site.css"
1919
end
2020

2121
body class: "font-sans" do
@@ -34,41 +34,8 @@ defmodule TabDemo.Layouts.App do
3434
end
3535
end
3636

37-
script defer: true do
38-
"""
39-
function connect() {
40-
try {
41-
window.socket = new WebSocket('ws://' + location.host + '/ws');
42-
43-
window.socket.onmessage = function(e) {
44-
if (e.data === "reload") {
45-
location.reload();
46-
}
47-
}
48-
49-
window.socket.onopen = () => {
50-
waitForConnection(() => window.socket.send("subscribe"), 300);
51-
};
52-
53-
window.socket.onclose = () => {
54-
setTimeout(() => connect(), 500);
55-
};
56-
57-
function waitForConnection(callback, interval) {
58-
console.log("Waiting for connection!")
59-
if (window.socket.readyState === 1) {
60-
callback();
61-
} else {
62-
setTimeout(() => waitForConnection(callback, interval), interval);
63-
}
64-
}
65-
} catch (e) {
66-
setTimeout(() => connect(), 500);
67-
}
68-
}
69-
70-
connect();
71-
"""
37+
if Mix.env() == :dev do
38+
c Tableau.Components.LiveReload
7239
end
7340
end
7441
end

test/support/tab_demo/lib/layouts/post.ex renamed to example/lib/layouts/post.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule TabDemo.Layouts.Post do
22
use Tableau.Layout
33

4-
layout TabDemo.Layouts.App
4+
layout(TabDemo.Layouts.App)
55

66
render do
77
h1 class: "text-4xl font-bold", do: @page["title"]

test/support/tab_demo/lib/layouts/with_header.ex renamed to example/lib/layouts/with_header.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule TabDemo.Layouts.WithHeader do
22
use Tableau.Layout
33

4-
layout Tableau.Layout.default()
4+
layout(Tableau.Layout.default())
55

66
render do
77
header class: "px-2 py-4 border border-red-500 w-full flex justify-between" do

test/support/tab_demo/lib/pages/about.ex renamed to example/lib/pages/about.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ defmodule TabDemo.Pages.About do
33

44
render do
55
span class: "text-red-500 font-bold" do
6-
"i'm a super cool and smart! dfkj"
6+
"i'm a super cool and smart!"
77

8-
div class: "font-bold italic" do
9-
"and i'm very humble"
8+
div class: "font-bold italic text-yellow-800" do
9+
"and i'm very yellow"
1010
end
1111
end
1212
end
File renamed without changes.
File renamed without changes.

test/support/tab_demo/lib/pages/communist.ex renamed to example/lib/pages/communist.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule TabDemo.Pages.Communist do
22
use Tableau.Page
33

4-
layout TabDemo.Layouts.WithHeader
4+
layout(TabDemo.Layouts.WithHeader)
55

66
render do
77
span class: "text-red-500 font-bold" do

test/support/tab_demo/lib/pages/desk.ex renamed to example/lib/pages/desk.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule TabDemo.Pages.Desk do
22
use Tableau.Page
33

4-
layout TabDemo.Layouts.WithHeader
4+
layout(TabDemo.Layouts.WithHeader)
55

66
render do
77
span class: "text-red-500 font-bold" do
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

test/support/tab_demo/lib/pages/posts.ex renamed to example/lib/pages/posts.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ defmodule TabDemo.Pages.Posts do
66
for post <- @posts do
77
li do
88
a class: "text-blue-500 hover:underline", href: post.permalink do
9-
post.frontmatter["title"]
9+
post.frontmatter["title"] <> " 🧨"
1010
end
1111
end
1212
end
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

test/support/tab_demo/mix.exs renamed to example/mix.exs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ defmodule TabDemo.MixProject do
2121
# Run "mix help deps" to learn about dependencies.
2222
defp deps do
2323
[
24-
{:tableau, path: "../../.."}
24+
{:tableau, path: "../"},
25+
{:benchee, "~> 1.0"}
2526
# {:dep_from_hexpm, "~> 0.3.0"},
2627
# {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"}
2728
]

test/support/tab_demo/mix.lock renamed to example/mix.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
%{
2+
"benchee": {:hex, :benchee, "1.0.1", "66b211f9bfd84bd97e6d1beaddf8fc2312aaabe192f776e8931cb0c16f53a521", [:mix], [{:deep_merge, "~> 1.0", [hex: :deep_merge, repo: "hexpm", optional: false]}], "hexpm", "3ad58ae787e9c7c94dd7ceda3b587ec2c64604563e049b2a0e8baafae832addb"},
23
"cowboy": {:hex, :cowboy, "2.9.0", "865dd8b6607e14cf03282e10e934023a1bd8be6f6bacf921a7e2a96d800cd452", [:make, :rebar3], [{:cowlib, "2.11.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "1.8.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "2c729f934b4e1aa149aff882f57c6372c15399a20d54f65c8d67bef583021bde"},
34
"cowboy_telemetry": {:hex, :cowboy_telemetry, "0.3.1", "ebd1a1d7aff97f27c66654e78ece187abdc646992714164380d8a041eda16754", [:rebar3], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "3a6efd3366130eab84ca372cbd4a7d3c3a97bdfcfb4911233b035d117063f0af"},
45
"cowlib": {:hex, :cowlib, "2.11.0", "0b9ff9c346629256c42ebe1eeb769a83c6cb771a6ee5960bd110ab0b9b872063", [:make, :rebar3], [], "hexpm", "2b3e9da0b21c4565751a6d4901c20d1b4cc25cbb7fd50d91d2ab6dd287bc86a9"},
6+
"deep_merge": {:hex, :deep_merge, "1.0.0", "b4aa1a0d1acac393bdf38b2291af38cb1d4a52806cf7a4906f718e1feb5ee961", [:mix], [], "hexpm", "ce708e5f094b9cd4e8f2be4f00d2f4250c4095be93f8cd6d018c753894885430"},
57
"earmark": {:hex, :earmark, "1.4.15", "2c7f924bf495ec1f65bd144b355d0949a05a254d0ec561740308a54946a67888", [:mix], [{:earmark_parser, ">= 1.4.13", [hex: :earmark_parser, repo: "hexpm", optional: false]}], "hexpm", "3b1209b85bc9f3586f370f7c363f6533788fb4e51db23aa79565875e7f9999ee"},
68
"earmark_parser": {:hex, :earmark_parser, "1.4.13", "0c98163e7d04a15feb62000e1a891489feb29f3d10cb57d4f845c405852bbef8", [:mix], [], "hexpm", "d602c26af3a0af43d2f2645613f65841657ad6efc9f0e361c3b6c06b578214ba"},
79
"file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"},

example/tailwind.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = {
2+
mode: "jit",
3+
purge: ["_site/**/index.html"],
4+
darkMode: false, // or 'media' or 'class'
5+
theme: {
6+
extend: {},
7+
},
8+
variants: {
9+
extend: {},
10+
},
11+
plugins: [],
12+
}

0 commit comments

Comments
 (0)