From 8b7dc0a2cc80b19806a048adb873f93bdacb4a4c Mon Sep 17 00:00:00 2001 From: maxwell <maxwell@joindiaspora.com> Date: Mon, 28 Mar 2011 19:57:06 -0700 Subject: [PATCH] translated bookmarklet, added post to main page --- app/helpers/application_helper.rb | 4 ++++ app/views/admins/user_search.html.haml | 1 - app/views/aspects/index.html.haml | 4 ++++ app/views/aspects/show.html.haml | 2 +- app/views/status_messages/bookmarklet.html.haml | 5 +++-- config/locales/diaspora/en.yml | 4 +++- public/stylesheets/sass/application.sass | 1 + spec/controllers/status_messages_controller_spec.rb | 7 +++++++ 8 files changed, 23 insertions(+), 5 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d99e35036e..c1b0182216 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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)+'¬es='+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) diff --git a/app/views/admins/user_search.html.haml b/app/views/admins/user_search.html.haml index f861870f59..4fb7425075 100644 --- a/app/views/admins/user_search.html.haml +++ b/app/views/admins/user_search.html.haml @@ -52,7 +52,6 @@ %br -%a{:href => "javascript:(function(){f='#{AppConfig[:pod_url]}bookmarklet?url='+encodeURIComponent(window.location.href)+'&title='+encodeURIComponent(document.title)+'¬es='+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()}})()"} post to Diaspora v1 diff --git a/app/views/aspects/index.html.haml b/app/views/aspects/index.html.haml index 3983696b2f..985a2f327b 100644 --- a/app/views/aspects/index.html.haml +++ b/app/views/aspects/index.html.haml @@ -27,12 +27,16 @@ - if @request_count > 0 %h4 = new_request_link(@request_count) + %h4 + = link_to 'Post to Diaspora', bookmarklet + from anywhere by bookmarking this link. - 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 diff --git a/app/views/aspects/show.html.haml b/app/views/aspects/show.html.haml index 81149f9bb2..e103ea15c0 100644 --- a/app/views/aspects/show.html.haml +++ b/app/views/aspects/show.html.haml @@ -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 diff --git a/app/views/status_messages/bookmarklet.html.haml b/app/views/status_messages/bookmarklet.html.haml index 76080f4223..e25248aa4b 100644 --- a/app/views/status_messages/bookmarklet.html.haml +++ b/app/views/status_messages/bookmarklet.html.haml @@ -14,7 +14,7 @@ { Publisher.open(); $("#publisher").bind('ajax:success', function(){ - $('h4').text("Your post was successful! Closing!"); + $('h4').text("#{t('bookmarklet.post_success')}"); Publisher.close(); window.setTimeout(window.close, 2000, true); @@ -27,13 +27,14 @@ $("#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 - Post something to Diaspora + =t('bookmarklet.post_something') = render :partial => 'shared/publisher', :locals => { :aspect => :profile, :aspects_with_person => @aspects, :aspect_ids => @aspect_ids} diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 265a5b2251..69765df54c 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -143,7 +143,9 @@ en: success: "Successfully removed person from aspect" failure: "Failed to remove person from aspect" no_membership: "Could not find the selected person in that aspect" - + bookmarklet: + post_success: "Posted! Closeing!" + post_something: 'Post something to Diaspora' comments: zero: "no comments" one: "1 comment" diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 706548001f..cb088f9b90 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -855,6 +855,7 @@ label .options_and_submit :min-height 21px + :clear both :position relative :padding :top 6px diff --git a/spec/controllers/status_messages_controller_spec.rb b/spec/controllers/status_messages_controller_spec.rb index 128a7a7af7..4ffc7e6a6d 100644 --- a/spec/controllers/status_messages_controller_spec.rb +++ b/spec/controllers/status_messages_controller_spec.rb @@ -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, -- GitLab