Merge pull request #3714 from marpo60/refactor

Housekeeping
This commit is contained in:
Jonne Haß 2012-11-22 01:06:05 -08:00
commit 5f6e03cfe5
30 changed files with 16 additions and 530 deletions

View file

@ -1,2 +0,0 @@
<input type="image" src="{{imageUrl "buttons/close@2x.png"}}" class="cancel" />
<input type="image" src="{{imageUrl "buttons/next_hov@2x.png"}}" class="next" />

View file

@ -1,24 +0,0 @@
<div id="framer">
<div class="container">
<div class="row">
<div class="span6 offset3">
<div class="row">
<div class="span4 offset1">
<h3>
Make something!
</h3>
</div>
</div>
<div class="row">
<div class="flow-content"/>
</div>
<div class="row">
<div class="flow-controls">
<div class="controls"/>
</div>
</div>
</div>
</div>
</div>
</div>

View file

@ -1,14 +0,0 @@
<div class="preview offset1"> </div>
<div class='template-picker'>
{{#each templates}}
<input id='frame_name_{{name}}' name="frame_name" type="radio" class="mood" value={{name}} {{#if checked}}checked=checked{{/if}} />
<label for='frame_name_{{name}}'>
<img src="/assets/buttons/templates/{{name}}@2x.png" />
<div class="template-name">
{{name}}
</div>
</label>
<br />
{{/each}}
</div>

View file

@ -1,4 +0,0 @@
<input type="image" src="{{imageUrl "buttons/back_hov@2x.png"}}" class="back" />
<div class="aspect-selector"/>
<div class="service-selector"/>
<input type="image" src="{{imageUrl "buttons/done_hov@2x.png"}}" class="done" />

View file

@ -1,5 +0,0 @@
<div class="framer-controls">
<div class="controls">
<button class="btn-primary next">Next</button>
</div>
</div>

View file

@ -1,51 +0,0 @@
{{#if is_own_profile}}
<div id="wallpaper-upload"></div>
{{/if}}
<div class="container">
<div id="top-right-nav">
{{#if current_user.guid}}
<a href="/" id="home-button">
<span class="label label-inverse">
<i class="icon-home icon-white"></i>
<span>
HOME
</span>
</span>
</a>
<a href="/users/sign_out" title="Log out" id="logout-button">
<span class="label label-inverse">
<i class="icon-off icon-white"></i>
</span>
</a>
{{else}}
<a href="/" id="home-button">
<span class="label label-inverse">
<span>
DIASPORA
</span>
</span>
</a>
{{/if}}
</div>
<section id="profile-info"/>
<section id="profile-controls">
{{#if is_own_profile}}
<div id="composer" class="hidden"></div>
<a href="#" id="composer-button" class="control small label label-inverse">
MAKE
</a>
<a href="#" id="edit-mode-toggle" class="control small label label-inverse" title="Edit Posts" rel="tooltip">
<img src='{{imageUrl "buttons/edit2@2x.png"}}'/>
</a>
{{/if}}
</section>
<section id="canvas"></section>
<div id="paginate"><span class="loader hidden"/></div>
</div>

View file

@ -1,13 +0,0 @@
<form accept-charset="UTF-8" action="/upload_wallpaper" class="new_photo" data-remote="true" enctype="multipart/form-data" method="post" style="position:absolute; left:10px; top: 10px; opacity:0.4;">
<input name="authenticity_token" type="hidden"/>
<div style="margin:0;padding:0;display:inline">
<input name="utf8" type="hidden" value="✓"/>
</div>
<div id='photo_upload_button'>
<a href="#" class='label label-inverse'>
<i class="icon-picture icon-white" style="margin-right:4px;"></i>CHANGE WALLPAPER
</a>
<input name="photo[user_file]" type="file"/>
</div>
</form>

View file

@ -66,20 +66,6 @@ class PeopleController < ApplicationController
respond_with @people
end
def hashes_for_people(people, aspects)
ids = people.map{|p| p.id}
contacts = {}
Contact.unscoped.where(:user_id => current_user.id, :person_id => ids).each do |contact|
contacts[contact.person_id] = contact
end
people.map{|p|
{:person => p,
:contact => contacts[p.id],
:aspects => aspects}
}
end
def show
@person = Person.find_from_guid_or_username(params)
@ -162,6 +148,8 @@ class PeopleController < ApplicationController
end
end
private
def redirect_if_tag_search
if search_query.starts_with?('#')
if search_query.length > 1
@ -173,7 +161,19 @@ class PeopleController < ApplicationController
end
end
private
def hashes_for_people(people, aspects)
ids = people.map{|p| p.id}
contacts = {}
Contact.unscoped.where(:user_id => current_user.id, :person_id => ids).each do |contact|
contacts[contact.person_id] = contact
end
people.map{|p|
{:person => p,
:contact => contacts[p.id],
:aspects => aspects}
}
end
def search_query
@search_query ||= params[:q] || params[:term] || ''

View file

@ -65,7 +65,7 @@ module LayoutHelper
end
def include_base_css_framework(use_bootstrap=false)
if use_bootstrap || @aspect == :getting_started || @page == :experimental
if use_bootstrap || @aspect == :getting_started
stylesheet_link_tag 'bootstrap-complete'
else
stylesheet_link_tag 'blueprint', :media => 'screen'

View file

@ -16,15 +16,6 @@ module PeopleHelper
end
end
def request_partial single_aspect_form
if single_aspect_form
'requests/new_request_with_aspect_to_person'
else
'requests/new_request_to_person'
end
end
def search_or_index
if search_query
I18n.t 'people.helper.results_for',:params => search_query

View file

@ -227,14 +227,6 @@ class User < ActiveRecord::Base
where(conditions).first
end
# @param [Person] person
# @return [Boolean] whether this user can add person as a contact.
def can_add?(person)
return false if self.person == person
return false if self.contact_for(person).present?
true
end
def confirm_email(token)
return false if token.blank? || token != confirm_email_token
self.email = unconfirmed_email

View file

@ -1,30 +0,0 @@
-# Copyright (c) 2010-2011, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
- content_for :head do
=javascript_include_tag 'aspect-contacts'
:javascript
EditPane.setTranslations({
doneEditing: "#{t('.done_editing')}",
editAspect:"#{t('aspects.show.edit_aspect')}"
});
- if aspect.contacts.count == 0
:javascript
$(document).ready(function(){
EditPane.fadeIn();
});
#left_pane
.section.contact_pictures
- for contact in contacts
= person_image_link(contact[:person])
%br
%br
%br
.section
%h3= t('shared.invitations.invites')
= render "shared/invitations"

View file

@ -1,9 +0,0 @@
-# Copyright (c) 2010-2011, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
%li{:data=>{:guid=>aspect.id}}
%span.name
= link_to aspect.name, aspect
.right
= aspect_membership_button(aspect, contact, person)

View file

@ -1,18 +0,0 @@
-# Copyright (c) 2010-2011, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
%h2{:style => "padding:0 10px;display:none;"}
- if @stream.for_all_aspects?
= t('all_aspects')
- else
= @stream.aspect
#main_stream.stream
= render 'shared/stream', :posts => @stream.stream_posts
-if @stream.stream_posts.length > 0
#pagination
%a.more-link.paginate{:href => next_page_path}
%h1
= t("more")

View file

@ -1,5 +0,0 @@
$(document).ready(function() {
var newName = "<%= @aspect.name %>"
$("#aspect_name").val( newName );
$("*[data-guid='<%= @aspect.id %>']").find('.name').html( newName );
});

View file

@ -1,47 +0,0 @@
= javascript_include_tag "validation"
= javascript_tag "Diaspora.Page = 'InvitationsEdit';"
.span-7.append-1.prepend-3
%br
%br
%br
%br
%h1
= t('welcome')
%h3.accept_invitation_text
= t('.accept_your_invitation')
- flash.each do |name, msg|
%p{:class => "login_#{name}"}= msg
= image_tag 'diaspora_collage.png', :style => "margin-left:-50px;"
.span-10
%br
%br
%br
%br
= form_for(resource, :as => resource_name, :url => invitation_path(resource_name), :html => {:method => :put, :class => 'accept_invitation_form'}, :validate => true) do |f|
%fieldset
.clearfix
%b
= t('username')
= f.text_field :username, :title => t('registrations.new.enter_username')
%span.host_uri
= diaspora_id_host
.clearfix
%b
= t('email')
= f.email_field :email, :title => t('registrations.new.enter_email')
.clearfix
%b
= t('password')
= f.password_field :password, :title => t('registrations.new.enter_password')
.clearfix
%b
= t('password_confirmation')
= f.password_field :password_confirmation, :title => t('registrations.new.enter_password_again')
= f.hidden_field :invitation_token
.submit_field
= f.submit t('registrations.new.create_my_account'), :class => 'in_aspects'

View file

@ -1,26 +0,0 @@
-# Copyright (c) 2010-2011, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
#login_form
%h3
= t('.your_account_awaits')
= form_for(resource, :as => resource_name, :url => invitation_path(resource_name), :html => {:method => :put }) do |f|
%p
= f.label :username , t('username')
= f.text_field :username, :title => t('registrations.new.enter_username')
%p
= f.label :email , t('email')
= f.text_field :email, :title => t('registrations.new.enter_email')
%p
= f.label :password , t('password')
= f.password_field :password, :title => t('registrations.new.enter_password')
%p
= f.label :password_confirmation , t('password_confirmation')
= f.password_field :password_confirmation, :title => t('registrations.new.enter_password_again')
= f.hidden_field :invitation_token
= f.submit t('registrations.new.create_my_account')
%br
= render :partial => "devise/shared/links"

View file

@ -1,3 +0,0 @@
.span-15.last
%h2
= t('devise.invitations.invitation_token_invalid')

View file

@ -1,12 +0,0 @@
-# Copyright (c) 2010-2011, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
- if likes_count > 0
= image_tag('icons/heart.png')
- if target_type == "Comment"
= link_to t('likes.likes.people_like_this_comment', :count => likes_count), comment_likes_path(target_id), :class => "expand_likes"
- else
= link_to t('likes.likes.people_like_this', :count => likes_count), post_likes_path(target_id), :class => "expand_likes"
%span.hidden.likes_list

View file

@ -1,6 +0,0 @@
-# Copyright (c) 2010-2011, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
.notification
= person_image_tag(person)
= notification_message_for(note)

View file

@ -1,9 +0,0 @@
- if current_user.can_add?(person)
.add_contact
= link_to image_tag("icons/monotone_plus_add_round.png"),
{:controller => "contacts",
:action => "new",
:person_id => person.id},
:alt => t('.add_contact_from_tag'),
:class => 'button',
:rel => 'facebox'

View file

@ -1,20 +0,0 @@
-# Copyright (c) 2010-2011, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
- content_for :head do
=javascript_include_tag 'contact-list'
.aspects
/ TODO(*) add following method in contact
- if contact && contact.persisted?
.badges{:class => ("hidden" if !contact.persisted?)}
= aspect_badges(aspects_with_person, :link => true)
%p
= link_to t('.edit_membership'),
{:controller => "contacts",
:action => "edit",
:id => contact.id,
:person_id => person.id},
:class => 'button',
:rel => 'facebox'

View file

@ -1,14 +0,0 @@
-# Copyright (c) 2010-2011, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
#profile_photo_upload
= owner_image_tag(:thumb_medium)
= file_field_tag 'profile[image]'
-if !@aspect.nil? && @aspect != :getting_started
%p
\...#{t('photos.new_profile_photo.or_select_one')}
= link_to t('_photos'), person_photos_path(@person)

View file

@ -1,11 +0,0 @@
-# Copyright (c) 2010-2011, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
%div{:id => destination_handle}
= form_for(Request.new, :remote => true ) do |request|
= request.select(:into, options_from_collection_for_select(aspects, "id", "name"))
= request.hidden_field :to, :value => destination_handle
= request.submit t('people.person.add_contact'), 'data-disable-with' => t('requests.create.sending')
.message.hidden
%i= t('.sent')

View file

@ -1,11 +0,0 @@
-# Copyright (c) 2010-2011, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
%div{:id => destination_handle}
= form_for Request.new, :remote => true do |request|
= request.hidden_field :into, :value => "changeme"
= request.hidden_field :to, :value => destination_handle
= request.submit '+', :class => 'add', 'data-disable-with' => t('requests.create.sending')
.message.hidden
%i= t('requests.new_request_to_person.sent')

View file

@ -1,9 +0,0 @@
#author_info.show
= person_image_link(person)
.from
%h5
= person.name
#person_nav_links
= link_to t('layouts.header.profile'), local_or_remote_person_path(person)
= link_to t('_photos'), person_photos_path(person)

View file

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

View file

@ -1,126 +0,0 @@
<!-- Begin MailChimp Signup Form -->
<%= javascript_include_tag :mailchimp %>
<div id="mc_embed_signup">
<form action="http://joindiaspora.us1.list-manage.com/subscribe/post?u=d759919b94f9cdcf39d204f3f&amp;id=7b5ceb2f8b" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank">
<div class="mc-field-group">
<input type="text" value="" name="EMAIL" class="required email" placeholder="Email" id="mce-EMAIL">
</div>
<div><input type="submit" value="<%= t('devise.shared.mail_signup_form.sign_up_for_an_invite') %>" name="subscribe" id="mc-embedded-subscribe" class="btn"></div>
<div id="mce-responses">
<div class="response" id="mce-error-response" style="display:none"></div>
<div class="response" id="mce-success-response" style="display:none"></div>
</div>
</form>
</div>
<script type="text/javascript">
var fnames = new Array();var ftypes = new Array();fnames[0]='EMAIL';ftypes[0]='email';fnames[3]='MMERGE3';ftypes[3]='text';fnames[4]='MMERGE4';ftypes[4]='text';var err_style = '';
try{
err_style = mc_custom_error_style;
} catch(e){
err_style = 'margin: 1em 0 0 0; padding: 1em 0.5em 0.5em 0.5em; background: ERROR_BGCOLOR none repeat scroll 0% 0%; font-weight: bold; float: left; z-index: 1; width: 80%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: ERROR_COLOR;';
}
var mce_jQuery = jQuery.noConflict();
mce_jQuery(document).ready( function($) {
var options = { errorClass: 'mce_inline_error', errorElement: 'div', errorStyle: err_style, onkeyup: function(){}, onfocusout:function(){}, onblur:function(){} };
var mce_validator = mce_jQuery("#mc-embedded-subscribe-form").validate(options);
options = { url: 'http://joindiaspora.us1.list-manage2.com/subscribe/post-json?u=d759919b94f9cdcf39d204f3f&id=7b5ceb2f8b&c=?', type: 'GET', dataType: 'json', contentType: "application/json; charset=utf-8",
beforeSubmit: function(){
mce_jQuery('#mce_tmp_error_msg').remove();
mce_jQuery('.datefield','#mc_embed_signup').each(
function(){
var txt = 'filled';
var fields = new Array();
var i = 0;
mce_jQuery(':text', this).each(
function(){
fields[i] = this;
i++;
});
mce_jQuery(':hidden', this).each(
function(){
if ( fields[0].value=='MM' && fields[1].value=='DD' && fields[2].value=='YYYY' ){
this.value = '';
} else if ( fields[0].value=='' && fields[1].value=='' && fields[2].value=='' ){
this.value = '';
} else {
this.value = fields[0].value+'/'+fields[1].value+'/'+fields[2].value;
}
});
});
return mce_validator.form();
},
success: mce_success_cb
};
mce_jQuery('#mc-embedded-subscribe-form').ajaxForm(options);
});
function mce_success_cb(resp){
mce_jQuery('#mce-success-response').hide();
mce_jQuery('#mce-error-response').hide();
if (resp.result=="success"){
mce_jQuery('#mce-'+resp.result+'-response').show();
mce_jQuery('#mce-'+resp.result+'-response').html(resp.msg);
mce_jQuery('#mc-embedded-subscribe-form').each(function(){
this.reset();
});
} else {
var index = -1;
var msg;
try {
var parts = resp.msg.split(' - ',2);
if (parts[1]==undefined){
msg = resp.msg;
} else {
i = parseInt(parts[0]);
if (i.toString() == parts[0]){
index = parts[0];
msg = parts[1];
} else {
index = -1;
msg = resp.msg;
}
}
} catch(e){
index = -1;
msg = resp.msg;
}
try{
if (index== -1){
mce_jQuery('#mce-'+resp.result+'-response').show();
mce_jQuery('#mce-'+resp.result+'-response').html(msg);
} else {
err_id = 'mce_tmp_error_msg';
html = '<div id="'+err_id+'" style="'+err_style+'"> '+msg+'</div>';
var input_id = '#mc_embed_signup';
var f = mce_jQuery(input_id);
if (ftypes[index]=='address'){
input_id = '#mce-'+fnames[index]+'-addr1';
f = mce_jQuery(input_id).parent().parent().get(0);
} else if (ftypes[index]=='date'){
input_id = '#mce-'+fnames[index]+'-month';
f = mce_jQuery(input_id).parent().parent().get(0);
} else {
input_id = '#mce-'+fnames[index];
f = mce_jQuery().parent(input_id).get(0);
}
if (f){
mce_jQuery(f).append(html);
mce_jQuery(input_id).focus();
} else {
mce_jQuery('#mce-'+resp.result+'-response').show();
mce_jQuery('#mce-'+resp.result+'-response').html(msg);
}
}
} catch(e){
mce_jQuery('#mce-'+resp.result+'-response').show();
mce_jQuery('#mce-'+resp.result+'-response').html(msg);
}
}
}
</script>
<!--End mc_embed_signup-->

View file

@ -407,28 +407,6 @@ describe User do
end
end
describe "#can_add?" do
it "returns true if there is no existing connection" do
alice.can_add?(eve.person).should be_true
end
it "returns false if the user and the person are the same" do
alice.can_add?(alice.person).should be_false
end
it "returns false if the users are already connected" do
alice.can_add?(bob.person).should be_false
end
it "returns false if the user has already sent a request to that person" do
alice.share_with(eve.person, alice.aspects.first)
alice.reload
eve.reload
alice.can_add?(eve.person).should be_false
end
end
describe '#process_invite_acceptence' do
it 'sets the inviter on user' do
inv = InvitationCode.create(:user => bob)