flutterby 0.0.21 → 0.0.22

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: 96aee2fa59687454d203632f86ce8d712bc620b5
4
- data.tar.gz: 73e7f4e3c4d91397b9af439ab2869e7f4182d165
3
+ metadata.gz: 228421ceea60b8f82d3269e16d6fc5512c80203c
4
+ data.tar.gz: '055628b999ec4a2205f54e4ed04e2aad2d1f742a'
5
5
  SHA512:
6
- metadata.gz: 18aa6fc2e80487c7c9d1c3567e5f6293e2ab4db8c65a08c4624c2beca364e648d86f8f087ef6f39dd1f352b167234e1f5491a1af9e5ec6559a13a5169d6e4ac2
7
- data.tar.gz: a0d9b1f5f1ce74a4c2a1453b9c698225e02a1c11e8ce529d1aaa6b3eb020aca6a219ee46f66e19a7fe415412b6d4b6245eb934e6ca7c2ff78f040e704b479d51
6
+ metadata.gz: e1d7364fbdfbc303eecfa84cc3d538e442868a8d40068927802214dc498e0f468aa33a39e9270402c3d6ce317a875ae9b8b58578c8f6b744f5f2fc2054733840
7
+ data.tar.gz: f98eaf3a429f0abdfe5542e4ef43a5df537e4d1c108150c5a6ac23cfc15a3a4f9e813d86277820a7743510954081da1c91def20b2a18ebfb5123268d8e39a504
data/.gitignore CHANGED
@@ -1,7 +1,7 @@
1
1
  /out/
2
2
  /.bundle/
3
3
  /.yardoc
4
- /Gemfile.lock
4
+ Gemfile.lock
5
5
  /_yardoc/
6
6
  /coverage/
7
7
  /doc/
data/README.md CHANGED
@@ -2,48 +2,101 @@
2
2
 
3
3
  # Flutterby
4
4
 
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!)
5
+ #### A very good static site generator.
6
6
 
7
7
 
8
- ## Example
8
+ ### Key Features
9
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).
10
+ - Generate a static website from a source directory!
11
+ - Apply any number of transformations on files!
12
+ - Built-in support for Markdown, Sass, Erb, Slim and more!
13
+ - Extremely easy to extend with new transformation filters!
14
+ - Sprinkle your site with Ruby code that can interact with your site's pages and data!
11
15
 
12
16
 
13
- ## Actual Features
17
+ ## Installation & Basic Usage
14
18
 
