pieces 0.1.0
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 +3 -0
- data/.ruby-version +1 -0
- data/.travis.yml +3 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +21 -0
- data/README.md +53 -0
- data/Rakefile +2 -0
- data/bin/pieces +17 -0
- data/example/config/routes.yml +26 -0
- data/example/layouts/layout.html.mustache +15 -0
- data/example/pieces/post/post.css +3 -0
- data/example/pieces/post/post.html.mustache +7 -0
- data/lib/pieces.rb +6 -0
- data/lib/pieces/builder.rb +75 -0
- data/lib/pieces/generator.rb +14 -0
- data/lib/pieces/version.rb +3 -0
- data/pieces.gemspec +24 -0
- metadata +120 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bd176c28e444501f000b658818bf1ae701fa5a12
|
4
|
+
data.tar.gz: 5949e839b62e968d2adb00e17a5d85a110ab2ae8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b0a5169dc1346fc056c6ffdd9fc184a37eb41586a4d89f86c7c05cbf2bec328f28d502d4725b252329f68263cdae86218187ff255873403e3b2cdccd60bad873
|
7
|
+
data.tar.gz: 0d26d18a75598d1dfc9298ca35ee2b518526bfd697a0146ff33f86a38f09cec8e9edc1a8a89fe4f144f47d515596a591ec91a2abeaf1346b22845ea92e8f787b
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.2.1
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Luke Morton
|
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,53 @@
|
|
1
|
+
# Pieces
|
2
|
+
|
3
|
+
This gem will take your HTML and CSS components and compile them into a static
|
4
|
+
site. Very very alpha.
|
5
|
+
|
6
|
+
## Create new static site
|
7
|
+
|
8
|
+
To create a new static site with pieces:
|
9
|
+
|
10
|
+
```
|
11
|
+
gem install pieces
|
12
|
+
pieces init
|
13
|
+
```
|
14
|
+
|
15
|
+
## Create styleguide within existing application
|
16
|
+
|
17
|
+
Add pieces to your Gemfile:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
gem 'pieces'
|
21
|
+
```
|
22
|
+
|
23
|
+
Then run
|
24
|
+
|
25
|
+
```
|
26
|
+
bundle
|
27
|
+
pieces init styleguide
|
28
|
+
```
|
29
|
+
|
30
|
+
This will install pieces inside a subfolder called `styleguide/`.
|
31
|
+
|
32
|
+
## Building your site
|
33
|
+
|
34
|
+
Please follow examples for a howto right now. Once you've built the pieces
|
35
|
+
and routes for your site all you have to do is run:
|
36
|
+
|
37
|
+
```
|
38
|
+
pieces build
|
39
|
+
```
|
40
|
+
|
41
|
+
Make sure you run this from your pieces directory!
|
42
|
+
|
43
|
+
## Contributing
|
44
|
+
|
45
|
+
1. Fork it ( https://github.com/[my-github-username]/pieces/fork )
|
46
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
47
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
48
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
49
|
+
5. Create a new Pull Request
|
50
|
+
|
51
|
+
## Author
|
52
|
+
|
53
|
+
Luke Morton (again)
|
data/Rakefile
ADDED
data/bin/pieces
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'pieces'
|
5
|
+
|
6
|
+
case ARGV[0]
|
7
|
+
when 'init'
|
8
|
+
init_path = ARGV[1] || '.'
|
9
|
+
Pieces::Generator.new.init(path: init_path)
|
10
|
+
puts "Pieces placed in #{init_path}"
|
11
|
+
when 'build'
|
12
|
+
print 'Building pieces into current directory...'
|
13
|
+
Pieces::Builder.new.build(path: '.')
|
14
|
+
puts 'done.'
|
15
|
+
else
|
16
|
+
puts 'Run either `pieces init` or `pieces build`'
|
17
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
_global:
|
2
|
+
title_suffix: 'Your Site'
|
3
|
+
|
4
|
+
_layout: 'layout'
|
5
|
+
|
6
|
+
index:
|
7
|
+
_global:
|
8
|
+
title: 'Home'
|
9
|
+
pieces:
|
10
|
+
- post:
|
11
|
+
title: 'A block title'
|
12
|
+
content: '<p>Some paragraph</p>'
|
13
|
+
- post:
|
14
|
+
title: 'Another'
|
15
|
+
content: '<p>Another thing.</p>'
|
16
|
+
- post:
|
17
|
+
title: 'And another'
|
18
|
+
content: '<p>Blah blah blah.</p>'
|
19
|
+
|
20
|
+
about:
|
21
|
+
_global:
|
22
|
+
title: 'About'
|
23
|
+
pieces:
|
24
|
+
- post:
|
25
|
+
title: 'About Author'
|
26
|
+
content: '<p>He is a cool dude.</p>'
|
data/lib/pieces.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'mustache'
|
3
|
+
|
4
|
+
module Pieces
|
5
|
+
class Builder
|
6
|
+
def build(config)
|
7
|
+
Dir.chdir(config[:path]) do
|
8
|
+
files = routes.reduce({}) { |files, (name, route)| build_route(files, name, route) }
|
9
|
+
save_files(render_files_in_layout(files))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def route_config
|
16
|
+
@route_config ||= YAML.load_file('config/routes.yml')
|
17
|
+
end
|
18
|
+
|
19
|
+
def layout_path
|
20
|
+
"layouts/#{route_config['_layout']}.html.mustache"
|
21
|
+
end
|
22
|
+
|
23
|
+
def globals
|
24
|
+
route_config['_global'] or {}
|
25
|
+
end
|
26
|
+
|
27
|
+
def routes
|
28
|
+
route_config.reject { |key, _| key =~ /^_/ }
|
29
|
+
end
|
30
|
+
|
31
|
+
def build_route(files, name, route)
|
32
|
+
route['pieces'].reduce(files) do |files, piece|
|
33
|
+
piece, data = piece.keys.first, piece.values.first
|
34
|
+
route_globals = globals.merge(route.delete('_global') || {})
|
35
|
+
|
36
|
+
Dir["pieces/#{piece}/*"].each do |file|
|
37
|
+
case File.extname(file)
|
38
|
+
when '.mustache'
|
39
|
+
files["#{name}.html"] = { contents: '', type: 'mustache' } unless files.has_key?("#{name}.html")
|
40
|
+
files["#{name}.html"][:contents] << Mustache.render(File.read(file), route_globals.merge(data))
|
41
|
+
when '.css'
|
42
|
+
files['compiled.css'] = { contents: '', type: 'css' } unless files.has_key?('compiled.css')
|
43
|
+
files['compiled.css'][:contents] << File.read(file)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
files
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def save_files(files)
|
52
|
+
FileUtils.rm_rf('build')
|
53
|
+
Dir.mkdir('build')
|
54
|
+
files.each { |name, file| save_file(name, file) }
|
55
|
+
end
|
56
|
+
|
57
|
+
def save_file(name, file)
|
58
|
+
File.open("build/#{name}", 'w') { |f| f.write(file[:contents]) }
|
59
|
+
end
|
60
|
+
|
61
|
+
def render_in_layout(contents)
|
62
|
+
Mustache.render(File.read(layout_path), globals.merge(contents: contents))
|
63
|
+
end
|
64
|
+
|
65
|
+
def render_files_in_layout(files)
|
66
|
+
files.reduce({}) do |files, (name, file)|
|
67
|
+
if file[:type] == 'mustache'
|
68
|
+
file[:contents] = render_in_layout(file[:contents])
|
69
|
+
end
|
70
|
+
|
71
|
+
files.merge(name => file)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Pieces
|
2
|
+
class Generator
|
3
|
+
def init(config)
|
4
|
+
FileUtils.mkdir_p(config[:path])
|
5
|
+
Dir["#{example_path}/{config,layouts,pieces}"].each { |dir| FileUtils.cp_r(dir, config[:path]) }
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def example_path
|
11
|
+
File.dirname(__FILE__) + '/../../example'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/pieces.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'pieces/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'pieces'
|
7
|
+
spec.version = Pieces::VERSION
|
8
|
+
spec.authors = ['Luke Morton']
|
9
|
+
spec.email = ['lukemorton.dev@gmail.com']
|
10
|
+
|
11
|
+
spec.summary = %q{Component based static site builder}
|
12
|
+
spec.homepage = 'https://github.com/drpheltright/pieces'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
spec.executables = ['pieces']
|
17
|
+
spec.require_paths = ['lib']
|
18
|
+
|
19
|
+
spec.add_dependency 'mustache'
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler'
|
22
|
+
spec.add_development_dependency 'rake'
|
23
|
+
spec.add_development_dependency 'rspec'
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pieces
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Luke Morton
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: mustache
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
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
|
+
description:
|
70
|
+
email:
|
71
|
+
- lukemorton.dev@gmail.com
|
72
|
+
executables:
|
73
|
+
- pieces
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- ".rspec"
|
79
|
+
- ".ruby-version"
|
80
|
+
- ".travis.yml"
|
81
|
+
- CODE_OF_CONDUCT.md
|
82
|
+
- Gemfile
|
83
|
+
- LICENSE.txt
|
84
|
+
- README.md
|
85
|
+
- Rakefile
|
86
|
+
- bin/pieces
|
87
|
+
- example/config/routes.yml
|
88
|
+
- example/layouts/layout.html.mustache
|
89
|
+
- example/pieces/post/post.css
|
90
|
+
- example/pieces/post/post.html.mustache
|
91
|
+
- lib/pieces.rb
|
92
|
+
- lib/pieces/builder.rb
|
93
|
+
- lib/pieces/generator.rb
|
94
|
+
- lib/pieces/version.rb
|
95
|
+
- pieces.gemspec
|
96
|
+
homepage: https://github.com/drpheltright/pieces
|
97
|
+
licenses:
|
98
|
+
- MIT
|
99
|
+
metadata: {}
|
100
|
+
post_install_message:
|
101
|
+
rdoc_options: []
|
102
|
+
require_paths:
|
103
|
+
- lib
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
requirements: []
|
115
|
+
rubyforge_project:
|
116
|
+
rubygems_version: 2.4.5
|
117
|
+
signing_key:
|
118
|
+
specification_version: 4
|
119
|
+
summary: Component based static site builder
|
120
|
+
test_files: []
|