Last active
December 27, 2015 17:19
-
-
Save k2052/7361043 to your computer and use it in GitHub Desktop.
Padrino + MongoMapper + Zurb Foundation + Compass
This file contains hidden or 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
project :orm => :mongomapper, :test => :rspec, :renderer => :slim | |
require_dependencies( | |
'puma', 'imperator', 'oj', 'multi_json', | |
# Assets | |
'sprockets', 'sprockets-sass', | |
'coffee-script', 'uglifier', | |
'padrino-pipeline', | |
# Responses | |
'padrino-response', | |
# CSS | |
'compass', 'sassy-buttons', 'zurb-foundation' | |
) | |
empty_directory 'config/initializers' | |
sprockets_plugin = <<-RUBY | |
require 'sprockets' | |
# Append sprockets paths | |
Sprockets.append_path File.join Padrino.root, "app/assets/js" | |
Sprockets.append_path File.join Padrino.root, "app/assets/css" | |
Sprockets.append_path File.join Padrino.root, "bower_components" | |
Sprockets.append_path File.join Padrino.root, "vendor/assets/js" | |
Sprockets.append_path File.join Padrino.root, "vendor/assets/css" | |
RUBY | |
create_file 'config/initializers/sprockets.rb', sprockets_plugin | |
compass_plugin = <<-RUBY | |
module CompassInitializer | |
def self.registered(app) | |
require 'sass/plugin/rack' | |
require 'sprockets-sass' | |
require "sassy-buttons" | |
require "zurb-foundation" | |
require "susy" | |
Compass.configuration do |config| | |
config.environment = Padrino.env | |
config.project_path = Padrino.root | |
config.sass_dir = 'assets/css' | |
config.http_path = '/' | |
config.css_dir = 'public/css' | |
config.images_dir = 'public/images' | |
config.http_images_path = '/' + 'images' | |
config.http_fonts_path = '/' + 'fonts' | |
config.javascripts_dir = 'public/js' | |
config.output_style = :expanded | |
config.http_generated_images_path = '/' + 'images' | |
end | |
Compass.configure_sass_plugin! | |
Compass.handle_configuration_change! | |
app.use Sass::Plugin::Rack | |
end | |
end | |
RUBY | |
create_file 'config/initializers/compass.rb', compass_plugin | |
apps = <<-RUBY | |
Padrino.configure_apps do | |
set :session_secret, ENV['SESSION_SECRET'] | |
set :login_page, '/sessions/new' | |
set :session_id, ENV['SESSION_ID'] | |
enable :store_location | |
end | |
# Mounts the core application for this project | |
Padrino.mount('app').to('/') | |
RUBY | |
create_file 'config/apps.rb', apps | |
boot = <<-'RUBY' | |
# Defines our constants | |
PADRINO_ENV = ENV['PADRINO_ENV'] ||= ENV['RACK_ENV'] ||= 'development' unless defined?(PADRINO_ENV) | |
PADRINO_ROOT = File.expand_path('../..', __FILE__) unless defined?(PADRINO_ROOT) | |
# Load our dependencies | |
require 'rubygems' unless defined?(Gem) | |
require 'bundler/setup' | |
Bundler.require(:default, PADRINO_ENV) | |
# Set Some Env Variables | |
ENV['MONGO_DB'] ||= 'padrino_app_dev' | |
ENV['SESSION_SECRET'] ||= 'session_secret' | |
ENV['SESSION_ID'] ||= 'session_id' | |
## Configure I18n | |
I18n.default_locale = :en | |
Padrino.before_load do | |
# Dependencies | |
Padrino.dependency_paths.unshift("#{Padrino.root}/config/initializers/*.rb") | |
# Load Locale | |
I18n.load_path += Dir["#{File.dirname(__FILE__)}/../locale/*.yml"] | |
end | |
Padrino.load! | |
RUBY | |
create_file 'config/boot.rb', boot | |
database = <<-RUBY | |
if ENV['MONGOLAB_URI'] | |
MongoMapper.connection = Mongo::Connection.from_uri(ENV['MONGOLAB_URI']) | |
elsif ENV['MONGOHQ_URL'] | |
MongoMapper.connection = Mongo::Connection.from_uri(ENV['MONGOHQ_URL']) | |
else | |
MongoMapper.connection = Mongo::Connection.new('localhost', nil, :logger => logger) | |
end | |
case Padrino.env | |
when :development then MongoMapper.database = ENV['MONGO_DB'] | |
when :production then MongoMapper.database = ENV['MONGO_DB'] | |
when :test then MongoMapper.database = 'padrino_app_test' | |
end | |
RUBY | |
create_file 'config/database.rb', database | |
procfile = <<-TEXT | |
web: bundle exec rackup config.ru -s puma -p $PORT | |
TEXT | |
create_file 'Procfile', procfile | |
env = <<-ENV | |
RACK_ENV=development | |
SESSION_ID=changeme | |
SESSION_SECRET=changeme | |
MONGO_DB=padrino_app_dev | |
ENV | |
create_file '.env', env | |
create_file '.env_example', env | |
git :init | |
git :add, "--all" | |
git :commit, "-am 'initial commit'" | |
run_bundler |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment