troy 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/troy.rb +1 -0
- data/lib/troy/generator.rb +7 -0
- data/lib/troy/server.rb +9 -8
- data/lib/troy/site.rb +3 -0
- data/lib/troy/version.rb +1 -1
- data/templates/Gemfile +5 -0
- data/templates/Procfile +1 -0
- data/templates/config.ru +10 -0
- data/templates/unicorn.rb +2 -0
- metadata +5 -1
data/Gemfile.lock
CHANGED
data/lib/troy.rb
CHANGED
data/lib/troy/generator.rb
CHANGED
@@ -29,6 +29,13 @@ module Troy
|
|
29
29
|
copy_file "index.erb", "source/index.erb"
|
30
30
|
copy_file "404.erb", "source/404.erb"
|
31
31
|
copy_file "500.erb", "source/500.erb"
|
32
|
+
copy_file "Gemfile", "Gemfile"
|
33
|
+
copy_file "config.ru", "config.ru"
|
34
|
+
copy_file "unicorn.rb", "config/unicorn.rb"
|
35
|
+
end
|
36
|
+
|
37
|
+
def bundle_install
|
38
|
+
run "bundle install"
|
32
39
|
end
|
33
40
|
end
|
34
41
|
end
|
data/lib/troy/server.rb
CHANGED
@@ -31,27 +31,28 @@ module Troy
|
|
31
31
|
path
|
32
32
|
end
|
33
33
|
|
34
|
+
def redirect(path)
|
35
|
+
[301, {"Content-Type" => "text/html", "Location" => path}, []]
|
36
|
+
end
|
37
|
+
|
34
38
|
def process
|
35
39
|
path = request.path[%r[^/(.*?)/?$], 1]
|
36
40
|
path = "index" if path == ""
|
37
41
|
path = root.join(path)
|
38
42
|
|
39
43
|
if request.path != "/" && request.path.end_with?("/")
|
40
|
-
|
41
|
-
"Content-Type" => "text/html",
|
42
|
-
"Location" => normalized_path
|
43
|
-
}, []]
|
44
|
+
redirect normalized_path
|
44
45
|
elsif (_path = Pathname.new("#{path}.html")).file?
|
45
|
-
render(200, "text/html", _path)
|
46
|
+
render(200, "text/html; charset=utf-8", _path)
|
46
47
|
elsif (_path = Pathname.new("#{path}.xml")).file?
|
47
|
-
render(200, "text/xml", _path)
|
48
|
+
render(200, "text/xml; charset=utf-8", _path)
|
48
49
|
elsif path.file? && path.extname !~ /\.(html?|xml)$/
|
49
50
|
render(200, Rack::Mime.mime_type(path.extname, "text/plain"), path)
|
50
51
|
else
|
51
|
-
render(404, "text/html", root.join("404.html"))
|
52
|
+
render(404, "text/html; charset=utf-8", root.join("404.html"))
|
52
53
|
end
|
53
54
|
rescue Exception => error
|
54
|
-
render(500, "text/html", root.join("500.html"))
|
55
|
+
render(500, "text/html; charset=utf-8", root.join("500.html"))
|
55
56
|
end
|
56
57
|
end
|
57
58
|
end
|
data/lib/troy/site.rb
CHANGED
@@ -70,6 +70,9 @@ module Troy
|
|
70
70
|
sprockets = Sprockets::Environment.new
|
71
71
|
sprockets.append_path root.join("assets/javascripts")
|
72
72
|
sprockets.append_path root.join("assets/stylesheets")
|
73
|
+
sprockets.css_compressor = Sprockets::SassCompressor
|
74
|
+
sprockets.js_compressor = Uglifier.new(:copyright => false)
|
75
|
+
sprockets.default_external_encoding = Encoding::UTF_8
|
73
76
|
|
74
77
|
Troy.configuration.assets.precompile.each do |asset_name|
|
75
78
|
asset = sprockets[asset_name]
|
data/lib/troy/version.rb
CHANGED
data/templates/Gemfile
ADDED
data/templates/Procfile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
|
data/templates/config.ru
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: troy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -204,12 +204,16 @@ files:
|
|
204
204
|
- spec/spec_helper.rb
|
205
205
|
- templates/404.erb
|
206
206
|
- templates/500.erb
|
207
|
+
- templates/Gemfile
|
208
|
+
- templates/Procfile
|
209
|
+
- templates/config.ru
|
207
210
|
- templates/default.erb
|
208
211
|
- templates/helpers.rb
|
209
212
|
- templates/index.erb
|
210
213
|
- templates/script.js
|
211
214
|
- templates/style.scss
|
212
215
|
- templates/troy.rb
|
216
|
+
- templates/unicorn.rb
|
213
217
|
- troy.gemspec
|
214
218
|
homepage: http://github.com/fnando/troy
|
215
219
|
licenses: []
|