pieces 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/README.md +83 -2
- data/Rakefile +2 -0
- data/lib/pieces/builder.rb +5 -1
- data/lib/pieces/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b51682b37d7d66fcb1ca1d9b4c771b183891d7b
|
4
|
+
data.tar.gz: 76d48e3faa29e687c112bbada03c820d76909203
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6e6b397790bcf4d07933b206d137bc69657626115229b1525b3015eb694341855e79f050606dae413a155948d21aa22d846e10041328481812295f4c69cc78e
|
7
|
+
data.tar.gz: f4f78c2ee4db24950ce27f59f68706111fcf4a2632bb8450e201d3bee5ba6b2b14ff8bb55c4f1a7009f275b1716e4596cea60b0bde06e9553e747663d2bc43c4
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Pieces
|
2
2
|
|
3
|
+
[![Build Status](https://travis-ci.org/drpheltright/pieces.svg)](https://travis-ci.org/drpheltright/pieces)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/drpheltright/pieces/badges/gpa.svg)](https://codeclimate.com/github/drpheltright/pieces)
|
5
|
+
[![Test Coverage](https://codeclimate.com/github/drpheltright/pieces/badges/coverage.svg)](https://codeclimate.com/github/drpheltright/pieces/coverage)
|
6
|
+
|
3
7
|
This gem will take your HTML and CSS components and compile them into a static
|
4
8
|
site. Very very alpha.
|
5
9
|
|
@@ -9,9 +13,11 @@ To create a new static site with pieces:
|
|
9
13
|
|
10
14
|
```
|
11
15
|
gem install pieces
|
12
|
-
pieces init
|
16
|
+
pieces init hello_world
|
13
17
|
```
|
14
18
|
|
19
|
+
This will install some boiler plate in `hello_world/`.
|
20
|
+
|
15
21
|
## Create styleguide within existing application
|
16
22
|
|
17
23
|
Add pieces to your Gemfile:
|
@@ -40,9 +46,84 @@ pieces build
|
|
40
46
|
|
41
47
|
Make sure you run this from your pieces directory!
|
42
48
|
|
49
|
+
## How it works
|
50
|
+
|
51
|
+
Using configuration found in `config/routes.yml` pieces will compile your
|
52
|
+
modular components ala BEM (or whatever you prefer) into a static HTML site.
|
53
|
+
|
54
|
+
At the top level of your `routes.yml` you define your output files, or "routes".
|
55
|
+
The following example will build both `index.html` and `about.html`.
|
56
|
+
|
57
|
+
``` yml
|
58
|
+
index:
|
59
|
+
_pieces:
|
60
|
+
- intro: { title: 'Welcome to my site' }
|
61
|
+
|
62
|
+
about:
|
63
|
+
_pieces:
|
64
|
+
- intro: { title: 'About me' }
|
65
|
+
```
|
66
|
+
|
67
|
+
Both `index.html` and `about.html` make use of a piece called "intro". This
|
68
|
+
piece will be found in either `pieces/intro.html.*`, `pieces/intro/intro.html.*`
|
69
|
+
or `pieces/application/intro.html.*`. The `*` can be any format supported by
|
70
|
+
[tilt](https://github.com/rtomayko/tilt).
|
71
|
+
|
72
|
+
You can generate your HTML into directories quite easily:
|
73
|
+
|
74
|
+
``` yml
|
75
|
+
portfolio/a-client:
|
76
|
+
_pieces:
|
77
|
+
- carousel: {}
|
78
|
+
- case_study: {}
|
79
|
+
portfolio/another-client:
|
80
|
+
_pieces:
|
81
|
+
- carousel: {}
|
82
|
+
- case_study: {}
|
83
|
+
```
|
84
|
+
|
85
|
+
Likewise you can structure your pieces in directories:
|
86
|
+
|
87
|
+
``` yml
|
88
|
+
about:
|
89
|
+
_pieces:
|
90
|
+
- header: {}
|
91
|
+
- copy/intro: {}
|
92
|
+
- galleries/photo: {}
|
93
|
+
- footer: {}
|
94
|
+
```
|
95
|
+
|
96
|
+
"copy/intro" and "galleries/photo" will be found in `pieces/copy/intro.html.*`
|
97
|
+
and `pieces/galleries/photo.html.*` respectively.
|
98
|
+
|
99
|
+
You can place your content in a layout quite easily with nested pieces.
|
100
|
+
|
101
|
+
``` yml
|
102
|
+
about:
|
103
|
+
_pieces:
|
104
|
+
- layouts/application:
|
105
|
+
_pieces:
|
106
|
+
- header: {}
|
107
|
+
- copy/intro: {}
|
108
|
+
- galleries/photo: {}
|
109
|
+
- footer: {}
|
110
|
+
```
|
111
|
+
|
112
|
+
The child pieces will be rendered in order and passed into the parent
|
113
|
+
"layouts/application" piece as `yield`. If you had
|
114
|
+
`pieces/layouts/application.html.erb` then you can call yield like so:
|
115
|
+
|
116
|
+
``` erb
|
117
|
+
<html>
|
118
|
+
<body>
|
119
|
+
<%= yield %>
|
120
|
+
</body>
|
121
|
+
</html>
|
122
|
+
```
|
123
|
+
|
43
124
|
## Contributing
|
44
125
|
|
45
|
-
1. Fork it ( https://github.com/
|
126
|
+
1. Fork it ( https://github.com/drpheltright/pieces/fork )
|
46
127
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
47
128
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
48
129
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/Rakefile
CHANGED
data/lib/pieces/builder.rb
CHANGED
@@ -61,10 +61,14 @@ module Pieces
|
|
61
61
|
def save_files(files)
|
62
62
|
FileUtils.rm_rf('build')
|
63
63
|
Dir.mkdir('build')
|
64
|
-
|
64
|
+
|
65
|
+
files.each do |name, file|
|
66
|
+
save_file(name, file)
|
67
|
+
end
|
65
68
|
end
|
66
69
|
|
67
70
|
def save_file(name, file)
|
71
|
+
FileUtils.mkdir_p(File.dirname("build/#{name}"))
|
68
72
|
File.open("build/#{name}", 'w') { |f| f.write(file[:contents]) }
|
69
73
|
end
|
70
74
|
end
|
data/lib/pieces/version.rb
CHANGED