flutterby 0.5.0 → 0.5.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
  SHA1:
3
- metadata.gz: 679b8fba9c9fda2c5e70df5bb73a16903be5181f
4
- data.tar.gz: 5a27688b1713d0bd8bb49695afcb1bb9272682e6
3
+ metadata.gz: 6f25431bf9e8f2dafc67f58b966c2fde5a368055
4
+ data.tar.gz: f32e383638dfc175617f1f5a3af8eff54ca288e9
5
5
  SHA512:
6
- metadata.gz: b24fcfd4c696520de83fcc2f6a0318f7e3895bf558bdc30145ccf8eca1af57845fca6c393ceac928edcfa3afaf5f99409324d9027269c88a89fd698d6512c35c
7
- data.tar.gz: 8a2827f70bc5484a202d9f147e7c0cb0ba04ee3e95106041ceb8439e014321b01474a9273e3d2bcbbcba740eed03263c4d5b86bdb848a453cf13602647da2edb
6
+ metadata.gz: 59134f58f623e20cc2e168671e43dfa7012577c90108db6f6bb0bb92af52a990f2f2629a6cd00a55da4aa43aff5c86155572e5f9d3c81c0804419f256b4f1f72
7
+ data.tar.gz: 7900512a1c3d2cf8d193c3c427d6c4f06d16cef75c5b3be817f7db3bf658685e15654894a6f2cbf352a96922b12e6dd2e28f260a972fdafbd80732dcc1cc3109
data/CHANGES.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Version History
2
2
 
3
+ ### HEAD
4
+
5
+ - **NEW:** Views now provide an `extend_view` method that you can (and should) use in `_view.rb` extensions.
6
+ - **NEW:** Improved log output, especially when using `--debug`.
7
+
8
+
3
9
  ### 0.5.0 (2017-01-24)
4
10
 
5
11
  - **NEW:** Nodes have two new attributes, `prefix` and `slug`, which are automatically generated from the node's name. If the name starts with a combination of decimals and dashes, these will become the `prefix`, and the remainder auf the name the `suffix`. For example, a name of `123-introduction` will result in a prefix of `123` and a slug of `introduction`. As before, a prefix that looks like a date (eg. `2017-04-01-introduction`) will automatically be parsed into `data[:date]`.
@@ -32,6 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.add_development_dependency 'pry', '~> 0.10'
33
33
  spec.add_development_dependency 'yard', '~> 0.9'
34
34
 
35
+ spec.add_dependency 'colorize', '~> 0.8'
35
36
  spec.add_dependency 'erubis', '~> 2.7'
36
37
  spec.add_dependency 'erubis-auto', '~> 1.0'
37
38
  spec.add_dependency 'json', '~> 2.0'
@@ -2,6 +2,7 @@ require 'active_support/all'
2
2
  require 'toml'
3
3
  require 'mime-types'
4
4
  require 'json'
5
+ require 'colorize'
5
6
 
6
7
  require "flutterby/dotaccess"
7
8
  require "flutterby/version"
@@ -17,7 +17,7 @@ module Flutterby
17
17
 
18
18
  if node.file?
19
19
  ::File.write(path, node.render(layout: true))
20
- logger.info "Exported #{node.url}"
20
+ logger.info "Exported #{node.url.colorize(:light_white)}"
21
21
  else
22
22
  FileUtils.mkdir_p(path)
23
23
  node.children.each do |child|
@@ -1,3 +1,3 @@
1
1
  module Flutterby
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
@@ -30,7 +30,16 @@ module Flutterby
30
30
  end
31
31
  end
32
32
 
33
- logger.info "Rendered #{node.url} in #{sprintf "%.1f", time * 1000}ms"
33
+ # Log rendering times using different colors based on duration
34
+ color = if time > 1
35
+ :red
36
+ elsif time > 0.25
37
+ :yellow
38
+ else
39
+ :green
40
+ end
41
+
42
+ logger.debug "Rendered #{node.url.colorize(:blue)} in #{sprintf("%.1fms", time * 1000).colorize(color)}"
34
43
 
