Some JavaScript
// Delete confirmation modals
$('#delete-confirm').on('show', function() {
var $submit = $(this).find('.btn-danger'),
href = $submit.attr('href');
$submit.attr('href', href.replace('pony', $(this).data('id')));| # encoding: utf-8 | |
| class AlbumForm < BaseForm | |
| has_many :songs, class_name: 'SongForm' | |
| validates :songs, form_collection: true | |
| end |
| # add a new "put_copy" method to the Amazon client's S3Object class | |
| # to enable copying an object from 1 bucket to another | |
| # http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectCOPY.html | |
| class AWS::S3::S3Object | |
| def self.put_copy(source_key, target_key, source_bucket, target_bucket, options = {}) | |
| original = open(url_for(source_key, source_bucket)) | |
| default_options = { :content_type => original.content_type } | |
| store(target_key, original, target_bucket, default_options.merge(options)) | |
| acl(target_key, target_bucket, acl(source_key, source_bucket)) | |
| end |
| # to generate your dhparam.pem file, run in the terminal | |
| openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048 |
| namespace :assets do | |
| desc "compile assets locally and upload before finalize_update" | |
| task :deploy do | |
| %x[RAILS_ENV=production bundle exec rake assets:clean && RAILS_ENV=production bundle exec rake assets:precompile] | |
| run "sudo rm -rf #{release_path}/public/assets" | |
| ENV['COMMAND'] = " mkdir '#{release_path}/public/assets'" | |
| invoke | |
| path = File.expand_path("../../public/assets", __FILE__) | |
| puts path | |
| upload path, "#{release_path}/public/assets", {:recursive => true} |
| for F in $(find ./app/assets -name '*.scss'); do export FILENAME=${F##*/} && sass-convert $F ${F%$FILENAME}`basename "${F}" ".scss"`.sass && rm $F; done |
| require "sinatra/base" | |
| require "sinatra/namespace" | |
| require "multi_json" | |
| require "api/authentication" | |
| require "api/error_handling" | |
| require "api/pagination" | |
| module Api | |
| class Base < ::Sinatra::Base |
| # lib/tasks/deploy.rake | |
| namespace :deploy do | |
| desc 'Deploy to staging environment' | |
| task :staging do | |
| exec 'mina deploy -f config/deploy/staging.rb' | |
| end | |
| end |
| load 'deploy/assets' | |
| namespace :deploy do | |
| namespace :assets do | |
| desc 'Run the precompile task locally and rsync with shared' | |
| task :precompile, :roles => :web, :except => { :no_release => true } do | |
| %x{bundle exec rake assets:precompile} | |
| %x{rsync --recursive --times --rsh=ssh --compress --human-readable --progress public/assets #{user}@#{host}:#{shared_path}} | |
| %x{bundle exec rake assets:clean} | |
| end |