easy_html_generator 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/CONTRIBUTING.md +44 -0
  3. data/LICENSE +22 -0
  4. data/README.md +332 -0
  5. data/bin/ehg +52 -0
  6. data/lib/easy_html_generator.rb +100 -0
  7. data/lib/easy_html_generator/checksum.rb +39 -0
  8. data/lib/easy_html_generator/config.rb +147 -0
  9. data/lib/easy_html_generator/generator.rb +25 -0
  10. data/lib/easy_html_generator/generator/base.rb +83 -0
  11. data/lib/easy_html_generator/generator/combine.rb +28 -0
  12. data/lib/easy_html_generator/generator/compile/coffee.rb +30 -0
  13. data/lib/easy_html_generator/generator/compile/haml.rb +70 -0
  14. data/lib/easy_html_generator/generator/compile/haml/context.rb +52 -0
  15. data/lib/easy_html_generator/generator/compile/haml/helper/activesupport_override.rb +48 -0
  16. data/lib/easy_html_generator/generator/compile/haml/helper/asset_helper.rb +78 -0
  17. data/lib/easy_html_generator/generator/compile/haml/layout.rb +35 -0
  18. data/lib/easy_html_generator/generator/compile/sass.rb +47 -0
  19. data/lib/easy_html_generator/generator/copy.rb +44 -0
  20. data/lib/easy_html_generator/generator/delete.rb +20 -0
  21. data/lib/easy_html_generator/generator/minimize/css.rb +28 -0
  22. data/lib/easy_html_generator/generator/minimize/html.rb +32 -0
  23. data/lib/easy_html_generator/generator/minimize/images.rb +33 -0
  24. data/lib/easy_html_generator/generator/minimize/js.rb +28 -0
  25. data/lib/easy_html_generator/generator/service/analytics.rb +34 -0
  26. data/lib/easy_html_generator/generator/service/bower.rb +34 -0
  27. data/lib/easy_html_generator/generator/service/grunt.rb +24 -0
  28. data/lib/easy_html_generator/generator/structure.rb +20 -0
  29. data/lib/easy_html_generator/generators.rb +53 -0
  30. data/lib/easy_html_generator/project.rb +77 -0
  31. data/lib/easy_html_generator/rackapp.rb +67 -0
  32. data/lib/easy_html_generator/workspace.rb +59 -0
  33. data/src/demo/assets/images/demo.png +0 -0
  34. data/src/demo/assets/public/robots.txt +0 -0
  35. data/src/demo/assets/scripts/demo.js.coffee +1 -0
  36. data/src/demo/assets/scripts/plain.js +0 -0
  37. data/src/demo/assets/styles/app.css.sass +2 -0
  38. data/src/demo/assets/styles/plain.css +0 -0
  39. data/src/demo/lib/generators/project_generator.rb +12 -0
  40. data/src/demo/lib/helper/projecthelper.rb +5 -0
  41. data/src/demo/views/index.html.haml +1 -0
  42. data/src/demo/views/index/_lore_ipsum.haml +1 -0
  43. data/src/demo/views/layout.haml +8 -0
  44. data/src/demo/views/plain.html +0 -0
  45. data/src/shared/assets/images/shared.png +0 -0
  46. data/src/shared/assets/scripts/shared.js.coffee +1 -0
  47. data/src/shared/assets/scripts/shared.plain.js +0 -0
  48. data/src/shared/assets/styles/mixins/_arrows.sass +32 -0
  49. data/src/shared/assets/styles/mixins/_bootstrap-fixes.sass +12 -0
  50. data/src/shared/assets/styles/mixins/_buttons.sass +32 -0
  51. data/src/shared/assets/styles/mixins/_css3.sass +266 -0
  52. data/src/shared/assets/styles/mixins/_headjs-bootstrap-mediaqueries.sass +42 -0
  53. data/src/shared/assets/styles/mixins/_helper.sass +70 -0
  54. data/src/shared/assets/styles/mixins/_normalize.sass +340 -0
  55. data/src/shared/assets/styles/mixins/_reset.sass +46 -0
  56. data/src/shared/lib/generators/shared_generator.rb +12 -0
  57. data/src/shared/lib/helper/shared_helper.rb +16 -0
  58. data/src/shared/project.yml +127 -0
  59. data/src/shared/views/404.yml +5 -0
  60. data/src/template/assets/public/robots.txt +0 -0
  61. data/src/template/assets/scripts/index.js.coffee +1 -0
  62. data/src/template/assets/styles/index.css.sass +2 -0
  63. data/src/template/lib/generators/project_generator.rb +12 -0
  64. data/src/template/lib/helper/project_helper.rb +5 -0
  65. data/src/template/project.yml +128 -0
  66. data/src/template/views/index.html.haml +4 -0
  67. data/src/template/views/index/_lore_ipsum.haml +2 -0
  68. data/src/template/views/layout.haml +9 -0
  69. metadata +402 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bbf67d8cf7bfda5daf5f4921a24c1ba0715c3c87
