Created
December 8, 2012 02:25
-
-
Save bbttxu/4238252 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#\ -p 4000 | |
require 'rubygems' | |
require 'bundler' | |
require 'json' | |
begin | |
Bundler.setup(:default, :development) | |
rescue Bundler::BundlerError => e | |
$stderr.puts e.message | |
$stderr.puts "Run `bundle install` to install missing gems" | |
exit e.status_code | |
end | |
require 'serve' | |
require 'serve/rack' | |
# The project root directory | |
root = ::File.dirname(__FILE__) | |
# Compile Sass on the fly with the Sass plugin. Some production environments | |
# don't allow you to write to the file system on the fly (like Heroku). | |
# Remove this conditional if you want to compile Sass in production. | |
if ENV['RACK_ENV'] != 'production' | |
require 'sass' | |
require 'sass/plugin/rack' | |
require 'compass' | |
Compass.add_project_configuration(root + '/compass.config') | |
Compass.configure_sass_plugin! | |
use Sass::Plugin::Rack # Sass Middleware | |
end | |
# Other Rack Middleware | |
use Rack::ShowStatus # Nice looking 404s and other messages | |
use Rack::ShowExceptions # Nice looking errors | |
# Rack Application | |
if ENV['SERVER_SOFTWARE'] =~ /passenger/i | |
# Passendger only needs the adapter | |
run Serve::RackAdapter.new(root + '/views') | |
else | |
# Use Rack::Cascade and Rack::Directory on other platforms for static assets | |
run Rack::Cascade.new([ | |
Serve::RackAdapter.new(root + '/views'), | |
Rack::Directory.new(root + '/public') | |
]) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% | |
has_waypoints = true | |
lat = 34 | |
lon = 118 | |
min = 0.01 | |
max = 0.09 | |
lat_min = lat + min | |
lat_max = lat + max | |
lon_min = lon + min | |
lon_max = lon + max | |
num = 8 | |
data = { | |
:start => [ rand * (lat_max - lat_min) + lat_min, rand * (lon_max - lon_min) + lon_min ], | |
:end => [ rand * (lat_max - lat_min) + lat_min, rand * (lon_max - lon_min) + lon_min ] | |
} | |
if has_waypoints | |
waypoints = [] | |
(0..num).each do |foo| | |
waypoints << [ rand * (lat_max - lat_min) + lat_min, rand * (lon_max - lon_min) + lon_min ] | |
end | |
data[:waypoints] = waypoints | |
end | |
# puts data.to_json # production | |
%> | |
<pre> | |
<%= JSON.pretty_generate(data) %> | |
</pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source :rubygems | |
gem 'serve', '1.5.1' | |
# Use edge instead: | |
# gem 'serve', :git => 'git://github.com/jlong/serve.git' | |
# Use Compass and Sass | |
gem 'compass' | |
# Markdown and Textile | |
# gem 'rdiscount' # Markdown | |
# gem 'RedCloth' # Textile | |
# Other templating languages | |
# gem 'erubis' | |
# gem 'haml' | |
# gem 'slim' | |
# gem 'radius' | |
# gem 'less' | |
# Coffee Script | |
# gem 'coffee-script' | |
# Use mongrel for the Web server | |
# gem 'mongrel' | |
gem 'json' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Serve has a special file type for mapping HTTP redirects. Redirects make nice | |
end points for form posts or short URLs. | |
Redirect URLs can be fully formed, like this: | |
http://wiseheartdesign.com/ | |
Or, relative to the site root, like this: | |
/action | |
Extra lines at the beginning of a redirect file are ignored. By convention, | |
the last line of a redirect file is the URL to redirect to: | |
/welcome | |
/foo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment