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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1025da710c673e347a8e739d8d378b986386040ec9bdbe97e92ea5639d4a792
4
- data.tar.gz: 5aa256a0a55e2b4d345af8e63e6cb19f3627f723d24706091505f54d58bdafb0
3
+ metadata.gz: 5aad0573cb2ab398c995d0c4b52df0c85b6ddad503cf25ae3a69f9c84ee59068
4
+ data.tar.gz: ff36bfc9b1a12ff134c568abfa0abb0c37f75425dcb2bd75d475b47af3d46000
5
5
  SHA512:
6
- metadata.gz: b261bf5ab0e0d8c5203de5950792d5f272a7a7fb7da9055ea06a543018387534d7964f6d5dfc4550ed0cbcb6e529240176466c66f720d62445adfd09d87fb168
7
- data.tar.gz: e275dad3c3090f5aa53a5df129ea0fc3f2a3921ea3c4a35bf335764ae34c902cb3a07f4987dd8f8163f7f02654ad94c922d521a8f515c268293fbd2827afcc38
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
@@ -50,7 +50,7 @@ class Flora::App
50
50
  end
51
51
 
52
52
  def call(env)
53
- @flora.reload_blueprint
53
+ @flora.reload_project
54
54
 
55
55
  @app.call(env)
56
56
  end
@@ -1,4 +1,4 @@
1
- module Flora::Project::Blueprint::Html
1
+ module Flora::Lilac
2
2
 
3
3
  TAGS = %i[
4
4
  a abbr address area article aside audio
@@ -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
@@ -3,7 +3,7 @@ module Flora::Plugins::Blog
3
3
  module ProjectMethods
4
4
 
5
5
  def posts
6
- @dir.glob('posts/**').map { Post.new(it, @dir) }
6
+ @dir.glob('posts/**').map { Post.new(it, @dir) }.sort_by(&:date).reverse
7
7
  end
8
8
 
9
9
  end
@@ -10,7 +10,7 @@ class Flora::Project::Blueprint::Markdown < Flora::Project::Blueprint
10
10
 
11
11
  private
12
12
 
13
- def render_tree
13
+ def render_lilac
14
14
  silence_warnings do
15
15
  raw_html(Kramdown::Document.new(@file.read).to_html)
16
16
  end
@@ -1,5 +1,5 @@
1
- # A Blueprint that includes Nestable is something that can best nested into
2
- # Flora's HTML DSL layouts.
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
- render_tree
11
+ render_lilac
12
12
  end
13
13
 
14
- Flora::Project::Blueprint::Html.to_html(tree)
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
 
@@ -10,7 +10,7 @@ class Flora::Project::Blueprint::RubyHtml < Flora::Project::Blueprint
10
10
 
11
11
  private
12
12
 
13
- def render_tree
13
+ def render_lilac
14
14
  instance_eval(@file.read)
15
15
  end
16
16
 
data/lib/flora/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Flora
2
- VERSION = '0.7.0'
2
+ VERSION = '0.7.1'
3
3
  end
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 HTML helpers into Kernel so they're available everywhere. Just
14
- # instance_eval isn't enough because they'll be missing in lib/ code.
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::Project::Blueprint::Html)
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.0
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