topkit 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -28,10 +28,11 @@ module Topkit
28
28
  end
29
29
 
30
30
  def download_file(uri_string, destination)
31
+ require 'net/http'
31
32
  uri = URI.parse(uri_string)
32
- http = Net::HTTP.new(uri.host, uri.port)
33
+ http = ::Net::HTTP.new(uri.host, uri.port)
33
34
  http.use_ssl = true if uri_string =~ /^https/
34
- request = Net::HTTP::Get.new(uri.path)
35
+ request = ::Net::HTTP::Get.new(uri.path)
35
36
  contents = http.request(request).body
36
37
  path = File.join(destination_root, destination)
37
38
  File.open(path, "w") { |file| file.write(contents) }
@@ -79,6 +79,22 @@ module Topkit
79
79
  generate "backbone:install"
80
80
  end
81
81
 
82
+ def generate_backtrace
83
+ download_file "https://gist.github.com/apcomplete/4113645/download", "vendor/assets/javascripts/backtrace.js"
84
+ end
85
+
86
+ def add_relative_url_root
87
+ relative_root = <<-eos
88
+ #Deploy staging to subdirectory
89
+ config.action_controller.relative_url_root = '/#{options[:client]}/#{options[:project]}'
90
+ eos
91
+ inject_into_file "config/environments/staging.rb", "\n#{relative_root}", after: "config.serve_static_assets = true\n"
92
+
93
+ replace_in_file "config.ru",
94
+ "run #{app_const}",
95
+ %(map ActionController::Base.config.relative_url_root || "/" do\n run #{app_const}\nend)
96
+ end
97
+
82
98
  def enable_database_cleaner
83
99
  replace_in_file 'spec/spec_helper.rb',
84
100
  'config.use_transactional_fixtures = true',
@@ -4,7 +4,10 @@ require 'rails/generators/rails/app/app_generator'
4
4
  module Topkit
5
5
  class AppGenerator < Rails::Generators::AppGenerator
6
6
  #class_option :gitlab, type: :string, aliases: '-G', default: false
7
- class_option :skip_admin, type: :boolean, aliases: '-A', default: false
7
+ class_option :skip_admin, type: :boolean, aliases: '-A', default: false,
8
+ desc: "Skip rails admin generators"
9
+ class_option :client, type: :string, desc: "Specify client abbreviation"
10
+ class_option :project, type: :string, desc: "Specify project number"
8
11
 
9
12
  def finish_template
10
13
  invoke :topkit_customization
@@ -80,6 +83,8 @@ module Topkit
80
83
  def configure_backbone
81
84
  say "Generating backbone"
82
85
  build :generate_backbone
86
+ build :generate_backtrace
87
+ build :add_relative_url_root if options[:client] and options[:project]
83
88
  end
84
89
 
85
90
  def configure_admin
@@ -1,3 +1,3 @@
1
1
  module Topkit
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -16,9 +16,12 @@
16
16
  <!--[if IE]>
17
17
  <%# stylesheet_link_tag "ie", :media => "screen, projection" %>
18
18
  <![endif]-->
19
+ <script type="text/javascript">
20
+ var BASE_PATH = '<%= ActionController::Base.config.relative_url_root || "" %>';
21
+ </script>
19
22
  <%= csrf_meta_tags %>
20
23
  </head>
21
- <body data-env="<%= Rails.env %>">
24
+ <body>
22
25
  <div id="container">
23
26
  <%= render "status" %>
24
27
  <%= render "header" %>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: topkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-04 00:00:00.000000000 Z
12
+ date: 2013-06-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler