flutterby 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/generate +6 -0
- data/bin/rake +17 -0
- data/bin/rspec +17 -0
- data/bin/server +7 -0
- data/bin/setup +8 -0
- data/exe/flutterby +3 -0
- data/flutterby.gemspec +36 -0
- data/in/_layout.erb +19 -0
- data/in/about.html.md +3 -0
- data/in/contact.html.erb +3 -0
- data/in/index.html.erb +11 -0
- data/in/posts/_layout.slim +7 -0
- data/in/posts/hello-world.html.md +6 -0
- data/in/posts/really-old-blog-post.html.md +8 -0
- data/in/slim-test.html.slim +3 -0
- data/in/styles.css.scss +160 -0
- data/lib/flutterby.rb +20 -0
- data/lib/flutterby/cli.rb +33 -0
- data/lib/flutterby/entity.rb +79 -0
- data/lib/flutterby/file.rb +102 -0
- data/lib/flutterby/folder.rb +34 -0
- data/lib/flutterby/server.rb +13 -0
- data/lib/flutterby/version.rb +3 -0
- data/lib/flutterby/view.rb +13 -0
- metadata +232 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 20cc78c87b60aef744ffbc565db9bee17d25733f
|
4
|
+
data.tar.gz: '09966bb3f860d28727e6569e73b105679ac39045'
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 94a9745b04134116f517348ebf0dc3569827226d67ee04fcfd59928781b15c12cf47ac58e4eb1d99b1f3eee4df020caf0857b53a8577f26881d755d2c7886fdf
|
7
|
+
data.tar.gz: d46433b7fd0c1ec835032739bd39afaf320e16f60d8f43248dbfc6b54a35711e76373a13f817cceadc3adc492506b47471ef7de2da974643a212a12b79d28cad
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Hendrik Mans
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Flutterby
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/flutterby`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'flutterby'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install flutterby
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/flutterby.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "flutterby"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/generate
ADDED
data/bin/rake
ADDED
@@ -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 'rake' 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("rake", "rake")
|
data/bin/rspec
ADDED
@@ -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 'rspec' 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("rspec-core", "rspec")
|
data/bin/server
ADDED
data/bin/setup
ADDED
data/exe/flutterby
ADDED
data/flutterby.gemspec
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'flutterby/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "flutterby"
|
8
|
+
spec.version = Flutterby::VERSION
|
9
|
+
spec.authors = ["Hendrik Mans"]
|
10
|
+
spec.email = ["hendrik@mans.de"]
|
11
|
+
|
12
|
+
spec.summary = %q{There are many static site generators. This is mine.}
|
13
|
+
spec.description = %q{There are many static site generators. This is mine.}
|
14
|
+
spec.homepage = "https://github.com/hmans/flutterby"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = ["flutterby"]
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
27
|
+
spec.add_development_dependency 'awesome_print'
|
28
|
+
|
29
|
+
spec.add_dependency 'commander'
|
30
|
+
spec.add_dependency 'slodown'
|
31
|
+
spec.add_dependency 'sass'
|
32
|
+
spec.add_dependency 'tilt'
|
33
|
+
spec.add_dependency 'slim'
|
34
|
+
spec.add_dependency 'toml-rb'
|
35
|
+
spec.add_dependency 'rack'
|
36
|
+
end
|
data/in/_layout.erb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title>The Blawg of Hendrik Mans</title>
|
6
|
+
<link rel="stylesheet" href="/styles.css">
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
<div class="container">
|
10
|
+
<nav role="main">
|
11
|
+
<a href="/">hmans is blogging, yo</a>
|
12
|
+
</nav>
|
13
|
+
|
14
|
+
<main role="main">
|
15
|
+
<%= yield %>
|
16
|
+
</main>
|
17
|
+
</div>
|
18
|
+
</body>
|
19
|
+
</html>
|
data/in/about.html.md
ADDED
data/in/contact.html.erb
ADDED
data/in/index.html.erb
ADDED
data/in/styles.css.scss
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
@import 'https://fonts.googleapis.com/css?family=Noto+Sans:400,700,900|EB+Garamond';
|
2
|
+
|
3
|
+
$col1: steelblue;
|
4
|
+
$col2: peru;
|
5
|
+
$col3: rgb(138, 138, 138);
|
6
|
+
$col-link: #666;
|
7
|
+
|
8
|
+
$font: 16px/1.5 "Noto Sans","Helvetica Neue",Arial,sans-serif;
|
9
|
+
|
10
|
+
* { box-sizing: inherit; }
|
11
|
+
html, body { box-sizing: border-box; }
|
12
|
+
|
13
|
+
body {
|
14
|
+
font: $font;
|
15
|
+
background-color: white;
|
16
|
+
color: #333;
|
17
|
+
}
|
18
|
+
|
19
|
+
.container {
|
20
|
+
margin-left: auto;
|
21
|
+
margin-right: auto;
|
22
|
+
max-width: 800px;
|
23
|
+
padding: 50px;
|
24
|
+
}
|
25
|
+
|
26
|
+
nav[role="main"] {
|
27
|
+
color: grey;
|
28
|
+
font-size: 0.825em;
|
29
|
+
|
30
|
+
a { color: inherit; }
|
31
|
+
}
|
32
|
+
|
33
|
+
main {
|
34
|
+
margin-top: 2em;
|
35
|
+
}
|
36
|
+
|
37
|
+
h1, h2, h3, h4, h5, h6 {
|
38
|
+
font-size: inherit;
|
39
|
+
}
|
40
|
+
|
41
|
+
a {
|
42
|
+
color: $col1;
|
43
|
+
}
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
/* action lists */
|
48
|
+
ul.actions {
|
49
|
+
list-style: none;
|
50
|
+
padding-left: 0;
|
51
|
+
li {
|
52
|
+
display: inline-block;
|
53
|
+
margin-right: 0.5em;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
|
58
|
+
/* buttons */
|
59
|
+
button, a.button {
|
60
|
+
display: inline-block;
|
61
|
+
line-height: 2em;
|
62
|
+
padding: 0 1em;
|
63
|
+
border-radius: 2px;
|
64
|
+
background-color: $col1;
|
65
|
+
color: white;
|
66
|
+
text-decoration: none;
|
67
|
+
font-size: 0.825em;
|
68
|
+
border: none;
|
69
|
+
cursor: pointer;
|
70
|
+
|
71
|
+
&.button-grey {
|
72
|
+
background-color: lightgrey;
|
73
|
+
color: dimgrey;
|
74
|
+
}
|
75
|
+
|
76
|
+
&.button-red {
|
77
|
+
background-color: tomato;
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
/* forms */
|
86
|
+
label {
|
87
|
+
display: block;
|
88
|
+
font-weight: bold;
|
89
|
+
abbr { color: grey; text-decoration: none !important }
|
90
|
+
}
|
91
|
+
|
92
|
+
input, textarea, select {
|
93
|
+
font: inherit;
|
94
|
+
}
|
95
|
+
|
96
|
+
input.string, input.password, input.email, textarea {
|
97
|
+
width: 100%;
|
98
|
+
padding: 5px;
|
99
|
+
border: 1px solid lightgrey;
|
100
|
+
}
|
101
|
+
|
102
|
+
input[type="submit"] {
|
103
|
+
@extend button;
|
104
|
+
}
|
105
|
+
|
106
|
+
.input.field_with_errors {
|
107
|
+
input, textarea { border-color: crimson }
|
108
|
+
}
|
109
|
+
|
110
|
+
textarea {
|
111
|
+
height: 7em;
|
112
|
+
}
|
113
|
+
|
114
|
+
textarea#post_body {
|
115
|
+
height: 18em;
|
116
|
+
}
|
117
|
+
|
118
|
+
.input {
|
119
|
+
margin: 1em 0;
|
120
|
+
}
|
121
|
+
|
122
|
+
.error, .help-block {
|
123
|
+
color: crimson;
|
124
|
+
font-size: 0.825em;
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
/* stupid non-UJS link forms */
|
129
|
+
|
130
|
+
form.link {
|
131
|
+
display: inline;
|
132
|
+
}
|
133
|
+
|
134
|
+
/* post specific */
|
135
|
+
|
136
|
+
article.post {
|
137
|
+
margin: 4em 0;
|
138
|
+
|
139
|
+
.meta {
|
140
|
+
color: lightgrey;
|
141
|
+
font-size: 0.825em;
|
142
|
+
|
143
|
+
a {
|
144
|
+
color: inherit;
|
145
|
+
text-decoration: none;
|
146
|
+
&:hover {
|
147
|
+
text-decoration: underline;
|
148
|
+
}
|
149
|
+
}
|
150
|
+
}
|
151
|
+
|
152
|
+
h1 {
|
153
|
+
font: 44px "EB Garamond", serif;
|
154
|
+
color: #555;
|
155
|
+
}
|
156
|
+
|
157
|
+
h2 {
|
158
|
+
color: $col2;
|
159
|
+
}
|
160
|
+
}
|
data/lib/flutterby.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require "flutterby/version"
|
2
|
+
require "flutterby/entity"
|
3
|
+
require "flutterby/file"
|
4
|
+
require "flutterby/folder"
|
5
|
+
require "flutterby/view"
|
6
|
+
require "flutterby/server"
|
7
|
+
|
8
|
+
module Flutterby
|
9
|
+
def Flutterby.from(fs_path, name: nil, parent: nil)
|
10
|
+
name ||= ::File.basename(fs_path)
|
11
|
+
|
12
|
+
if ::File.directory?(fs_path)
|
13
|
+
Folder.new(name, fs_path: fs_path, parent: parent)
|
14
|
+
elsif ::File.file?(fs_path)
|
15
|
+
File.new(name, fs_path: fs_path, parent: parent)
|
16
|
+
else
|
17
|
+
raise "Path #{fs_path} could not be found."
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'commander'
|
2
|
+
require 'flutterby'
|
3
|
+
|
4
|
+
Commander.configure do
|
5
|
+
program :name, 'Flutterby'
|
6
|
+
program :version, Flutterby::VERSION
|
7
|
+
program :description, 'There are many static site generators. This one is mine.'
|
8
|
+
|
9
|
+
command :build do |c|
|
10
|
+
c.syntax = 'flutterby build [options]'
|
11
|
+
c.description = "Build your website."
|
12
|
+
|
13
|
+
c.option '--in DIR', String, "Directory containing your source files"
|
14
|
+
c.option '--out DIR', String, "Target directory"
|
15
|
+
|
16
|
+
c.action do |args, options|
|
17
|
+
options.default in: "./site/", out: "./_build/"
|
18
|
+
|
19
|
+
root = Flutterby.from(options.in, name: "/")
|
20
|
+
root.export(options.out)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
command :test do |c|
|
25
|
+
c.syntax = 'flutterby test'
|
26
|
+
c.description = 'TEST. Yo.'
|
27
|
+
c.action do |args, options|
|
28
|
+
root = Flutterby.from("./in", name: "/")
|
29
|
+
root.list
|
30
|
+
root.export("./out/")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module Flutterby
|
2
|
+
class Entity
|
3
|
+
attr_reader :name, :ext, :filters, :parent, :fs_path, :path
|
4
|
+
|
5
|
+
def initialize(name, parent: nil, fs_path: nil)
|
6
|
+
@parent = parent
|
7
|
+
|
8
|
+
# Extract name, extension, and filters from given name
|
9
|
+
parts = name.split(".")
|
10
|
+
@name = parts.shift
|
11
|
+
@ext = parts.shift
|
12
|
+
@filters = parts
|
13
|
+
|
14
|
+
# Calculate full path
|
15
|
+
@path = parent ? ::File.join(parent.path, full_name) : full_name
|
16
|
+
|
17
|
+
# If a filesystem path was given, read the entity from disk
|
18
|
+
if fs_path
|
19
|
+
@fs_path = ::File.expand_path(fs_path)
|
20
|
+
read
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def list(indent: 0)
|
25
|
+
puts "#{" " * indent}[#{self.class}] #{path}"
|
26
|
+
end
|
27
|
+
|
28
|
+
def export(out_path)
|
29
|
+
if should_publish?
|
30
|
+
out_path = full_path(out_path)
|
31
|
+
puts "* #{@name}: #{out_path}"
|
32
|
+
write_static(out_path)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def process
|
37
|
+
end
|
38
|
+
|
39
|
+
def url
|
40
|
+
@url ||= ::File.join(parent ? parent.url : "/", full_name)
|
41
|
+
end
|
42
|
+
|
43
|
+
def full_path(base)
|
44
|
+
::File.expand_path(::File.join(base, full_name))
|
45
|
+
end
|
46
|
+
|
47
|
+
def call(env)
|
48
|
+
['200', {"Content-Type" => "text/html"}, [name]]
|
49
|
+
end
|
50
|
+
|
51
|
+
def root
|
52
|
+
parent ? parent.root : self
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def sibling(name)
|
58
|
+
parent && parent.find(name)
|
59
|
+
end
|
60
|
+
|
61
|
+
def full_name
|
62
|
+
@full_name ||= [name, ext].compact.join(".")
|
63
|
+
end
|
64
|
+
|
65
|
+
def read
|
66
|
+
end
|
67
|
+
|
68
|
+
def write_static(path)
|
69
|
+
end
|
70
|
+
|
71
|
+
def should_publish?
|
72
|
+
!name.start_with?("_")
|
73
|
+
end
|
74
|
+
|
75
|
+
def page?
|
76
|
+
false
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require 'slodown'
|
2
|
+
require 'sass'
|
3
|
+
require 'tilt'
|
4
|
+
require 'slim'
|
5
|
+
require 'toml'
|
6
|
+
|
7
|
+
module Flutterby
|
8
|
+
class File < Entity
|
9
|
+
attr_reader :contents, :data
|
10
|
+
|
11
|
+
def read
|
12
|
+
@contents = ::File.read(fs_path)
|
13
|
+
@data = parse_frontmatter
|
14
|
+
end
|
15
|
+
|
16
|
+
def parse_frontmatter
|
17
|
+
data = {}
|
18
|
+
@contents.sub!(/\A\-\-\-\n(.+)\n\-\-\-\n/m) do
|
19
|
+
data.merge! YAML.load($1)
|
20
|
+
""
|
21
|
+
end
|
22
|
+
|
23
|
+
@contents.sub!(/\A\+\+\+\n(.+)\n\+\+\+\n/m) do
|
24
|
+
data.merge! TOML.parse($1)
|
25
|
+
""
|
26
|
+
end
|
27
|
+
|
28
|
+
data
|
29
|
+
end
|
30
|
+
|
31
|
+
def process!
|
32
|
+
# Apply processors
|
33
|
+
while filter = filters.pop do
|
34
|
+
meth = "process_#{filter}"
|
35
|
+
if respond_to?(meth)
|
36
|
+
send(meth)
|
37
|
+
else
|
38
|
+
puts "Woops, no #{meth} available :("
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def page?
|
44
|
+
ext == "html"
|
45
|
+
end
|
46
|
+
|
47
|
+
def view
|
48
|
+
@view ||= View.new(self)
|
49
|
+
end
|
50
|
+
|
51
|
+
def process_erb
|
52
|
+
tilt = Tilt["erb"].new { @contents }
|
53
|
+
@contents = tilt.render(view)
|
54
|
+
end
|
55
|
+
|
56
|
+
def process_slim
|
57
|
+
tilt = Tilt["slim"].new { @contents }
|
58
|
+
@contents = tilt.render(view)
|
59
|
+
end
|
60
|
+
|
61
|
+
def process_md
|
62
|
+
@contents = Slodown::Formatter.new(@contents).complete.to_s
|
63
|
+
end
|
64
|
+
|
65
|
+
def process_scss
|
66
|
+
engine = Sass::Engine.new(@contents, syntax: :scss)
|
67
|
+
@contents = engine.render
|
68
|
+
end
|
69
|
+
|
70
|
+
def apply_layout
|
71
|
+
output = @contents
|
72
|
+
|
73
|
+
# collect layouts to apply
|
74
|
+
layouts = []
|
75
|
+
current = self
|
76
|
+
while current = current.parent
|
77
|
+
if layout = current.find("_layout")
|
78
|
+
layouts << layout
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# Apply all layouts in order
|
83
|
+
layouts.each do |layout|
|
84
|
+
tilt = Tilt[layout.ext].new { layout.contents }
|
85
|
+
output = tilt.render(view) { output }
|
86
|
+
end
|
87
|
+
|
88
|
+
output
|
89
|
+
end
|
90
|
+
|
91
|
+
def apply_layout?
|
92
|
+
page?
|
93
|
+
end
|
94
|
+
|
95
|
+
def write_static(path)
|
96
|
+
process!
|
97
|
+
output = apply_layout? ? apply_layout : @contents
|
98
|
+
|
99
|
+
::File.write(path, output)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Flutterby
|
2
|
+
class Folder < Entity
|
3
|
+
attr_reader :children
|
4
|
+
|
5
|
+
def list(indent: 0)
|
6
|
+
super
|
7
|
+
children.each { |c| c.list(indent: indent + 1) }
|
8
|
+
end
|
9
|
+
|
10
|
+
def read
|
11
|
+
@children = Dir[::File.join(fs_path, "*")].map do |entry|
|
12
|
+
Flutterby.from(entry, parent: self)
|
13
|
+
end.compact
|
14
|
+
end
|
15
|
+
|
16
|
+
def write_static(path)
|
17
|
+
Dir.mkdir(path) unless ::File.exists?(path)
|
18
|
+
|
19
|
+
@children.each do |child|
|
20
|
+
child.export(path)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def find(name)
|
25
|
+
@children.find { |c| c.name == name }
|
26
|
+
end
|
27
|
+
|
28
|
+
# Returns all children that will compile to a HTML page.
|
29
|
+
#
|
30
|
+
def pages
|
31
|
+
children.select { |c| c.ext == "html" }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,232 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: flutterby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Hendrik Mans
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-01-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.13'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: awesome_print
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: commander
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: slodown
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: sass
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: tilt
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: slim
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: toml-rb
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rack
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :runtime
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
description: There are many static site generators. This is mine.
|
168
|
+
email:
|
169
|
+
- hendrik@mans.de
|
170
|
+
executables:
|
171
|
+
- flutterby
|
172
|
+
extensions: []
|
173
|
+
extra_rdoc_files: []
|
174
|
+
files:
|
175
|
+
- ".gitignore"
|
176
|
+
- ".rspec"
|
177
|
+
- ".travis.yml"
|
178
|
+
- Gemfile
|
179
|
+
- LICENSE.txt
|
180
|
+
- README.md
|
181
|
+
- Rakefile
|
182
|
+
- bin/console
|
183
|
+
- bin/generate
|
184
|
+
- bin/rake
|
185
|
+
- bin/rspec
|
186
|
+
- bin/server
|
187
|
+
- bin/setup
|
188
|
+
- exe/flutterby
|
189
|
+
- flutterby.gemspec
|
190
|
+
- in/_layout.erb
|
191
|
+
- in/about.html.md
|
192
|
+
- in/contact.html.erb
|
193
|
+
- in/index.html.erb
|
194
|
+
- in/posts/_layout.slim
|
195
|
+
- in/posts/hello-world.html.md
|
196
|
+
- in/posts/really-old-blog-post.html.md
|
197
|
+
- in/slim-test.html.slim
|
198
|
+
- in/styles.css.scss
|
199
|
+
- lib/flutterby.rb
|
200
|
+
- lib/flutterby/cli.rb
|
201
|
+
- lib/flutterby/entity.rb
|
202
|
+
- lib/flutterby/file.rb
|
203
|
+
- lib/flutterby/folder.rb
|
204
|
+
- lib/flutterby/server.rb
|
205
|
+
- lib/flutterby/version.rb
|
206
|
+
- lib/flutterby/view.rb
|
207
|
+
- out/.gitkeep
|
208
|
+
homepage: https://github.com/hmans/flutterby
|
209
|
+
licenses:
|
210
|
+
- MIT
|
211
|
+
metadata: {}
|
212
|
+
post_install_message:
|
213
|
+
rdoc_options: []
|
214
|
+
require_paths:
|
215
|
+
- lib
|
216
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
217
|
+
requirements:
|
218
|
+
- - ">="
|
219
|
+
- !ruby/object:Gem::Version
|
220
|
+
version: '0'
|
221
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
222
|
+
requirements:
|
223
|
+
- - ">="
|
224
|
+
- !ruby/object:Gem::Version
|
225
|
+
version: '0'
|
226
|
+
requirements: []
|
227
|
+
rubyforge_project:
|
228
|
+
rubygems_version: 2.5.2
|
229
|
+
signing_key:
|
230
|
+
specification_version: 4
|
231
|
+
summary: There are many static site generators. This is mine.
|
232
|
+
test_files: []
|