From 16c25afaefe2bf7ac37c4ae22d9616afd7ca2de4 Mon Sep 17 00:00:00 2001 From: magnolia-fan Date: Sun, 27 Nov 2011 22:17:09 +0400 Subject: [PATCH] Color fixes, deploy task --- app/assets/javascripts/ajax.coffee | 4 +- app/assets/javascripts/search.coffee | 4 +- app/assets/javascripts/session.coffee | 2 + app/assets/stylesheets/misc.scss | 7 +++ app/views/artist/_page.html.haml | 7 ++- app/views/playlist/_tracks.html.haml | 2 +- lib/tasks/deploy.rake | 79 +++++++++++++++++++++++++++ 7 files changed, 97 insertions(+), 8 deletions(-) create mode 100644 lib/tasks/deploy.rake diff --git a/app/assets/javascripts/ajax.coffee b/app/assets/javascripts/ajax.coffee index 030cf7b..f6fdd21 100644 --- a/app/assets/javascripts/ajax.coffee +++ b/app/assets/javascripts/ajax.coffee @@ -47,9 +47,9 @@ class window.Ajax _page.render response _ajax.hideSpinner() if _session.getUser().id? - $('.button-container').show() + $('.authorized-action').show() else - $('.button-container').hide() + $('.authorized-action').hide() false false diff --git a/app/assets/javascripts/search.coffee b/app/assets/javascripts/search.coffee index 66ccc0e..46c1e27 100644 --- a/app/assets/javascripts/search.coffee +++ b/app/assets/javascripts/search.coffee @@ -20,9 +20,9 @@ class window.Search _page.render data _search.hideSpinner() if _session.getUser().id? - $('.button-container').show() + $('.authorized-action').show() else - $('.button-container').hide() + $('.authorized-action').hide() if data.status is 'loading' setTimeout () -> _search.loadArtistData name diff --git a/app/assets/javascripts/session.coffee b/app/assets/javascripts/session.coffee index 715774e..b8a680e 100644 --- a/app/assets/javascripts/session.coffee +++ b/app/assets/javascripts/session.coffee @@ -41,9 +41,11 @@ class window.Session displayAuthorizedContent: -> $('.playlist, .player').show() $('.ad_here, #login').hide() + $('.authorized-action').show() $('#authorized').css display: 'block' hideAuthorizedContent: -> $('.playlist, .player, #authorized').hide() $('.ad_here').show() + $('.authorized-action').hide() $('#login').css display: 'block' diff --git a/app/assets/stylesheets/misc.scss b/app/assets/stylesheets/misc.scss index ac4b68f..f8aec55 100644 --- a/app/assets/stylesheets/misc.scss +++ b/app/assets/stylesheets/misc.scss @@ -33,4 +33,11 @@ table.stats { .data.artist { color: inherit; cursor: pointer; +} + +.page-link { + color: inherit; + &:hover { + color: inherit; + } } \ No newline at end of file diff --git a/app/views/artist/_page.html.haml b/app/views/artist/_page.html.haml index 59b5626..a60f347 100644 --- a/app/views/artist/_page.html.haml +++ b/app/views/artist/_page.html.haml @@ -24,15 +24,16 @@ %table.zebra-striped %tr %td - %span.label.success.set-playlist{ href: "", 'data-playlist' => "lastfm-top50/#{@data[:url_name]}" }= t('player.set_playlist') + %span.label.success.authorized-action.set-playlist{ href: "", 'data-playlist' => "lastfm-top50/#{@data[:url_name]}" } + = t('player.set_playlist') %a.page-link.playlist-name{ href: "/playlist/lastfm-top50/#{@data[:url_name]}" }= "#{@data[:name]}: Last.fm TOP" - @data[:albums].each do |album| .row.album .span4.columns.art %img{ src: album[:pic_url] } - .button-container - %a.btn.add-album{ 'data-tracks' => album[:tracks].map{|_|_[:id]}.join(",") }= t('player.add') + .button-container.authorized-action + %a.btn.success.add-album{ 'data-tracks' => album[:tracks].map{|_|_[:id]}.join(",") }= t('player.add') .span7.columns.tracks %h3 = album[:name] diff --git a/app/views/playlist/_tracks.html.haml b/app/views/playlist/_tracks.html.haml index 482f307..16070c9 100644 --- a/app/views/playlist/_tracks.html.haml +++ b/app/views/playlist/_tracks.html.haml @@ -3,7 +3,7 @@ - unless @data[:pic_url].nil? %img{ src: @data[:pic_url] } .button-container - %a.btn.add-album{ 'data-tracks' => @data[:tracks].map{|_|_[:id]}.join(",") }= t('player.play_all') + %a.btn.success.authorized-action.add-album{ 'data-tracks' => @data[:tracks].map{|_|_[:id]}.join(",") }= t('player.play_all') .span8.columns.tracks %h3= @data[:name] %table.zebra-striped.tracklist diff --git a/lib/tasks/deploy.rake b/lib/tasks/deploy.rake new file mode 100644 index 0000000..4899317 --- /dev/null +++ b/lib/tasks/deploy.rake @@ -0,0 +1,79 @@ +namespace :deploy do + desc "Deploys our application on heroku" + task :run => [:test, :off, :push, :migrate, :restart, :on, :tag] + + desc "Rolls previous deploy revision back" + task :rollback => [:off, :push_previous, :restart, :on] + + task :test do + puts "Running tests ..." # and look in $?.exitstatus + throw "Tests failed!" if `cucumber`.match /\d+ scenarios \(.*?\d+ failed.*?\)/ + end + + task :push do + puts 'Deploying site to Heroku ...' + system('git push heroku master') + end + + task :restart do + puts 'Restarting app servers ...' + system('heroku restart') + end + + task :tag do + release_name = "heroku-build-#{Time.now.utc.strftime("%Y%m%d%H%M%S")}" + puts "Tagging release as '#{release_name}'" + system('git tag -a #{release_name} -m "Tagged release"') + system('git push --tags heroku') + end + + task :migrate do + puts 'Running database migrations ...' + system('heroku run rake db:migrate') + end + + task :off do + puts 'Putting the app into maintenance mode ...' + system('heroku maintenance:on') + end + + task :on do + puts 'Taking the app out of maintenance mode ...' + system('heroku maintenance:off') + end + + task :push_previous do + releases = `git tag`.split("\n").select{ |t| t[0..7] == 'heroku-build-' }.sort + current_release = releases.last + previous_release = releases[-2] if releases.length >= 2 + if previous_release + puts "Rolling back to '#{previous_release}' ..." + + puts "Checking out '#{previous_release}' in a new branch on local git repo ..." + system('git checkout #{previous_release}') + system('git checkout -b #{previous_release}') + + puts "Removing tagged version '#{previous_release}' (now transformed in branch) ..." + system('git tag -d #{previous_release}') + system('git push heroku :refs/tags/#{previous_release}') + + puts "Pushing '#{previous_release}' to Heroku master ..." + system('git push heroku +#{previous_release}:master --force') + + puts "Deleting rollbacked release '#{current_release}' ..." + system('git tag -d #{current_release}') + system('git push heroku :refs/tags/#{current_release}') + + puts "Retagging release '#{previous_release}' in case to repeat this process (other rollbacks)..." + system('git tag -a #{previous_release} -m "Tagged release"') + system('git push --tags heroku') + + puts "Turning local repo checked out on master ..." + system('git checkout master') + puts "All done!" + else + puts "No release tags found - can't roll back!" + puts releases + end + end +end \ No newline at end of file