everything ported from pre-mysql mobile stuff. things missing: search page, aspect switcher, notification badge.

This commit is contained in:
danielvincent 2011-01-21 22:45:24 -08:00 committed by zhitomirskiyi
parent 4b63a14198
commit 39c5189c1f
18 changed files with 379 additions and 205 deletions

View file

@ -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

View file

@ -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

View file

@ -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|

View file

@ -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

View file

@ -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])

View file

@ -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]

View file

@ -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

View file

@ -20,10 +20,3 @@
%p
= render :partial => "devise/shared/links"
.alpha-warning
%h1
= t('.alpha_software')
%h3
= t('.bugs_and_feedback_mobile')

View file

@ -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', '#'

View file

@ -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')

View file

@ -0,0 +1,6 @@
#author_info.show
= person_image_tag(person, :thumb_small)
= link_to person.name, person
%br
.diaspora_handle
= person.diaspora_handle

View file

@ -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;"

View file

@ -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'

View file

@ -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

View file

@ -30,6 +30,7 @@ en:
_home: "Home"
_more: "More"
_comments: "Comments"
_comment: "Comment"
next: 'next'
previous: 'previous'
contacts:

View file

@ -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

View file

@ -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)
ActionController::Base.send(:include, ActionController::MobileFu)