flutterby 0.0.9 → 0.0.10
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 +4 -4
- data/.travis.yml +3 -0
- data/README.md +8 -3
- data/lib/flutterby/cli.rb +3 -2
- data/lib/flutterby/entity.rb +23 -1
- data/lib/flutterby/file.rb +7 -21
- data/lib/flutterby/filters.rb +8 -0
- data/lib/flutterby/folder.rb +0 -17
- data/lib/flutterby/server.rb +3 -2
- data/lib/flutterby/version.rb +1 -1
- data/lib/flutterby/view.rb +22 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92409201cdf6f744cf869271e0361b75b771dc6c
|
4
|
+
data.tar.gz: 274684a4a805f04b6b8f3739a5c8fcaf5f148f97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6b3cf80130ea4afdb07faa75e04ba6e680883a7c5f3f6ada5cd2b426a73c5ee23fa9e413dbd3587614e7c78a54c6cef7041f240360f446698102570d06bf806
|
7
|
+
data.tar.gz: 28596862f6dce075e164ef713c38497e494d2b7e132b75fe1930e9710c116ffcde346c234c19f94c1e53e971b2962c01704d680b65b25bdd604ed4c2ddab55cf
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,13 @@
|
|
1
|
+
[](https://badge.fury.io/rb/flutterby) [](https://travis-ci.org/hmans/flutterby) 
|
2
|
+
|
1
3
|
# Flutterby
|
2
4
|
|
3
|
-
A currently highly experimental static site generator. Yes, there are many like it;
|
4
|
-
|
5
|
-
|
5
|
+
### A currently highly experimental static site generator. Yes, there are many like it; but this one is mine. (Actually, there are none like it. Ha! I'm very serious about the _experimental_ bit, though. Use with care, if at all!)
|
6
|
+
|
7
|
+
|
8
|
+
## Example
|
9
|
+
|
10
|
+
Even though Flutterby is still very much in flux, I'm already building a bunch of sites with it; one of them is [my blog](http://hmans.io/), the source code for which you can find [here](https://github.com/hmans/hmans_me).
|
6
11
|
|
7
12
|
|
8
13
|
## Actual Features
|
data/lib/flutterby/cli.rb
CHANGED
@@ -27,12 +27,13 @@ Commander.configure do
|
|
27
27
|
c.description = "Serve your website for development."
|
28
28
|
|
29
29
|
c.option '--in DIR', String, "Directory containing your source files"
|
30
|
+
c.option '--port NUM', String, "Port to serve on (default: 4004)"
|
30
31
|
|
31
32
|
c.action do |args, options|
|
32
|
-
options.default in: "./site/"
|
33
|
+
options.default in: "./site/", port: 4004
|
33
34
|
|
34
35
|
root = Flutterby.from(options.in, name: "/")
|
35
|
-
server = Flutterby::Server.new(root)
|
36
|
+
server = Flutterby::Server.new(root, port: options.port)
|
36
37
|
server.run!
|
37
38
|
end
|
38
39
|
end
|
data/lib/flutterby/entity.rb
CHANGED
@@ -2,6 +2,7 @@ module Flutterby
|
|
2
2
|
class Entity
|
3
3
|
attr_accessor :parent, :ext
|
4
4
|
attr_reader :name, :filters, :fs_path, :data, :children
|
5
|
+
alias_method :folder, :parent
|
5
6
|
|
6
7
|
def initialize(name, parent: nil, fs_path: nil)
|
7
8
|
@parent = parent
|
@@ -12,7 +13,12 @@ module Flutterby
|
|
12
13
|
parts = name.split(".")
|
13
14
|
@name = parts.shift
|
14
15
|
@filters = parts.reverse
|
15
|
-
|
16
|
+
|
17
|
+
# We're assuming the extension is the name of the final filter
|
18
|
+
# that will be applied. This may not be always correct, since filters
|
19
|
+
# can also change a file's extension.
|
20
|
+
#
|
21
|
+
@ext = @filters.last
|
16
22
|
|
17
23
|
# If a filesystem path was given, read the entity from disk
|
18
24
|
if fs_path
|
@@ -99,6 +105,22 @@ module Flutterby
|
|
99
105
|
end
|
100
106
|
end
|
101
107
|
|
108
|
+
# Walk the tree up, invoking the passed block for every entity
|
109
|
+
# found on the way, passing the entity as its only argument.
|
110
|
+
#
|
111
|
+
def walk_up(val = nil, &blk)
|
112
|
+
val = blk.call(self, val)
|
113
|
+
parent ? parent.walk_up(val, &blk) : val
|
114
|
+
end
|
115
|
+
|
116
|
+
# Walk the graph from the root to this entity. Just like walk_up,
|
117
|
+
# except the block will be called on higher level entities first.
|
118
|
+
#
|
119
|
+
def walk_down(val = nil, &blk)
|
120
|
+
val = parent ? parent.walk_up(val, &blk) : val
|
121
|
+
blk.call(self, val)
|
122
|
+
end
|
123
|
+
|
102
124
|
|
103
125
|
#
|
104
126
|
# Reading from filesystem
|
data/lib/flutterby/file.rb
CHANGED
@@ -58,11 +58,7 @@ module Flutterby
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def view
|
61
|
-
@view ||=
|
62
|
-
View.new(self).tap do |view|
|
63
|
-
parent.extend_view!(view) if parent
|
64
|
-
end
|
65
|
-
end
|
61
|
+
@view ||= View.for(self)
|
66
62
|
end
|
67
63
|
|
68
64
|
def read_json
|
@@ -74,24 +70,14 @@ module Flutterby
|
|
74
70
|
end
|
75
71
|
|
76
72
|
def apply_layout(input)
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
if layout = current.find("_layout")
|
84
|
-
layouts << layout
|
73
|
+
walk_up(input) do |e, current|
|
74
|
+
if layout = e.sibling("_layout")
|
75
|
+
tilt = Tilt[layout.ext].new { layout.source }
|
76
|
+
tilt.render(view) { current }
|
77
|
+
else
|
78
|
+
current
|
85
79
|
end
|
86
80
|
end
|
87
|
-
|
88
|
-
# Apply all layouts in order
|
89
|
-
layouts.each do |layout|
|
90
|
-
tilt = Tilt[layout.ext].new { layout.source }
|
91
|
-
output = tilt.render(view) { output }
|
92
|
-
end
|
93
|
-
|
94
|
-
output
|
95
81
|
end
|
96
82
|
|
97
83
|
def apply_layout?
|
data/lib/flutterby/filters.rb
CHANGED
@@ -7,6 +7,14 @@ module Flutterby
|
|
7
7
|
file.filters.each do |filter|
|
8
8
|
meth = "process_#{filter}"
|
9
9
|
|
10
|
+
# Set the file's extension to the requested filter. The filter
|
11
|
+
# itself can, of course, override this (eg. the "md" filter can default
|
12
|
+
# the extension to "html".)
|
13
|
+
#
|
14
|
+
file.ext = filter
|
15
|
+
|
16
|
+
# Now apply the actual filter!
|
17
|
+
#
|
10
18
|
if Filters.respond_to?(meth)
|
11
19
|
body = Filters.send(meth, body, file)
|
12
20
|
end
|
data/lib/flutterby/folder.rb
CHANGED
@@ -15,22 +15,5 @@ module Flutterby
|
|
15
15
|
child.export(path)
|
16
16
|
end
|
17
17
|
end
|
18
|
-
|
19
|
-
def extend_view!(view)
|
20
|
-
# Load the view extension available in this folder into the given view.
|
21
|
-
#
|
22
|
-
if view_entity = find("_view.rb")
|
23
|
-
case view_entity.ext
|
24
|
-
when "rb" then
|
25
|
-
view.instance_eval(view_entity.source)
|
26
|
-
else
|
27
|
-
raise "Unknown view extension #{view_entity.full_name}"
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
# Then pass the whole thing up the stack.
|
32
|
-
#
|
33
|
-
parent ? parent.extend_view!(view) : view
|
34
|
-
end
|
35
18
|
end
|
36
19
|
end
|
data/lib/flutterby/server.rb
CHANGED
@@ -3,8 +3,9 @@ require 'listen'
|
|
3
3
|
|
4
4
|
module Flutterby
|
5
5
|
class Server
|
6
|
-
def initialize(root)
|
6
|
+
def initialize(root, port: 4004)
|
7
7
|
@root = root
|
8
|
+
@port = port
|
8
9
|
end
|
9
10
|
|
10
11
|
def run!
|
@@ -29,7 +30,7 @@ module Flutterby
|
|
29
30
|
|
30
31
|
# Go!
|
31
32
|
listener.start
|
32
|
-
server.run self
|
33
|
+
server.run self, Port: @port
|
33
34
|
end
|
34
35
|
|
35
36
|
def call(env)
|
data/lib/flutterby/version.rb
CHANGED
data/lib/flutterby/view.rb
CHANGED
@@ -18,5 +18,27 @@ module Flutterby
|
|
18
18
|
def find(expr)
|
19
19
|
entity.find(expr) or raise "No entity found for #{expr}"
|
20
20
|
end
|
21
|
+
|
22
|
+
class << self
|
23
|
+
def for(file)
|
24
|
+
# create a new view instance
|
25
|
+
view = new(file)
|
26
|
+
|
27
|
+
# walk the tree up to dynamically extend the view
|
28
|
+
file.folder.walk_down do |e|
|
29
|
+
if view_entity = e.find("_view.rb")
|
30
|
+
case view_entity.ext
|
31
|
+
when "rb" then
|
32
|
+
view.instance_eval(view_entity.source)
|
33
|
+
else
|
34
|
+
raise "Unknown view extension #{view_entity.full_name}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# return the finished view object
|
40
|
+
view
|
41
|
+
end
|
42
|
+
end
|
21
43
|
end
|
22
44
|
end
|