bobkit 0.0.1 → 0.0.2
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 +4 -4
- data/README.md +196 -6
- data/lib/bobkit.rb +9 -2
- data/lib/bobkit/actions.rb +8 -36
- data/lib/bobkit/assets.rb +14 -0
- data/lib/bobkit/coffee_bridge.rb +13 -0
- data/lib/bobkit/file_helpers.rb +14 -3
- data/lib/bobkit/location_options.rb +41 -0
- data/lib/bobkit/options_base.rb +19 -0
- data/lib/bobkit/{sass_extra.rb → sass_bridge.rb} +3 -2
- data/lib/bobkit/scope.rb +1 -1
- data/lib/bobkit/{slim_extra.rb → slim_bridge.rb} +1 -1
- data/lib/bobkit/version.rb +1 -1
- metadata +51 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7db6c694ea1adaf5fec4c8dab145d0204744aca3
|
4
|
+
data.tar.gz: 369d8e39afb9dea61523f7f8208283946d840b9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed1294af999ff86255b1fd08091085478b19c3440955c706b220de5ed0dd86b029b3be09974cc9a36376a3691d5b8201fa2842600cc0a6214bc9134b1712a458
|
7
|
+
data.tar.gz: f88938070983f3e62cbf2705449a66de85b4d5512624851d93e1b76b03ee85728b79634e94d42930a6a44d6ff10a171c93db607062e182a51c065ec653641890
|
data/README.md
CHANGED
@@ -1,13 +1,203 @@
|
|
1
1
|
Bobkit - Site Generation Toolkit
|
2
2
|
==================================================
|
3
3
|
|
4
|
+
[](https://rubygems.org/gems/bobkit)
|
5
|
+
[](https://travis-ci.org/DannyBen/bobkit)
|
6
|
+
[](https://codeclimate.com/github/DannyBen/bobkit)
|
7
|
+
[](https://gemnasium.com/DannyBen/bobkit)
|
8
|
+
|
9
|
+
---
|
10
|
+
|
11
|
+
Bobkit is a lightweight tookit for generating static websites with Slim, SCSS
|
12
|
+
and CoffeeScript.
|
13
|
+
|
14
|
+
The design intentions were:
|
15
|
+
|
16
|
+
- To provide easy to use wrapper methods for Slim, SCSS and CoffeeScript
|
17
|
+
- To not impose any directory structure (this is not a blog generator...).
|
18
|
+
- To allow you to use standard ruby for generating your site.
|
19
|
+
- To be packaged as a library, and not a command line tool.
|
20
|
+
- To provide sensible default locations that are easily overridable.
|
21
|
+
- To add `render` and `layout` support to Slim (Rails-like).
|
22
|
+
- To add `@import 'globbing/*`` support to SCSS (Rails-like).
|
23
|
+
|
24
|
+
---
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
Install
|
29
|
+
--------------------------------------------------
|
30
|
+
|
31
|
+
`gem install bobkit`
|
32
|
+
|
33
|
+
Or with Bundler:
|
34
|
+
|
35
|
+
`gem 'bobkit'`
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
Usage
|
40
|
+
--------------------------------------------------
|
41
|
+
|
42
|
+
The basic usage pattern is this:
|
43
|
+
|
44
|
+
- Create a ruby file and include Bobkit
|
45
|
+
- Create your input folders (for Slim templates, SCSS files etc.)
|
46
|
+
wherever you want (or use the default locations, see below).
|
47
|
+
- In your Ruby script, call Bobkit methods to generate your site.
|
48
|
+
|
49
|
+
### Example
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
require 'bobkit'
|
53
|
+
include Bobkit::Actions
|
54
|
+
|
55
|
+
# Convert Slim to HTML string
|
56
|
+
html = render 'youtube', video: 'hi9tOILaiNs'
|
57
|
+
puts html
|
58
|
+
|
59
|
+
# Convert Slim to HTML file
|
60
|
+
# This will use 'templates/youtube.slim', with the layout file
|
61
|
+
# `templates/layouts/default.slim` and will generate 'output/bobcat.html'.
|
62
|
+
render 'youtube', layout: 'default', video: 'hi9tOILaiNs', output: 'bobcat'
|
63
|
+
|
64
|
+
# Compile SCSS
|
65
|
+
# This will convert `styles/main.scss` to `output/css/style.css`
|
66
|
+
compile_css 'main', output: 'style'
|
67
|
+
```
|
68
|
+
|
69
|
+
See more examples in the [Examples folder][1]
|
70
|
+
|
71
|
+
|
72
|
+
Reference
|
73
|
+
--------------------------------------------------
|
74
|
+
|
75
|
+
### Setting folder locations and options
|
76
|
+
|
77
|
+
Bobkit has defaults for everything, but you can easily change them.
|
78
|
+
Each of these methods can be called with or without a parameter. When
|
79
|
+
called without a parameter, it will simply return the value.
|
80
|
+
|
81
|
+
```ruby
|
82
|
+
# Location of source Slim templates. Default: "templates"
|
83
|
+
templates_folder 'views'
|
84
|
+
|
85
|
+
# Location of source Slim templates for layouts.
|
86
|
+
# Default: "#{templates_folder}/layouts"
|
87
|
+
layouts_folder 'my_layouts'
|
88
|
+
|
89
|
+
# Location of the source SCSS files. Default: "styles"
|
90
|
+
styles_folder 'styles'
|
91
|
+
|
92
|
+
# Output location. Default: "output"
|
93
|
+
output_folder 'site'
|
94
|
+
|
95
|
+
# Output location for CSS. Default: "#{output_folder}/css"
|
96
|
+
css_output_folder "#{output_folder}/stylesheets"
|
97
|
+
|
98
|
+
# Location of other source asset files (images etc.). Default: 'assets'
|
99
|
+
assets_folder 'files'
|
100
|
+
|
101
|
+
# Output location for assets. Default: "#{output_folder}/assets"
|
102
|
+
assets_output_folder 'images'
|
103
|
+
|
104
|
+
# Options for Slim generation.
|
105
|
+
slim_options pretty: true, disable_escape: true
|
106
|
+
|
107
|
+
# Options for SCSS generation.
|
108
|
+
scss_options cache: true, syntax: :scss, style: :nested
|
109
|
+
|
110
|
+
# Restore all settings to defaults
|
111
|
+
use_defaults
|
112
|
+
```
|
113
|
+
|
114
|
+
|
115
|
+
### Slim
|
116
|
+
|
117
|
+
```ruby
|
118
|
+
# You can set a scope before calling any `render`
|
119
|
+
scope CatVideo.new
|
120
|
+
html = render 'cats'
|
121
|
+
|
122
|
+
# You can use a hash as scope
|
123
|
+
scope email: 'bob@kit.com', name: 'Bob'
|
124
|
+
html = render 'user'
|
125
|
+
|
126
|
+
# You can send a scope directly to `render`
|
127
|
+
html = render 'user', email: 'bob@kit.com', name: 'Bob'
|
128
|
+
|
129
|
+
# You can render with a layout
|
130
|
+
html = render 'user', layout: 'default', email: 'bob@kit.com'
|
131
|
+
|
132
|
+
# You can save to a file in the `output_folder`
|
133
|
+
render 'user', layout: 'default', email: 'bob@kit.com', output: 'bob'
|
134
|
+
```
|
135
|
+
|
136
|
+
|
137
|
+
### SCSS
|
138
|
+
|
139
|
+
```ruby
|
140
|
+
# You can compile SCSS to a CSS string, to do as you please with it
|
141
|
+
css = compile_css 'style'
|
142
|
+
|
143
|
+
# You can compile SCSS directly to a file
|
144
|
+
compile_css 'style', output: 'main'
|
145
|
+
```
|
146
|
+
|
147
|
+
### CoffeeScript
|
148
|
+
|
149
|
+
```ruby
|
150
|
+
# You can compile CoffeeScript to a Javascript string
|
151
|
+
js = compile_js 'script'
|
152
|
+
|
153
|
+
# You can compile CoffeeScript directly to a file
|
154
|
+
compile_js 'script', output: 'main'
|
155
|
+
```
|
156
|
+
|
157
|
+
|
158
|
+
### Asset helpers
|
159
|
+
|
160
|
+
Anything other than CSS, Javascript and HTML is considered an asset.
|
161
|
+
These are some helpers to help you move them acount from input to output
|
162
|
+
folders.
|
163
|
+
|
164
|
+
```ruby
|
165
|
+
# Copy a file from the `assets_folder` to the `assets_output_folder`
|
166
|
+
copy_asset 'presskit.zip'
|
167
|
+
|
168
|
+
# Copy a folder
|
169
|
+
copy_asset 'images'
|
170
|
+
```
|
171
|
+
|
172
|
+
|
173
|
+
### Low level file and folder helpers
|
174
|
+
|
175
|
+
If you want more control over what the `copy_asset` method provides, you
|
176
|
+
can use any of these methods.
|
177
|
+
|
178
|
+
```ruby
|
179
|
+
# Copy a file - needed parent folders will be created as needed
|
180
|
+
copy_file 'exact/path.zip', 'exact/output/file.zip'
|
181
|
+
|
182
|
+
# Copy a folder - needed parent folders will be created as needed
|
183
|
+
copy_file 'exact/path', 'exact/output/folder'
|
184
|
+
|
185
|
+
# Create folder, and any of the needed parent folders
|
186
|
+
create_folder 'my_folder'
|
187
|
+
|
188
|
+
# Create folder for a file, with any of the needed parent folders
|
189
|
+
create_folder_for 'some/folder/with/file.png'
|
190
|
+
```
|
191
|
+
|
4
192
|
|
5
193
|
Todo
|
6
194
|
--------------------------------------------------
|
7
195
|
|
8
|
-
[ ]
|
9
|
-
[ ]
|
10
|
-
[ ]
|
11
|
-
[ ]
|
12
|
-
[ ]
|
13
|
-
|
196
|
+
- [ ] YAML loader (data_folder?)
|
197
|
+
- [ ] CSV Loader (data_folder?)
|
198
|
+
- [ ] Maybe: Include file watcher and auto generate
|
199
|
+
- [ ] Maybe: Render from/to Markdown
|
200
|
+
- [ ] Maybe: Render to JSON
|
201
|
+
|
202
|
+
|
203
|
+
[1]: https://github.com/DannyBen/bobkit/tree/master/examples
|
data/lib/bobkit.rb
CHANGED
@@ -1,9 +1,16 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
require 'sass'
|
3
|
+
require 'sass-globbing'
|
3
4
|
require 'slim'
|
5
|
+
require 'coffee_script'
|
4
6
|
|
7
|
+
require 'bobkit/options_base'
|
8
|
+
require 'bobkit/location_options'
|
5
9
|
require 'bobkit/file_helpers'
|
6
|
-
require 'bobkit/
|
7
|
-
require 'bobkit/
|
10
|
+
require 'bobkit/sass_bridge'
|
11
|
+
require 'bobkit/slim_bridge'
|
12
|
+
require 'bobkit/coffee_bridge'
|
13
|
+
require 'bobkit/assets'
|
14
|
+
|
8
15
|
require 'bobkit/scope'
|
9
16
|
require 'bobkit/actions'
|
data/lib/bobkit/actions.rb
CHANGED
@@ -1,27 +1,11 @@
|
|
1
1
|
module Bobkit
|
2
2
|
module Actions
|
3
|
-
include
|
4
|
-
include
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
def layouts_folder(path=nil)
|
11
|
-
setopt :layouts_folder, path, "#{templates_folder}/layouts"
|
12
|
-
end
|
13
|
-
|
14
|
-
def styles_folder(path=nil)
|
15
|
-
setopt :styles_folder, path, 'styles'
|
16
|
-
end
|
17
|
-
|
18
|
-
def output_folder(path=nil)
|
19
|
-
setopt :output_folder, path, 'output'
|
20
|
-
end
|
21
|
-
|
22
|
-
def css_output_folder(path=nil)
|
23
|
-
setopt :css_output_folder, path, "#{output_folder}/css"
|
24
|
-
end
|
3
|
+
include OptionsBase
|
4
|
+
include LocationOptions
|
5
|
+
include SassBridge
|
6
|
+
include SlimBridge
|
7
|
+
include CoffeeBridge
|
8
|
+
include Assets
|
25
9
|
|
26
10
|
def slim_options(options=nil)
|
27
11
|
setopt :slim_options, options, slim_defaults
|
@@ -35,10 +19,6 @@ module Bobkit
|
|
35
19
|
scope ? setopt(:scope, Scope.new(scope)) : options[:scope]
|
36
20
|
end
|
37
21
|
|
38
|
-
def use_defaults
|
39
|
-
@@options = {}
|
40
|
-
end
|
41
|
-
|
42
22
|
protected
|
43
23
|
|
44
24
|
def slim_defaults
|
@@ -46,17 +26,9 @@ module Bobkit
|
|
46
26
|
end
|
47
27
|
|
48
28
|
def scss_defaults
|
49
|
-
{ cache: true, syntax: :scss, style: :nested
|
29
|
+
{ cache: true, syntax: :scss, style: :nested,
|
30
|
+
load_paths: [styles_folder] }
|
50
31
|
end
|
51
32
|
|
52
|
-
def setopt(key, value=nil, default=nil)
|
53
|
-
options[key] = value if value
|
54
|
-
options[key] ||= default
|
55
|
-
options[key]
|
56
|
-
end
|
57
|
-
|
58
|
-
def options
|
59
|
-
@@options ||= {}
|
60
|
-
end
|
61
33
|
end
|
62
34
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Bobkit
|
2
|
+
module Assets
|
3
|
+
include FileHelpers
|
4
|
+
|
5
|
+
def copy_asset(source, target=nil)
|
6
|
+
if target
|
7
|
+
target = "#{output_folder}/#{target}"
|
8
|
+
else
|
9
|
+
target = "#{assets_output_folder}/#{source}"
|
10
|
+
end
|
11
|
+
copy_entry "#{assets_folder}/#{source}", target
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Bobkit
|
2
|
+
module CoffeeBridge
|
3
|
+
include FileHelpers
|
4
|
+
|
5
|
+
def compile_js(file, options={})
|
6
|
+
@file = "#{coffee_folder}/#{file}.coffee"
|
7
|
+
content = CoffeeScript.compile File.read @file
|
8
|
+
output = options[:output]
|
9
|
+
create_file "#{js_output_folder}/#{output}.js", content if output
|
10
|
+
content
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/bobkit/file_helpers.rb
CHANGED
@@ -1,13 +1,24 @@
|
|
1
1
|
module Bobkit
|
2
2
|
module FileHelpers
|
3
|
+
def create_folder(path)
|
4
|
+
FileUtils.mkdir_p(path) unless File.directory?(path)
|
5
|
+
end
|
6
|
+
|
7
|
+
def create_folder_for(path)
|
8
|
+
create_folder File.dirname(path)
|
9
|
+
end
|
10
|
+
|
3
11
|
def create_file(path, content)
|
4
12
|
create_folder_for path
|
5
13
|
File.write path, content
|
6
14
|
end
|
7
15
|
|
8
|
-
def
|
9
|
-
|
10
|
-
FileUtils.
|
16
|
+
def copy_file(source, target)
|
17
|
+
create_folder_for target
|
18
|
+
FileUtils.copy_entry source, target
|
11
19
|
end
|
20
|
+
alias_method :copy_folder, :copy_file
|
21
|
+
alias_method :copy_entry, :copy_file
|
22
|
+
|
12
23
|
end
|
13
24
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Bobkit
|
2
|
+
module LocationOptions
|
3
|
+
include OptionsBase
|
4
|
+
|
5
|
+
def templates_folder(path=nil)
|
6
|
+
setopt :templates_folder, path, 'templates'
|
7
|
+
end
|
8
|
+
|
9
|
+
def layouts_folder(path=nil)
|
10
|
+
setopt :layouts_folder, path, "#{templates_folder}/layouts"
|
11
|
+
end
|
12
|
+
|
13
|
+
def styles_folder(path=nil)
|
14
|
+
setopt :styles_folder, path, 'styles'
|
15
|
+
end
|
16
|
+
|
17
|
+
def coffee_folder(path=nil)
|
18
|
+
setopt :coffee_folder, path, 'coffee'
|
19
|
+
end
|
20
|
+
|
21
|
+
def output_folder(path=nil)
|
22
|
+
setopt :output_folder, path, 'output'
|
23
|
+
end
|
24
|
+
|
25
|
+
def css_output_folder(path=nil)
|
26
|
+
setopt :css_output_folder, path, "#{output_folder}/css"
|
27
|
+
end
|
28
|
+
|
29
|
+
def js_output_folder(path=nil)
|
30
|
+
setopt :js_output_folder, path, "#{output_folder}/js"
|
31
|
+
end
|
32
|
+
|
33
|
+
def assets_folder(path=nil)
|
34
|
+
setopt :assets_folder, path, 'assets'
|
35
|
+
end
|
36
|
+
|
37
|
+
def assets_output_folder(path=nil)
|
38
|
+
setopt :assets_output_folder, path, "#{output_folder}/assets"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Bobkit
|
2
|
+
module OptionsBase
|
3
|
+
def use_defaults
|
4
|
+
@@options = {}
|
5
|
+
end
|
6
|
+
|
7
|
+
protected
|
8
|
+
|
9
|
+
def setopt(key, value=nil, default=nil)
|
10
|
+
options[key] = value if value
|
11
|
+
options[key] ||= default
|
12
|
+
options[key]
|
13
|
+
end
|
14
|
+
|
15
|
+
def options
|
16
|
+
@@options ||= {}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -1,10 +1,11 @@
|
|
1
1
|
module Bobkit
|
2
|
-
module
|
2
|
+
module SassBridge
|
3
3
|
include FileHelpers
|
4
4
|
|
5
5
|
def compile_css(file, options={})
|
6
6
|
@file = "#{styles_folder}/#{file}.scss"
|
7
|
-
|
7
|
+
extended_options = scss_options.merge({ filename: @file })
|
8
|
+
content = Sass::Engine.new(File.read(@file), extended_options).render
|
8
9
|
output = options[:output]
|
9
10
|
create_file "#{css_output_folder}/#{output}.css", content if output
|
10
11
|
content
|
data/lib/bobkit/scope.rb
CHANGED
data/lib/bobkit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bobkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Ben Shitrit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: slim
|
@@ -38,6 +38,34 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '3.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sass-globbing
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.1'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: coffee-script
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.4'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.4'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: runfile
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,7 +94,21 @@ dependencies:
|
|
66
94
|
- - "~>"
|
67
95
|
- !ruby/object:Gem::Version
|
68
96
|
version: '0.4'
|
69
|
-
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: byebug
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '8.2'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '8.2'
|
111
|
+
description: Lightweight Site Generation Toolkit with Slim, SCSS and CoffeeScript
|
70
112
|
email: db@dannyben.com
|
71
113
|
executables: []
|
72
114
|
extensions: []
|
@@ -75,10 +117,14 @@ files:
|
|
75
117
|
- README.md
|
76
118
|
- lib/bobkit.rb
|
77
119
|
- lib/bobkit/actions.rb
|
120
|
+
- lib/bobkit/assets.rb
|
121
|
+
- lib/bobkit/coffee_bridge.rb
|
78
122
|
- lib/bobkit/file_helpers.rb
|
79
|
-
- lib/bobkit/
|
123
|
+
- lib/bobkit/location_options.rb
|
124
|
+
- lib/bobkit/options_base.rb
|
125
|
+
- lib/bobkit/sass_bridge.rb
|
80
126
|
- lib/bobkit/scope.rb
|
81
|
-
- lib/bobkit/
|
127
|
+
- lib/bobkit/slim_bridge.rb
|
82
128
|
- lib/bobkit/version.rb
|
83
129
|
homepage: https://github.com/DannyBen/bobkit
|
84
130
|
licenses:
|