Skip to content

Instantly share code, notes, and snippets.

@bergantine
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bergantine/8923446 to your computer and use it in GitHub Desktop.
Save bergantine/8923446 to your computer and use it in GitHub Desktop.
Modifying django-newproj to use with Zurb Foundation

setup project directories

mkdir project
cd $_

download the bootstrap.sh file

curl https://gist.github.com/jbergantine/8923446/raw/bootstrap.sh > bootstrap.sh

download the vagrant file

curl https://gist.github.com/jbergantine/8923446/raw/Vagrantfile > Vagrantfile

run the bootstrap file

bash bootstrap.sh

modify the bootstrap::static-media cookbook

subl ./my-recipes/cookbooks/bootstrap/recipes/static-media.rb

Remove everything and replace with the following:

# Configure Static Media
bash "configure static media" do
    user "vagrant"
    code <<-EOH
        cd /vagrant/myproject/myproject
        mkdir -p media static static_media
        cd static_media
    EOH
    not_if "ls /vagrant/myproject/myproject | grep static_media"
end

bash "install bower and grunt-cli" do
    user "vagrant"
    code <<-EOH
        cd /vagrant/myproject
        sudo npm install -g bower grunt-cli
    EOH
    not_if "npm -g list | grep grunt"
end

bash "start foundation project" do
    user "vagrant"
    code <<-EOH
        cd /vagrant/myproject/myproject/static_media
        compass create stylesheets -r zurb-foundation --using foundation
    EOH
  not_if "ls /vagrant/myproject/myproject/static_media | grep stylesheets"
end

vagrant up and ssh in

vagrant up
vagrant ssh

modify the base template references to static_media

Update the paths to the stylesheets to be:

<link href="{{ STATIC_URL }}stylesheets/stylesheets/app.css" media="screen, projector, print" rel="stylesheet" type="text/css" />

Update the path to modernizr.js to be:

<script src="javascripts/vendor/custom.modernizr.js"></script>

Replace the jQuery script in {% block javascript %} with:

<script>
    document.write('<script src=' +
    ('__proto__' in {} ? '{{ STATIC_URL }}stylesheets/javascripts/vendor/zepto' : '{{ STATIC_URL }}stylesheets/javascripts/vendor/jquery') +
    '.js><\/script>')
</script>

<script src="{{ STATIC_URL }}stylesheets/javascripts/foundation/foundation.js"></script>

<script src="{{ STATIC_URL }}stylesheets/javascripts/foundation/foundation.abide.js"></script>

<script src="{{ STATIC_URL }}stylesheets/javascripts/foundation/foundation.orbit.js"></script>

<script src="{{ STATIC_URL }}stylesheets/javascripts/foundation/foundation.joyride.js"></script>

<script src="{{ STATIC_URL }}stylesheets/javascripts/foundation/foundation.forms.js"></script>

<script src="{{ STATIC_URL }}stylesheets/javascripts/foundation/foundation.tooltips.js"></script>

<script src="{{ STATIC_URL }}stylesheets/javascripts/foundation/foundation.clearing.js"></script>

<script src="{{ STATIC_URL }}stylesheets/javascripts/foundation/foundation.alerts.js"></script>

<script src="{{ STATIC_URL }}stylesheets/javascripts/foundation/foundation.magellan.js"></script>

<script src="{{ STATIC_URL }}stylesheets/javascripts/foundation/foundation.placeholder.js"></script>

<script src="{{ STATIC_URL }}stylesheets/javascripts/foundation/foundation.cookie.js"></script>

<script src="{{ STATIC_URL }}stylesheets/javascripts/foundation/foundation.interchange.js"></script>

<script src="{{ STATIC_URL }}stylesheets/javascripts/foundation/foundation.dropdown.js"></script>

<script src="{{ STATIC_URL }}stylesheets/javascripts/foundation/foundation.section.js"></script>

<script src="{{ STATIC_URL }}stylesheets/javascripts/foundation/foundation.reveal.js"></script>

<script src="{{ STATIC_URL }}stylesheets/javascripts/foundation/foundation.topbar.js"></script>


<script>
    $(document).foundation();
</script>

from here

  1. syncdb, migrate and smoke test (frs)

Documentation

