From ee02a073cd88d8b68f922e3704ad6fc16a52b36a Mon Sep 17 00:00:00 2001 From: maxwell Date: Thu, 3 Feb 2011 18:36:42 -0800 Subject: [PATCH] toggle mobile site, when mobile device --- app/controllers/aspects_controller.rb | 2 -- app/controllers/home_controller.rb | 9 +++++++++ app/views/layouts/application.html.haml | 1 + app/views/layouts/application.mobile.haml | 7 ++++++- config/locales/diaspora/en.yml | 1 + config/routes.rb | 4 ++-- 6 files changed, 19 insertions(+), 5 deletions(-) diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index 46321e441..af33ad4fd 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -95,12 +95,10 @@ class AspectsController < ApplicationController end def manage - Rails.logger.info("Controller time") @aspect = :manage @contacts = current_user.contacts.includes(:person => :profile).where(:pending => false) @remote_requests = Request.where(:recipient_id => current_user.person.id).includes(:sender => :profile) @aspects = @all_aspects.includes(:contacts => {:person => :profile}) - Rails.logger.info("VIEW TIME!!!!!!") end def update diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 64665147f..55b235c2c 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -18,4 +18,13 @@ class HomeController < ApplicationController render :show end end + + def toggle_mobile + if session[:mobile_view] + session[:mobile_view] = false + else + session[:mobile_view] = true + end + redirect_to :back + end end diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 0a4a141c8..7d8a2fe4d 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -99,6 +99,7 @@ %li= link_to t('layouts.header.blog'), "http://blog.joindiaspora.com" %li= link_to t('layouts.header.code'), "#{root_url.chomp('/')}/source.tar.gz" unless request.url.match(/joindiaspora.com/) %li= link_to t('.whats_new'), 'https://github.com/diaspora/diaspora/wiki/Changelog' + %li= link_to(t('layouts.application.toggle'), toggle_mobile_path) if is_mobile_device? = image_tag 'powered_by_diaspora.png', :height => "11px", :width => "145px" %br = link_to t('.have_a_problem'), 'http://diaspora.shapado.com/' diff --git a/app/views/layouts/application.mobile.haml b/app/views/layouts/application.mobile.haml index e68bbcae7..bbf505762 100644 --- a/app/views/layouts/application.mobile.haml +++ b/app/views/layouts/application.mobile.haml @@ -60,6 +60,9 @@ %br = link_to t('layouts.header.logout'), destroy_user_session_path + %br + %br + = link_to t('layouts.application.toggle'), toggle_mobile_path -if current_user #menu{:data => {:role => 'page'}} @@ -102,6 +105,8 @@ = link_to aspect, aspects_path('a_ids[]' => aspect.id) | %br - %br = link_to t('layouts.header.logout'), destroy_user_session_path + %br + %br + = link_to t('layouts.application.toggle'), toggle_mobile_path diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 4c732af84..8c8f25753 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -99,6 +99,7 @@ en: have_a_problem: "Have a problem? Find an answer here" your_aspects: "your aspects" logged_in_as: "logged in as %{name}" + toggle: 'toggle mobile site' shared: publisher: posting: "Posting..." diff --git a/config/routes.rb b/config/routes.rb index 33373d58f..f64a29be3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -56,8 +56,8 @@ Diaspora::Application.routes.draw do match 'receive/users/:guid', :to => 'publics#receive' match 'hub', :to => 'publics#hub' - match 'localize', :to => "localize#show" - + match'localize', :to => "localize#show" + match 'mobile/toggle', :to => 'home#toggle_mobile', :as => 'toggle_mobile' #root root :to => 'home#show' end