From 39c5189c1ff1232ab89be89c1527da1e8125e2d2 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Fri, 21 Jan 2011 22:45:24 -0800 Subject: [PATCH] everything ported from pre-mysql mobile stuff. things missing: search page, aspect switcher, notification badge. --- .../_mixins.sassc | Bin 0 -> 1420 bytes app/controllers/application_controller.rb | 2 +- app/controllers/comments_controller.rb | 3 +- app/controllers/status_messages_controller.rb | 3 + app/views/aspects/index.mobile.haml | 11 +- app/views/comments/_comment.mobile.haml | 15 + app/views/comments/_comments.haml | 2 +- app/views/comments/_new_comment.mobile.haml | 11 + app/views/devise/sessions/new.mobile.haml | 7 - app/views/layouts/application.mobile.haml | 15 +- app/views/people/show.mobile.haml | 49 +++ app/views/shared/_author_info.mobile.haml | 6 + app/views/shared/_publisher.mobile.haml | 26 +- app/views/shared/_stream_element.mobile.haml | 22 ++ app/views/status_messages/show.mobile.haml | 23 ++ config/locales/diaspora/en.yml | 1 + public/stylesheets/sass/mobile.sass | 335 ++++++++++-------- vendor/plugins/mobile-fu/lib/mobile_fu.rb | 53 +-- 18 files changed, 379 insertions(+), 205 deletions(-) create mode 100644 .sass-cache/45e4e9f67747727a1d5f5f5a66df9ff84e1a8282/_mixins.sassc create mode 100644 app/views/comments/_comment.mobile.haml create mode 100644 app/views/comments/_new_comment.mobile.haml create mode 100644 app/views/people/show.mobile.haml create mode 100644 app/views/shared/_author_info.mobile.haml create mode 100644 app/views/shared/_stream_element.mobile.haml create mode 100644 app/views/status_messages/show.mobile.haml diff --git a/.sass-cache/45e4e9f67747727a1d5f5f5a66df9ff84e1a8282/_mixins.sassc b/.sass-cache/45e4e9f67747727a1d5f5f5a66df9ff84e1a8282/_mixins.sassc new file mode 100644 index 0000000000000000000000000000000000000000..2e7ac1635abf83d9c7d3c5c3399e6159398aad3d GIT binary patch literal 1420 zcmai!-*3|}5XXyzx+ZBUl#PJ|QdE9FtVuf+t@cZ#?Uf&5<7p3-6JJ-0#ExtiTK2%- z!GFs+X-7APc&X#7@9uk_JNs}D4@Tqg&2i3*S%t^=EBNZIACHg5Y?NjU;y69b4#)2x z9Rfd^O-6?qjM$KmkJ8Dz*uUFSGm({h&B_Ux^wQ|0QO0%(xvWT zYRgh18stGzqH$_g(y}FKshm^qyx9+GUer%~jMKpLxsV`sNRWJE`2wy2pJrN=mXHsN zA_d(h`w0iB3L%+Qdb*Ipn)3$jqUT;B7X|1od$Ye&F0o{#1@?yJeb2RrbdpR-3rkDd z9A<2hTY6t~(X2`ofEiC^(1fdpfL)BR*m(V#=yqCq?KUPZ0F z9;*#Dth+_;EAq6SfeovVn6i=+xZsDQRT)Y`AE?RZQ85wwdg}E3~|w2q=X|& z_vjsGaT(rlY2fi@ygu7-XDdn0*L~ksLr_opRtX-KK>GoGPG8WMe>MKpYP?8@ zC$Xy%NLOJ0t(XbWn98eD_xLk?=)G&t%U0mvTHxS+fe~Gk^pZI<)6E-nhMmE;&)q^-U3})2-#N&UB>(^b literal 0 HcmV?d00001 diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9654cb515..805931fa9 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -3,7 +3,7 @@ # the COPYRIGHT file. class ApplicationController < ActionController::Base - #has_mobile_fu + has_mobile_fu protect_from_forgery :except => :receive #before_filter :mobile_except_ipad diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index e8a502c66..9d8b69a0b 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -6,7 +6,7 @@ class CommentsController < ApplicationController include ApplicationHelper before_filter :authenticate_user! - respond_to :html + respond_to :html, :mobile respond_to :json, :only => :show def create @@ -34,6 +34,7 @@ class CommentsController < ApplicationController render(:json => json, :status => 201) } format.html{ render :nothing => true, :status => 201 } + format.mobile{ redirect_to status_message_path(@comment.post_id) } end else render :nothing => true, :status => 406 diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index 78b772952..fa82eb048 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -6,6 +6,7 @@ class StatusMessagesController < ApplicationController before_filter :authenticate_user! respond_to :html + respond_to :mobile respond_to :json, :only => :show def create @@ -33,6 +34,7 @@ class StatusMessagesController < ApplicationController current_user.dispatch_post(photo) end end + respond_to do |format| format.js { render :json => {:post_id => @status_message.id, :html => render_to_string( @@ -49,6 +51,7 @@ class StatusMessagesController < ApplicationController }, :status => 201 } format.html { respond_with @status_message } + format.mobile{ redirect_to aspects_path('a_ids' => params[:aspect_ids]) } end else respond_to do |format| diff --git a/app/views/aspects/index.mobile.haml b/app/views/aspects/index.mobile.haml index bbcd3ab8b..7c36a2609 100644 --- a/app/views/aspects/index.mobile.haml +++ b/app/views/aspects/index.mobile.haml @@ -2,10 +2,11 @@ -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. -= select_tag "aspect_picker", aspect_select_options(@aspects, @aspect) +.grey_back + = render 'shared/publisher', :aspect_ids => @aspect_ids + +#main_stream.stream + = render 'shared/stream', :posts => @posts += will_paginate @posts -%div{:data => {:role => 'content'}} - %div{:data => {:role => 'fieldcontain'}} - =render 'shared/publisher', :aspect => @aspect -= render 'shared/stream', :posts => @posts diff --git a/app/views/comments/_comment.mobile.haml b/app/views/comments/_comment.mobile.haml new file mode 100644 index 000000000..0bfaa7d3a --- /dev/null +++ b/app/views/comments/_comment.mobile.haml @@ -0,0 +1,15 @@ +-# Copyright (c) 2010, Diaspora Inc. This file is +-# licensed under the Affero General Public License version 3 or later. See +-# the COPYRIGHT file. + +%li.comment{:data=>{:guid=>comment.id}, :class => ("hidden" if(defined? hidden))} + .right + %span.time + = comment.created_at ? t('ago', :time => time_ago_in_words(comment.created_at)) : time_ago_in_words(Time.now) + + = person_image_link(comment.person) + .content + .from + = person_link(comment.person) + = markdownify(comment.text, :youtube_maps => comment[:youtube_titles]) + diff --git a/app/views/comments/_comments.haml b/app/views/comments/_comments.haml index 2c6142171..31669a289 100644 --- a/app/views/comments/_comments.haml +++ b/app/views/comments/_comments.haml @@ -9,7 +9,7 @@ = image_tag 'icons/spechbubble_2.png', :class => 'more_comments_icon' %b= comment_toggle(comments.size) -%ul.comments{:id => post_id, :class => ("hidden" if comments.size == 0)} +%ul.comments{:id => post_id, :class => ("hidden" if comments.size == 0 && !defined?(force_open))} -if comments.size > 3 .older_comments{:class => ("hidden inactive" if defined?(condensed) && condensed)} = render :partial => 'comments/comment', :collection => comments[0..-4] diff --git a/app/views/comments/_new_comment.mobile.haml b/app/views/comments/_new_comment.mobile.haml new file mode 100644 index 000000000..a5e2d2bca --- /dev/null +++ b/app/views/comments/_new_comment.mobile.haml @@ -0,0 +1,11 @@ +-# Copyright (c) 2010, Diaspora Inc. This file is +-# licensed under the Affero General Public License version 3 or later. See +-# the COPYRIGHT file. + += form_tag( comments_path, :id => "new_comment_on_#{post_id}", :class => 'new_comment', :remote => true) do + = hidden_field_tag :post_id, post_id, :id => "post_id_on_#{post_id}" + = text_area_tag :text, nil, :rows => 2, :class => "comment_box",:id => "comment_text_on_#{post_id}" + + %div{:data => {:inline => 'true'}, :style => 'text-align:right;'} + = submit_tag t('.comment'), :id => "comment_submit_#{post_id}", :disable_with => t('.commenting'), "data-role" => 'button', 'data-theme' => 'b', 'data-inline' => true + diff --git a/app/views/devise/sessions/new.mobile.haml b/app/views/devise/sessions/new.mobile.haml index 4109bf593..2d9a16adb 100644 --- a/app/views/devise/sessions/new.mobile.haml +++ b/app/views/devise/sessions/new.mobile.haml @@ -20,10 +20,3 @@ %p = render :partial => "devise/shared/links" - -.alpha-warning - %h1 - = t('.alpha_software') - - %h3 - = t('.bugs_and_feedback_mobile') diff --git a/app/views/layouts/application.mobile.haml b/app/views/layouts/application.mobile.haml index d13432019..acd9337ee 100644 --- a/app/views/layouts/application.mobile.haml +++ b/app/views/layouts/application.mobile.haml @@ -21,8 +21,15 @@ %body #content{:data => {:role => 'page'}} - %div{:data => {:role => 'header', :nobackbtn => 'true'}} - %h4 - DIASPORA* - /= link_to image_tag('logo_large.png', :height => "32px", :width => "321px", :class => "diaspora_header_logo"), root_path + #header_sauce + = link_to(image_tag('white.png'), aspects_path) + = yield + + #footer_sauce + logged in as + = link_to current_user.name, current_user.person + + %br + = link_to 'logout', '#' + diff --git a/app/views/people/show.mobile.haml b/app/views/people/show.mobile.haml new file mode 100644 index 000000000..f7941b2e4 --- /dev/null +++ b/app/views/people/show.mobile.haml @@ -0,0 +1,49 @@ +-# Copyright (c) 2010, Diaspora Inc. This file is +-# licensed under the Affero General Public License version 3 or later. See +-# the COPYRIGHT file. + +- content_for :page_title do + %h1 + DIASPORA* + +#author_info.profile + - unless @contact || current_user.person == @person + .right + = link_to "start sharing", + {:controller => "people", + :action => "share_with", + :id => @person.id}, + :class => 'share_with button', + :rel => 'facebox' + + = person_image_tag @person, :thumb_medium + + .content + %h3 + = @person.name + .description + = @person.diaspora_handle + +- unless @contact || current_user.person == @person + - if @incoming_request + .floating + %h3 + = t('.incoming_request') + %h4 + = link_to t('.return_to_aspects'), aspects_manage_path + = t('.to_accept_or_ignore') + +- if @posts.count > 0 + -if @post_type == :photos + = render 'photos/index', :photos => @posts + - else + #main_stream.stream + = render 'shared/stream', :posts => @posts + + = will_paginate @posts + +- else + #stream + %li{:style=>"text-align:center;"} + .dull= t('.no_posts') + diff --git a/app/views/shared/_author_info.mobile.haml b/app/views/shared/_author_info.mobile.haml new file mode 100644 index 000000000..7ccc8b35f --- /dev/null +++ b/app/views/shared/_author_info.mobile.haml @@ -0,0 +1,6 @@ +#author_info.show + = person_image_tag(person, :thumb_small) + = link_to person.name, person + %br + .diaspora_handle + = person.diaspora_handle diff --git a/app/views/shared/_publisher.mobile.haml b/app/views/shared/_publisher.mobile.haml index a6536377d..2226b865e 100644 --- a/app/views/shared/_publisher.mobile.haml +++ b/app/views/shared/_publisher.mobile.haml @@ -2,29 +2,13 @@ -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. - #publisher = form_for StatusMessage.new, :remote => true do |status| - %p - = status.label :message, t('.post_a_message_to', :aspect => (aspect == :all ? t('.all') : aspect)) - = status.text_area :message, :rows => 2, :value => h(params[:prefill]) - = javascript_tag "if ($('textarea#status_message_message').val() != ''){ $('textarea#status_message_message').focus();}" + = status.text_area :message, :class => 'scrunch' - = status.hidden_field :to, :value => (aspect == :all ? aspect : aspect.id) + - for aspect_id in @aspect_ids + = hidden_field_tag 'aspect_ids[]', aspect_id.to_s - %fieldset{:class => 'ui-grid-a'} - .options_and_submit - %div{:class => 'ui-block-a'} - - if aspect == :all - = status.submit t('.share'), :title => t('.share_with_all') - - else - = status.submit t('.share'), :title => t('.share_with', :aspect => aspect) + %fieldset.hidden{:style => 'text-align:right;'} + = status.submit t('.share'), 'data-inline' => 'true', 'data-theme' => 'b' - - if aspect == :all - %div{:class => 'ui-block-a'} - - .public_toggle - %p.checkbox_select - = status.check_box( :public, {}, true, false ) - = status.label :public, t('.make_public') - = link_to '(?)', "#question_mark_pane", :class => 'question_mark', :style=>"display:none;" diff --git a/app/views/shared/_stream_element.mobile.haml b/app/views/shared/_stream_element.mobile.haml new file mode 100644 index 000000000..dcc1d0eea --- /dev/null +++ b/app/views/shared/_stream_element.mobile.haml @@ -0,0 +1,22 @@ +-# Copyright (c) 2010, Diaspora Inc. This file is +-# licensed under the Affero General Public License version 3 or later. See +-# the COPYRIGHT file. + +.stream_element{:data=>{:guid=>post.id}} + .right + %span.time= how_long_ago(post) + + = person_image_link(post.person, :size => :thumb_small) + + .content + .from + = person_link(post.person) + + = render 'status_messages/status_message', :post => post, :photos => post.photos + + .info + - if post.comments.length == 1 + = link_to "#{post.comments.length} #{t('_comment').downcase} →", status_message_path(post), :class => 'comment_link' + - else + = link_to "#{post.comments.length} #{t('_comments').downcase} →", status_message_path(post), :class => 'comment_link' + diff --git a/app/views/status_messages/show.mobile.haml b/app/views/status_messages/show.mobile.haml new file mode 100644 index 000000000..1833932a4 --- /dev/null +++ b/app/views/status_messages/show.mobile.haml @@ -0,0 +1,23 @@ +-# Copyright (c) 2010, Diaspora Inc. This file is +-# licensed under the Affero General Public License version 3 or later. See +-# the COPYRIGHT file. + +#show_content{:data=>{:guid=>@status_message.id}} + = render 'shared/author_info', :person => @status_message.person, :post => @status_message + + %p + = markdownify(@status_message.message, :youtube_maps => @status_message[:youtube_titles]) + + - for photo in @status_message.photos + = link_to (image_tag photo.url(:thumb_small)), photo.url(:thumb_medium) + + .info + %span.time + = t('ago', :time => time_ago_in_words(@status_message.created_at)) + + %br + - if current_user.owns? @status_message + = link_to t('.destroy'), @status_message, :confirm => t('are_you_sure'), :method => :delete + +.stream.show{:data=>{:guid=>@status_message.id}} + = render "comments/comments", :post_id => @status_message.id, :comments => @status_message.comments, :always_expanded => true, :force_open => true diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 3637a1cf4..80545bfe0 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -30,6 +30,7 @@ en: _home: "Home" _more: "More" _comments: "Comments" + _comment: "Comment" next: 'next' previous: 'previous' contacts: diff --git a/public/stylesheets/sass/mobile.sass b/public/stylesheets/sass/mobile.sass index 3c2ee9153..5fb84a5a5 100644 --- a/public/stylesheets/sass/mobile.sass +++ b/public/stylesheets/sass/mobile.sass @@ -1,5 +1,11 @@ @import "mixins" +a + :text + :decoration none + :font + :weight normal + #landing_content :text-align center @@ -39,164 +45,211 @@ label :font-weight bold -ul - :list-style none - -.avatar - :width 40px - :height 40px - :padding 0 - -li.message - :width 90% +.stream_element, +.comment :position relative - :margin - :top 1em - :padding - :bottom 1.5em - :border - :bottom 1px #eee solid - :line-height 19px - :font - :family 'Arial', 'Helvetica', sans-serif - :color #777 + + :background + :color #fff + + * + :max-width 100% + + :min-height 34px .avatar :float left + :height 34px + :width 34px + + .from :margin - :right 15px + :bottom 4px + a + :color #000 .content - :margin - :top 0 :padding - :left 65px + :left 41px - .aspect - :display inline + :border + :bottom 1px solid #eee + :padding 6px 6px + :right 8px - :color #444 - :font - :weight normal - :size 14px - - .stream_photo - :float left - :margin - :top 6px - - .photo_description - :margin - :top 6px - :padding - :left 220px - :min-height 185px - :color #888 - :font - :style italic - - .small_text - :font - :size 10px - - div.info - :color #999 - :font-size smaller - a - :color #ccc - .time - a - :color #bbb - :font - :weight bold - :margin - :right 5px - - &:hover - div.info, .time - a - :color #107FC9 - &:hover - :color #22AAE0 - &:active - :color #005D9C - - -.right .reshare_pane .reshare_button a.inactive - :color #ccc - &:hover - :text - :decoration none - :cursor default - -.right .reshare_pane .reshare_button - :padding 5px - &.active - :background - :color #333 - - :-webkit-border-radius 5px 5px 0 0 - :-moz-border-radius 5px 5px 0 0 - :border-radius 5px 5px 0 0 - - a - :color #fff - :text-shadow none - -.right .reshare_pane - :margin - :left 5px - :right 5px - :display inline - :position relative - - - ul.reshare_box - :width 150px - :display none - :z-index 10 - :position absolute + .info :margin - :top 0 - :padding 0 + :top 0.5em + :font + :size smaller + :text + :align right - :background - :color #fafafa + .photo_attachments + :margin + :top 6px - :list - :style none +.comment + :padding + :top 12px + :bottom 12px - :border 5px solid #333 +#main_stream + :font + :size 0.9em - :text-shadow 0 2px #fff +.stream_element.person + .from + :font + :size larger + +.time + :color #ccc + :font + :size smaller + :weight bold + +.info + :font + :size smaller + +#show_content + :padding 12px + :bottom 24px + :border + :bottom 1px solid #bbb + :background + :color #fff + + :font + :size larger + + img + :max-width 100% + + .photo + :text-align center + + .controls + :font + :size smaller + +ul + :margin 0 + :padding 0 + :list + :style none + +#author_info.show + :margin + :bottom 24px + a :color #000 - > li - :font - :weight bold - :color #ccc - :border - :top 1px solid #fff - :bottom 1px solid #ccc + img + :float left + :height 36px + :width 36px + :margin + :right 6px - &:first-child - :border - :top none - &:last-child - :border - :bottom none - a - :display block - :height 100% - :padding 2px 5px - :cursor default + :font + :size smaller - &:hover - :background - :color #eee - :text - :decoration none - &:active - :background - :color #ccc + .diaspora_handle + :font + :size 14px + :color #999 + +#author_info.profile + :background + :color #eee + :border + :bottom 2px solid #ccc + :height 90px + :padding 6px + :margin + :bottom 6px + + img + :float left + :height 90px + :width 90px + + .content + :padding + :left 100px + + .description + :font + :weight normal + :size small + :color #999 + +.comments + :border + :top 2px solid #D2DBE1 + :background + :color #EDF5FB + :font + :size smaller + + .comment + :background + :color #EDF5FB + +.stream_marker + :background + :color #eee + :border + :bottom 1px solid #aaa + :top 1px solid #ccc + :font + :weight bold + :size smaller + :color #666 + :padding 3px 6px + +.right + :float right + +.hidden + :display none + +textarea.scrunch + :height 1em + +.grey_back + :background + :color #eee + :border 1px solid #999 + :padding 6px + :margin + :bottom 12px + + #publisher + :text + :align center + +#aspect_title + :padding 0 6px + :bottom 6px + :font + :weight bold + :text + :align left + +#header_sauce + :background + :color #111 + :text + :align center + :padding 12px 0 + :border + :bottom 1px solid #000 + +#footer_sauce + :background + :color #ccc + :padding 12px diff --git a/vendor/plugins/mobile-fu/lib/mobile_fu.rb b/vendor/plugins/mobile-fu/lib/mobile_fu.rb index b3aac852f..fbe49f28a 100644 --- a/vendor/plugins/mobile-fu/lib/mobile_fu.rb +++ b/vendor/plugins/mobile-fu/lib/mobile_fu.rb @@ -8,29 +8,29 @@ module ActionController 'pdxgw|netfront|xiino|vodafone|portalmmm|sagem|mot-|sie-|ipod|up\\.b|' + 'webos|amoi|novarra|cdm|alcatel|pocket|ipad|iphone|mobileexplorer|' + 'mobile' - + def self.included(base) base.extend(ClassMethods) end - + module ClassMethods - - # Add this to one of your controllers to use MobileFu. + + # Add this to one of your controllers to use MobileFu. # - # class ApplicationController < ActionController::Base + # class ApplicationController < ActionController::Base # has_mobile_fu # end # # You can also force mobile mode by passing in 'true' # - # class ApplicationController < ActionController::Base + # class ApplicationController < ActionController::Base # has_mobile_fu(true) # end - + def has_mobile_fu(test_mode = false) include ActionController::MobileFu::InstanceMethods - if test_mode + if test_mode before_filter :force_mobile_format else before_filter :set_mobile_format @@ -40,7 +40,7 @@ module ActionController helper_method :in_mobile_view? helper_method :is_device? end - + def is_mobile_device? @@is_mobile_device end @@ -53,50 +53,55 @@ module ActionController @@is_device end end - + module InstanceMethods - + # Forces the request format to be :mobile - + def force_mobile_format - request.format = :mobile - session[:mobile_view] = true if session[:mobile_view].nil? + #request.format = :mobile + #session[:mobile_view] = true if session[:mobile_view].nil? + + if !request.xhr? + request.format = :mobile + session[:mobile_view] = true if session[:mobile_view].nil? + end end - + # Determines the request format based on whether the device is mobile or if # the user has opted to use either the 'Standard' view or 'Mobile' view. - + def set_mobile_format if is_mobile_device? && !request.xhr? request.format = session[:mobile_view] == false ? :html : :mobile session[:mobile_view] = true if session[:mobile_view].nil? end end - + # Returns either true or false depending on whether or not the format of the # request is either :mobile or not. - + def in_mobile_view? request.format.to_sym == :mobile end - + # Returns either true or false depending on whether or not the user agent of # the device making the request is matched to a device in our regex. - + def is_mobile_device? request.user_agent.to_s.downcase =~ Regexp.new(ActionController::MobileFu::MOBILE_USER_AGENTS) end # Can check for a specific user agent # e.g., is_device?('iphone') or is_device?('mobileexplorer') - + def is_device?(type) request.user_agent.to_s.downcase.include?(type.to_s.downcase) end end - + end - + end -ActionController::Base.send(:include, ActionController::MobileFu) \ No newline at end of file +ActionController::Base.send(:include, ActionController::MobileFu)