From f08b5dfafe38d54288a9d1a45ae0ed1c8accc358 Mon Sep 17 00:00:00 2001
From: maxwell <maxwell@joindiaspora.com>
Date: Mon, 28 Mar 2011 18:11:24 -0700
Subject: [PATCH] basic functionality done, fixing rough edges

---
 app/controllers/sessions_controller.rb        |  1 +
 app/controllers/status_messages_controller.rb |  7 +++++
 app/views/admins/user_search.html.haml        |  7 +++++
 .../status_messages/bookmarklet.html.haml     | 31 +++++++++++++++++++
 config/routes.rb                              |  1 +
 5 files changed, 47 insertions(+)
 create mode 100644 app/views/status_messages/bookmarklet.html.haml

diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index e887549c28..47ac32530d 100644
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -13,4 +13,5 @@ class SessionsController < Devise::SessionsController
       }
     end
   end
+
 end
diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb
index aa5914952a..126c275140 100644
--- a/app/controllers/status_messages_controller.rb
+++ b/app/controllers/status_messages_controller.rb
@@ -25,6 +25,13 @@ class StatusMessagesController < ApplicationController
     end
   end
 
+  def bookmarklet 
+    puts "foo"
+    @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]
 
diff --git a/app/views/admins/user_search.html.haml b/app/views/admins/user_search.html.haml
index 5ec26af376..d1c1cd2d6f 100644
--- a/app/views/admins/user_search.html.haml
+++ b/app/views/admins/user_search.html.haml
@@ -50,3 +50,10 @@
   %br
   #resp
 
+
+%br
+%a{:href => "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=6&';a=function(){if(!window.open(f+'noui=1&jump=doclose','deliciousuiv6','location=yes,links=no,scrollbars=no,toolbar=no,width=600,height=300'))location.href=f+'jump=yes'};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})()"}
+  post to Diaspora!
+
+
+
diff --git a/app/views/status_messages/bookmarklet.html.haml b/app/views/status_messages/bookmarklet.html.haml
new file mode 100644
index 0000000000..67ca649e31
--- /dev/null
+++ b/app/views/status_messages/bookmarklet.html.haml
@@ -0,0 +1,31 @@
+-#   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").bind('ajax:success', function(){
+        $('h4').text("Your post was successful! Closing!");
+        window.setTimeout(window.close, 2000, true);
+      });
+      $("#publisher #status_message_fake_text").val("#{params[:url]} - #{params[:notes]}");
+      $("#publisher #status_message_text").val("#{params[:url]}");
+      Publisher.open();
+    });
+
+#new_status_message_pane
+  .span-15.last
+    #facebox_header
+      %h4
+        Post something to Diaspora
+
+    = render :partial => 'shared/publisher', :locals => { :aspect => :profile, :aspects_with_person => @aspects,  :aspect_ids => @aspect_ids}
+
diff --git a/config/routes.rb b/config/routes.rb
index 684c4b0569..f8d68a5e61 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -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]
-- 
GitLab