summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--EVENTS.txt10
-rw-r--r--lib/userprofile.php9
-rw-r--r--plugins/OStatus/OStatusPlugin.php16
-rw-r--r--plugins/OStatus/actions/ostatusinit.php28
-rw-r--r--plugins/OStatus/actions/ostatussub.php4
-rw-r--r--plugins/OStatus/js/ostatus.js60
-rw-r--r--plugins/OStatus/theme/base/css/ostatus.css30
7 files changed, 141 insertions, 16 deletions
diff --git a/EVENTS.txt b/EVENTS.txt
index 6bf12bf13..69fe2ddcc 100644
--- a/EVENTS.txt
+++ b/EVENTS.txt
@@ -1,4 +1,4 @@
-InitializePlugin: a chance to initialize a plugin in a complete environment
+\InitializePlugin: a chance to initialize a plugin in a complete environment
CleanupPlugin: a chance to cleanup a plugin at the end of a program
@@ -355,6 +355,14 @@ EndShowHeadElements: Right before the </head> tag; put <script>s here if you nee
CheckSchema: chance to check the schema
+StartProfileRemoteSubscribe: Before showing the link to remote subscription
+- $userprofile: UserProfile widget
+- &$profile: the profile being shown
+
+EndProfileRemoteSubscribe: After showing the link to remote subscription
+- $userprofile: UserProfile widget
+- &$profile: the profile being shown
+
StartProfilePageProfileSection: Starting to show the section of the
profile page with the actual profile data;
hook to prevent showing the profile (e.g.)
diff --git a/lib/userprofile.php b/lib/userprofile.php
index 07e575085..43dfd05be 100644
--- a/lib/userprofile.php
+++ b/lib/userprofile.php
@@ -238,9 +238,12 @@ class UserProfile extends Widget
if (Event::handle('StartProfilePageActionsElements', array(&$this->out, $this->profile))) {
if (empty($cur)) { // not logged in
- $this->out->elementStart('li', 'entity_subscribe');
- $this->showRemoteSubscribeLink();
- $this->out->elementEnd('li');
+ if (Event::handle('StartProfileRemoteSubscribe', array(&$this->out, $this->profile))) {
+ $this->out->elementStart('li', 'entity_subscribe');
+ $this->showRemoteSubscribeLink();
+ $this->out->elementEnd('li');
+ Event::handle('EndProfileRemoteSubscribe', array(&$this->out, $this->profile));
+ }
} else {
if ($cur->id == $this->profile->id) { // your own page
$this->out->elementStart('li', 'entity_edit');
diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php
index bf7dde296..276ca1b3d 100644
--- a/plugins/OStatus/OStatusPlugin.php
+++ b/plugins/OStatus/OStatusPlugin.php
@@ -188,7 +188,7 @@ class OStatusPlugin extends Plugin
/**
* Add in an OStatus subscribe button
*/
- function onStartProfilePageActionsElements($output, $profile)
+ function onStartProfileRemoteSubscribe($output, $profile)
{
$cur = common_current_user();
@@ -199,10 +199,12 @@ class OStatusPlugin extends Plugin
array('nickname' => $profile->nickname));
$output->element('a', array('href' => $url,
'class' => 'entity_remote_subscribe'),
- _m('OStatus'));
+ _m('Subscribe'));
$output->elementEnd('li');
}
+
+ return false;
}
/**
@@ -272,4 +274,14 @@ class OStatusPlugin extends Plugin
$schema->ensureTable('hubsub', HubSub::schemaDef());
return true;
}
+
+ function onEndShowStatusNetStyles($action) {
+ $action->cssLink(common_path('plugins/OStatus/theme/base/css/ostatus.css'));
+ return true;
+ }
+
+ function onEndShowStatusNetScripts($action) {
+ $action->script(common_path('plugins/OStatus/js/ostatus.js'));
+ return true;
+ }
}
diff --git a/plugins/OStatus/actions/ostatusinit.php b/plugins/OStatus/actions/ostatusinit.php
index bac2c4d43..d21774420 100644
--- a/plugins/OStatus/actions/ostatusinit.php
+++ b/plugins/OStatus/actions/ostatusinit.php
@@ -67,9 +67,21 @@ class OStatusInitAction extends Action
function showForm($err = null)
{
- $this->err = $err;
- $this->showPage();
-
+ $this->err = $err;
+ if ($this->boolean('ajax')) {
+ header('Content-Type: text/xml;charset=utf-8');
+ $this->xw->startDocument('1.0', 'UTF-8');
+ $this->elementStart('html');
+ $this->elementStart('head');
+ $this->element('title', null, _('Subscribe to user'));
+ $this->elementEnd('head');
+ $this->elementStart('body');
+ $this->showContent();
+ $this->elementEnd('body');
+ $this->elementEnd('html');
+ } else {
+ $this->showPage();
+ }
}
function showContent()
@@ -79,15 +91,15 @@ class OStatusInitAction extends Action
'class' => 'form_settings',
'action' => common_local_url('ostatusinit')));
$this->elementStart('fieldset');
- $this->element('legend', _('Subscribe to a remote user'));
+ $this->element('legend', null, sprintf(_('Subscribe to %s'), $this->nickname));
$this->hidden('token', common_session_token());
$this->elementStart('ul', 'form_data');
- $this->elementStart('li');
+ $this->elementStart('li', array('id' => 'ostatus_nickname'));
$this->input('nickname', _('User nickname'), $this->nickname,
_('Nickname of the user you want to follow'));
$this->elementEnd('li');
- $this->elementStart('li');
+ $this->elementStart('li', array('id' => 'ostatus_profile'));
$this->input('acct', _('Profile Account'), $this->acct,
_('Your account id (i.e. user@identi.ca)'));
$this->elementEnd('li');
@@ -95,7 +107,7 @@ class OStatusInitAction extends Action
$this->submit('submit', _('Subscribe'));
$this->elementEnd('fieldset');
$this->elementEnd('form');
- }
+ }
function ostatusConnect()
{
@@ -125,4 +137,4 @@ class OStatusInitAction extends Action
return _('OStatus Connect');
}
-} \ No newline at end of file
+}
diff --git a/plugins/OStatus/actions/ostatussub.php b/plugins/OStatus/actions/ostatussub.php
index 9774286fd..239122501 100644
--- a/plugins/OStatus/actions/ostatussub.php
+++ b/plugins/OStatus/actions/ostatussub.php
@@ -76,7 +76,7 @@ class OStatusSubAction extends Action
$this->elementStart('fieldset', array('id' => 'settings_feeds'));
$this->elementStart('ul', 'form_data');
- $this->elementStart('li', array('id' => 'settings_twitter_login_button'));
+ $this->elementStart('li');
$this->input('feedurl', _('Feed URL'), $this->feedurl, _('Enter the URL of a PubSubHubbub-enabled feed'));
$this->elementEnd('li');
$this->elementEnd('ul');
@@ -223,4 +223,4 @@ class OStatusSubAction extends Action
}
-} \ No newline at end of file
+}
diff --git a/plugins/OStatus/js/ostatus.js b/plugins/OStatus/js/ostatus.js
new file mode 100644
index 000000000..671795558
--- /dev/null
+++ b/plugins/OStatus/js/ostatus.js
@@ -0,0 +1,60 @@
+SN.U.DialogBox = {
+ Subscribe: function(a) {
+ var f = a.parent().find('#form_ostatus_connect');
+ if (f.length > 0) {
+ f.show();
+ }
+ else {
+ $.ajax({
+ type: 'GET',
+ dataType: 'xml',
+ url: a[0].href+'&ajax=1',
+ beforeSend: function(formData) {
+ a.addClass('processing');
+ },
+ error: function (xhr, textStatus, errorThrown) {
+ alert(errorThrown || textStatus);
+ },
+ success: function(data, textStatus, xhr) {
+ if (typeof($('form', data)[0]) != 'undefined') {
+ a.after(document._importNode($('form', data)[0], true));
+
+ var form = a.parent().find('#form_ostatus_connect');
+
+ form
+ .addClass('dialogbox')
+ .append('<button class="close">&#215;</button>');
+
+ form
+ .find('.submit')
+ .addClass('submit_dialogbox')
+ .removeClass('submit')
+ .bind('click', function() {
+ form.addClass('processing');
+ });
+
+ form.find('button.close').click(function(){
+ form.hide();
+
+ return false;
+ });
+
+ form.find('#acct').focus();
+ }
+
+ a.removeClass('processing');
+ }
+ });
+ }
+ }
+};
+
+SN.Init.Subscribe = function() {
+ $('.entity_subscribe a').live('click', function() { SN.U.DialogBox.Subscribe($(this)); return false; });
+};
+
+$(document).ready(function() {
+ if ($('.entity_subscribe .entity_remote_subscribe').length > 0) {
+ SN.Init.Subscribe();
+ }
+});
diff --git a/plugins/OStatus/theme/base/css/ostatus.css b/plugins/OStatus/theme/base/css/ostatus.css
new file mode 100644
index 000000000..9bc90a731
--- /dev/null
+++ b/plugins/OStatus/theme/base/css/ostatus.css
@@ -0,0 +1,30 @@
+/** theme: base for OStatus
+ *
+ * @package StatusNet
+ * @author Sarven Capadisli <csarven@status.net>
+ * @copyright 2010 StatusNet, Inc.
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+#form_ostatus_connect.dialogbox {
+width:70%;
+background-image:none;
+}
+#form_ostatus_connect.dialogbox .form_data label {
+width:34%;
+}
+#form_ostatus_connect.dialogbox .form_data input {
+width:57%;
+}
+#form_ostatus_connect.dialogbox .form_data .form_guide {
+margin-left:36%;
+}
+
+#form_ostatus_connect.dialogbox #ostatus_nickname {
+display:none;
+}
+
+#form_ostatus_connect.dialogbox .submit_dialogbox {
+min-width:96px;
+}