# Template for a Zurb Foundation app. It uses Bower to manage frontend resources. opts = options.dup opts.delete("template") # Check for valid template engine. until ["erb", "haml", "slim"].include?(opts["renderer"]) opts["renderer"] = ask( "Foundation is not compatible with #{opts["renderer"]} template engine. Choose another one [erb|haml]", "slim" ) end # Check for valid stylesheet engine. until ["compass", "scss", "none"].include?(opts["stylesheet"]) opts["stylesheet"] = ask( "Foundation is not compatible with #{opts["stylesheet"]} syntax. Choose another stylesheet engine [compass|scss]", "none" ) end project opts # Ignore Npm stuff gitignore = <<-IGNORE public/node_modules IGNORE append_file ".gitignore", gitignore # Create Npm's package.json package_json = <<-PACKAGE { "name": "foundation-app", "version": "0.0.1", "devDependencies": {} } PACKAGE create_file "public/package.json", package_json # Create bower.json bower_json = <<-BOWER { "name": "foundation-app", "version": "0.0.1", "private": "true", "dependencies": {} } BOWER create_file "public/bower.json", bower_json # Install Bower inside("public") do run("npm install bower --save-dev --silent", :capture => true) end # Install Foundation inside("public") do run("node_modules/bower/bin/bower install foundation --save --silent") end # Setup Stylesheets application_scss = <<-SCSS @import "partials/settings"; // Add your rules here SCSS if opts["stylesheet"] == "none" create_file("public/stylesheets/foundation/foundation.css") { File.read("#{name}/public/bower_components/foundation/css/foundation.css") } create_file("public/stylesheets/foundation/normalize.css") { File.read("#{name}/public/bower_components/foundation/css/normalize.css") } create_file("public/stylesheets/application.css", "// Add your rules here\n") else file_name = (opts["stylesheet"] == "compass") ? "compass_plugin.rb" : "scss_initializer.rb" inject_into_file("lib/#{file_name}", 'Sass::Plugin.add_template_location "#{Padrino.root}/public/bower_components/foundation/scss", "#{Padrino.root}/public/stylesheets/foundation"' << "\n ", :before => "app.use Sass::Plugin::Rack\n") remove_file("app/stylesheets/partials/_base.scss") remove_file("app/stylesheets/application.scss") create_file("app/stylesheets/partials/_settings.scss") { File.read("#{name}/public/bower_components/foundation/scss/foundation/_settings.scss") } create_file("app/stylesheets/application.scss", application_scss) end # Create Layout layouts = {} layouts["erb"] = <<-LAYOUT Foundation <%= stylesheet_link_tag "/stylesheets/foundation/normalize.css" %> <%= stylesheet_link_tag "/stylesheets/foundation/foundation.css" %> <%= stylesheet_link_tag "/stylesheets/application.css" %> <%= javascript_include_tag "/bower_components/modernizr/modernizr.js" %> <%= yield %> <%= javascript_include_tag "/bower_components/jquery/jquery.js" %> <%= javascript_include_tag "/bower_components/foundation/js/foundation.min.js" %> <%= javascript_include_tag "/javascripts/application.js" %> LAYOUT layouts["haml"] = <<-LAYOUT !!! 5 %html.no-js{:lang => "en"} %head %meta{:charset => "utf-8"} %meta{:name => "viewport", :content => "width=device-width, initial-scale=1.0"} %title Foundation = stylesheet_link_tag "/stylesheets/foundation/normalize.css" = stylesheet_link_tag "/stylesheets/foundation/foundation.css" = stylesheet_link_tag "/stylesheets/application.css" = javascript_include_tag "/bower_components/modernizr/modernizr.js" %body = yield = javascript_include_tag "/bower_components/jquery/jquery.js" = javascript_include_tag "/bower_components/foundation/js/foundation.min.js" = javascript_include_tag "/javascripts/application.js" LAYOUT layouts["slim"] = <<-LAYOUT doctype html html.no-js lang="en" head meta charset="utf-8" meta name="viewport" content="width=device-width, initial-scale=1.0" title Foundation = stylesheet_link_tag "/stylesheets/foundation/normalize.css" = stylesheet_link_tag "/stylesheets/foundation/foundation.css" = stylesheet_link_tag "/stylesheets/application.css" = javascript_include_tag "/bower_components/modernizr/modernizr.js" body = yield = javascript_include_tag "/bower_components/jquery/jquery.js" = javascript_include_tag "/bower_components/foundation/js/foundation.min.js" = javascript_include_tag "/javascripts/application.js" LAYOUT if layouts[opts["renderer"]] create_file "app/views/layouts/application.#{opts['renderer']}", layouts[opts["renderer"]] end # Create index page indexes = {} indexes["erb"] = <<-INDEX

Welcome to Foundation

We’re stoked you want to try Foundation!

A whole kitchen sink of goodies comes with Foundation. Checkout the docs to see them all, along with details on making them your own.

Go to Foundation Docs
INDEX indexes["haml"] = <<-INDEX .row .large-12.columns %h1 Welcome to Foundation .row .large-12.columns .panel %h3 We’re stoked you want to try Foundation! %p A whole kitchen sink of goodies comes with Foundation. Checkout the docs to see them all, along with details on making them your own. %a.small.button{:href => "http://foundation.zurb.com/docs/"} Go to Foundation Docs INDEX indexes["slim"] = <<-INDEX .row .large-12.columns h1 Welcome to Foundation .row .large-12.columns .panel h3 == "We’re stoked you want to try Foundation!" p A whole kitchen sink of goodies comes with Foundation. Checkout the docs to see them all, along with details on making them your own. a.small.button href="http://foundation.zurb.com/docs/" Go to Foundation Docs INDEX create_file "app/views/index.#{opts['renderer']}", indexes[opts["renderer"]] # Setup Javascript create_file "public/javascripts/application.js", "$(document).foundation();\n" # Setup default route default_route = <<-ROUTE get :index do render :index end ROUTE inject_into_file 'app/app.rb', default_route, :after => "enable :sessions\n"