4
+ data.tar.gz: 4305ffba33eb60ee1ca3aff1d560632dd99e5ab1
5
+ SHA512:
6
+ metadata.gz: 4386a2e634b820b4cc97cd8dbfbf0e6ae40916db22736f7d86418f85b19459c7ba18e884ebb2c83cdcc86dae244c8894be5f6ea01aa69b1506e38ce630077111
7
+ data.tar.gz: 3819e7952489e72af72bbacd050f4de9a2ea9f54a2be2f5a4932ec35872492c6eb1be93f922aea2caf4b106b164dafff0e022bc8e04dbd02b3827e2139b6bb49
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,44 @@
1
+ ##Issues
2
+
3
+ - Report issues or feature requests on [GitHub Issues](https://github.com/creative-workflow/easy-html-generator/issues).
4
+ - If reporting a bug, please add a [simplified example](http://sscce.org/).
5
+
6
+ ##Pull requests
7
+ - Create a new topic branch for every separate change you make.
8
+ - Create a test case if you are fixing a bug or implementing an important feature.
9
+ - Make sure the build runs successfully.
10
+
11
+ ## Development
12
+
13
+ ###Tools
14
+ We use the following tools for development:
15
+
16
+ - [RSpec](http://rspec.info/) for tests.
17
+ - [Rake](https://github.com/ruby/rake) for task management.
18
+ - [RuboCop](https://github.com/bbatsov/rubocop) for code quality.
19
+ - [NodeJS](http://nodejs.org/download/) required to run grunt.
20
+ - [Grunt](http://gruntjs.com/getting-started) for task management inside a project.
21
+ - [Bower](http://bower.io/#getting-started) for js dependency management inside a project.
22
+
23
+ ###Getting started
24
+ Install [NodeJS](http://nodejs.org/).
25
+ Install globally grunt-cli using the following command:
26
+
27
+ $ npm install -g grunt-cli
28
+
29
+ Browse to the project root directory and install the dev dependencies:
30
+
31
+ $ npm install -d
32
+
33
+ To execute the build and tests run the following command in the root of the project:
34
+
35
+ $ grunt
36
+
37
+ You should see a green message in the console:
38
+
39
+ Done, without errors.
40
+
41
+ ###testing
42
+ You can run the tests with using the following command:
43
+
44
+ $ rake
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 creative-workflow
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 all
13
+ 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 THE
21
+ SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1,332 @@
1
+ # easy-html-generator [![Build Status](https://travis-ci.org/creative-workflow/easy-html-generator.svg?branch=master)](https://travis-ci.org/creative-workflow/easy-html-generator) [![Code Climate](https://codeclimate.com/github/creative-workflow/easy-html-generator/badges/gpa.svg)](https://codeclimate.com/github/creative-workflow/easy-html-generator)
2
+
3
+ This gem is a powerful and easy to use web development tool that helps developing modern web sites by generating static html pages. It uses:
4
+ * [CoffeScript](http://coffeescript.org/) aka Javascript
5
+ * [Sass](http://sass-lang.com/) aka css
6
+ * [Haml](http://haml.info/) aka html
7
+ * [ActionView](https://github.com/rails/rails/tree/master/actionview) for ruby haml templating comfort
8
+
9
+ It can utilizes:
10
+ * [Bootstrap](http://getbootstrap.com/) for responsive and modern html layouts
11
+ * [HeadJS](http://headjs.com/) for performance optimized resource loading
12
+ * [Bower](http://bower.io/) for javascript dependency management
13
+ * [Grunt](http://gruntjs.com/) for javascript based task management
14
+ * [Google Anlaytics](https://www.google.com/analytics/) tracking of pageclicks
15
+ * minimizing from coffee-, javascript-, sass-, css-, png- and image-files
16
+
17
+ It is developed with:
18
+ - [Ruby](https://www.ruby-lang.org/) as implementation language
19
+ - [Rspec](http://rspec.info/) for testing
20
+ - [RuboCop](https://github.com/bbatsov/rubocop) for code quality
21
+
22
+ It is based on:
23
+ - [EasyHtmlCreator](https://github.com/dennisvandehoef/easy-html-creator) which was the fundament [Dennis van de Hoef](https://github.com/dennisvandehoef) and me developed on.
24
+
25
+ ## Basic concepts
26
+ ### setup
27
+ Create a new project folder
28
+
29
+ mkdir my_project
30
+ cd my_project
31
+
32
+ Create a ruby 'Gemfile'
33
+
34
+ touch Gemfile
35
+
36
+ Paste this into the 'Gemfile'
37
+
38
+ source 'https://rubygems.org'
39
+
40
+ gem 'easy_html_generator'
41
+
42
+ Run in terminal
43
+
44
+ bundle install
45
+ ehg --init
46
+ ehg --create my_project
47
+
48
+ Now you should see the following folder sructure
49
+
50
+ ├── dist # the generated result will be stored here
51
+ └── src # the generation input is stored here
52
+ ├── demo
53
+ ├── my_project # this is a project and will be available via http://localhost:9292/my_project
54
+ │   ├── assets
55
+ │   │   ├── images # content will be copied to `dist/my_project/images`
56
+ │   │   ├── public # public content gets directly copied to `dist/my_project/`
57
+ │   │   ├── scripts # content will be copied to `dist/my_project/scripts`
58
+ │   │   └── styles # content will be copied to `dist/my_project/styles`
59
+ │   ├── lib
60
+ │   │   ├── generators # project specific generators
61
+ │   │   └── helper # project specific view helpers you can use in haml files
62
+ │   ├── project.yml # project specific generators config
63
+ │   └── views
64
+ │   ├── index.html.haml # the ham file for index.html
65
+ │   └── layout.haml # the layout file index.html will use
66
+ |
67
+ └── shared # shared content over all projects
68
+ ├── assets # shared assets over all projects
69
+ │   ├── images
70
+ │   ├── public
71
+ │   ├── scripts
72
+ │   └── styles
73
+ │   └── mixins # here are css helpers for bootstrap and head js
74
+ ├── lib
75
+ │   ├── generators # generators shared over all projects
76
+ │   └── helper # view helpers you can use in haml files
77
+ ├── project.yml # if a project doesnt have a `project.yml` this config will be used
78
+
79
+ Now run
80
+ ehg --server
81
+
82
+ ...and go to `http://localhost:9292`
83
+
84
+ After a sort time of generating you should see a directory listening in your browser.
85
+
86
+ ## Usage terminal
87
+ Usage: ehg [options]
88
+ -s, --server [HOST_AND_PORT] start the rack server, default: 0.0.0.0:9292
89
+ -g, --generate [PROJECT] generate one or all projects, default: all
90
+ -i, --init initialise ehg workspace
91
+ -c, --create [PROJECT] create a new project from template, default: demo
92
+ -h, --help Show this message
93
+
94
+ ## Usage Generators
95
+ There are several generators controlled by the `project.yml` configured like:
96
+
97
+ paths:
98
+ src:
99
+ images: 'assets/images'
100
+ scripts: 'assets/scripts'
101
+ styles: 'assets/styles'
102
+ ...
103
+
104
+ generators:
105
+ - structure:
106
+ enabled: true
107
+
108
+ - compile_coffee:
109
+ enabled: true
110
+ minimize: true
111
+ selector: '**/*.js.coffee'
112
+
113
+ - service_bower:
114
+ enabled: true
115
+ selector: 'bower.json'
116
+ target: 'lib'
117
+
118
+ ## Generators
119
+ Generators are processed the way they appear in the `project.yml`. At the moment only one generator instance per `project.yml` is allowed. Every generator has the property `enabled`.
120
+
121
+ ### Basic-Generators
122
+ #### Structure
123
+ * operates on: `dist`
124
+ * creates necessary dist folders
125
+ * config:
126
+
127
+
128
+ generators:
129
+ - structure:
130
+ enabled: true
131
+
132
+ #### Copy
133
+ * operates on: `dist` and `src`
134
+ * copies folder or files from dist to src
135
+ * config:
136
+
137
+
138
+ generators:
139
+ - copy:
140
+ enabled: true
141
+ dirs:
142
+ -
143
+ source: 'assets/styles'
144
+ target: 'styles'
145
+ selector: '**/*.css'
146
+ -
147
+ source: 'assets/scripts'
148
+ target: 'scripts'
149
+ selector: '**/*.js'
150
+
151
+ #### Combine
152
+ * operates on: `dist`
153
+ * combines merges files on dist
154
+ * config:
155
+
156
+
157
+ generators:
158
+ - combine
159
+ enabled: true
160
+ packages:
161
+ -
162
+ file: 'scripts/combined.js'
163
+ files:
164
+ - 'scripts/**/*.js'
165
+ -
166
+ file: 'styles/combined.css'
167
+ files:
168
+ - 'styles/**/*.css'
169
+
170
+ #### Delete
171
+ * operates on: `dist`
172
+ * deletes files or folders on dist
173
+ * config:
174
+
175
+
176
+ generators:
177
+ - delete
178
+ enabled: false
179
+ files:
180
+ - '*'
181
+
182
+
183
+ ### Complie-Generators
184
+ #### Compile::Haml
185
+ * operates on: `dist` and `src`
186
+ * compiles haml files from src to html files in dist, supports partials and action view, supports minimizing
187
+ * config:
188
+
189
+
190
+ generators:
191
+ - compile_haml:
192
+ enabled: true
193
+ minimize: true
194
+ default_layout: 'views/layout.haml'
195
+ selector: '**/*.html.haml'
196
+ renderer:
197
+ attr_wrapper: '"'
198
+ format: :html5
199
+ shared_helper_path: 'shared/lib'
200
+
201
+ #### Compile::Sass
202
+ * operates on: `dist` and `src`
203
+ * compiles sass files from src to css files in dist, supports shared mixins and minimizing
204
+ * config:
205
+
206
+
207
+ generators:
208
+ - compile_sass:
209
+ enabled: true
210
+ minimize: true
211
+ selector: '**/*.css.sass'
212
+
213
+ #### Compile::Coffee
214
+ * operates on: `dist` and `src`
215
+ * compiles coffee files from src to js files in dist, supports minimizing
216
+ * config:
217
+
218
+
219
+ generators:
220
+ - compile_coffee:
221
+ enabled: true
222
+ minimize: true
223
+ selector: '**/*.js.coffee'
224
+
225
+ ### Minimize-Generators
226
+ #### Minimize::Html
227
+ * operates on: `dist` and `src`
228
+ * minimizes src html files and copies to dist
229
+ * config:
230
+
231
+
232
+ generators:
233
+ - minimize_html:
234
+ enabled: true
235
+ selector: '**/*.html'
236
+ prefix_extension: ''
237
+
238
+ #### Minimize::Css
239
+ * operates on: `dist` and `src`
240
+ * cminimizes src css files and copies to dist
241
+ * config:
242
+
243
+
244
+ generators:
245
+ - minimize_css:
246
+ enabled: true
247
+ selector: '**/*.css'
248
+ prefix_extension: '.min'
249
+
250
+ #### Minimize::Js
251
+ * operates on: `dist` and `src`
252
+ * minimizes src js files and copies to dist
253
+ * config:
254
+
255
+
256
+ generators:
257
+ - minimize_js:
258
+ enabled: true
259
+ selector: '**/*.js'
260
+ prefix_extension: '.min'
261
+
262
+ #### Minimize::Images
263
+ * operates on: `dist` and `src`
264
+ * minimizes src image files and copies to dist, uses [Piet](https://github.com/albertbellonch/piet)
265
+ * config:
266
+
267
+
268
+ generators:
269
+ - minimize_images:
270
+ enabled: true
271
+ selector: '**/*.{jpg,jpeg,png}'
272
+ options:
273
+ quality: 90
274
+ level: 3
275
+ verbose: true
276
+
277
+
278
+ ### Service-Generators
279
+ #### Service::Bower
280
+ * operates on: `dist` and `src`
281
+ * resolves my_project/bower.json and copies bower_components to target in dist
282
+ * config:
283
+
284
+
285
+ generators:
286
+ - service_bower:
287
+ enabled: true
288
+ selector: 'bower.json'
289
+ target: 'lib'
290
+
291
+ #### Service::Grunt
292
+ * operates on: `dist`
293
+ * resolves my_project/Gruntfile.coffee and runs a task
294
+ * config:
295
+
296
+
297
+ generators:
298
+ - service_grunt:
299
+ enabled: true
300
+ selector: 'Gruntfile.coffee'
301
+ task: 'default'
302
+
303
+ #### Service::Analytics
304
+ * operates on: `dist`
305
+ * appends google analytics code to selected html files
306
+ * config:
307
+
308
+
309
+ generators:
310
+ - service_analytics:
311
+ enabled: true
312
+ append_to_files:
313
+ - '**/*.html'
314
+ google:
315
+ enabled: true
316
+ code: "<script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create', '{GOOGLE_UA_ID}', 'auto');ga('send', 'pageview');</script>"
317
+ id: -1
318
+
319
+ ### Resources
320
+ * https://github.com/dennisvandehoef/easy-html-creator
321
+ * https://github.com/creative-workflow/easy-html-generator
322
+ * https://travis-ci.org/creative-workflow/easy-html-generator
323
+ * https://codeclimate.com/github/creative-workflow/easy-html-generator
324
+ * https://rubygems.org/gems/easy_html_generator
325
+
326
+ ### Authors
327
+
328
+ [Tom Hanoldt](https://github.com/monotom)
329
+
330
+ # Contributing
331
+
332
+ Check out the [Contributing Guidelines](CONTRIBUTING.md)
data/bin/ehg ADDED
@@ -0,0 +1,52 @@
1
+ # encoding: utf-8
2
+ # !/usr/bin/env ruby
3
+
4
+ require 'optparse'
5
+ require 'easy_html_generator'
6
+
7
+ class EhgOptparse
8
+ def self.parse(args)
9
+ opt_parser = OptionParser.new do |opts|
10
+ opts.banner = 'Usage: ehg [options]'
11
+
12
+ # http://hawkins.io/2012/07/rack_from_the_beginning/
13
+ opts.on('-s', '--server [HOST_AND_PORT]', '0.0.0.0:9292', 'start the rack server') do |host_and_port|
14
+ host_and_port ||= '0.0.0.0:9292'
15
+
16
+ tmp = host_and_port.split ':'
17
+ host = tmp.first
18
+ port = tmp.last
19
+
20
+ EasyHtmlGenerator.start_server(host, port)
21
+ end
22
+
23
+ opts.on('-g', '--generate [PROJECT]', 'all', 'generate one or all projects') do |project|
24
+ project ||= 'all'
25
+
26
+ if project == 'all'
27
+ EasyHtmlGenerator.generate_all
28
+ else
29
+ EasyHtmlGenerator.generate_project project
30
+ end
31
+ end
32
+
33
+ opts.on('-i', '--init', 'initialise ehg workspace') do
34
+ EasyHtmlGenerator::Workspace.init
35
+ end
36
+
37
+ opts.on('-c', '--create [PROJECT]', 'demo', 'create a new project from template') do |name|
38
+ name ||= 'demo'
39
+ EasyHtmlGenerator::Workspace.create_project name
40
+ end
41
+
42
+ opts.on_tail('-h', '--help', 'Show this message') do
43
+ puts opts
44
+ exit
45
+ end
46
+ end
47
+
48
+ opt_parser.parse!(args)
49
+ end
50
+ end
51
+
52
+ EhgOptparse.parse(ARGV)