#!/bin/bash
# setup the infrastructure
mkdir -p ./my-recipes/cookbooks
# download cookbooks
mkdir -p ./my-recipes/cookbooks/apt && wget --no-check-certificate https://github.com/opscode-cookbooks/apt/tarball/master -O - | tar -xz --strip-components=1 --directory=./my-recipes/cookbooks/apt
mkdir -p ./my-recipes/cookbooks/build-essential && wget --no-check-certificate https://github.com/opscode-cookbooks/build-essential/tarball/master -O - | tar -xz --strip-components=1 --directory=./my-recipes/cookbooks/build-essential
mkdir -p ./my-recipes/cookbooks/sudo && wget --no-check-certificate https://github.com/opscode-cookbooks/sudo/tarball/master -O - | tar -xz --strip-components=1 --directory=./my-recipes/cookbooks/sudo
mkdir -p ./my-recipes/cookbooks/openssl && wget --no-check-certificate https://github.com/opscode-cookbooks/openssl/tarball/master -O - | tar -xz --strip-components=1 --directory=./my-recipes/cookbooks/openssl
mkdir -p ./my-recipes/cookbooks/postgresql && wget --no-check-certificate https://github.com/opscode-cookbooks/postgresql/tarball/master -O - | tar -xz --strip-components=1 --directory=./my-recipes/cookbooks/postgresql
mkdir -p ./my-recipes/cookbooks/git && wget --no-check-certificate https://github.com/opscode-cookbooks/git/tarball/master -O - | tar -xz --strip-components=1 --directory=./my-recipes/cookbooks/git
mkdir -p ./my-recipes/cookbooks/memcached && wget --no-check-certificate https://github.com/opscode-cookbooks/memcached/tarball/master -O - | tar -xz --strip-components=1 --directory=./my-recipes/cookbooks/memcached
mkdir -p ./my-recipes/cookbooks/python && wget --no-check-certificate https://github.com/comandrei/python/tarball/master -O - | tar -xz --strip-components=1 --directory=./my-recipes/cookbooks/python
mkdir -p ./my-recipes/cookbooks/nodejs && wget --no-check-certificate https://github.com/mdxp/nodejs-cookbook/tarball/master -O - | tar -xz --strip-components=1 --directory=./my-recipes/cookbooks/nodejs
mkdir -p ./my-recipes/cookbooks/rvm && wget --no-check-certificate https://github.com/fnichol/chef-rvm/tarball/master -O - | tar -xz --strip-components=1 --directory=./my-recipes/cookbooks/rvm
mkdir -p ./my-recipes/cookbooks/bootstrap && wget --no-check-certificate https://github.com/jbergantine/chef-cookbook-djangonewproj/tarball/master -O - | tar -xz --strip-components=1 --directory=./my-recipes/cookbooks/bootstrap
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise64"
# The url from where the 'config.vm.box' box will be fetched if it
# doesn't already exist on the user's system.
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
# Provision
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = "./my-recipes/cookbooks"
chef.add_recipe "apt"
chef.add_recipe "build-essential"
chef.add_recipe "sudo"
# openssl is a requirement for postgresql
chef.add_recipe "openssl"
# postgresql database server
chef.add_recipe "postgresql::client"
chef.add_recipe "postgresql::server"
# git
chef.add_recipe "git"
# python, python-dev plus pip and virtualenv
chef.add_recipe "python"
chef.add_recipe "python::pip"
chef.add_recipe "python::virtualenv"
# memcached
chef.add_recipe "memcached"
# rvm
chef.add_recipe "rvm::user"
#chef.add_recipe "rvm::gem_package"
# nodejs and npm
chef.add_recipe "nodejs::install_from_source"
chef.add_recipe "nodejs::npm"
# Assign the password 'thisisapassword' to psql user 'postgres'
# Setup memcached
chef.json = {
:authorization => {
:sudo => {
:users => [ "vagrant" ],
:passwordless => "true"
}
},
:postgresql => {
:version => "9.1",
:listen_address => "*",
:hba => [
{ :method => "trust", :address => "0.0.0.0/0" },
{ :method => "trust", :address => "::1/0" }
],
:password => {
:postgres => "thisisapassword"
}
},
:memcached => {
:memory => '32', # in MB
:user => 'vagrant',
:port => '11211',
:listen => '127.0.0.1'
},
:rvm => {
:user_installs => [
{ :user => 'vagrant',
:default_ruby => '2.1.0',
:gems => { 'ruby-2.1.0' => [
{ 'name' => 'sass' },
{ 'name' => 'chunky_png' },
{ 'name' => 'fssm' },
{ 'name' => 'compass' },
{ 'name' => 'susy' },
{ 'name' => 'foreman' },
{ 'name' => 'foundation' },
{ 'name' => 'zurb-foundation' }
]}
}
]
}
}
chef.add_recipe "bootstrap::virtualenv"
chef.add_recipe "bootstrap::bash"
chef.add_recipe "bootstrap::postgresql"
chef.add_recipe "bootstrap::start-project"
chef.add_recipe "bootstrap::init-git"
chef.add_recipe "bootstrap::static-media"
end
# To access a website running on port 8000, we can open a web browser
# on our workstation and go to http://localhost:8000
config.vm.network "forwarded_port", guest: 8000, host: 8000
# Shared folder
config.vm.synced_folder "vagrant/", "/vagrant", create: true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment