From 81661c883f0230cafc1562961e5dd62fce901f5d Mon Sep 17 00:00:00 2001
From: danielgrippi <danielgrippi@gmail.com>
Date: Fri, 11 May 2012 17:05:09 -0700
Subject: [PATCH] custom landing page logic for mobile.  yay

---
 app/controllers/home_controller.rb              | 6 +++++-
 app/views/layouts/{post.html.haml => post.haml} | 0
 lib/tasks/after_deploy.rake                     | 2 +-
 lib/tasks/before_deploy.rake                    | 9 ++++-----
 4 files changed, 10 insertions(+), 7 deletions(-)
 rename app/views/layouts/{post.html.haml => post.haml} (100%)

diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb
index df57d3d288..d3bbdf881c 100644
--- a/app/controllers/home_controller.rb
+++ b/app/controllers/home_controller.rb
@@ -13,7 +13,11 @@ class HomeController < ApplicationController
         redirect_to stream_path
       end
     elsif is_mobile_device?
-      redirect_to user_session_path
+      unless(File.exist?("#{Rails.root}/app/views/home/_show.mobile.erb"))
+        redirect_to user_session_path
+      else
+        render :show, :layout => 'post'
+      end
     else
       @landing_page = true
       render :show, :layout => 'post'
diff --git a/app/views/layouts/post.html.haml b/app/views/layouts/post.haml
similarity index 100%
rename from app/views/layouts/post.html.haml
rename to app/views/layouts/post.haml
diff --git a/lib/tasks/after_deploy.rake b/lib/tasks/after_deploy.rake
index b42ea45ee3..05afc38964 100644
--- a/lib/tasks/after_deploy.rake
+++ b/lib/tasks/after_deploy.rake
@@ -2,7 +2,7 @@ desc "revert custom landing page commit after heroku san deploys"
 task :after_deploy => :environment do
 
   # Perform this task only if custom landing page is not present in app/views/home/_show.html.haml
-  if File.exist?(File.join(Rails.root, "app", "views", "home", "_show.html.erb")) && system("git log | head -5 | grep 'custom\ landing\ page'")
+  if (File.exist?(File.join(Rails.root, "app", "views", "home", "_show.html.erb")) || File.exist?(File.join(Rails.root, "app", "views", "home", "_show.mobile.erb"))) && system("git log | head -5 | grep 'custom\ landing\ page(s)'")
     puts "-----> resetting HEAD before custom landing page commit"
 
     system("git reset HEAD^") ? true : fail
diff --git a/lib/tasks/before_deploy.rake b/lib/tasks/before_deploy.rake
index 41cd8a0fd4..fcbd7ebf49 100644
--- a/lib/tasks/before_deploy.rake
+++ b/lib/tasks/before_deploy.rake
@@ -2,16 +2,15 @@ desc "include custom landing page before heroku san deploys"
 task :before_deploy => :environment do
 
     each_heroku_app do |stage|
-      home_file = stage.config['HOME_FILE']
+      home_file = stage.config['HOME_FILE_DESKTOP']
     # Perform this task only if custom landing page is not present in app/views/home/_show.html.haml
     if home_file.present?
-      puts "-----> custom landing page detected..."
-
-      puts "-----> including custom landing page in a temp commit"
+      puts "-----> custom landing page(s) detected..."
+      puts "-----> including custom landing page(s) in a temp commit"
 
       @did_not_stash = system("git stash| grep 'No local changes to save'")      
       system("git add #{home_file} -f") ? true : fail
-      system("git commit -m 'adding custom landing page for heroku'") ? true : fail
+      system("git commit -m 'adding custom landing page(s) for heroku'") ? true : fail
 
       puts "-----> done"
     end
-- 
GitLab