troy 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- troy (0.0.5)
4
+ troy (0.0.6)
5
5
  builder
6
6
  i18n
7
7
  rack
@@ -6,6 +6,7 @@ require "sprockets"
6
6
  require "thor"
7
7
  require "thor/group"
8
8
  require "rack"
9
+ require "uglifier"
9
10
 
10
11
  require "cgi"
11
12
  require "fileutils"
@@ -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
@@ -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
- [301, {
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
@@ -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]
@@ -1,3 +1,3 @@
1
1
  module Troy
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -0,0 +1,5 @@
1
+ source :rubygems
2
+
3
+ gem "rack"
4
+ gem "unicorn"
5
+ gem "troy"
@@ -0,0 +1 @@
1
+ web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
@@ -0,0 +1,10 @@
1
+ require "bundler"
2
+ Bundler.setup
3
+ Bundler.require
4
+
5
+ require "troy"
6
+
7
+ use Rack::ContentLength
8
+ use Rack::CommonLogger
9
+ use Rack::Deflater
10
+ run Troy::Server.new(File.expand_path("../public", __FILE__))
@@ -0,0 +1,2 @@
1
+ worker_processes 4
2
+ timeout 30
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.5
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: []