flutterby 0.2.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 51679cec3fb95d5b0e6a2ee392373856eb160b3f
4
- data.tar.gz: 17e5203af322a8bc0c9fbe9b435b25c7a27f9166
3
+ metadata.gz: 0bfb4189fdcf9b5640df468a2818ae3d2f647c71
4
+ data.tar.gz: adb8399cc0fe5f5c8ca452f8570c8b19fd74aacb
5
5
  SHA512:
6
- metadata.gz: dc7c1767f95d7a49e5fd2612a187e9e10d1976da0dfd6afad7172a79ac684d3f11e9ef8dffe078e4a4a538b9ff629fd0af45d1461dd45d7bf26d7dbaeccbbc82
7
- data.tar.gz: 73b5970b058190ec21e67339d5134f00a795aa92e18d3a65fca87da627b1c9ae7dc2944045aa9e2c91cfe1de7cc243199b1c786bb55ad3481be33805f37b654d
6
+ metadata.gz: fcdb6900c5bd5aee4c1425bb226b110a151413a27af13f368aa317326521c9a0afe0be656f48413aec7f9bad327642d3ff2c0360c37267b0a271fa83a7e78272
7
+ data.tar.gz: 832097dcf92dd891160a04a1d164a392efe316aa6a8d79f92e660b76232fab0bf18d9934ce1f6d09c85fa8edc5b2765ee61a28cb64bb6241d197731b565ff649
data/CHANGES.md CHANGED
@@ -1,6 +1,12 @@
1
1
  # Version History
2
2
 
3
- ### 0.2.0 (in development)
3
+ ### 0.3.1 (2017-01-15)
4
+
5
+ - **NEW:** Flutterby now uses ActiveSupport. It's a big dependency, but there's just so much useful goodness in there -- let's ride on the shoulders of that giant! This allows you to use all the neat little ActiveSupport toys you may know from Rails in your Flutterby project.
6
+ - **CHANGE:** Thanks to the new inclusion of ActiveSupport, Flutterby now properly deals with HTML escaping (by way of `ActiveSupport::SafeBuffer`). This may not be critically important to static sites, but since Flutterby aspires to also power live sites, better make this change now than later. To sum things up, Flutterby now deals with HTML escaping pretty much like Rails does. Hooray!
7
+
8
+
9
+ ### 0.2.0 (2017-01-13)
4
10
 
5
11
  - **BREAKING CHANGE:** The default for `Node#render` is now to _not_ render a layout. Pass `layout: true` if you do want the node to be rendered within a layout.