15
- - Build your site simply as a tree of files and folders. Each file will be converted according to its extension chain (eg. `styles.css.scss` will be rendered as `styles.css`, `about.html.md` as `about.html` and so on.)
16
- - Built-in support for Markdown (by way of [Slodown](https://github.com/hmans/slodown)), [Sass](https://github.com/sass/sass), [ERB](http://ruby-doc.org/stdlib-2.4.0/libdoc/erb/rdoc/ERB.html) and [Slim](http://slim-lang.com/).
17
- - A (slow) HTTP server to serve your site dynamically (for development.)
18
- - Dynamically enhance your site's functionality with Ruby code.
19
+ Flutterby is distributed as a RubyGem, so let's install it first:
19
20
 
21
+ gem install flutterby
20
22
 
21
- ## Missing (but Planned) Features
23
+ Now let's create a new project:
22
24
 
23
- - Extract filters (like Slim, Sass etc.) to separate gems
25
+ flutterby new mysite
26
+ cd mysite
27
+
28
+ Now let's generate that static site:
29
+
30
+ flutterby build
31
+
32
+ Or run a local development server for faster development:
33
+
34
+ flutterby server
35
+
36
+ **Note**: by default, both the `build` and `server` commands assume `./site/` to be the source directory and `./_build/` to be the export directory. Please refer to `flutterby help` to see how you can override these.
37
+
38
+
39
+ ## Examples
40
+
41
+ Please refer to the [Sites built with Flutterby](https://github.com/hmans/flutterby/wiki/Sites-built-with-Flutterby) page on the Flutterby Wiki for some examples.
42
+
43
+
44
+ ## Roadmap
45
+
46
+ Flutterby is young, but already quite functional. Here's a list of changes I'm intending to make in the near future -- if you want to work on one of these, let me know!
47
+
48
+ - Improve the template site (`flutterby new`)
49
+ - Change `flutterby server` so it doesn't always regenerate the _entire_ site graph when a file is modified
50
+ - Extract filters (like Slim, Sass etc.) to separate gems, to make the core gem more light-weight
24
51
  - Produce a fun screencast to explain what the heck is going on here!
25
- - More tests, of course!
26
-
27
- ## How does Flutterby work?
28
-
29
- A loose collection of notes on how Flutterby actually generates your site -- mostly intended as rubberducking with myself.
30
-
31
- - Flutterby reads a _source directory_ and writes a static website into a _target directory_. (It can also serve a live version of your site.)
32
- - Before it writes (or serves) anything, it reads the entire contents from the source directory into a graph of plain old Ruby objects. Each of these objects represents a file (or folder) from your site.
33
- - Flutterby then walks this tree to write the resulting static site, optionally _applying filters_ first. For example, `index.html.md` will be exported as `index.html` after applying a Markdown filter.
34
- - These filters can be anything that modifies the Ruby object. Some examples:
35
- - Rendering Markdown to HTML
36
- - Parsing and executing ERB, Slim, HAML and other templating engines
37
- - Processing Sass, CoffeeScript and the likes
38
- - Leaving the current body intact, but modifying file attributes like the generated file's extension
39
- - Filters can be chained at any length you require.
40
- - Ruby code embedded in ERB, Slim etc. templates can interact with this object graph to do funky stuff like:
41
- - including the rendered contents of another object (ie. partials)
42
- - query the graph for certain objects (eg. "all objects in `/posts` that have `published_at` set")
43
- - and much more, I guess!
44
- - When a `_layout` object is available in the same folder as the rendered object, it will be used to wrap the object's rendered output. These layout files stack, so you can have a `/posts/_layout.erb` with the layout for a single post, and a `/_layout.erb` with the layout of your site.
45
- - When a `_view.rb` object is available in the same folder as the rendered object, it will be evaluated against the current view, allowing you to define your own view helpers. Like layouts, these will stack.
46
- - Files and folders starting with underscores (eg. `_header.html`) will never be exported.
52
+ - Write even more tests
53
+
54
+
55
+ ## Notes
56
+
57
+ ### How does Flutterby work?
58
+
59
+ #### The Basics:
60
+
61
+ Flutterby reads a _source directory_ and writes a static website into a _target directory_. (It can also serve a live version of your site.)
62
+
63
+ Before it writes (or serves) anything, it reads the entire contents from the source directory into a graph of plain old Ruby objects. Each of these objects represents a file (or folder) from your site.
64
+
65
+ Flutterby then walks this tree to write the resulting static site, optionally _applying filters_ first. For example, `index.html.md` will be exported as `index.html` after applying a Markdown filter.
66
+
67
+ These filters can be anything that modifies the Ruby object. Some examples:
68
+
69
+ - Rendering Markdown to HTML
70
+ - Parsing and executing ERB, Slim, HAML and other templating engines
71
+ - Processing Sass, CoffeeScript and the likes
72
+ - Leaving the current body intact, but modifying file attributes like the generated file's extension
73
+
74
+ Filters can be chained at any length you require.
75
+
76
+ Files and folders starting with underscores (eg. `_secret.html`) will never be exported. There's a number of special files that start with this underscore -- more on that later.
77
+
78
+ #### Using Ruby in templates:
79
+
80
+ Ruby code embedded in ERB, Slim etc. templates can interact with this object graph to do funky stuff like:
81
+
82
+ - including the rendered contents of another object (ie. partials)
83
+ - query the graph for certain objects (eg. "all objects in `/posts` that have `published_at` set")
84
+ - and much more, I guess!
85
+
86
+ #### Layout files:
87
+
88
+ When a `_layout` file is available in the same folder as the rendered page, it will be used to wrap the object's rendered output. These layout files stack, so you can have a `/posts/_layout.erb` with the layout for a single post, and a `/_layout.erb` with the layout of your site.
89
+
90
+ #### Extending views:
91
+
92
+ When a `_view.rb` file is available in the same folder as the rendered page, it will be evaluated against the current view object, allowing you to define your own view helpers. Like layouts, these will stack.
93
+
94
+ #### Writing Ruby nodes:
95
+
96
+ When a file has a `.rb` filter extension, the contained Ruby code will be evaluated against the Node instance. This allows you to build Ruby-based nodes. These nodes can do some powerful things, like creating other "virtual" nodes on the fly. I'm using this technique for the [archives on my blog](https://github.com/hmans/hmans_me/tree/master/site/archive).
97
+
98
+ When a file named `_node.rb` is present, the contained code will be evaluated against _all_ nodes in the same directory. This allows you to easily extend multiple nodes with functionality. [I'm using this in the template project](https://github.com/hmans/flutterby/tree/master/lib/templates/new_project/site/blog) to add `#title` and `#date` methods to blog posts.
99
+
47
100
 
48
101
  ## License
49
102
 
@@ -96,6 +96,10 @@ module Flutterby
96
96
  parent && parent.find(name)
97
97
  end
98
98
 
99
+ def siblings
100
+ parent && parent.children
101
+ end
102
+
99
103
  def find(path)
100
104
  return self if path.nil? || path.empty?
101
105
 
@@ -1,3 +1,3 @@
1
1
  module Flutterby
2
- VERSION = "0.0.21"
2
+ VERSION = "0.0.22"
3
3
  end
@@ -15,8 +15,12 @@ module Flutterby
15
15
  find(expr).render(*args)
16
16
  end
17
17
 
18
- def find(expr)
19
- node.find(expr) or raise "No node found for #{expr}"
18
+ def find(*args)
19
+ node.find(*args) or raise "No node found for #{args}"
20
+ end
21
+
22
+ def siblings(*args)
23
+ node.siblings(*args)
20
24
  end
21
25
 
22
26
  class << self
@@ -4,8 +4,11 @@
4
4
  <meta charset="utf-8">
5
5
  <title>My Site</title>
6
6
  <link rel="stylesheet" href="/css/styles.css">
7
+ <script src="/js/app.js"></script>
7
8
  </head>
8
9
  <body>
9
- <%= yield %>
10
+ <div class="container">
11
+ <%= yield %>
12
+ </div>
10
13
  </body>
11
14
  </html>
@@ -0,0 +1,5 @@
1
+ ---
2
+ title: Hello World!
3
+ ---
4
+
5
+ This is your first blog post!
@@ -0,0 +1,7 @@
1
+ article.post
2
+ .post-meta
3
+ = date_format page.date, "%B %e, %Y"
4
+
5
+ h1 = page.title
6
+
7
+ == page.body
@@ -0,0 +1,6 @@
1
+ ul.post-list
2
+ - for post in blog_posts
3
+ li
4
+ .post-meta = date_format post.date, "%B %e, %Y"
5
+
6
+ a href=post.url = post.title
@@ -0,0 +1,7 @@
1
+ def date
2
+ data["date"]
3
+ end
4
+
5
+ def title
6
+ data["title"]
7
+ end
@@ -0,0 +1,6 @@
1
+ def blog_posts
2
+ siblings
3
+ .select { |p| p.data["date"] }
4
+ .sort_by { |p| p.data["date"] }
5
+ .reverse
6
+ end
@@ -1 +1,28 @@
1
- /* add your SCSS here */
1
+ body {
2
+ background-color: #fff;
3
+ color: #444;
4
+ font: 18px/1.5 Arial,Helvetica,sans-serif;
5
+ }
6
+
7
+ div.container {
8
+ max-width: 800px;
9
+ margin: 0 auto;
10
+ padding: 30px;
11
+ }
12
+
13
+ h1 {
14
+ font-family: "Arial Black";
15
+ }
16
+
17
+ a {
18
+ color: blue;
19
+ }
20
+
21
+ .post-meta {
22
+ color: grey;
23
+ }
24
+
25
+ ul.post-list {
26
+ list-style: none;
27
+ padding-left: 0;
28
+ }
@@ -0,0 +1,7 @@
1
+ <h1>Hi!</h1>
2
+
3
+ <p>This is my new website!</p>
4
+
5
+
6
+ <h3>Latest Posts:</h3>
7
+ <%= find("/blog/_list").render(layout: false) %>
@@ -0,0 +1 @@
1
+ /* insert your JavaScript here */
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.0.21
4
+ version: 0.0.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hendrik Mans
@@ -294,8 +294,14 @@ files:
294
294
  - lib/templates/new_project/.gitignore
295
295
  - lib/templates/new_project/Gemfile
296
296
  - lib/templates/new_project/site/_layout.erb
297
+ - lib/templates/new_project/site/blog/2017-01-01-hello-world.html.md
298
+ - lib/templates/new_project/site/blog/_layout.slim
299
+ - lib/templates/new_project/site/blog/_list.html.slim
300
+ - lib/templates/new_project/site/blog/_node.rb
301
+ - lib/templates/new_project/site/blog/_view.rb
297
302
  - lib/templates/new_project/site/css/styles.css.scss
298
- - lib/templates/new_project/site/index.html.md
303
+ - lib/templates/new_project/site/index.html.erb
304
+ - lib/templates/new_project/site/js/app.js
299
305
  homepage: https://github.com/hmans/flutterby
300
306
  licenses:
301
307
  - MIT
@@ -316,7 +322,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
316
322
  version: '0'
317
323
  requirements: []
318
324
  rubyforge_project:
319
- rubygems_version: 2.6.8
325
+ rubygems_version: 2.5.2
320
326
  signing_key:
321
327
  specification_version: 4
322
328
  summary: There are many static site generators. This is mine.
@@ -1,3 +0,0 @@
1
- # Hi!
2
-
3
- This is my new website!