Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

create rewrite rules and add it as json when pushing the app

  • Loading branch information...
commit 9cbb2a545dd2473df89708edd8425d094cc27eba 1 parent c8e3138
@rmetzler rmetzler authored quirkey committed
View
1  lib/soca/cli.rb
@@ -79,6 +79,7 @@ def generate(to = nil)
directory('db')
template('Jimfile')
template('index.html.erb', 'index.html')
+ template('rewrites.js.erb', 'rewrites.js')
@dir_mappings = {
"config.js" => "",
"index.html" => "_attachments/index.html",
View
2  lib/soca/pusher.rb
@@ -138,6 +138,8 @@ def map_file(path, hash)
if base_path =~ /^_attachments/
hash['_attachments'] ||= {}
hash['_attachments'][base_path.gsub(/_attachments\//, '')] = make_attachment(path, file_data)
+ elsif base_path == 'rewrites.js'
+ hash['rewrites'] = JSON.parse(file_data)
else
parts = base_path.gsub(/^\//, '').gsub(/\.js$/, '').split('/')
current_hash = hash
View
8 lib/soca/templates/rewrites.js.erb
@@ -0,0 +1,8 @@
+[
+ {
+ "from":"/",
+ "to":"index.html",
+ "method":"GET",
+ "query":{}
+ }
+]
View
4 test/test_soca_cli.rb
@@ -57,6 +57,10 @@ class TestSocaCLI < Test::Unit::TestCase
assert_file(/\<html/, @new_app_dir, 'index.html')
end
+ should "generate a rewrites.js file" do
+ assert_file(/from/,@new_app_dir,'rewrites.js')
+ end
+
should "generate a css directory" do
assert_directory(@new_app_dir, 'css')
end
View
5 test/test_soca_pusher.rb
@@ -50,6 +50,11 @@ class TestSocaPusher < Test::Unit::TestCase
assert_match(/function/, @app_file['views']['recent']['map'])
assert @app_file['_attachments']['css/app.css']
end
+
+ should "include rewrites.js as json" do
+ assert @app_file['rewrites']
+ assert @app_file['rewrites'][0]['from']
+ end
end
context "push_url" do
View
8 test/testapp/rewrites.js
@@ -0,0 +1,8 @@
+[
+ {
+ "from":"/",
+ "to":"index.html",
+ "method":"GET",
+ "query":{}
+ }
+]
Please sign in to comment.
Something went wrong with that request. Please try again.