35
44
  @_body
36
45
  end
@@ -100,6 +109,14 @@ module Flutterby
100
109
  tag(:pre, class: "debug") { h obj.to_yaml }
101
110
  end
102
111
 
112
+ def extend_view(*mods, &blk)
113
+ if block_given?
114
+ mods << Module.new(&blk)
115
+ end
116
+
117
+ extend(*mods)
118
+ end
119
+
103
120
  def logger
104
121
  @logger ||= Flutterby.logger
105
122
  end
@@ -3,7 +3,7 @@
3
3
  site:
4
4
  title: My Flutterby Site
5
5
  description: >
6
- This is my new <a href="https://github.com/hmans/flutterby">Flutterby</a> Site. I should probably
6
+ This is my new <a href="http://www.flutterby.run">Flutterby</a> Site. I should probably
7
7
  change this description in my site's configuration file,
8
8
  found at ./site/_config.yaml. Or I can just leave it as is.
9
9
  Isn't choice wonderful?
@@ -1,11 +1,12 @@
1
- # When you add a _view.rb file to a folder, all pages in this folder
2
- # and all folders below it will have the methods defined in it available
3
- # as view helper methods.
1
+ # Use _view.rb files like this one to add helper methos to your views. Any
2
+ # helpers defined here will be available to all pages within the same
3
+ # folder, AND all of its sub-folders.
4
4
 
5
-
6
- # Define a `config` view helper that provides quick access to the
7
- # site configuration object's data.
8
- #
9
- def config
10
- find("/_config").data
5
+ extend_view do
6
+ # Define a `config` view helper that provides quick access to the
7
+ # site configuration object's data.
8
+ #
9
+ def config
10
+ find("/_config").data
11
+ end
11
12
  end
@@ -2,4 +2,4 @@
2
2
 
3
3
  This is a small template site [Flutterby] generated for you. You can keep using it, modify it as you wish, or get rid of everything and start from scratch. It's up to you!
4
4
 
5
- [Flutterby]: https://github.com/hmans/flutterby
5
+ [Flutterby]: http://www.flutterby.run
@@ -1,15 +1,17 @@
1
- # Returns all blog posts contained in this directory. We assume
2
- # that a blog post is any page object that has a date set.
3
- #
4
- def blog_posts
5
- siblings
6
- .select { |p| blog_post?(p) }
7
- .sort_by(&:date)
8
- .reverse
9
- end
1
+ extend_view do
2
+ # Returns all blog posts contained in this directory. We assume
3
+ # that a blog post is any page object that has a date set.
4
+ #
5
+ def blog_posts
6
+ siblings
7
+ .select { |p| blog_post?(p) }
8
+ .sort_by(&:date)
9
+ .reverse
10
+ end
10
11
 
11
- # Checks if a specific node is a blog post.
12
- #
13
- def blog_post?(node)
14
- node.page? && !node.date.nil?
12
+ # Checks if a specific node is a blog post.
13
+ #
14
+ def blog_post?(node)
15
+ node.page? && !node.date.nil?
16
+ end
15
17
  end
@@ -15,6 +15,8 @@ This sample project is set up as a simple blog, but of course you can do so much
15
15
 
16
16
  #### Recommended Reading
17
17
 
18
+ - [Flutterby Website](http://www.flutterby.run)
19
+ - [Flutterby Documentation](http://www.flutterby.run/docs/)
18
20
  - [Flutterby on Github](https://github.com/hmans/flutterby)
19
21
 
20
22
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flutterby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hendrik Mans
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0.9'
125
+ - !ruby/object:Gem::Dependency
126
+ name: colorize
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '0.8'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '0.8'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: erubis
127
141
  requirement: !ruby/object:Gem::Requirement