Commit eaedfc98 authored by Maxwell Salzberg's avatar Maxwell Salzberg

create a new publisher using the new composer. only for beta users

parent a46e16cb
......@@ -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
# 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.
......
......@@ -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!
......
......@@ -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)+'&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()}})()"
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)+'&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=#{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
......
......@@ -107,7 +107,7 @@ class User < ActiveRecord::Base
end
def beta?
Role.is_beta?(self.person)
@beta ||= Role.is_beta?(self.person)
end
#@deprecated
......
......@@ -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
......
-# 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
......@@ -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"
......
......@@ -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
......
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment