Merge branch 'master' of git://github.com/diaspora/diaspora

This commit is contained in:
Jordi Mallach 2011-03-29 20:40:43 +02:00
commit 8a222e2991
15 changed files with 86 additions and 17 deletions

View file

@ -13,4 +13,5 @@ class SessionsController < Devise::SessionsController
}
end
end
end

View file

@ -25,6 +25,12 @@ class StatusMessagesController < ApplicationController
end
end
def bookmarklet
@aspects = current_user.aspects
@aspect_ids = @aspects.map{|x| x.id}
render :layout => nil
end
def create
params[:status_message][:aspect_ids] = params[:aspect_ids]

View file

@ -21,13 +21,13 @@ module ApplicationHelper
def aspects_with_post aspects, post
aspects.select do |aspect|
aspect.has_post?(post)
PostVisibility.exists?(:aspect_id => aspect.id, :post_id => post.id)
end
end
def aspects_without_post aspects, post
aspects.reject do |aspect|
aspect.has_post?(post)
PostVisibility.exists?(:aspect_id => aspect.id, :post_id => post.id)
end
end
@ -39,6 +39,10 @@ module ApplicationHelper
str.html_safe
end
def bookmarklet
"javascript:(function(){f='#{AppConfig[:pod_url]}bookmarklet?url='+encodeURIComponent(window.location.href)+'&title='+encodeURIComponent(document.title)+'&notes='+encodeURIComponent(''+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text))+'&v=1&';a=function(){if(!window.open(f+'noui=1&jump=doclose','diasporav1','location=yes,links=no,scrollbars=no,toolbar=no,width=620,height=250'))location.href=f+'jump=yes'};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})()"
end
def aspect_badge aspect, opts = {}
str = "<span class='aspect_badge single'>"
link = opts.delete(:link)

View file

@ -21,14 +21,6 @@ class Aspect < ActiveRecord::Base
name.strip!
end
def has_post? post
post_ids = post_visibilities.each { |pv| pv.post_id }
post_ids.each { |id|
return true if id == post.id
}
return false
end
def to_s
name
end

View file

@ -40,7 +40,9 @@ class Profile < ActiveRecord::Base
:image_url_small, :birthday, :gender, :bio, :location, :searchable, :date, :tag_string
belongs_to :person
before_validation do
self.tag_string = self.tag_string.split[0..4].join(' ')
end
before_save do
self.build_tags
end

View file

@ -50,3 +50,9 @@
%br
#resp
%br
post to Diaspora v1

View file

@ -27,12 +27,14 @@
- if @request_count > 0
%h4
= new_request_link(@request_count)
%h4
!= t('bookmarklet.explanation', :link => link_to(t('bookmarklet.explanation_link_text'), bookmarklet))
- if @invites > 0
.section.invite_friends
%h4= t('shared.invitations.invite_your_friends')
= render "shared/invitations", :invites => @invites
#aspect_listings.section
= render 'aspects/aspect_listings', :aspects => @aspects

View file

@ -20,7 +20,7 @@
.span-8.append-1
= render 'aspects/aspect_contacts', :contacts => @aspect_contacts, :aspect => @aspect
= render 'aspects/edit_aspect_pane', :contacts => @all_contacts, :aspect => @aspect
moms
.span-15.last
= render 'shared/publisher', :aspect => @aspect, :aspect_ids => @aspect_ids

View file

@ -0,0 +1,40 @@
-# Copyright (c) 2010, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
= include_javascripts :jquery
= include_javascripts :main
= include_stylesheets :default, :media => 'all'
= stylesheet_link_tag "blueprint/screen", :media => 'screen'
= javascript_include_tag "publisher.js"
:javascript
Diaspora.widgets.i18n.loadLocale(#{get_javascript_strings_for(current_user.language).to_json}, "#{current_user.language}");
$(document).ready(function()
{
Publisher.open();
$("#publisher").bind('ajax:success', function(){
$('h4').text("#{t('bookmarklet.post_success')}");
Publisher.close();
window.setTimeout(window.close, 2000, true);
});
var contents = "#{params[:title]} - #{params[:url]}";
if ("#{params[:notes]}".length > 0){
contents = contents + " - #{params[:notes]}";
}
$("#publisher #status_message_fake_text").val(contents);
$("#publisher #status_message_text").val(contents);
$('input.button')[0].removeAttribute('disabled');
});
#new_status_message_pane
.span-15.last
#facebox_header
%h4
=t('bookmarklet.post_something')
= render :partial => 'shared/publisher', :locals => { :aspect => :profile, :aspects_with_person => @aspects, :aspect_ids => @aspect_ids}

View file

@ -144,6 +144,12 @@ en:
failure: "Failed to remove person from aspect"
no_membership: "Could not find the selected person in that aspect"
bookmarklet:
post_success: "Posted! Closing!"
post_something: "Post something to Diaspora"
explanation: "%{link} from anywhere by bookmarking this link."
explanation_link_text: "Post to Diaspora"
comments:
zero: "no comments"
one: "1 comment"

View file

@ -64,6 +64,7 @@ Diaspora::Application.routes.draw do
get 'admin_inviter' => :admin_inviter
end
get 'bookmarklet' => 'status_messages#bookmarklet'
resource :profile
resources :requests, :only => [:destroy, :create]

View file

@ -1,5 +1,5 @@
# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
#
# To ban all spiders from the entire site uncomment the next two lines:
# User-Agent: *
# Disallow: /
User-Agent: *
Disallow: /

View file

@ -855,6 +855,7 @@ label
.options_and_submit
:min-height 21px
:clear both
:position relative
:padding
:top 6px

View file

@ -17,6 +17,13 @@ describe StatusMessagesController do
alice.reload
end
describe '#bookmarklet' do
it 'succeeds' do
get :bookmarklet
response.should be_success
end
end
describe '#new' do
it 'succeeds' do
get :new,

View file

@ -188,9 +188,10 @@ describe Profile do
@object.should be_valid
end
it 'allows no more than 5 tags' do
it 'strips more than 5 tags' do
@object.tag_string = '#one #two #three #four #five #six'
@object.should_not be_valid
@object.save
@object.tags.count.should == 5
end
it_should_behave_like 'it is taggable'
end