diff --git a/app/assets/javascripts/app/pages/framer.js b/app/assets/javascripts/app/pages/framer.js index aab1e5c1e1852285634338cde79fe95d68aba50f..9094d983c48100214cc63f40230f5bf63a9c1f0e 100644 --- a/app/assets/javascripts/app/pages/framer.js +++ b/app/assets/javascripts/app/pages/framer.js @@ -48,9 +48,14 @@ app.views.framerControls = app.views.Base.extend({ // this is gross hack to make this action work in the iframe version and not iframe version. var callback = {} var parentDoc = parent; + var parentPath = parentDoc.location.pathname - if(parentDoc.location.pathname != '/framer'){ - callback = {success : function(){ parentDoc.closeIFrame() }} + if(parentPath == '/new_bookmarklet'){ + callback.success = function(){ parentDoc.close() } + } else if(parentPath != '/framer'){ + callback.success = function(){ parentDoc.goToCurrentUserProfile() } + } else{ + // do nothing, and let the navigate event fire } this.model.save({}, callback) @@ -58,6 +63,6 @@ app.views.framerControls = app.views.Base.extend({ }); //crazy hack for model publisher. -function closeIFrame(){ +function goToCurrentUserProfile(){ location = "/people/" + app.currentUser.get("guid") }; \ No newline at end of file diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index faa4b51a6b35fad346eb7c9de96f7298098567d9..2b6176776f2a3bc738cc069d34164bb7192badc1 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -1,4 +1,4 @@ -# Copyright (c) 2010-2011, Diaspora Inc. This file is + # Copyright (c) 2010-2011, Diaspora Inc. This file is # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index b6764b890a61c456607587c7b1635797e44c5878..0a372b3fbbf21b89983e8db23f891717f3c7b719 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -39,6 +39,10 @@ class StatusMessagesController < ApplicationController end end + def new_bookmarklet + render :layout => nil + end + def create params[:status_message][:aspect_ids] = [*params[:aspect_ids]] normalize_public_flag! diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index acebf3057b9c433164c6a9a02b3b36b7cde6bffb..210442d34868f712721e9c43de1d0b91e266e35f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -13,7 +13,24 @@ module ApplicationHelper 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()}})()" + raw_bookmarklet + end + + def new_bookmarklet + raw_bookmarklet(520, 720, true) + end + + def raw_bookmarklet( height = 250, width = 620, new=false) + route = new ? 'new_bookmarklet' : 'bookmarklet' + "javascript:(function(){f='#{AppConfig[:pod_url]}#{route}?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=#{width},height=#{height}'))location.href=f+'jump=yes'};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})()" + end + + def magic_bookmarklet_link + if user_signed_in? && current_user.beta? + new_bookmarklet + else + bookmarklet + end end def contacts_link diff --git a/app/models/user.rb b/app/models/user.rb index 83276d6d005a4d96f9237918202163353d6092d5..33146a2187adac068208c1b14e67902569777b09 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -107,7 +107,7 @@ class User < ActiveRecord::Base end def beta? - Role.is_beta?(self.person) + @beta ||= Role.is_beta?(self.person) end #@deprecated diff --git a/app/views/shared/_right_sections.html.haml b/app/views/shared/_right_sections.html.haml index dc550ffa99ae00af0393e85f8d833179de150202..3d2c4894d4f19e3ad9c2b8c627f75b8f0e65444e 100644 --- a/app/views/shared/_right_sections.html.haml +++ b/app/views/shared/_right_sections.html.haml @@ -74,7 +74,7 @@ %h5 = t('bookmarklet.heading') .content - != t('bookmarklet.explanation', :link => link_to(t('bookmarklet.explanation_link_text'), bookmarklet)) + != t('bookmarklet.explanation', :link => link_to(t('bookmarklet.post_something'), magic_bookmarklet_link)) .section .title diff --git a/app/views/status_messages/new_bookmarklet.haml b/app/views/status_messages/new_bookmarklet.haml new file mode 100644 index 0000000000000000000000000000000000000000..475a06e440b894d2a4e3eff01f12ec08d6553c4d --- /dev/null +++ b/app/views/status_messages/new_bookmarklet.haml @@ -0,0 +1,9 @@ +-# Copyright (c) 2010-2012, Diaspora Inc. This file is +-# licensed under the Affero General Public License version 3 or later. See +-# the COPYRIGHT file. + +!!! +%html{:lang => I18n.locale.to_s, :dir => (rtl?) ? 'rtl' : 'ltr'} + %head + %body + %iframe{:src =>"/posts/new", :height => 500, :width => 700, :style => "border:none;"} \ No newline at end of file diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 1ab44d6ddded38433ce289379400a2d2bce875a1..6eb45de340630f116196858ffe894065ceb0c03c 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -234,9 +234,8 @@ en: bookmarklet: heading: "Bookmarklet" post_success: "Posted! Closing!" - post_something: "Post something to Diaspora" - explanation: "Post to Diaspora from anywhere by bookmarking %{link}." - explanation_link_text: "this link" + post_something: "Post to Diaspora" + explanation: "Post to Diaspora from anywhere by bookmarking this link => %{link}." comments: zero: "no comments" diff --git a/config/routes.rb b/config/routes.rb index 5f468bff3f6b3c107665e2fc50d913c31c7bc295..9944d9e84b8d8c3b930d5667d144b92b9ba14ece 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -51,6 +51,7 @@ Diaspora::Application.routes.draw do end get 'bookmarklet' => 'status_messages#bookmarklet' + get 'new_bookmarklet' => 'status_messages#new_bookmarklet' resources :photos, :except => [:index] do put :make_profile_photo diff --git a/spec/controllers/status_messages_controller_spec.rb b/spec/controllers/status_messages_controller_spec.rb index fa823b3fd590f447f02cd365b73cbc85b222cdcf..2effdac35fbf5f48b18c727f20cf4d0066cefd1e 100644 --- a/spec/controllers/status_messages_controller_spec.rb +++ b/spec/controllers/status_messages_controller_spec.rb @@ -53,6 +53,13 @@ describe StatusMessagesController do end end + describe '#new_bookmarklet' do + it 'works' do + get :new_bookmarklet + response.should be_success + end + end + describe '#new' do it 'succeeds' do get :new,