inert 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +34 -4
- data/exe/inert +2 -10
- data/lib/inert.rb +18 -3
- data/lib/inert/builder.rb +20 -1
- data/lib/inert/cli.rb +24 -0
- data/lib/inert/middleware.rb +8 -6
- data/lib/inert/version.rb +3 -0
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8de98e13138a538909b6d856ff7f4a4762d1a37223c75b6cfbe68b5f4bd46f5e
|
4
|
+
data.tar.gz: 9100c98bbd9f506a34d6ca5ae01c2155d2d0242bb250eafb18b7480ebd8ea9e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca5acf9848a8bc84bfc1fb98d6f2ec21be80b5488f8640e033d9f42dd52d2bbe3fc2daaf95eee10368d91d3009c96461c898e60a4f9667270d9aca22c90e7ad7
|
7
|
+
data.tar.gz: e3f092cf3c2cf05eaa97895de13292a4b43303cd818fc2fc4fdfb9a73052204ff91ea8ea482ba7b2f67411e841aa19bd4955557ae75099afdda0bf52e05422bb
|
data/README.md
CHANGED
@@ -46,11 +46,11 @@ Inert.config do |inert|
|
|
46
46
|
"Inert v#{Inert::VERSION}"
|
47
47
|
end
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
inert.app do
|
51
51
|
plugin :h
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
inert.routes do |r|
|
55
55
|
r.on "employees.html" do
|
56
56
|
@employees = [] # Read in actual data here
|
@@ -84,6 +84,36 @@ in `static/` wherever you'd just use the filename itself:
|
|
84
84
|
<img src="<%= timestamp_path "some_image_in_static_folder.png" %>">
|
85
85
|
```
|
86
86
|
|
87
|
+
## Asset Minification
|
88
|
+
|
89
|
+
Use asset minification to compile and compress all your CSS and JS assets into
|
90
|
+
a single file.
|
91
|
+
|
92
|
+
```ruby
|
93
|
+
# Inertfile
|
94
|
+
|
95
|
+
Inert.config do |inert|
|
96
|
+
inert.app do
|
97
|
+
plugin :assets, css: %w"text.css layout.css"
|
98
|
+
compile_assets if Inert.building?
|
99
|
+
end
|
100
|
+
|
101
|
+
inert.routes do |r|
|
102
|
+
r.assets
|
103
|
+
end
|
104
|
+
end
|
105
|
+
```
|
106
|
+
|
107
|
+
And inside your layout, use the `assets` helper with the name of the asset group:
|
108
|
+
|
109
|
+
```ruby
|
110
|
+
<%= assets(:css) %>
|
111
|
+
```
|
112
|
+
|
113
|
+
Make sure you put your assets in `assets/group`. For the example above, you'd have
|
114
|
+
`assets/css/text.css` and `assets/css/layout.css`.
|
115
|
+
|
116
|
+
|
87
117
|
## Live Reloads
|
88
118
|
|
89
119
|
Use the `roda-live_reload` gem to enable live reloads:
|
@@ -98,11 +128,11 @@ gem "puma" # Webrick wont' currently work with roda-live_reload
|
|
98
128
|
# Inertfile
|
99
129
|
Inert.config do |inert|
|
100
130
|
inert.app do
|
101
|
-
plugin :live_reload if
|
131
|
+
plugin :live_reload if Inert.development?
|
102
132
|
end
|
103
133
|
|
104
134
|
inert.routes do |r|
|
105
|
-
r.live_reload if
|
135
|
+
r.live_reload if Inert.development?
|
106
136
|
end
|
107
137
|
end
|
108
138
|
```
|
data/exe/inert
CHANGED
@@ -6,13 +6,5 @@ if File.exist?(inertfile)
|
|
6
6
|
load inertfile
|
7
7
|
end
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
ENV["RACK_ENV"] = "production"
|
12
|
-
require "inert"
|
13
|
-
Inert.build
|
14
|
-
else
|
15
|
-
ENV["RACK_ENV"] = "development"
|
16
|
-
require "inert"
|
17
|
-
Inert.start
|
18
|
-
end
|
9
|
+
require "inert"
|
10
|
+
Inert::CLI.start
|
data/lib/inert.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
require_relative "inert/version"
|
2
3
|
require_relative "inert/config"
|
4
|
+
require_relative "inert/cli"
|
3
5
|
|
4
6
|
module Inert
|
5
7
|
module_function
|
6
8
|
|
7
|
-
def start
|
9
|
+
def start(server: nil, host: nil, port: nil)
|
8
10
|
app = Rack::Builder.app do
|
9
|
-
if
|
11
|
+
if Inert.development?
|
10
12
|
use Rack::ShowExceptions
|
11
13
|
use Rack::CommonLogger
|
12
14
|
end
|
@@ -14,7 +16,12 @@ module Inert
|
|
14
16
|
run Inert::Middleware
|
15
17
|
end
|
16
18
|
|
17
|
-
Rack::Server.start(
|
19
|
+
Rack::Server.start({
|
20
|
+
app: app,
|
21
|
+
server: server,
|
22
|
+
"Host": host,
|
23
|
+
"Port": port
|
24
|
+
})
|
18
25
|
end
|
19
26
|
|
20
27
|
def build
|
@@ -24,6 +31,14 @@ module Inert
|
|
24
31
|
def view_path
|
25
32
|
File.expand_path(Inert.config.views, Dir.pwd)
|
26
33
|
end
|
34
|
+
|
35
|
+
def development?
|
36
|
+
ENV["RACK_ENV"] == "development"
|
37
|
+
end
|
38
|
+
|
39
|
+
def building?
|
40
|
+
!development?
|
41
|
+
end
|
27
42
|
end
|
28
43
|
|
29
44
|
require_relative "inert/page"
|
data/lib/inert/builder.rb
CHANGED
@@ -17,10 +17,13 @@ module Inert
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def call(starting_url)
|
20
|
+
copy_static
|
21
|
+
|
20
22
|
save(starting_url)
|
23
|
+
history.add(starting_url)
|
21
24
|
|
22
25
|
while (url = queue.pop)
|
23
|
-
next if
|
26
|
+
next if already_visited?(url) || is_anchor?(url) || is_remote?(url)
|
24
27
|
|
25
28
|
save(url)
|
26
29
|
history.add(url)
|
@@ -59,5 +62,21 @@ module Inert
|
|
59
62
|
end
|
60
63
|
end
|
61
64
|
end
|
65
|
+
|
66
|
+
def copy_static
|
67
|
+
FileUtils.cp_r(app.opts[:public_root]+"/.", build_path)
|
68
|
+
end
|
69
|
+
|
70
|
+
def already_visited?(url)
|
71
|
+
history.include?(url)
|
72
|
+
end
|
73
|
+
|
74
|
+
def is_anchor?(url)
|
75
|
+
url.start_with?("#")
|
76
|
+
end
|
77
|
+
|
78
|
+
def is_remote?(url)
|
79
|
+
url =~ /\A(\w+):/ || url.start_with?("//")
|
80
|
+
end
|
62
81
|
end
|
63
82
|
end
|
data/lib/inert/cli.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
|
3
|
+
require "thor"
|
4
|
+
|
5
|
+
module Inert
|
6
|
+
class CLI < Thor
|
7
|
+
default_command :server
|
8
|
+
|
9
|
+
desc "build", "Build site"
|
10
|
+
def build
|
11
|
+
ENV["RACK_ENV"] = "production"
|
12
|
+
Inert.build
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "server", "Run server"
|
16
|
+
method_option :port, aliases: "-p", desc: "port to listen on", type: :numeric, default: 3000
|
17
|
+
method_option :bind, aliases: "-b", desc: "address to listen on", type: :string, default: "localhost"
|
18
|
+
method_option :server, aliases: "-s", desc: "server to use", type: :string
|
19
|
+
def server
|
20
|
+
ENV["RACK_ENV"] = "development"
|
21
|
+
Inert.start(server: options.server, host: options.bind, port: options.port)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/inert/middleware.rb
CHANGED
@@ -4,7 +4,7 @@ require "roda"
|
|
4
4
|
module Inert
|
5
5
|
class Middleware < Roda
|
6
6
|
plugin :render,
|
7
|
-
cache:
|
7
|
+
cache: Inert.building?,
|
8
8
|
views: Inert.config.views
|
9
9
|
|
10
10
|
plugin :partials
|
@@ -13,20 +13,18 @@ module Inert
|
|
13
13
|
|
14
14
|
class_exec &Inert.config.app
|
15
15
|
|
16
|
-
attr_reader :page
|
17
|
-
|
18
16
|
route do |r|
|
19
17
|
r.public
|
20
18
|
|
21
|
-
Inert.config.routes
|
19
|
+
instance_exec(r, &Inert.config.routes)
|
22
20
|
|
23
21
|
view_file = r.remaining_path.dup
|
24
|
-
view_file << "index
|
22
|
+
view_file << "index" if view_file.end_with?("/")
|
25
23
|
|
26
24
|
begin
|
27
25
|
page = Page.load_from_file(File.join(Inert.view_path, view_file))
|
28
26
|
rescue Errno::ENOENT
|
29
|
-
r.halt([404, {}, ["Not found"]])
|
27
|
+
r.halt([404, {}, ["#{view_file} Not found"]])
|
30
28
|
end
|
31
29
|
|
32
30
|
@page = page.frontmatter
|
@@ -39,6 +37,10 @@ module Inert
|
|
39
37
|
def inline(file)
|
40
38
|
File.read(File.join(Inert.view_path, file))
|
41
39
|
end
|
40
|
+
|
41
|
+
def page
|
42
|
+
@page ||= OpenStruct.new
|
43
|
+
end
|
42
44
|
end
|
43
45
|
end
|
44
46
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Daniels
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: roda
|
@@ -50,6 +50,20 @@ dependencies:
|
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '4.0'
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: thor
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "<"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '1.0'
|
60
|
+
type: :runtime
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - "<"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '1.0'
|
53
67
|
- !ruby/object:Gem::Dependency
|
54
68
|
name: oga
|
55
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,9 +95,11 @@ files:
|
|
81
95
|
- exe/inert
|
82
96
|
- lib/inert.rb
|
83
97
|
- lib/inert/builder.rb
|
98
|
+
- lib/inert/cli.rb
|
84
99
|
- lib/inert/config.rb
|
85
100
|
- lib/inert/middleware.rb
|
86
101
|
- lib/inert/page.rb
|
102
|
+
- lib/inert/version.rb
|
87
103
|
homepage: https://github.com/adam12/inert
|
88
104
|
licenses:
|
89
105
|
- MIT
|
@@ -103,8 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
119
|
- !ruby/object:Gem::Version
|
104
120
|
version: '0'
|
105
121
|
requirements: []
|
106
|
-
|
107
|
-
rubygems_version: 2.5.2
|
122
|
+
rubygems_version: 3.0.1
|
108
123
|
signing_key:
|
109
124
|
specification_version: 4
|
110
125
|
summary: An experimental static site builder with unambitious goals
|