flora 0.7.0 → 0.7.1
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/README.md +27 -0
- data/lib/flora/app.rb +1 -1
- data/lib/flora/{project/blueprint/html.rb → lilac.rb} +1 -1
- data/lib/flora/plugins/blog/post.rb +7 -2
- data/lib/flora/plugins/blog.rb +1 -1
- data/lib/flora/project/blueprint/markdown.rb +1 -1
- data/lib/flora/project/blueprint/nestable.rb +9 -4
- data/lib/flora/project/blueprint/ruby_html.rb +1 -1
- data/lib/flora/version.rb +1 -1
- data/lib/flora.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5aad0573cb2ab398c995d0c4b52df0c85b6ddad503cf25ae3a69f9c84ee59068
|
|
4
|
+
data.tar.gz: ff36bfc9b1a12ff134c568abfa0abb0c37f75425dcb2bd75d475b47af3d46000
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2c333e1169af9dcaccf7d0c9492e07659db5dde8fbbf43b1107d1e8e48beb7ca75a2606f53f0c8a7ef54a812f287e5b928729215a41390c2fe69fa3f11b76e16
|
|
7
|
+
data.tar.gz: 8f08d99a5eccb379f715bebd480151e1a29db0ea524bd29b5c3bdef0f416934143de5103b1ed521b203f118cb18d58183d59386e391f2dd6353bc0cec7665149
|
data/README.md
CHANGED
|
@@ -26,6 +26,33 @@ end
|
|
|
26
26
|
|
|
27
27
|
Install everything with `bundle install`, and then run `bundle exec flora serve` and open up http://localhost:3000!
|
|
28
28
|
|
|
29
|
+
## Lilac
|
|
30
|
+
|
|
31
|
+
Lilac is Flora's DSL for writing HTML. Tags are just methods named the same as the tag, and children of tags are put inside blocks.
|
|
32
|
+
|
|
33
|
+
Looking for a way to make reusable components? Write a function! For example:
|
|
34
|
+
|
|
35
|
+
```ruby
|
|
36
|
+
# lib/cool_title.rb
|
|
37
|
+
class CoolTitle
|
|
38
|
+
|
|
39
|
+
def self.render(text)
|
|
40
|
+
div(class: 'title') do
|
|
41
|
+
h1 do
|
|
42
|
+
text
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# index.rb
|
|
50
|
+
html do
|
|
51
|
+
body do
|
|
52
|
+
CoolTitle.render('My blog')
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
```
|
|
29
56
|
|
|
30
57
|
## The Flora way
|
|
31
58
|
|
data/lib/flora/app.rb
CHANGED
|
@@ -17,8 +17,13 @@ class Flora::Plugins::Blog::Post
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
|
|
20
|
+
def date
|
|
21
|
+
@frontmatter['date']
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
|
|
20
25
|
def method_missing(name, ...)
|
|
21
|
-
return @frontmatter[name] if @frontmatter[name]
|
|
26
|
+
return @frontmatter[name.to_s] if @frontmatter[name.to_s]
|
|
22
27
|
|
|
23
28
|
super(name, ...)
|
|
24
29
|
end
|
|
@@ -32,7 +37,7 @@ class Flora::Plugins::Blog::Post
|
|
|
32
37
|
return {} unless page_data.start_with?('---')
|
|
33
38
|
/(?<=---\n)(?<yaml>.*)(?=---\n)/m =~ @page.read
|
|
34
39
|
|
|
35
|
-
YAML.load(yaml)
|
|
40
|
+
YAML.load(yaml, permitted_classes: [Date])
|
|
36
41
|
end
|
|
37
42
|
|
|
38
43
|
end
|
data/lib/flora/plugins/blog.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
# A Blueprint that includes Nestable is something that can
|
|
2
|
-
#
|
|
1
|
+
# A Blueprint that includes Nestable is something that can be nested into a
|
|
2
|
+
# Lilac-based layout.
|
|
3
3
|
module Flora::Project::Blueprint::Nestable
|
|
4
4
|
|
|
5
5
|
def render
|
|
@@ -8,10 +8,10 @@ module Flora::Project::Blueprint::Nestable
|
|
|
8
8
|
|
|
9
9
|
layouts = find_layouts
|
|
10
10
|
tree = render_internal(layouts, layouts.size) do
|
|
11
|
-
|
|
11
|
+
render_lilac
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
Flora::
|
|
14
|
+
Flora::Lilac.to_html(tree)
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
|
|
@@ -25,6 +25,11 @@ module Flora::Project::Blueprint::Nestable
|
|
|
25
25
|
layouts << maybe_layout if maybe_layout.exist?
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
+
# Ascend doesn't go to the top level directory.
|
|
29
|
+
# TODO: Make this code less brittle.
|
|
30
|
+
maybe_layout = Pathname.new('./_layout.rb')
|
|
31
|
+
layouts << maybe_layout if maybe_layout.exist?
|
|
32
|
+
|
|
28
33
|
layouts
|
|
29
34
|
end
|
|
30
35
|
|
data/lib/flora/version.rb
CHANGED
data/lib/flora.rb
CHANGED
|
@@ -10,11 +10,11 @@ class Flora
|
|
|
10
10
|
def initialize(dir)
|
|
11
11
|
dir = Pathname.new(dir)
|
|
12
12
|
|
|
13
|
-
# Inject
|
|
14
|
-
# instance_eval isn't enough because
|
|
13
|
+
# Inject Lilac into the Kernel so it's available everywhere. Just
|
|
14
|
+
# instance_eval isn't enough because it'll be missing in lib/ code.
|
|
15
15
|
#
|
|
16
16
|
# TODO: is there a less disruptive way to do this?
|
|
17
|
-
Kernel.prepend(Flora::
|
|
17
|
+
Kernel.prepend(Flora::Lilac)
|
|
18
18
|
|
|
19
19
|
# The classes that are pluggable get their own instances to avoid conflicting
|
|
20
20
|
# with other instances of Flora in the same process. This is mostly for the
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: flora
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.7.
|
|
4
|
+
version: 0.7.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nick Vladimiroff
|
|
@@ -109,13 +109,13 @@ files:
|
|
|
109
109
|
- lib/flora/cli.rb
|
|
110
110
|
- lib/flora/config.rb
|
|
111
111
|
- lib/flora/factory.rb
|
|
112
|
+
- lib/flora/lilac.rb
|
|
112
113
|
- lib/flora/plugins/blog.rb
|
|
113
114
|
- lib/flora/plugins/blog/post.rb
|
|
114
115
|
- lib/flora/plugins/redirector.rb
|
|
115
116
|
- lib/flora/plugins/static_files.rb
|
|
116
117
|
- lib/flora/project.rb
|
|
117
118
|
- lib/flora/project/blueprint.rb
|
|
118
|
-
- lib/flora/project/blueprint/html.rb
|
|
119
119
|
- lib/flora/project/blueprint/markdown.rb
|
|
120
120
|
- lib/flora/project/blueprint/nestable.rb
|
|
121
121
|
- lib/flora/project/blueprint/ruby_html.rb
|