6
12
  - **BREAKING CHANGE:** The behavior of `find` has now changed with regard to relative paths. `find(".")` will now return _the node's parent_ (ie. it's folder); before, a single dot would return the node itself. This change was made to make `find` behave more like what you would expect from a file system.
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  [![Gem Version](https://badge.fury.io/rb/flutterby.svg)](https://badge.fury.io/rb/flutterby) [![Build Status](https://travis-ci.org/hmans/flutterby.svg?branch=master)](https://travis-ci.org/hmans/flutterby) [![license](https://img.shields.io/github/license/hmans/flutterby.svg)](https://github.com/hmans/flutterby/blob/master/LICENSE.txt) ![Status](https://img.shields.io/badge/status-active-brightgreen.svg)
6
6
 
7
7
 
8
- #### Key Features
8
+ #### Key Features:
9
9
 
10
10
  - Generate a static website from a source directory!
11
11
  - Apply any number of transformations on files!
@@ -13,10 +13,11 @@
13
13
  - Extremely easy to extend with new transformation filters!
14
14
  - Sprinkle your site with Ruby code that can interact with your site's pages and data!
15
15
 
16
- #### Recommended Reading
16
+ #### Recommended Reading:
17
17
 
18
18
  - [Blog post introducing Flutterby](http://hmans.io/posts/2017/01/11/flutterby.html)
19
19
  - [New project template](https://github.com/hmans/flutterby/tree/master/lib/templates/new_project) (example code)
20
+ - [Version History](https://github.com/hmans/flutterby/blob/master/CHANGES.md)
20
21
 
21
22
  ## Installation & Basic Usage
22
23
 
@@ -31,6 +31,8 @@ Gem::Specification.new do |spec|
31
31
  spec.add_development_dependency 'gem-release', '~> 0'
32
32
  spec.add_development_dependency 'pry', '~> 0.10'
33
33
 
34
+ spec.add_dependency 'erubis', '~> 2.7'
35
+ spec.add_dependency 'erubis-auto', '~> 1.0'
34
36
  spec.add_dependency 'json', '~> 2.0'
35
37
  spec.add_dependency 'thor', '~> 0.19'
36
38
  spec.add_dependency 'highline', '~> 1.7'
@@ -40,6 +42,7 @@ Gem::Specification.new do |spec|
40
42
  spec.add_dependency 'listen', '~> 3.1'
41
43
  spec.add_dependency 'mime-types', '~> 3.1'
42
44
  spec.add_dependency 'better_errors', '~> 2.1'
45
+ spec.add_dependency 'activesupport', '~> 5.0'
43
46
 
44
47
  # We support some template engines out of the box.
45
48
  # There's a chance these will be extracted/made optional
@@ -1,3 +1,4 @@
1
+ require 'active_support/all'
1
2
  require 'toml'
2
3
  require 'mime-types'
3
4
  require 'json'
@@ -1,3 +1,5 @@
1
+ require 'erubis'
2
+ require 'erubis/auto'
1
3
  require 'sass'
2
4
  require 'tilt'
3
5
  require 'slim'
@@ -7,7 +9,7 @@ require 'flutterby/markdown_formatter'
7
9
  module Flutterby
8
10
  module Filters
9
11
  def self.apply!(node)
10
- node.body = node.source
12
+ node.body = node.source.try(:html_safe)
11
13
 
12
14
  # Apply all filters
13
15
  node.filters.each do |filter|
@@ -16,7 +18,7 @@ module Flutterby
16
18
  if Filters.respond_to?(meth)
17
19
  Filters.send(meth, node)
18
20
  elsif template = tilt(filter, node.body)
19
- node.body = template.render(node.view)
21
+ node.body = template.render(node.view).html_safe
20
22
  else
21
23
  Flutterby.logger.warn "Unsupported filter '#{filter}' for #{node.url}"
22
24
  end
@@ -29,8 +31,14 @@ module Flutterby
29
31
  end
30
32
  end
31
33
 
32
- def self.tilt(format, body)
33
- t = Tilt[format] and t.new { body }
34
+ def self.tilt(format, body, options = {})
35
+ default_options = {
36
+ "erb" => { engine_class: Erubis::Auto::EscapedEruby }
37
+ }
38
+
39
+ options = default_options.fetch(format, {}).merge(options)
40
+
41
+ t = Tilt[format] and t.new(options) { body }
34
42
  end
35
43
  end
36
44
  end
@@ -40,7 +48,7 @@ Flutterby::Filters.add("rb") do |node|
40
48
  end
41
49
 
42
50
  Flutterby::Filters.add(["md", "markdown"]) do |node|
43
- node.body = Flutterby::MarkdownFormatter.new(node.body).complete.to_s
51
+ node.body = Flutterby::MarkdownFormatter.new(node.body).complete.to_s.html_safe
44
52
  end
45
53
 
46
54
  Flutterby::Filters.add("scss") do |node|
@@ -252,10 +252,10 @@ module Flutterby
252
252
  end
253
253
 
254
254
  def apply_layout(input)
255
- walk_up(input) do |e, current|
256
- if layout = e.sibling("_layout")
257
- tilt = Tilt[layout.ext].new { layout.source }
258
- tilt.render(view) { current }
255
+ walk_up(input) do |node, current|
256
+ if layout = node.sibling("_layout")
257
+ tilt = Flutterby::Filters.tilt(layout.ext, layout.source)
258
+ tilt.render(view) { current }.html_safe
259
259
  else
260
260
  current
261
261
  end
@@ -1,3 +1,3 @@
1
1
  module Flutterby
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -3,6 +3,13 @@ module Flutterby
3
3
  attr_reader :node, :opts
4
4
  alias_method :page, :node
5
5
 
6
+ # Include ERB::Util from ActiveSupport. This will provide
7
+ # html_escape, h, and json_escape helpers.
8
+ #
9
+ # http://api.rubyonrails.org/classes/ERB/Util.html
10
+ #
11
+ include ERB::Util
12
+
6
13
  def initialize(node)
7
14
  @node = node
8
15
  @opts = {}
@@ -12,6 +19,10 @@ module Flutterby
12
19
  date.strftime(fmt)
13
20
  end
14
21
 
22
+ def raw(str)
23
+ str.html_safe
24
+ end
25
+
15
26
  def render(expr, *args)
16
27
  find(expr).render(*args)
17
28
  end
@@ -25,6 +36,9 @@ module Flutterby
25
36
  end
26
37
 
27
38
  class << self
39
+ # Factory method that returns a newly created view for the given node.
40
+ # It also makes sure all available _view.rb extensions are loaded.
41
+ #
28
42
  def for(file)
29
43
  # create a new view instance
30
44
  view = new(file)
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  source "https://rubygems.org"
3
3
 
4
- gem "flutterby"
5
- # gem "flutterby-coffeescript"
4
+ gem "flutterby", "~> 0.3.0"
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'flutterby' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("flutterby", "flutterby")
@@ -0,0 +1,20 @@
1
+ doctype html
2
+ html
3
+ head
4
+ meta charset="utf-8"
5
+ title = config["site"]["title"]
6
+
7
+ // highlight.js for syntax highlighting
8
+ link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/styles/default.min.css"
9
+ script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/highlight.min.js"
10
+
11
+ // Our own assets
12
+ link rel="stylesheet" href="/css/styles.css"
13
+ script src="/js/app.js"
14
+
15
+ body
16
+ .container
17
+ = yield
18
+
19
+ footer role="main"
20
+ = config["site"]["description"]
@@ -1,3 +1,11 @@
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.
4
+
5
+
6
+ # Define a `config` view helper that provides quick access to the
7
+ # site configuration object's data.
8
+ #
1
9
  def config
2
10
  find("/_config").data
3
11
  end
@@ -9,8 +9,8 @@ This sample project is set up as a simple blog, but of course you can do so much
9
9
 
10
10
  | `/_config.toml` | Your site configuration. |
11
11
  | `/css/styles.css.scss` | Your stylesheet. [Sass]-powered, of course! |
12
- | `/_layout.erb` | Your global site layout. |
13
- | `/posts/_layout.erb` | Your post-specific layout. |
12
+ | `/_layout.slim` | Your global site layout. |
13
+ | `/posts/_layout.slim` | Your post-specific layout. |
14
14
 
15
15
  #### Recommended Reading
16
16
 
@@ -4,4 +4,4 @@ article.post
4
4
 
5
5
  h1 = page.title
6
6
 
7
- == page.body
7
+ = page.body
@@ -1,3 +1,10 @@
1
+ # A _node.rb will be run against all nodes from the same directory -- use it
2
+ # to enhance the Ruby objects representing these nodes with extra methods
3
+ # or behavior.
4
+ #
5
+ # In this example, we're simply adding some convenience methods for easier
6
+ # access to specific pieces of data.
7
+
1
8
  def date
2
9
  data["date"]
3
10
  end
@@ -1,6 +1,15 @@
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
+ #
1
4
  def blog_posts
2
5
  siblings
3
- .select { |p| p.data["date"] }
4
- .sort_by { |p| p.data["date"] }
6
+ .select { |p| blog_post?(p) }
7
+ .sort_by(&:date)
5
8
  .reverse
6
9
  end
10
+
11
+ # Checks if a specific node is a blog post.
12
+ #
13
+ def blog_post?(node)
14
+ node.page? && !node.date.nil?
15
+ end
@@ -0,0 +1,6 @@
1
+ h1 = config["site"]["title"]
2
+
3
+ p This is my new website! <a href="/about.html">Find out more</a>.
4
+
5
+ h3 Latest Posts:
6
+ == render("/blog/_list")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flutterby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hendrik Mans
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-13 00:00:00.000000000 Z
11
+ date: 2017-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -108,6 +108,34 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0.10'
111
+ - !ruby/object:Gem::Dependency
112
+ name: erubis
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '2.7'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '2.7'
125
+ - !ruby/object:Gem::Dependency
126
+ name: erubis-auto
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '1.0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '1.0'
111
139
  - !ruby/object:Gem::Dependency
112
140
  name: json
113
141
  requirement: !ruby/object:Gem::Requirement
@@ -234,6 +262,20 @@ dependencies:
234
262
  - - "~>"
235
263
  - !ruby/object:Gem::Version
236
264
  version: '2.1'
265
+ - !ruby/object:Gem::Dependency
266
+ name: activesupport
267
+ requirement: !ruby/object:Gem::Requirement
268
+ requirements:
269
+ - - "~>"
270
+ - !ruby/object:Gem::Version
271
+ version: '5.0'
272
+ type: :runtime
273
+ prerelease: false
274
+ version_requirements: !ruby/object:Gem::Requirement
275
+ requirements:
276
+ - - "~>"
277
+ - !ruby/object:Gem::Version
278
+ version: '5.0'
237
279
  - !ruby/object:Gem::Dependency
238
280
  name: sass
239
281
  requirement: !ruby/object:Gem::Requirement
@@ -324,8 +366,9 @@ files:
324
366
  - lib/templates/new_project/.gitignore
325
367
  - lib/templates/new_project/Gemfile
326
368
  - lib/templates/new_project/README.md
369
+ - lib/templates/new_project/bin/flutterby
327
370
  - lib/templates/new_project/site/_config.toml
328
- - lib/templates/new_project/site/_layout.erb
371
+ - lib/templates/new_project/site/_layout.slim
329
372
  - lib/templates/new_project/site/_view.rb
330
373
  - lib/templates/new_project/site/about.html.md
331
374
  - lib/templates/new_project/site/blog/2017-01-01-hello-world.html.md
@@ -334,7 +377,7 @@ files:
334
377
  - lib/templates/new_project/site/blog/_node.rb
335
378
  - lib/templates/new_project/site/blog/_view.rb
336
379
  - lib/templates/new_project/site/css/styles.css.scss
337
- - lib/templates/new_project/site/index.html.erb
380
+ - lib/templates/new_project/site/index.html.slim
338
381
  - lib/templates/new_project/site/js/app.js
339
382
  homepage: https://github.com/hmans/flutterby
340
383
  licenses:
@@ -356,7 +399,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
356
399
  version: '0'
357
400
  requirements: []
358
401
  rubyforge_project:
359
- rubygems_version: 2.6.8
402
+ rubygems_version: 2.5.2
360
403
  signing_key:
361
404
  specification_version: 4
362
405
  summary: There are many static site generators. This is mine.
@@ -1,23 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <title><%= config["site"]["title"] %></title>
6
- <link rel="stylesheet" href="/css/styles.css">
7
-
8
- <!-- highlight.js for syntax highlighting -->
9
- <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/styles/default.min.css">
10
- <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/highlight.min.js"></script>
11
-
12
- <script src="/js/app.js"></script>
13
- </head>
14
- <body>
15
- <div class="container">
16
- <%= yield %>
17
-
18
- <footer role="main">
19
- <%= config["site"]["description"] %>
20
- </footer>
21
- </div>
22
- </body>
23
- </html>
@@ -1,7 +0,0 @@
1
- <h1><%= config["site"]["title"] %></h1>
2
-
3
- <p>This is my new website! <a href="/about.html">Find out more</a>.</p>
4
-
5
-
6
- <h3>Latest Posts:</h3>
7
- <%= find("/blog/_list").render(layout: false) %>