easy_html_generator 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +28 -28
- data/lib/easy_html_generator.rb +15 -8
- data/lib/easy_html_generator/{rackapp.rb → rack_dispatcher.rb} +12 -29
- metadata +4 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc54c42e3b8dbf0a17a5e8c9230c9cb41b142823
|
4
|
+
data.tar.gz: 0549d73e2cf263dafe4721a8dd3a45e7d0a64f0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c07365b28f8aaf47c7d8d63ec863fef847cb1cab3d9747d13affa36915687d68555b17649d40d3f1742c9fdb0a2b82f1d2b311d463cddc2d36b1c4510119930b
|
7
|
+
data.tar.gz: 5fdef7471df56eaa4bf8cb1408ea6c09752035ad2f77288bf54e91923b6d4a63db8aebe2b00b8b65cb05cec5f9dca26fba9b6573dfe6eeca563c8934a5076c14
|
data/README.md
CHANGED
@@ -59,34 +59,34 @@ Run in terminal
|
|
59
59
|
Now you should see the following folder structure with `ls -alR`
|
60
60
|
|
61
61
|
my_workspace
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
62
|
+
├── dist # the generated result will be stored here
|
63
|
+
└── src # the generation input is stored here
|
64
|
+
├── demo
|
65
|
+
├── my_project # this is a project and will be available via http://localhost:9292/my_project
|
66
|
+
│ ├── assets
|
67
|
+
│ │ ├── images # content will be copied to `dist/my_project/images`
|
68
|
+
│ │ ├── public # public content gets directly copied to `dist/my_project/`
|
69
|
+
│ │ ├── scripts # content will be copied to `dist/my_project/scripts`
|
70
|
+
│ │ └── styles # content will be copied to `dist/my_project/styles`
|
71
|
+
│ ├── lib
|
72
|
+
│ │ ├── generators # project specific generators
|
73
|
+
│ │ └── helper # project specific view helpers you can use in haml files
|
74
|
+
│ ├── project.yml # project specific generators config
|
75
|
+
│ └── views
|
76
|
+
│ ├── index.html.haml # the ham file for index.html
|
77
|
+
│ └── layout.haml # the layout file index.html will use
|
78
|
+
|
|
79
|
+
└── shared # shared content over all projects
|
80
|
+
├── assets # shared assets over all projects
|
81
|
+
│ ├── images
|
82
|
+
│ ├── public
|
83
|
+
│ ├── scripts
|
84
|
+
│ └── styles
|
85
|
+
│ └── mixins # here are css helpers for bootstrap and head js
|
86
|
+
├── lib
|
87
|
+
│ ├── generators # generators shared over all projects
|
88
|
+
│ └── helper # view helpers you can use in haml files
|
89
|
+
└── project.yml # if a project doesnt have a `project.yml` this config will be used
|
90
90
|
|
91
91
|
Now run
|
92
92
|
|
data/lib/easy_html_generator.rb
CHANGED
@@ -8,6 +8,7 @@ require 'bootstrap-sass'
|
|
8
8
|
require 'bundler'
|
9
9
|
require 'colorize'
|
10
10
|
require 'rack'
|
11
|
+
require 'thin'
|
11
12
|
|
12
13
|
# main module loads projects and dispatches rack requests
|
13
14
|
module EasyHtmlGenerator
|
@@ -73,28 +74,34 @@ module EasyHtmlGenerator
|
|
73
74
|
end
|
74
75
|
|
75
76
|
def self.generate_all
|
76
|
-
Workspace.projects.each
|
77
|
+
Workspace.projects.each{|name, project| project.generate }
|
77
78
|
end
|
78
79
|
|
79
80
|
def self.generate_project(project)
|
80
81
|
Workspace.projects[project].generate
|
81
82
|
end
|
82
83
|
|
83
|
-
def self.
|
84
|
-
|
84
|
+
def self.rack_app
|
85
|
+
Rack::Builder.new do
|
85
86
|
use Rack::Reloader, 0
|
87
|
+
use EasyHtmlGenerator::RackDispatcher
|
88
|
+
use Rack::Static,
|
89
|
+
urls: [''],
|
90
|
+
root: EasyHtmlGenerator::DIST_PATH,
|
91
|
+
index: 'index.html'
|
92
|
+
|
86
93
|
use Rack::ContentLength
|
87
|
-
use Rack::AbstractFormat
|
88
94
|
use Rack::Deflater
|
89
95
|
use Rack::ETag
|
90
96
|
|
91
|
-
run
|
97
|
+
run lambda { |env| [404, {'Content-Type' => 'text/plain'}, ['404 File not found!']] }
|
92
98
|
end
|
99
|
+
end
|
93
100
|
|
94
|
-
|
95
|
-
|
101
|
+
def self.start_server(host, port)
|
102
|
+
config = { Host: host,
|
96
103
|
Port: port}
|
97
104
|
|
98
|
-
Rack::
|
105
|
+
Rack::Handler.get('thin').run(rack_app, config)
|
99
106
|
end
|
100
107
|
end
|
@@ -1,12 +1,8 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'rack'
|
3
|
-
require 'rack/abstract_format'
|
4
|
-
require 'rack/respond_to'
|
5
3
|
|
6
4
|
# this is the rack application for ehg
|
7
|
-
class EasyHtmlGenerator::
|
8
|
-
include Rack::RespondTo
|
9
|
-
|
5
|
+
class EasyHtmlGenerator::RackDispatcher
|
10
6
|
EHG_URL = 'https://github.com/creative-workflow/easy-html-generator'
|
11
7
|
LIST_BODY = "<!DOCTYPE html><html><head>
|
12
8
|
<style>*{ font-size: 20px;
|
@@ -17,35 +13,22 @@ class EasyHtmlGenerator::Rackapp
|
|
17
13
|
{CONTENT}
|
18
14
|
<a target='_blank' href='#{EHG_URL}'>ehc on Github</a></body></html>"
|
19
15
|
|
20
|
-
def
|
21
|
-
|
22
|
-
|
16
|
+
def initialize(app)
|
17
|
+
@app = app
|
18
|
+
end
|
23
19
|
|
20
|
+
def call(env)
|
21
|
+
request = Rack::Request.new(env)
|
24
22
|
case request.path_info
|
25
23
|
when '/'
|
26
|
-
|
27
|
-
else
|
28
|
-
dispatch(request)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.respond(body, status_code = 200)
|
33
|
-
content_type = Rack::RespondTo.selected_media_type || 'text/html'
|
34
|
-
|
35
|
-
[status_code, { 'Content-Type' => "#{content_type}; charset=UTF-8" }, [body || '']]
|
36
|
-
end
|
37
|
-
|
38
|
-
def self.dispatch(request)
|
39
|
-
file = EasyHtmlGenerator.dispatch(request)
|
40
|
-
|
41
|
-
if File.exist? file
|
42
|
-
respond(File.read(file))
|
24
|
+
create_directory_listening_index_file
|
43
25
|
else
|
44
|
-
|
26
|
+
EasyHtmlGenerator.dispatch(request)
|
45
27
|
end
|
28
|
+
@app.call(env)
|
46
29
|
end
|
47
30
|
|
48
|
-
def
|
31
|
+
def create_directory_listening_index_file
|
49
32
|
content = ''
|
50
33
|
EasyHtmlGenerator.projects.each do |_name, project|
|
51
34
|
content += "<h3>#{project.name}</h3>"
|
@@ -55,10 +38,10 @@ class EasyHtmlGenerator::Rackapp
|
|
55
38
|
end
|
56
39
|
content = LIST_BODY.sub('{CONTENT}', "<ul>#{content}</ul>")
|
57
40
|
|
58
|
-
|
41
|
+
File.write("#{EasyHtmlGenerator::DIST_PATH}/index.html", content)
|
59
42
|
end
|
60
43
|
|
61
|
-
def
|
44
|
+
def build_list_dir_row(file)
|
62
45
|
f = File.path(file)
|
63
46
|
f_name = File.basename(f)
|
64
47
|
f_path = File.dirname(f)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy_html_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Hanoldt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -25,21 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
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: rack-abstract-format
|
28
|
+
name: thin
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
44
30
|
requirements:
|
45
31
|
- - ">="
|
@@ -315,7 +301,7 @@ files:
|
|
315
301
|
- lib/easy_html_generator/generator/structure.rb
|
316
302
|
- lib/easy_html_generator/generators.rb
|
317
303
|
- lib/easy_html_generator/project.rb
|
318
|
-
- lib/easy_html_generator/
|
304
|
+
- lib/easy_html_generator/rack_dispatcher.rb
|
319
305
|
- lib/easy_html_generator/workspace.rb
|
320
306
|
- src/demo/assets/images/demo.png
|
321
307
|
- src/demo/assets/public/robots.txt
|
@@ -380,4 +366,3 @@ specification_version: 4
|
|
380
366
|
summary: This gem is a powerful and easy to use web development tool that helps developing
|
381
367
|
modern web sites by generating static html pages.
|
382
368
|
test_files: []
|
383
|
-
has_rdoc:
|