From 584ea1b23c540cdd781f52eeecd6ad893f63c1a8 Mon Sep 17 00:00:00 2001
From: Craig Andrews
Date: Thu, 10 Sep 2009 12:13:43 -0400
Subject: Revert "If a shortened URL begins with http://, don't include it in
the shortened url. Saves 7 characters, which is pretty awesome for 140
character max length notices."
This reverts commit e2848eb8621dd645fa68cb1641c0af1df5530408.
Downstream consumers of our notices (such as Friendfeed, Facebook, etc) don't have sophisticated URL detection, so a notice that reads: "check out ur1.ca/1" won't be linked. So the http:// prefix is
mandatory.
---
lib/util.php | 3 ---
1 file changed, 3 deletions(-)
(limited to 'lib')
diff --git a/lib/util.php b/lib/util.php
index 3e95d2bea..256acf199 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -1414,9 +1414,6 @@ function common_shorten_url($long_url)
curl_close($curlh);
- if(substr($short_url,0,7)=='http://'){
- $short_url = substr($short_url,7);
- }
return $short_url;
}
--
cgit v1.2.3-54-g00ecf
From 2a56245614f90221946ab918e820f6546133a212 Mon Sep 17 00:00:00 2001
From: Craig Andrews
Date: Thu, 10 Sep 2009 21:13:30 -0400
Subject: Re-use enclosure decision logic to decide if a link gets a
paperclip/lightbox popup.
---
lib/util.php | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
(limited to 'lib')
diff --git a/lib/util.php b/lib/util.php
index 256acf199..292045928 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -552,12 +552,13 @@ function common_linkify($url) {
}
if (!empty($f)) {
- if (isset($f->filename)) {
+ if ($f->isEnclosure()) {
$is_attachment = true;
$attachment_id = $f->id;
- } else { // if it has OEmbed info, it's an attachment, too
+ } else {
$foe = File_oembed::staticGet('file_id', $f->id);
if (!empty($foe)) {
+ // if it has OEmbed info, it's an attachment, too
$is_attachment = true;
$attachment_id = $f->id;
--
cgit v1.2.3-54-g00ecf
From 292bb7c4d8ca469447385e29a80f125e03284d70 Mon Sep 17 00:00:00 2001
From: Craig Andrews
Date: Thu, 10 Sep 2009 21:19:38 -0400
Subject: Allow @ signs in the path, querystring, and fragment parts of URLs
---
lib/util.php | 6 +++---
tests/URLDetectionTest.php | 2 ++
2 files changed, 5 insertions(+), 3 deletions(-)
(limited to 'lib')
diff --git a/lib/util.php b/lib/util.php
index 292045928..b831859e9 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -442,9 +442,9 @@ function common_replace_urls_callback($text, $callback, $notice_id = null) {
')'.
'(?:'.
'(?:\:\d+)?'. //:port
- '(?:/[\pN\pL$\[\]\,\!\(\)\.\:\-\_\+\/\=\&\;\%\~\*\$\+\'\"]*)?'. // /path
- '(?:\?[\pN\pL\$\[\]\,\!\(\)\.\:\-\_\+\/\=\&\;\%\~\*\$\+\'\"\/]*)?'. // ?query string
- '(?:\#[\pN\pL$\[\]\,\!\(\)\.\:\-\_\+\/\=\&\;\%\~\*\$\+\'\"\/\?\#]*)?'. // #fragment
+ '(?:/[\pN\pL$\[\]\,\!\(\)\.\:\-\_\+\/\=\&\;\%\~\*\$\+\'\"@]*)?'. // /path
+ '(?:\?[\pN\pL\$\[\]\,\!\(\)\.\:\-\_\+\/\=\&\;\%\~\*\$\+\'\"@\/]*)?'. // ?query string
+ '(?:\#[\pN\pL$\[\]\,\!\(\)\.\:\-\_\+\/\=\&\;\%\~\*\$\+\'\"\@/\?\#]*)?'. // #fragment
')(?http://www.somesite.com/xyz/35637563@N00/52803365/ link'),
array('http://127.0.0.1',
'http://127.0.0.1'),
array('127.0.0.1',
--
cgit v1.2.3-54-g00ecf
From c04987018cd6c845c6da7a92d9857d8c651f7022 Mon Sep 17 00:00:00 2001
From: Marcel van der Boom
Date: Tue, 8 Sep 2009 22:21:33 +0200
Subject: Several fixes to make RabbitMQ a player.
* extlib/Stomp.php
-spaces for tabs (we're on PEAR, right?)
- send: initialize the $properties parameter as array() instead of null
this prevents unsetting $headers if $properties was not set
(besides that, it's the proper way to initialize an array)
- subscribe: insert FIXME's on ActiveMQ specifics
- ack: make sure the content-length header is set *and* is zero.
I have seen the header set to '3' there but could not find where it
came from, this is at least safe.
- disconnect: typo in $headers variable
- readFrame: use fgets() instead of gets() so that RabbitQ, which is more protocol strict can also play
* extlib/Stomp/Frame.php
- spaces for tabs
- add note on possibly protocol violating linefeed
* extlib/Stomp/Message.php
- space for tabs
- add content-length header for message
* lib/stompqueuemanager.php
- use the notice for logging, not the frame
---
extlib/Stomp.php | 124 ++++++++++++++++++++++++++--------------------
extlib/Stomp/Frame.php | 87 ++++++++++++++++----------------
extlib/Stomp/Message.php | 6 ++-
lib/stompqueuemanager.php | 5 +-
4 files changed, 123 insertions(+), 99 deletions(-)
(limited to 'lib')
diff --git a/extlib/Stomp.php b/extlib/Stomp.php
index abd9cba62..c9e90629c 100644
--- a/extlib/Stomp.php
+++ b/extlib/Stomp.php
@@ -26,7 +26,7 @@ require_once 'Stomp/Frame.php';
*
* @package Stomp
* @author Hiram Chirino
- * @author Dejan Bosanac
+ * @author Dejan Bosanac
* @author Michael Caplan
* @version $Revision: 43 $
*/
@@ -44,15 +44,15 @@ class Stomp
*
* @var int
*/
- public $prefetchSize = 1;
-
- /**
+ public $prefetchSize = 1;
+
+ /**
* Client id used for durable subscriptions
*
* @var string
*/
- public $clientId = null;
-
+ public $clientId = null;
+
protected $_brokerUri = null;
protected $_socket = null;
protected $_hosts = array();
@@ -66,7 +66,7 @@ class Stomp
protected $_sessionId;
protected $_read_timeout_seconds = 60;
protected $_read_timeout_milliseconds = 0;
-
+
/**
* Constructor
*
@@ -134,10 +134,10 @@ class Stomp
require_once 'Stomp/Exception.php';
throw new Stomp_Exception("No broker defined");
}
-
+
// force disconnect, if previous established connection exists
$this->disconnect();
-
+
$i = $this->_currentHost;
$att = 0;
$connected = false;
@@ -190,11 +190,11 @@ class Stomp
if ($password != '') {
$this->_password = $password;
}
- $headers = array('login' => $this->_username , 'passcode' => $this->_password);
- if ($this->clientId != null) {
- $headers["client-id"] = $this->clientId;
- }
- $frame = new Stomp_Frame("CONNECT", $headers);
+ $headers = array('login' => $this->_username , 'passcode' => $this->_password);
+ if ($this->clientId != null) {
+ $headers["client-id"] = $this->clientId;
+ }
+ $frame = new Stomp_Frame("CONNECT", $headers);
$this->_writeFrame($frame);
$frame = $this->readFrame();
if ($frame instanceof Stomp_Frame && $frame->command == 'CONNECTED') {
@@ -209,7 +209,7 @@ class Stomp
}
}
}
-
+
/**
* Check if client session has ben established
*
@@ -229,7 +229,7 @@ class Stomp
return $this->_sessionId;
}
/**
- * Send a message to a destination in the messaging system
+ * Send a message to a destination in the messaging system
*
* @param string $destination Destination queue
* @param string|Stomp_Frame $msg Message
@@ -237,7 +237,7 @@ class Stomp
* @param boolean $sync Perform request synchronously
* @return boolean
*/
- public function send ($destination, $msg, $properties = null, $sync = null)
+ public function send ($destination, $msg, $properties = array(), $sync = null)
{
if ($msg instanceof Stomp_Frame) {
$msg->headers['destination'] = $destination;
@@ -319,10 +319,12 @@ class Stomp
public function subscribe ($destination, $properties = null, $sync = null)
{
$headers = array('ack' => 'client');
- $headers['activemq.prefetchSize'] = $this->prefetchSize;
- if ($this->clientId != null) {
- $headers["activemq.subcriptionName"] = $this->clientId;
- }
+ // FIXME: this seems to be activemq specific, but not hurting rabbitmq?
+ $headers['activemq.prefetchSize'] = $this->prefetchSize;
+ if ($this->clientId != null) {
+ // FIXME: this seems to be activemq specific, but not hurting rabbitmq?
+ $headers["activemq.subcriptionName"] = $this->clientId;
+ }
if (isset($properties)) {
foreach ($properties as $name => $value) {
$headers[$name] = $value;
@@ -424,7 +426,7 @@ class Stomp
}
/**
* Acknowledge consumption of a message from a subscription
- * Note: This operation is always asynchronous
+ * Note: This operation is always asynchronous
*
* @param string|Stomp_Frame $messageMessage ID
* @param string $transactionId
@@ -433,20 +435,26 @@ class Stomp
*/
public function ack ($message, $transactionId = null)
{
+ // Handle the headers,
+ $headers = array();
+
if ($message instanceof Stomp_Frame) {
- $frame = new Stomp_Frame('ACK', $message->headers);
- $this->_writeFrame($frame);
- return true;
+ // Copy headers from the object
+ // FIXME: at least content-length can be wrong here (set to 3 sometimes).
+ $headers = $message->headers;
} else {
- $headers = array();
if (isset($transactionId)) {
$headers['transaction'] = $transactionId;
}
$headers['message-id'] = $message;
- $frame = new Stomp_Frame('ACK', $headers);
- $this->_writeFrame($frame);
- return true;
}
+ // An ACK has no content
+ $headers['content-length'] = 0;
+
+ // Create it and write it out
+ $frame = new Stomp_Frame('ACK', $headers);
+ $this->_writeFrame($frame);
+ return true;
}
/**
* Graceful disconnect from the server
@@ -454,11 +462,11 @@ class Stomp
*/
public function disconnect ()
{
- $headers = array();
+ $headers = array();
- if ($this->clientId != null) {
- $headers["client-id"] = $this->clientId;
- }
+ if ($this->clientId != null) {
+ $headers["client-id"] = $this->clientId;
+ }
if (is_resource($this->_socket)) {
$this->_writeFrame(new Stomp_Frame('DISCONNECT', $headers));
@@ -490,19 +498,19 @@ class Stomp
$this->_writeFrame($stompFrame);
}
}
-
+
/**
* Set timeout to wait for content to read
*
* @param int $seconds_to_wait Seconds to wait for a frame
* @param int $milliseconds Milliseconds to wait for a frame
*/
- public function setReadTimeout($seconds, $milliseconds = 0)
+ public function setReadTimeout($seconds, $milliseconds = 0)
{
$this->_read_timeout_seconds = $seconds;
$this->_read_timeout_milliseconds = $milliseconds;
}
-
+
/**
* Read responce frame from server
*
@@ -513,19 +521,29 @@ class Stomp
if (!$this->hasFrameToRead()) {
return false;
}
-
+
$rb = 1024;
$data = '';
- do {
- $read = fgets($this->_socket, $rb);
- if ($read === false) {
- $this->_reconnect();
- return $this->readFrame();
- }
- $data .= $read;
- $len = strlen($data);
- } while (($len < 2 || ! ($data[$len - 2] == "\x00" && $data[$len - 1] == "\n")));
-
+ do {
+ $read = fread($this->_socket, $rb);
+ if ($read === false) {
+ $this->_reconnect();
+ return $this->readFrame();
+ }
+ $data .= $read;
+ $len = strlen($data);
+
+ $continue = true;
+ // ActiveMq apparently add \n after 0 char
+ if($data[$len - 2] == "\x00" && $data[$len - 1] == "\n") {
+ $continue = false;
+ }
+
+ // RabbitMq does not
+ if($data[$len - 1] == "\x00") {
+ $continue = false;
+ }
+ } while ( $continue );
list ($header, $body) = explode("\n\n", $data, 2);
$header = explode("\n", $header);
$headers = array();
@@ -546,7 +564,7 @@ class Stomp
return $frame;
}
}
-
+
/**
* Check if there is a frame to read
*
@@ -557,7 +575,7 @@ class Stomp
$read = array($this->_socket);
$write = null;
$except = null;
-
+
$has_frame_to_read = stream_select($read, $write, $except, $this->_read_timeout_seconds, $this->_read_timeout_milliseconds);
if ($has_frame_to_read === false) {
@@ -565,18 +583,18 @@ class Stomp
} else if ($has_frame_to_read > 0) {
return true;
} else {
- return false;
+ return false;
}
}
-
+
/**
* Reconnects and renews subscriptions (if there were any)
- * Call this method when you detect connection problems
+ * Call this method when you detect connection problems
*/
protected function _reconnect ()
{
$subscriptions = $this->_subscriptions;
-
+
$this->connect($this->_username, $this->_password);
foreach ($subscriptions as $dest => $properties) {
$this->subscribe($dest, $properties);
diff --git a/extlib/Stomp/Frame.php b/extlib/Stomp/Frame.php
index dc59c1cb7..9fd97b4f5 100644
--- a/extlib/Stomp/Frame.php
+++ b/extlib/Stomp/Frame.php
@@ -17,46 +17,46 @@
*/
/* vim: set expandtab tabstop=3 shiftwidth=3: */
-
-/**
- * Stomp Frames are messages that are sent and received on a StompConnection.
- *
- * @package Stomp
- * @author Hiram Chirino
- * @author Dejan Bosanac
- * @author Michael Caplan
- * @version $Revision: 36 $
- */
-class Stomp_Frame
-{
- public $command;
- public $headers = array();
- public $body;
-
- /**
- * Constructor
- *
- * @param string $command
- * @param array $headers
- * @param string $body
- */
- public function __construct ($command = null, $headers = null, $body = null)
- {
- $this->_init($command, $headers, $body);
- }
-
- protected function _init ($command = null, $headers = null, $body = null)
- {
- $this->command = $command;
- if ($headers != null) {
- $this->headers = $headers;
- }
- $this->body = $body;
-
- if ($this->command == 'ERROR') {
- require_once 'Stomp/Exception.php';
- throw new Stomp_Exception($this->headers['message'], 0, $this->body);
- }
+
+/**
+ * Stomp Frames are messages that are sent and received on a StompConnection.
+ *
+ * @package Stomp
+ * @author Hiram Chirino
+ * @author Dejan Bosanac
+ * @author Michael Caplan
+ * @version $Revision: 36 $
+ */
+class Stomp_Frame
+{
+ public $command;
+ public $headers = array();
+ public $body;
+
+ /**
+ * Constructor
+ *
+ * @param string $command
+ * @param array $headers
+ * @param string $body
+ */
+ public function __construct ($command = null, $headers = null, $body = null)
+ {
+ $this->_init($command, $headers, $body);
+ }
+
+ protected function _init ($command = null, $headers = null, $body = null)
+ {
+ $this->command = $command;
+ if ($headers != null) {
+ $this->headers = $headers;
+ }
+ $this->body = $body;
+
+ if ($this->command == 'ERROR') {
+ require_once 'Stomp/Exception.php';
+ throw new Stomp_Exception($this->headers['message'], 0, $this->body);
+ }
}
/**
@@ -74,7 +74,8 @@ class Stomp_Frame
$data .= "\n";
$data .= $this->body;
- return $data .= "\x00\n";
- }
-}
+ $data .= "\x00\n"; // Should there really be a linefeed here?
+ return $data;
+ }
+}
?>
\ No newline at end of file
diff --git a/extlib/Stomp/Message.php b/extlib/Stomp/Message.php
index 6bcad3efd..055662133 100644
--- a/extlib/Stomp/Message.php
+++ b/extlib/Stomp/Message.php
@@ -29,8 +29,12 @@ require_once 'Stomp/Frame.php';
*/
class Stomp_Message extends Stomp_Frame
{
- public function __construct ($body, $headers = null)
+ public function __construct ($body, $headers = array())
{
+ if(!isset($headers['content-length'])) {
+ // TODO: log this, to see if this is correct
+ $headers['content-length'] = strlen($body);
+ }
$this->_init("SEND", $headers, $body);
}
}
diff --git a/lib/stompqueuemanager.php b/lib/stompqueuemanager.php
index f059b42f0..5d8b2996b 100644
--- a/lib/stompqueuemanager.php
+++ b/lib/stompqueuemanager.php
@@ -141,10 +141,11 @@ class StompQueueManager
$this->con->ack($frame);
} else {
if ($handler->handle_notice($notice)) {
- $this->_log(LOG_INFO, 'Successfully handled notice '. $notice->id .' posted at ' . $frame->headers['created'] . ' in queue '. $queue);
+ $this->_log(LOG_INFO, 'Successfully handled notice '. $notice->id .' originally posted at ' . $notice->created . ' in queue '. $queue);
+
$this->con->ack($frame);
} else {
- $this->_log(LOG_WARNING, 'Failed handling notice '. $notice->id .' posted at ' . $frame->headers['created'] . ' in queue '. $queue);
+ $this->_log(LOG_WARNING, 'Failed handling notice '. $notice->id .' originally posted at ' . $notice->created . ' in queue '. $queue);
// FIXME we probably shouldn't have to do
// this kind of queue management ourselves
$this->con->ack($frame);
--
cgit v1.2.3-54-g00ecf
From 57feeb566a0cb2c544545dbfc616437cae69b923 Mon Sep 17 00:00:00 2001
From: Craig Andrews
Date: Fri, 11 Sep 2009 22:37:37 -0400
Subject: Add a parameter named 'inreplyto' to the 'notice/new' page, so urls
can inclue 'inreplyto' id's. Also add 'inreplyto' to the urls sent in emails.
---
actions/newnotice.php | 3 ++-
lib/mail.php | 2 +-
lib/noticeform.php | 11 +++++++++--
lib/noticelist.php | 2 +-
lib/router.php | 4 ++++
5 files changed, 17 insertions(+), 5 deletions(-)
(limited to 'lib')
diff --git a/actions/newnotice.php b/actions/newnotice.php
index 00a822860..6e3720e09 100644
--- a/actions/newnotice.php
+++ b/actions/newnotice.php
@@ -431,13 +431,14 @@ class NewnoticeAction extends Action
$content = $this->trimmed('status_textarea');
if (!$content) {
$replyto = $this->trimmed('replyto');
+ $inreplyto = $this->trimmed('inreplyto');
$profile = Profile::staticGet('nickname', $replyto);
if ($profile) {
$content = '@' . $profile->nickname . ' ';
}
}
- $notice_form = new NoticeForm($this, '', $content);
+ $notice_form = new NoticeForm($this, '', $content, null, $inreplyto);
$notice_form->show();
}
diff --git a/lib/mail.php b/lib/mail.php
index df585406c..432b7b329 100644
--- a/lib/mail.php
+++ b/lib/mail.php
@@ -629,7 +629,7 @@ function mail_notify_attn($user, $notice)
$notice->content,//%4
$conversationUrl,//%5
common_local_url('newnotice',
- array('replyto' => $sender->nickname)),//%6
+ array('replyto' => $sender->nickname, 'inreplyto' => $notice->id)),//%6
common_local_url('replies',
array('nickname' => $user->nickname)),//%7
common_local_url('emailsettings'));//%8
diff --git a/lib/noticeform.php b/lib/noticeform.php
index 1e3a45142..d1387b1b7 100644
--- a/lib/noticeform.php
+++ b/lib/noticeform.php
@@ -69,6 +69,12 @@ class NoticeForm extends Form
var $user = null;
+ /**
+ * The notice being replied to
+ */
+
+ var $inreplyto = null;
+
/**
* Constructor
*
@@ -77,12 +83,13 @@ class NoticeForm extends Form
* @param string $content content to pre-fill
*/
- function __construct($out=null, $action=null, $content=null, $user=null)
+ function __construct($out=null, $action=null, $content=null, $user=null, $inreplyto)
{
parent::__construct($out);
$this->action = $action;
$this->content = $content;
+ $this->inreplyto = $inreplyto;
if ($user) {
$this->user = $user;
@@ -161,7 +168,7 @@ class NoticeForm extends Form
if ($this->action) {
$this->out->hidden('notice_return-to', $this->action, 'returnto');
}
- $this->out->hidden('notice_in-reply-to', $this->action, 'inreplyto');
+ $this->out->hidden('notice_in-reply-to', $this->inreplyto, 'inreplyto');
}
/**
diff --git a/lib/noticelist.php b/lib/noticelist.php
index ec85e4a5c..6b2bccd97 100644
--- a/lib/noticelist.php
+++ b/lib/noticelist.php
@@ -442,7 +442,7 @@ class NoticeListItem extends Widget
{
if (common_logged_in()) {
$reply_url = common_local_url('newnotice',
- array('replyto' => $this->profile->nickname));
+ array('replyto' => $this->profile->nickname, 'inreplyto' => $this->notice->id));
$this->out->elementStart('a', array('href' => $reply_url,
'class' => 'notice_reply',
'title' => _('Reply to this notice')));
diff --git a/lib/router.php b/lib/router.php
index 00e728f55..0505c9942 100644
--- a/lib/router.php
+++ b/lib/router.php
@@ -175,6 +175,10 @@ class Router
$m->connect('notice/new?replyto=:replyto',
array('action' => 'newnotice'),
array('replyto' => '[A-Za-z0-9_-]+'));
+ $m->connect('notice/new?replyto=:replyto&inreplyto=:inreplyto',
+ array('action' => 'newnotice'),
+ array('replyto' => '[A-Za-z0-9_-]+'),
+ array('inreplyto' => '[0-9]+'));
$m->connect('notice/:notice/file',
array('action' => 'file'),
--
cgit v1.2.3-54-g00ecf
From b75ed37eeb8318a5a5f82f080fb2536af0dbc6be Mon Sep 17 00:00:00 2001
From: Craig Andrews
Date: Sat, 12 Sep 2009 16:58:04 -0400
Subject: Show username in subject of emails
Fixes http://status.net/trac/ticket/1862
---
lib/mail.php | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
(limited to 'lib')
diff --git a/lib/mail.php b/lib/mail.php
index 432b7b329..5bf4d7425 100644
--- a/lib/mail.php
+++ b/lib/mail.php
@@ -551,9 +551,9 @@ function mail_notify_fave($other, $user, $notice)
common_init_locale($other->language);
- $subject = sprintf(_('%s added your notice as a favorite'), $bestname);
+ $subject = sprintf(_('%s (@%s) added your notice as a favorite'), $bestname, $user->nickname);
- $body = sprintf(_("%1\$s just added your notice from %2\$s".
+ $body = sprintf(_("%1\$s (@%7\$s) just added your notice from %2\$s".
" as one of their favorites.\n\n" .
"The URL of your notice is:\n\n" .
"%3\$s\n\n" .
@@ -570,7 +570,8 @@ function mail_notify_fave($other, $user, $notice)
$notice->content,
common_local_url('showfavorites',
array('nickname' => $user->nickname)),
- common_config('site', 'name'));
+ common_config('site', 'name'),
+ $user->nickname);
common_init_locale();
mail_to_user($other, $subject, $body);
@@ -607,9 +608,9 @@ function mail_notify_attn($user, $notice)
$conversationUrl = null;
}
- $subject = sprintf(_('%s sent a notice to your attention'), $bestname);
+ $subject = sprintf(_('%s (@%s) sent a notice to your attention'), $bestname, $sender->nickname);
- $body = sprintf(_("%1\$s just sent a notice to your attention (an '@-reply') on %2\$s.\n\n".
+ $body = sprintf(_("%1\$s (@%9\$s) just sent a notice to your attention (an '@-reply') on %2\$s.\n\n".
"The notice is here:\n\n".
"\t%3\$s\n\n" .
"It reads:\n\n".
@@ -632,7 +633,8 @@ function mail_notify_attn($user, $notice)
array('replyto' => $sender->nickname, 'inreplyto' => $notice->id)),//%6
common_local_url('replies',
array('nickname' => $user->nickname)),//%7
- common_local_url('emailsettings'));//%8
+ common_local_url('emailsettings'), //%8
+ $sender->nickname); //%9
common_init_locale();
mail_to_user($user, $subject, $body);
--
cgit v1.2.3-54-g00ecf
From 7cd80b29c45c2255e32328dc8b4e8a19933aa645 Mon Sep 17 00:00:00 2001
From: Craig Andrews
Date: Sat, 12 Sep 2009 17:06:46 -0400
Subject: NoticeForm's constructor's inreplyto argument should be optional
(defaulting to null)
---
lib/noticeform.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'lib')
diff --git a/lib/noticeform.php b/lib/noticeform.php
index d1387b1b7..350e37db8 100644
--- a/lib/noticeform.php
+++ b/lib/noticeform.php
@@ -83,7 +83,7 @@ class NoticeForm extends Form
* @param string $content content to pre-fill
*/
- function __construct($out=null, $action=null, $content=null, $user=null, $inreplyto)
+ function __construct($out=null, $action=null, $content=null, $user=null, $inreplyto=null)
{
parent::__construct($out);
--
cgit v1.2.3-54-g00ecf
From 0a1d2635c1278a12a643c6ee684a9707df6e87dd Mon Sep 17 00:00:00 2001
From: Craig Andrews
Date: Sun, 13 Sep 2009 01:01:31 -0400
Subject: Set a Vary header with accept-encoding and cookies.
Fixes http://status.net/trac/ticket/17
---
lib/action.php | 1 +
1 file changed, 1 insertion(+)
(limited to 'lib')
diff --git a/lib/action.php b/lib/action.php
index fafb2c6fc..670eb498c 100644
--- a/lib/action.php
+++ b/lib/action.php
@@ -881,6 +881,7 @@ class Action extends HTMLOutputter // lawsuit
*/
function handle($argarray=null)
{
+ header('Vary: Accept-Encoding,Cookie');
$lm = $this->lastModified();
$etag = $this->etag();
if ($etag) {
--
cgit v1.2.3-54-g00ecf
From 20997619b353faa94591800fbfc02bc19a4cdce3 Mon Sep 17 00:00:00 2001
From: Craig Andrews
Date: Sun, 13 Sep 2009 01:24:57 -0400
Subject: When viewing a page in https, all links to non-actions (links to CSS,
JS, etc) should be https. Fixes the mixed content warnings that browsers
display.
Fixes http://status.net/trac/ticket/1552
---
lib/util.php | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
(limited to 'lib')
diff --git a/lib/util.php b/lib/util.php
index b831859e9..5b57b79b5 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -750,8 +750,18 @@ function common_local_url($action, $args=null, $params=null, $fragment=null)
return $url;
}
-function common_path($relative, $ssl=false)
+function common_path($relative, $ssl=null)
{
+ if($ssl==null) {
+ //ssl was not specifically requested
+ if( $_SERVER['HTTPS'] && $_SERVER['HTTPS']!="off" ) {
+ //currently in https, so stay in https
+ $ssl=true;
+ } else {
+ //not in https, so stay not in https
+ $ssl=false;
+ }
+ }
$pathpart = (common_config('site', 'path')) ? common_config('site', 'path')."/" : '';
if (($ssl && (common_config('site', 'ssl') === 'sometimes'))
--
cgit v1.2.3-54-g00ecf
From b9e4b6dd49e8f2c56025df8424137144723d2021 Mon Sep 17 00:00:00 2001
From: Craig Andrews
Date: Sun, 13 Sep 2009 17:30:50 -0400
Subject: Generate ETags for pages which don't specify themselves.
---
index.php | 2 +-
lib/action.php | 43 ++++++++++++++++++++++++++++++++++++++-----
2 files changed, 39 insertions(+), 6 deletions(-)
(limited to 'lib')
diff --git a/index.php b/index.php
index 7669778f6..72ceb45df 100644
--- a/index.php
+++ b/index.php
@@ -227,7 +227,7 @@ function main()
try {
if ($action_obj->prepare($args)) {
- $action_obj->handle($args);
+ $action_obj->handleWrapper($args);
}
} catch (ClientException $cex) {
$cac = new ClientErrorAction($cex->getMessage(), $cex->getCode());
diff --git a/lib/action.php b/lib/action.php
index 670eb498c..06cdbdfe0 100644
--- a/lib/action.php
+++ b/lib/action.php
@@ -873,38 +873,71 @@ class Action extends HTMLOutputter // lawsuit
}
/**
- * Handler method
+ * Wrapper for the handle method that handles etags, last-modified, and other conditional headers
*
* @param array $argarray is ignored since it's now passed in in prepare()
*
* @return boolean is read only action?
*/
- function handle($argarray=null)
+ function handleWrapper($argarray=null)
{
- header('Vary: Accept-Encoding,Cookie');
+ header('Vary: Accept-Encoding,Cookie,Accept-Language,Authorization');
+ header("Cache-Control: must-revalidate");
$lm = $this->lastModified();
$etag = $this->etag();
if ($etag) {
header('ETag: ' . $etag);
}
+ $if_none_match = (array_key_exists('HTTP_IF_NONE_MATCH', $_SERVER)) ?
+ $_SERVER['HTTP_IF_NONE_MATCH'] : null;
if ($lm) {
header('Last-Modified: ' . date(DATE_RFC1123, $lm));
if (array_key_exists('HTTP_IF_MODIFIED_SINCE', $_SERVER)) {
$if_modified_since = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
$ims = strtotime($if_modified_since);
if ($lm <= $ims) {
- $if_none_match = (array_key_exists('HTTP_IF_NONE_MATCH', $_SERVER)) ?
- $_SERVER['HTTP_IF_NONE_MATCH'] : null;
if (!$if_none_match ||
!$etag ||
$this->_hasEtag($etag, $if_none_match)) {
header('HTTP/1.1 304 Not Modified');
+ header('Content-Length: 0');
// Better way to do this?
exit(0);
}
}
}
}
+ if($etag) {
+ $ret = $this->handle($argarray);
+ }else{
+ ob_start();
+ $ret = $this->handle($argarray);
+ $output = ob_get_contents();
+ ob_end_clean();
+ //deep etag
+ $etag = md5($output);
+ header('ETag: ' . $etag);
+ if($if_none_match && $this->_hasEtag($etag, $if_none_match)) {
+ header('HTTP/1.1 304 Not Modified');
+ header('Content-Length: 0');
+ // Better way to do this?
+ exit(0);
+ }
+ header('Content-Length: '.strlen($output));
+ print $output;
+ }
+ return $ret;
+ }
+
+ /**
+ * Handler method
+ *
+ * @param array $argarray is ignored since it's now passed in in prepare()
+ *
+ * @return boolean is read only action?
+ */
+ function handle($argarray=null)
+ {
}
/**
--
cgit v1.2.3-54-g00ecf
From 48565a2cdc9df329dee1ad327a1c632dd8f1d4c3 Mon Sep 17 00:00:00 2001
From: Evan Prodromou
Date: Tue, 15 Sep 2009 17:08:27 -0400
Subject: Revert "Several fixes to make RabbitMQ a player."
This reverts commit c04987018cd6c845c6da7a92d9857d8c651f7022.
---
extlib/Stomp.php | 124 ++++++++++++++++++++--------------------------
extlib/Stomp/Frame.php | 87 ++++++++++++++++----------------
extlib/Stomp/Message.php | 6 +--
lib/stompqueuemanager.php | 5 +-
4 files changed, 99 insertions(+), 123 deletions(-)
(limited to 'lib')
diff --git a/extlib/Stomp.php b/extlib/Stomp.php
index c9e90629c..abd9cba62 100644
--- a/extlib/Stomp.php
+++ b/extlib/Stomp.php
@@ -26,7 +26,7 @@ require_once 'Stomp/Frame.php';
*
* @package Stomp
* @author Hiram Chirino
- * @author Dejan Bosanac
+ * @author Dejan Bosanac
* @author Michael Caplan
* @version $Revision: 43 $
*/
@@ -44,15 +44,15 @@ class Stomp
*
* @var int
*/
- public $prefetchSize = 1;
-
- /**
+ public $prefetchSize = 1;
+
+ /**
* Client id used for durable subscriptions
*
* @var string
*/
- public $clientId = null;
-
+ public $clientId = null;
+
protected $_brokerUri = null;
protected $_socket = null;
protected $_hosts = array();
@@ -66,7 +66,7 @@ class Stomp
protected $_sessionId;
protected $_read_timeout_seconds = 60;
protected $_read_timeout_milliseconds = 0;
-
+
/**
* Constructor
*
@@ -134,10 +134,10 @@ class Stomp
require_once 'Stomp/Exception.php';
throw new Stomp_Exception("No broker defined");
}
-
+
// force disconnect, if previous established connection exists
$this->disconnect();
-
+
$i = $this->_currentHost;
$att = 0;
$connected = false;
@@ -190,11 +190,11 @@ class Stomp
if ($password != '') {
$this->_password = $password;
}
- $headers = array('login' => $this->_username , 'passcode' => $this->_password);
- if ($this->clientId != null) {
- $headers["client-id"] = $this->clientId;
- }
- $frame = new Stomp_Frame("CONNECT", $headers);
+ $headers = array('login' => $this->_username , 'passcode' => $this->_password);
+ if ($this->clientId != null) {
+ $headers["client-id"] = $this->clientId;
+ }
+ $frame = new Stomp_Frame("CONNECT", $headers);
$this->_writeFrame($frame);
$frame = $this->readFrame();
if ($frame instanceof Stomp_Frame && $frame->command == 'CONNECTED') {
@@ -209,7 +209,7 @@ class Stomp
}
}
}
-
+
/**
* Check if client session has ben established
*
@@ -229,7 +229,7 @@ class Stomp
return $this->_sessionId;
}
/**
- * Send a message to a destination in the messaging system
+ * Send a message to a destination in the messaging system
*
* @param string $destination Destination queue
* @param string|Stomp_Frame $msg Message
@@ -237,7 +237,7 @@ class Stomp
* @param boolean $sync Perform request synchronously
* @return boolean
*/
- public function send ($destination, $msg, $properties = array(), $sync = null)
+ public function send ($destination, $msg, $properties = null, $sync = null)
{
if ($msg instanceof Stomp_Frame) {
$msg->headers['destination'] = $destination;
@@ -319,12 +319,10 @@ class Stomp
public function subscribe ($destination, $properties = null, $sync = null)
{
$headers = array('ack' => 'client');
- // FIXME: this seems to be activemq specific, but not hurting rabbitmq?
- $headers['activemq.prefetchSize'] = $this->prefetchSize;
- if ($this->clientId != null) {
- // FIXME: this seems to be activemq specific, but not hurting rabbitmq?
- $headers["activemq.subcriptionName"] = $this->clientId;
- }
+ $headers['activemq.prefetchSize'] = $this->prefetchSize;
+ if ($this->clientId != null) {
+ $headers["activemq.subcriptionName"] = $this->clientId;
+ }
if (isset($properties)) {
foreach ($properties as $name => $value) {
$headers[$name] = $value;
@@ -426,7 +424,7 @@ class Stomp
}
/**
* Acknowledge consumption of a message from a subscription
- * Note: This operation is always asynchronous
+ * Note: This operation is always asynchronous
*
* @param string|Stomp_Frame $messageMessage ID
* @param string $transactionId
@@ -435,26 +433,20 @@ class Stomp
*/
public function ack ($message, $transactionId = null)
{
- // Handle the headers,
- $headers = array();
-
if ($message instanceof Stomp_Frame) {
- // Copy headers from the object
- // FIXME: at least content-length can be wrong here (set to 3 sometimes).
- $headers = $message->headers;
+ $frame = new Stomp_Frame('ACK', $message->headers);
+ $this->_writeFrame($frame);
+ return true;
} else {
+ $headers = array();
if (isset($transactionId)) {
$headers['transaction'] = $transactionId;
}
$headers['message-id'] = $message;
+ $frame = new Stomp_Frame('ACK', $headers);
+ $this->_writeFrame($frame);
+ return true;
}
- // An ACK has no content
- $headers['content-length'] = 0;
-
- // Create it and write it out
- $frame = new Stomp_Frame('ACK', $headers);
- $this->_writeFrame($frame);
- return true;
}
/**
* Graceful disconnect from the server
@@ -462,11 +454,11 @@ class Stomp
*/
public function disconnect ()
{
- $headers = array();
+ $headers = array();
- if ($this->clientId != null) {
- $headers["client-id"] = $this->clientId;
- }
+ if ($this->clientId != null) {
+ $headers["client-id"] = $this->clientId;
+ }
if (is_resource($this->_socket)) {
$this->_writeFrame(new Stomp_Frame('DISCONNECT', $headers));
@@ -498,19 +490,19 @@ class Stomp
$this->_writeFrame($stompFrame);
}
}
-
+
/**
* Set timeout to wait for content to read
*
* @param int $seconds_to_wait Seconds to wait for a frame
* @param int $milliseconds Milliseconds to wait for a frame
*/
- public function setReadTimeout($seconds, $milliseconds = 0)
+ public function setReadTimeout($seconds, $milliseconds = 0)
{
$this->_read_timeout_seconds = $seconds;
$this->_read_timeout_milliseconds = $milliseconds;
}
-
+
/**
* Read responce frame from server
*
@@ -521,29 +513,19 @@ class Stomp
if (!$this->hasFrameToRead()) {
return false;
}
-
+
$rb = 1024;
$data = '';
- do {
- $read = fread($this->_socket, $rb);
- if ($read === false) {
- $this->_reconnect();
- return $this->readFrame();
- }
- $data .= $read;
- $len = strlen($data);
-
- $continue = true;
- // ActiveMq apparently add \n after 0 char
- if($data[$len - 2] == "\x00" && $data[$len - 1] == "\n") {
- $continue = false;
- }
-
- // RabbitMq does not
- if($data[$len - 1] == "\x00") {
- $continue = false;
- }
- } while ( $continue );
+ do {
+ $read = fgets($this->_socket, $rb);
+ if ($read === false) {
+ $this->_reconnect();
+ return $this->readFrame();
+ }
+ $data .= $read;
+ $len = strlen($data);
+ } while (($len < 2 || ! ($data[$len - 2] == "\x00" && $data[$len - 1] == "\n")));
+
list ($header, $body) = explode("\n\n", $data, 2);
$header = explode("\n", $header);
$headers = array();
@@ -564,7 +546,7 @@ class Stomp
return $frame;
}
}
-
+
/**
* Check if there is a frame to read
*
@@ -575,7 +557,7 @@ class Stomp
$read = array($this->_socket);
$write = null;
$except = null;
-
+
$has_frame_to_read = stream_select($read, $write, $except, $this->_read_timeout_seconds, $this->_read_timeout_milliseconds);
if ($has_frame_to_read === false) {
@@ -583,18 +565,18 @@ class Stomp
} else if ($has_frame_to_read > 0) {
return true;
} else {
- return false;
+ return false;
}
}
-
+
/**
* Reconnects and renews subscriptions (if there were any)
- * Call this method when you detect connection problems
+ * Call this method when you detect connection problems
*/
protected function _reconnect ()
{
$subscriptions = $this->_subscriptions;
-
+
$this->connect($this->_username, $this->_password);
foreach ($subscriptions as $dest => $properties) {
$this->subscribe($dest, $properties);
diff --git a/extlib/Stomp/Frame.php b/extlib/Stomp/Frame.php
index 9fd97b4f5..dc59c1cb7 100644
--- a/extlib/Stomp/Frame.php
+++ b/extlib/Stomp/Frame.php
@@ -17,46 +17,46 @@
*/
/* vim: set expandtab tabstop=3 shiftwidth=3: */
-
-/**
- * Stomp Frames are messages that are sent and received on a StompConnection.
- *
- * @package Stomp
- * @author Hiram Chirino
- * @author Dejan Bosanac
- * @author Michael Caplan
- * @version $Revision: 36 $
- */
-class Stomp_Frame
-{
- public $command;
- public $headers = array();
- public $body;
-
- /**
- * Constructor
- *
- * @param string $command
- * @param array $headers
- * @param string $body
- */
- public function __construct ($command = null, $headers = null, $body = null)
- {
- $this->_init($command, $headers, $body);
- }
-
- protected function _init ($command = null, $headers = null, $body = null)
- {
- $this->command = $command;
- if ($headers != null) {
- $this->headers = $headers;
- }
- $this->body = $body;
-
- if ($this->command == 'ERROR') {
- require_once 'Stomp/Exception.php';
- throw new Stomp_Exception($this->headers['message'], 0, $this->body);
- }
+
+/**
+ * Stomp Frames are messages that are sent and received on a StompConnection.
+ *
+ * @package Stomp
+ * @author Hiram Chirino
+ * @author Dejan Bosanac
+ * @author Michael Caplan
+ * @version $Revision: 36 $
+ */
+class Stomp_Frame
+{
+ public $command;
+ public $headers = array();
+ public $body;
+
+ /**
+ * Constructor
+ *
+ * @param string $command
+ * @param array $headers
+ * @param string $body
+ */
+ public function __construct ($command = null, $headers = null, $body = null)
+ {
+ $this->_init($command, $headers, $body);
+ }
+
+ protected function _init ($command = null, $headers = null, $body = null)
+ {
+ $this->command = $command;
+ if ($headers != null) {
+ $this->headers = $headers;
+ }
+ $this->body = $body;
+
+ if ($this->command == 'ERROR') {
+ require_once 'Stomp/Exception.php';
+ throw new Stomp_Exception($this->headers['message'], 0, $this->body);
+ }
}
/**
@@ -74,8 +74,7 @@ class Stomp_Frame
$data .= "\n";
$data .= $this->body;
- $data .= "\x00\n"; // Should there really be a linefeed here?
- return $data;
- }
-}
+ return $data .= "\x00\n";
+ }
+}
?>
\ No newline at end of file
diff --git a/extlib/Stomp/Message.php b/extlib/Stomp/Message.php
index 055662133..6bcad3efd 100644
--- a/extlib/Stomp/Message.php
+++ b/extlib/Stomp/Message.php
@@ -29,12 +29,8 @@ require_once 'Stomp/Frame.php';
*/
class Stomp_Message extends Stomp_Frame
{
- public function __construct ($body, $headers = array())
+ public function __construct ($body, $headers = null)
{
- if(!isset($headers['content-length'])) {
- // TODO: log this, to see if this is correct
- $headers['content-length'] = strlen($body);
- }
$this->_init("SEND", $headers, $body);
}
}
diff --git a/lib/stompqueuemanager.php b/lib/stompqueuemanager.php
index 5d8b2996b..f059b42f0 100644
--- a/lib/stompqueuemanager.php
+++ b/lib/stompqueuemanager.php
@@ -141,11 +141,10 @@ class StompQueueManager
$this->con->ack($frame);
} else {
if ($handler->handle_notice($notice)) {
- $this->_log(LOG_INFO, 'Successfully handled notice '. $notice->id .' originally posted at ' . $notice->created . ' in queue '. $queue);
-
+ $this->_log(LOG_INFO, 'Successfully handled notice '. $notice->id .' posted at ' . $frame->headers['created'] . ' in queue '. $queue);
$this->con->ack($frame);
} else {
- $this->_log(LOG_WARNING, 'Failed handling notice '. $notice->id .' originally posted at ' . $notice->created . ' in queue '. $queue);
+ $this->_log(LOG_WARNING, 'Failed handling notice '. $notice->id .' posted at ' . $frame->headers['created'] . ' in queue '. $queue);
// FIXME we probably shouldn't have to do
// this kind of queue management ourselves
$this->con->ack($frame);
--
cgit v1.2.3-54-g00ecf
From d7e13e847dbce55ad8ed017f02e1ac8420881e4e Mon Sep 17 00:00:00 2001
From: Craig Andrews
Date: Tue, 15 Sep 2009 17:17:36 -0400
Subject: 304 responses should not have a Content-Length header.
---
lib/action.php | 2 --
1 file changed, 2 deletions(-)
(limited to 'lib')
diff --git a/lib/action.php b/lib/action.php
index 06cdbdfe0..ebef4f9e4 100644
--- a/lib/action.php
+++ b/lib/action.php
@@ -900,7 +900,6 @@ class Action extends HTMLOutputter // lawsuit
!$etag ||
$this->_hasEtag($etag, $if_none_match)) {
header('HTTP/1.1 304 Not Modified');
- header('Content-Length: 0');
// Better way to do this?
exit(0);
}
@@ -919,7 +918,6 @@ class Action extends HTMLOutputter // lawsuit
header('ETag: ' . $etag);
if($if_none_match && $this->_hasEtag($etag, $if_none_match)) {
header('HTTP/1.1 304 Not Modified');
- header('Content-Length: 0');
// Better way to do this?
exit(0);
}
--
cgit v1.2.3-54-g00ecf
From 4b7881c64e741d7b82f1d65bd9651148692cf1d4 Mon Sep 17 00:00:00 2001
From: Sarven Capadisli
Date: Fri, 18 Sep 2009 19:32:51 +0200
Subject: Removed trailing single space in author @title
---
lib/noticelist.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'lib')
diff --git a/lib/noticelist.php b/lib/noticelist.php
index 6b2bccd97..336457b45 100644
--- a/lib/noticelist.php
+++ b/lib/noticelist.php
@@ -261,7 +261,7 @@ class NoticeListItem extends Widget
$attrs = array('href' => $this->profile->profileurl,
'class' => 'url');
if (!empty($this->profile->fullname)) {
- $attrs['title'] = $this->profile->fullname . ' (' . $this->profile->nickname . ') ';
+ $attrs['title'] = $this->profile->fullname . ' (' . $this->profile->nickname . ')';
}
$this->out->elementStart('a', $attrs);
$this->showAvatar();
--
cgit v1.2.3-54-g00ecf
From 6af71f2cd2b2fcacb0f1eb2e0172a300802fe8bc Mon Sep 17 00:00:00 2001
From: Craig Andrews
Date: Fri, 18 Sep 2009 17:37:36 -0400
Subject: Show context link if this notice starts a conversation
---
lib/noticelist.php | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
(limited to 'lib')
diff --git a/lib/noticelist.php b/lib/noticelist.php
index 6b2bccd97..507413da7 100644
--- a/lib/noticelist.php
+++ b/lib/noticelist.php
@@ -418,9 +418,17 @@ class NoticeListItem extends Widget
function showContext()
{
- // XXX: also show context if there are replies to this notice
- if (!empty($this->notice->conversation)
- && $this->notice->conversation != $this->notice->id) {
+ $hasConversation = false;
+ if( !empty($this->notice->conversation)
+ && $this->notice->conversation != $this->notice->id){
+ $hasConversation = true;
+ }else{
+ $conversation = Notice::conversationStream($this->notice->id, 1, 1);
+ if($conversation->N > 0){
+ $hasConversation = true;
+ }
+ }
+ if ($hasConversation){
$convurl = common_local_url('conversation',
array('id' => $this->notice->conversation));
$this->out->element('a', array('href' => $convurl.'#notice-'.$this->notice->id,
--
cgit v1.2.3-54-g00ecf
From 74296fa12c7813ad5cdc80750173c11912b5860f Mon Sep 17 00:00:00 2001
From: Zach Copley
Date: Sat, 19 Sep 2009 18:34:07 -0700
Subject: Make statuses/home_timeline return the same thing as
statuses/friends_timeline to support apps trying to use the new retweet API
method.
---
actions/twitapistatuses.php | 5 +++++
lib/router.php | 6 +++---
2 files changed, 8 insertions(+), 3 deletions(-)
(limited to 'lib')
diff --git a/actions/twitapistatuses.php b/actions/twitapistatuses.php
index edee239a0..5e2867ea8 100644
--- a/actions/twitapistatuses.php
+++ b/actions/twitapistatuses.php
@@ -136,6 +136,11 @@ class TwitapistatusesAction extends TwitterapiAction
}
+ function home_timeline($args, $apidata)
+ {
+ call_user_func(array($this, 'friends_timeline'), $args, $apidata);
+ }
+
function user_timeline($args, $apidata)
{
parent::handle($args);
diff --git a/lib/router.php b/lib/router.php
index 0505c9942..5529e60ac 100644
--- a/lib/router.php
+++ b/lib/router.php
@@ -272,12 +272,12 @@ class Router
$m->connect('api/statuses/:method',
array('action' => 'api',
'apiaction' => 'statuses'),
- array('method' => '(public_timeline|friends_timeline|user_timeline|update|replies|mentions|show|friends|followers|featured)(\.(atom|rss|xml|json))?'));
+ array('method' => '(public_timeline|home_timeline|friends_timeline|user_timeline|update|replies|mentions|show|friends|followers|featured)(\.(atom|rss|xml|json))?'));
$m->connect('api/statuses/:method/:argument',
array('action' => 'api',
'apiaction' => 'statuses'),
- array('method' => '(|user_timeline|friends_timeline|replies|mentions|show|destroy|friends|followers)'));
+ array('method' => '(user_timeline|home_timeline|friends_timeline|replies|mentions|show|destroy|friends|followers)'));
// users
@@ -436,7 +436,7 @@ class Router
$m->connect('api/statuses/:method/:argument',
array('action' => 'api',
'apiaction' => 'statuses'),
- array('method' => '(|user_timeline|friends_timeline|replies|mentions|show|destroy|friends|followers)'));
+ array('method' => '(user_timeline|home_timeline|friends_timeline|replies|mentions|show|destroy|friends|followers)'));
$m->connect('api/statusnet/groups/:method/:argument',
array('action' => 'api',
--
cgit v1.2.3-54-g00ecf
From 8aad3154a7673091291af4b95da2736e98aa75e7 Mon Sep 17 00:00:00 2001
From: Zach Copley
Date: Sat, 19 Sep 2009 18:34:07 -0700
Subject: Make statuses/home_timeline return the same thing as
statuses/friends_timeline to support apps trying to use the new retweet API
method.
---
actions/twitapistatuses.php | 5 +++++
lib/router.php | 6 +++---
2 files changed, 8 insertions(+), 3 deletions(-)
(limited to 'lib')
diff --git a/actions/twitapistatuses.php b/actions/twitapistatuses.php
index ad6654dff..2f10ff966 100644
--- a/actions/twitapistatuses.php
+++ b/actions/twitapistatuses.php
@@ -136,6 +136,11 @@ class TwitapistatusesAction extends TwitterapiAction
}
+ function home_timeline($args, $apidata)
+ {
+ call_user_func(array($this, 'friends_timeline'), $args, $apidata);
+ }
+
function user_timeline($args, $apidata)
{
parent::handle($args);
diff --git a/lib/router.php b/lib/router.php
index 8f13b8852..2c4d63b0d 100644
--- a/lib/router.php
+++ b/lib/router.php
@@ -265,12 +265,12 @@ class Router
$m->connect('api/statuses/:method',
array('action' => 'api',
'apiaction' => 'statuses'),
- array('method' => '(public_timeline|friends_timeline|user_timeline|update|replies|mentions|show|friends|followers|featured)(\.(atom|rss|xml|json))?'));
+ array('method' => '(public_timeline|home_timeline|friends_timeline|user_timeline|update|replies|mentions|show|friends|followers|featured)(\.(atom|rss|xml|json))?'));
$m->connect('api/statuses/:method/:argument',
array('action' => 'api',
'apiaction' => 'statuses'),
- array('method' => '(|user_timeline|friends_timeline|replies|mentions|show|destroy|friends|followers)'));
+ array('method' => '(user_timeline|home_timeline|friends_timeline|replies|mentions|show|destroy|friends|followers)'));
// users
@@ -429,7 +429,7 @@ class Router
$m->connect('api/statuses/:method/:argument',
array('action' => 'api',
'apiaction' => 'statuses'),
- array('method' => '(|user_timeline|friends_timeline|replies|mentions|show|destroy|friends|followers)'));
+ array('method' => '(user_timeline|home_timeline|friends_timeline|replies|mentions|show|destroy|friends|followers)'));
$m->connect('api/statusnet/groups/:method/:argument',
array('action' => 'api',
--
cgit v1.2.3-54-g00ecf
From 44820d296dd0c00cef9b48af3a3574f765042715 Mon Sep 17 00:00:00 2001
From: Sarven Capadisli
Date: Sun, 20 Sep 2009 13:44:22 +0200
Subject: No need to call farbtastic.go.js because it was moved to
userdesign.go.js
---
lib/designsettings.php | 1 -
1 file changed, 1 deletion(-)
(limited to 'lib')
diff --git a/lib/designsettings.php b/lib/designsettings.php
index fdc05562e..820d534f2 100644
--- a/lib/designsettings.php
+++ b/lib/designsettings.php
@@ -325,7 +325,6 @@ class DesignSettingsAction extends AccountSettingsAction
parent::showScripts();
$this->script('js/farbtastic/farbtastic.js');
- $this->script('js/farbtastic/farbtastic.go.js');
$this->script('js/userdesign.go.js');
$this->autofocus('design_background-image_file');
--
cgit v1.2.3-54-g00ecf
From 0125f293245a55a46af202e49bfa98bb983d2c57 Mon Sep 17 00:00:00 2001
From: Brion Vibber
Date: Sun, 20 Sep 2009 21:39:57 -0700
Subject: Don't trigger E_NOTICE when looking for commands in the notice input
explode() only returns one item if there was no space, leading to an E_NOTICE
about an undefined array index in the list($a,$b) pattern.
---
lib/commandinterpreter.php | 42 +++++++++++++++++++++++++++---------------
1 file changed, 27 insertions(+), 15 deletions(-)
(limited to 'lib')
diff --git a/lib/commandinterpreter.php b/lib/commandinterpreter.php
index 6e4340e5d..60fc4c3c4 100644
--- a/lib/commandinterpreter.php
+++ b/lib/commandinterpreter.php
@@ -28,7 +28,7 @@ class CommandInterpreter
# XXX: localise
$text = preg_replace('/\s+/', ' ', trim($text));
- list($cmd, $arg) = explode(' ', $text, 2);
+ list($cmd, $arg) = $this->split_arg($text);
# We try to support all the same commands as Twitter, see
# http://getsatisfaction.com/twitter/topics/what_are_the_twitter_commands
@@ -43,7 +43,7 @@ class CommandInterpreter
return new HelpCommand($user);
case 'on':
if ($arg) {
- list($other, $extra) = explode(' ', $arg, 2);
+ list($other, $extra) = $this->split_arg($arg);
if ($extra) {
return null;
} else {
@@ -54,7 +54,7 @@ class CommandInterpreter
}
case 'off':
if ($arg) {
- list($other, $extra) = explode(' ', $arg, 2);
+ list($other, $extra) = $this->split_arg($arg);
if ($extra) {
return null;
} else {
@@ -74,7 +74,7 @@ class CommandInterpreter
if (!$arg) {
return null;
}
- list($other, $extra) = explode(' ', $arg, 2);
+ list($other, $extra) = $this->split_arg($arg);
if ($extra) {
return null;
} else {
@@ -84,7 +84,7 @@ class CommandInterpreter
if (!$arg) {
return null;
}
- list($other, $extra) = explode(' ', $arg, 2);
+ list($other, $extra) = $this->split_arg($arg);
if ($extra) {
return null;
} else {
@@ -95,7 +95,7 @@ class CommandInterpreter
if (!$arg) {
return null;
}
- list($other, $extra) = explode(' ', $arg, 2);
+ list($other, $extra) = $this->split_arg($arg);
if ($extra) {
return null;
} else {
@@ -106,7 +106,7 @@ class CommandInterpreter
if (!$arg) {
return null;
}
- list($other, $extra) = explode(' ', $arg, 2);
+ list($other, $extra) = $this->split_arg($arg);
if ($extra) {
return null;
} else {
@@ -117,7 +117,7 @@ class CommandInterpreter
if (!$arg) {
return null;
}
- list($other, $extra) = explode(' ', $arg, 2);
+ list($other, $extra) = $this->split_arg($arg);
if ($extra) {
return null;
} else {
@@ -128,7 +128,7 @@ class CommandInterpreter
if (!$arg) {
return null;
}
- list($other, $extra) = explode(' ', $arg, 2);
+ list($other, $extra) = $this->split_arg($arg);
if (!$extra) {
return null;
} else {
@@ -138,7 +138,7 @@ class CommandInterpreter
if (!$arg) {
return null;
}
- list($other, $extra) = explode(' ', $arg, 2);
+ list($other, $extra) = $this->split_arg($arg);
if ($extra) {
return null;
} else {
@@ -148,7 +148,7 @@ class CommandInterpreter
if (!$arg) {
return null;
}
- list($other, $extra) = explode(' ', $arg, 2);
+ list($other, $extra) = $this->split_arg($arg);
if ($extra) {
return null;
} else {
@@ -158,7 +158,7 @@ class CommandInterpreter
if (!$arg) {
return null;
}
- list($other, $extra) = explode(' ', $arg, 2);
+ list($other, $extra) = $this->split_arg($arg);
if ($extra) {
return null;
} else {
@@ -173,7 +173,7 @@ class CommandInterpreter
if (!$arg) {
return null;
}
- list($other, $extra) = explode(' ', $arg, 2);
+ list($other, $extra) = $this->split_arg($arg);
if ($extra) {
return null;
} else {
@@ -183,7 +183,7 @@ class CommandInterpreter
if (!$arg) {
return null;
}
- list($word, $extra) = explode(' ', $arg, 2);
+ list($word, $extra) = $this->split_arg($arg);
if ($extra) {
return null;
} else if ($word == 'off') {
@@ -195,7 +195,7 @@ class CommandInterpreter
if (!$arg) {
return null;
}
- list($word, $extra) = explode(' ', $arg, 2);
+ list($word, $extra) = $this->split_arg($arg);
if ($extra) {
return null;
} else if ($word == 'all') {
@@ -213,5 +213,17 @@ class CommandInterpreter
return false;
}
}
+
+ /**
+ * Split arguments without triggering a PHP notice warning
+ */
+ function split_arg($text)
+ {
+ $pieces = explode(' ', $text, 2);
+ if (count($pieces) == 1) {
+ $pieces[] = null;
+ }
+ return $pieces;
+ }
}
--
cgit v1.2.3-54-g00ecf
From 3c89d31b1883e478d69a121905e5a9a400a17622 Mon Sep 17 00:00:00 2001
From: Brion Vibber
Date: Sun, 20 Sep 2009 22:30:10 -0700
Subject: Fixes for posting shortened URLs or uploads * If no shortener plugin
is enabled, fall back to using the long URL instead of trying to load
nonexistent ur1.ca plugin and throwing 'Class does not exist' * Fix bad call
to call_user_func_array() in callback_helper() which broke all shortening
---
lib/util.php | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
(limited to 'lib')
diff --git a/lib/util.php b/lib/util.php
index b74dc619c..d9ff8b863 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -493,7 +493,7 @@ function callback_helper($matches, $callback, $notice_id) {
}while($original_url!=$url);
if(empty($notice_id)){
- $result = call_user_func_array($callback,$url);
+ $result = call_user_func_array($callback, array($url));
}else{
$result = call_user_func_array($callback, array(array($url,$notice_id)) );
}
@@ -1374,10 +1374,14 @@ function common_shorten_url($long_url)
$svc = $user->urlshorteningservice;
}
global $_shorteners;
- if(! $_shorteners[$svc]){
+ if (!isset($_shorteners[$svc])) {
//the user selected service doesn't exist, so default to ur1.ca
$svc = 'ur1.ca';
}
+ if (!isset($_shorteners[$svc])) {
+ // no shortener plugins installed.
+ return $long_url;
+ }
$reflectionObj = new ReflectionClass($_shorteners[$svc]['callInfo'][0]);
$short_url_service = $reflectionObj->newInstanceArgs($_shorteners[$svc]['callInfo'][1]);
--
cgit v1.2.3-54-g00ecf
From 5b91223ce4ece508b25397dc00e1d04ef2e1bc28 Mon Sep 17 00:00:00 2001
From: Evan Prodromou
Date: Mon, 21 Sep 2009 14:14:55 -0400
Subject: add a hook at point of enqueuing notices
---
EVENTS.txt | 7 +++++++
lib/util.php | 15 ++++++++++-----
2 files changed, 17 insertions(+), 5 deletions(-)
(limited to 'lib')
diff --git a/EVENTS.txt b/EVENTS.txt
index 121ae175d..64c3c08c7 100644
--- a/EVENTS.txt
+++ b/EVENTS.txt
@@ -254,3 +254,10 @@ StartApiRss: after the rss element is started
StartApiAtom: after the element is started
- $action: action object being shown
+StartEnqueueNotice: about to add a notice to the queues (good place to add a new transport)
+- $notice: the notice being added
+- &$transports: modifiable list of transports (as strings) to queue for
+
+EndEnqueueNotice: after adding a notice to the queues
+- $notice: the notice being added
+- $transports: modifiable list of transports to use
diff --git a/lib/util.php b/lib/util.php
index d9ff8b863..eb247562d 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -915,11 +915,16 @@ function common_enqueue_notice($notice)
}
}
- $qm = QueueManager::get();
+ if (Event::handle('StartEnqueueNotice', array($notice, &$transports))) {
- foreach ($transports as $transport)
- {
- $qm->enqueue($notice, $transport);
+ $qm = QueueManager::get();
+
+ foreach ($transports as $transport)
+ {
+ $qm->enqueue($notice, $transport);
+ }
+
+ Event::handle('EndEnqueueNotice', array($notice, $transports));
}
return true;
@@ -1384,7 +1389,7 @@ function common_shorten_url($long_url)
}
$reflectionObj = new ReflectionClass($_shorteners[$svc]['callInfo'][0]);
- $short_url_service = $reflectionObj->newInstanceArgs($_shorteners[$svc]['callInfo'][1]);
+ $short_url_service = $reflectionObj->newInstanceArgs($_shorteners[$svc]['callInfo'][1]);
$short_url = $short_url_service->shorten($long_url);
if(substr($short_url,0,7)=='http://'){
--
cgit v1.2.3-54-g00ecf
From eb41d9e5da6a9d1e9b31ca017b5534eb6bd25b32 Mon Sep 17 00:00:00 2001
From: Evan Prodromou
Date: Mon, 21 Sep 2009 14:23:35 -0400
Subject: add a hook for the unqueuemanager
---
EVENTS.txt | 4 ++++
lib/unqueuemanager.php | 4 +++-
2 files changed, 7 insertions(+), 1 deletion(-)
(limited to 'lib')
diff --git a/EVENTS.txt b/EVENTS.txt
index 64c3c08c7..56f91f87a 100644
--- a/EVENTS.txt
+++ b/EVENTS.txt
@@ -261,3 +261,7 @@ StartEnqueueNotice: about to add a notice to the queues (good place to add a new
EndEnqueueNotice: after adding a notice to the queues
- $notice: the notice being added
- $transports: modifiable list of transports to use
+
+UnqueueHandleNotice: Handle a notice when no queue manager is available
+- $notice: the notice to handle
+- $queue: the "queue" that is being executed
\ No newline at end of file
diff --git a/lib/unqueuemanager.php b/lib/unqueuemanager.php
index c5dc29d38..269ecdeaa 100644
--- a/lib/unqueuemanager.php
+++ b/lib/unqueuemanager.php
@@ -73,7 +73,9 @@ class UnQueueManager
jabber_broadcast_notice($notice);
break;
default:
- throw ServerException("UnQueueManager: Unknown queue: $type");
+ if (Event::handle('UnqueueHandleNotice', array(&$notice, $queue))) {
+ throw ServerException("UnQueueManager: Unknown queue: $queue");
+ }
}
}
--
cgit v1.2.3-54-g00ecf
From 98924a80d776107a734b44027dda18094b1f093f Mon Sep 17 00:00:00 2001
From: Evan Prodromou
Date: Mon, 21 Sep 2009 14:39:22 -0400
Subject: 'easy' way to handle notices at queue time
---
EVENTS.txt | 3 +++
lib/unqueuemanager.php | 3 +++
lib/util.php | 3 ++-
scripts/pluginqueuehandler.php | 58 ++++++++++++++++++++++++++++++++++++++++++
4 files changed, 66 insertions(+), 1 deletion(-)
create mode 100755 scripts/pluginqueuehandler.php
(limited to 'lib')
diff --git a/EVENTS.txt b/EVENTS.txt
index d3b58ffb0..2b16d43c0 100644
--- a/EVENTS.txt
+++ b/EVENTS.txt
@@ -268,3 +268,6 @@ UnqueueHandleNotice: Handle a notice when no queue manager is available
GetValidDaemons: Just before determining which daemons to run
- &$daemons: modifiable list of daemon scripts to run, filenames relative to scripts/
+
+HandleQueuedNotice: Handle a queued notice at queue time (or immediately if no queue)
+- &$notice: notice to handle
diff --git a/lib/unqueuemanager.php b/lib/unqueuemanager.php
index 269ecdeaa..6cfe5bcbd 100644
--- a/lib/unqueuemanager.php
+++ b/lib/unqueuemanager.php
@@ -72,6 +72,9 @@ class UnQueueManager
require_once(INSTALLDIR.'/lib/jabber.php');
jabber_broadcast_notice($notice);
break;
+ case 'plugin':
+ Event::handle('HandleQueuedNotice', array(&$notice));
+ break;
default:
if (Event::handle('UnqueueHandleNotice', array(&$notice, $queue))) {
throw ServerException("UnQueueManager: Unknown queue: $queue");
diff --git a/lib/util.php b/lib/util.php
index eb247562d..37744fc5b 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -897,7 +897,8 @@ function common_enqueue_notice($notice)
'twitter',
'facebook',
'ping');
- static $allTransports = array('sms');
+
+ static $allTransports = array('sms', 'plugin');
$transports = $allTransports;
diff --git a/scripts/pluginqueuehandler.php b/scripts/pluginqueuehandler.php
new file mode 100755
index 000000000..ae807db6a
--- /dev/null
+++ b/scripts/pluginqueuehandler.php
@@ -0,0 +1,58 @@
+#!/usr/bin/env php
+.
+ */
+
+define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
+
+$shortoptions = 'i::';
+$longoptions = array('id::');
+
+$helptext = <<runOnce();
--
cgit v1.2.3-54-g00ecf
From ebb52efeb48212626d41a79b9d7e4f505323d074 Mon Sep 17 00:00:00 2001
From: Craig Andrews
Date: Mon, 21 Sep 2009 22:48:19 -0400
Subject: Make link href the long url so users can tell where links are going
---
lib/util.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'lib')
diff --git a/lib/util.php b/lib/util.php
index 37744fc5b..018b7cad5 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -536,7 +536,7 @@ function common_linkify($url) {
throw new ServerException("Can't linkify url '$url'");
}
- $attrs = array('href' => $canon, 'rel' => 'external');
+ $attrs = array('href' => $longurl, 'rel' => 'external');
$is_attachment = false;
$attachment_id = null;
--
cgit v1.2.3-54-g00ecf
From f3c8fcccc1c90b6741a15963f3c6429a906bc97c Mon Sep 17 00:00:00 2001
From: Craig Andrews
Date: Tue, 22 Sep 2009 11:12:55 -0400
Subject: Link hrefs are the short url, and title is the long url
---
lib/util.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'lib')
diff --git a/lib/util.php b/lib/util.php
index 018b7cad5..bd15a5622 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -536,7 +536,7 @@ function common_linkify($url) {
throw new ServerException("Can't linkify url '$url'");
}
- $attrs = array('href' => $longurl, 'rel' => 'external');
+ $attrs = array('href' => $canon, 'title' => $longurl, 'rel' => 'external');
$is_attachment = false;
$attachment_id = null;
--
cgit v1.2.3-54-g00ecf
From 2cabfba767ba0d92d34a6ea4e4cf91c7325f3e95 Mon Sep 17 00:00:00 2001
From: Craig Andrews
Date: Tue, 22 Sep 2009 19:34:10 -0400
Subject: Allow some punctuation instead of just spaces before @user, !group,
and #tag
---
lib/util.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
(limited to 'lib')
diff --git a/lib/util.php b/lib/util.php
index bd15a5622..441dcf68e 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -391,10 +391,10 @@ function common_render_content($text, $notice)
{
$r = common_render_text($text);
$id = $notice->profile_id;
- $r = preg_replace('/(^|\s+)@([A-Za-z0-9]{1,64})/e', "'\\1@'.common_at_link($id, '\\2')", $r);
+ $r = preg_replace('/(^|[\s\.\,\:\;]+)@([A-Za-z0-9]{1,64})/e', "'\\1@'.common_at_link($id, '\\2')", $r);
$r = preg_replace('/^T ([A-Z0-9]{1,64}) /e', "'T '.common_at_link($id, '\\1').' '", $r);
- $r = preg_replace('/(^|\s+)@#([A-Za-z0-9]{1,64})/e', "'\\1@#'.common_at_hash_link($id, '\\2')", $r);
- $r = preg_replace('/(^|\s)!([A-Za-z0-9]{1,64})/e', "'\\1!'.common_group_link($id, '\\2')", $r);
+ $r = preg_replace('/(^|[\s\.\,\:\;]+)@#([A-Za-z0-9]{1,64})/e', "'\\1@#'.common_at_hash_link($id, '\\2')", $r);
+ $r = preg_replace('/(^|[\s\.\,\:\;]+)!([A-Za-z0-9]{1,64})/e', "'\\1!'.common_group_link($id, '\\2')", $r);
return $r;
}
--
cgit v1.2.3-54-g00ecf
From 4f833531dd5aa05e56ab00dd95eda4ce8419564d Mon Sep 17 00:00:00 2001
From: Evan Prodromou
Date: Mon, 20 Jul 2009 19:04:48 -0400
Subject: start a module for schema management
---
lib/schema.php | 124 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 124 insertions(+)
create mode 100644 lib/schema.php
(limited to 'lib')
diff --git a/lib/schema.php b/lib/schema.php
new file mode 100644
index 000000000..db2f49a78
--- /dev/null
+++ b/lib/schema.php
@@ -0,0 +1,124 @@
+.
+ *
+ * @category Database
+ * @package Laconica
+ * @author Evan Prodromou
+ * @copyright 2009 Control Yourself, Inc.
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://laconi.ca/
+ */
+
+if (!defined('LACONICA')) {
+ exit(1);
+}
+
+/**
+ * Class representing the database schema
+ *
+ * A class representing the database schema. Can be used to
+ * manipulate the schema -- especially for plugins and upgrade
+ * utilities.
+ *
+ * @category Database
+ * @package Laconica
+ * @author Evan Prodromou
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://laconi.ca/
+ */
+
+class Schema
+{
+ protected $db = null;
+
+ static function get()
+ {
+
+ }
+
+ public function getTableDef($name)
+ {
+ }
+
+ public function getColumnDef($table, $column)
+ {
+ }
+
+ public function getIndexDef($table, $index)
+ {
+ }
+
+ public function createTable($name, $columns, $indices=null)
+ {
+ }
+
+ public function dropTable($name)
+ {
+ }
+
+ public function createIndex($name, $table, $columns)
+ {
+ }
+
+ public function dropIndex($name, $table)
+ {
+ }
+
+ public function addColumn($table, $columndef)
+ {
+ }
+
+ public function modifyColumn($table, $column, $columndef)
+ {
+ }
+
+ public function dropColumn($table, $column)
+ {
+ }
+
+ public function ensureTable($name, $columns, $indices)
+ {
+ $def = $this->tableDef($name);
+ if (empty($def)) {
+ return $this->createTable($name, $columns, $indices);
+ }
+ }
+}
+
+class TableDef
+{
+ public $name;
+ public $columns;
+}
+
+class ColumnDef
+{
+ public $name;
+ public $type;
+ public $size;
+}
+
+class IndexDef
+{
+ public $name;
+ public $table;
+ public $columns;
+}
--
cgit v1.2.3-54-g00ecf
From f31653ca5bc06db4d1a2a2dc8a1943f2d99f735a Mon Sep 17 00:00:00 2001
From: Evan Prodromou
Date: Mon, 24 Aug 2009 11:22:40 -0400
Subject: make table def method of schema code work
---
lib/schema.php | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 56 insertions(+), 2 deletions(-)
(limited to 'lib')
diff --git a/lib/schema.php b/lib/schema.php
index db2f49a78..624765eb2 100644
--- a/lib/schema.php
+++ b/lib/schema.php
@@ -47,15 +47,65 @@ if (!defined('LACONICA')) {
class Schema
{
- protected $db = null;
+ static $_single = null;
+ protected $conn = null;
- static function get()
+ protected function __construct()
{
+ // XXX: there should be an easier way to do this.
+ $user = new User();
+ $this->conn = $user->getDatabaseConnection();
+ $user->free();
+ unset($user);
+ }
+ static function get()
+ {
+ if (empty(self::$_single)) {
+ self::$_single = new Schema();
+ }
+ return self::$_single;
}
public function getTableDef($name)
{
+ $res =& $this->conn->query('DESCRIBE ' . $name);
+
+ if (PEAR::isError($res)) {
+ throw new Exception($res->getMessage());
+ }
+
+ $td = new TableDef();
+
+ $td->name = $name;
+ $td->columns = array();
+
+ $row = array();
+
+ while ($res->fetchInto($row, DB_FETCHMODE_ASSOC)) {
+
+ $cd = new ColumnDef();
+
+ $cd->name = $row['Field'];
+
+ $packed = $row['Type'];
+
+ if (preg_match('/^(\w+)\((\d+)\)$/', $packed, $match)) {
+ $cd->type = $match[1];
+ $cd->size = $match[2];
+ } else {
+ $cd->type = $packed;
+ }
+
+ $cd->nullable = ($row['Null'] == 'YES') ? true : false;
+ $cd->key = $row['Key'];
+ $cd->default = $row['Default'];
+ $cd->extra = $row['Extra'];
+
+ $td->columns[] = $cd;
+ }
+
+ return $td;
}
public function getColumnDef($table, $column)
@@ -114,6 +164,10 @@ class ColumnDef
public $name;
public $type;
public $size;
+ public $nullable;
+ public $key;
+ public $default;
+ public $extra;
}
class IndexDef
--
cgit v1.2.3-54-g00ecf
From e206324f245145a0e8c9ec0535cba1d62344ebf7 Mon Sep 17 00:00:00 2001
From: Evan Prodromou
Date: Wed, 23 Sep 2009 09:20:04 -0400
Subject: statusize schema-related modules
---
lib/schema.php | 18 +++++++++---------
scripts/showtable.php | 4 ++--
2 files changed, 11 insertions(+), 11 deletions(-)
(limited to 'lib')
diff --git a/lib/schema.php b/lib/schema.php
index 624765eb2..d3b30aeeb 100644
--- a/lib/schema.php
+++ b/lib/schema.php
@@ -1,6 +1,6 @@
.
*
* @category Database
- * @package Laconica
- * @author Evan Prodromou
- * @copyright 2009 Control Yourself, Inc.
+ * @package StatusNet
+ * @author Evan Prodromou
+ * @copyright 2009 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://laconi.ca/
+ * @link http://status.net/
*/
-if (!defined('LACONICA')) {
+if (!defined('STATUSNET')) {
exit(1);
}
@@ -39,10 +39,10 @@ if (!defined('LACONICA')) {
* utilities.
*
* @category Database
- * @package Laconica
- * @author Evan Prodromou
+ * @package StatusNet
+ * @author Evan Prodromou
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://laconi.ca/
+ * @link http://status.net/
*/
class Schema
diff --git a/scripts/showtable.php b/scripts/showtable.php
index 30f0bb5a9..eb18a98e2 100644
--- a/scripts/showtable.php
+++ b/scripts/showtable.php
@@ -1,8 +1,8 @@
#!/usr/bin/env php
Date: Wed, 23 Sep 2009 09:33:40 -0400
Subject: revert output buffering (costly) for ETags (low priority)
---
index.php | 2 +-
lib/action.php | 41 +++++------------------------------------
2 files changed, 6 insertions(+), 37 deletions(-)
(limited to 'lib')
diff --git a/index.php b/index.php
index fa94f0c75..362ab3cd3 100644
--- a/index.php
+++ b/index.php
@@ -233,7 +233,7 @@ function main()
try {
if ($action_obj->prepare($args)) {
- $action_obj->handleWrapper($args);
+ $action_obj->handle($args);
}
} catch (ClientException $cex) {
$cac = new ClientErrorAction($cex->getMessage(), $cex->getCode());
diff --git a/lib/action.php b/lib/action.php
index ebef4f9e4..670eb498c 100644
--- a/lib/action.php
+++ b/lib/action.php
@@ -873,29 +873,28 @@ class Action extends HTMLOutputter // lawsuit
}
/**
- * Wrapper for the handle method that handles etags, last-modified, and other conditional headers
+ * Handler method
*
* @param array $argarray is ignored since it's now passed in in prepare()
*
* @return boolean is read only action?
*/
- function handleWrapper($argarray=null)
+ function handle($argarray=null)
{
- header('Vary: Accept-Encoding,Cookie,Accept-Language,Authorization');
- header("Cache-Control: must-revalidate");
+ header('Vary: Accept-Encoding,Cookie');
$lm = $this->lastModified();
$etag = $this->etag();
if ($etag) {
header('ETag: ' . $etag);
}
- $if_none_match = (array_key_exists('HTTP_IF_NONE_MATCH', $_SERVER)) ?
- $_SERVER['HTTP_IF_NONE_MATCH'] : null;
if ($lm) {
header('Last-Modified: ' . date(DATE_RFC1123, $lm));
if (array_key_exists('HTTP_IF_MODIFIED_SINCE', $_SERVER)) {
$if_modified_since = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
$ims = strtotime($if_modified_since);
if ($lm <= $ims) {
+ $if_none_match = (array_key_exists('HTTP_IF_NONE_MATCH', $_SERVER)) ?
+ $_SERVER['HTTP_IF_NONE_MATCH'] : null;
if (!$if_none_match ||
!$etag ||
$this->_hasEtag($etag, $if_none_match)) {
@@ -906,36 +905,6 @@ class Action extends HTMLOutputter // lawsuit
}
}
}
- if($etag) {
- $ret = $this->handle($argarray);
- }else{
- ob_start();
- $ret = $this->handle($argarray);
- $output = ob_get_contents();
- ob_end_clean();
- //deep etag
- $etag = md5($output);
- header('ETag: ' . $etag);
- if($if_none_match && $this->_hasEtag($etag, $if_none_match)) {
- header('HTTP/1.1 304 Not Modified');
- // Better way to do this?
- exit(0);
- }
- header('Content-Length: '.strlen($output));
- print $output;
- }
- return $ret;
- }
-
- /**
- * Handler method
- *
- * @param array $argarray is ignored since it's now passed in in prepare()
- *
- * @return boolean is read only action?
- */
- function handle($argarray=null)
- {
}
/**
--
cgit v1.2.3-54-g00ecf
From bef4a8b6ba9e19f2ec629031444279ca76f17bcf Mon Sep 17 00:00:00 2001
From: Evan Prodromou
Date: Wed, 23 Sep 2009 09:34:55 -0400
Subject: Revert "When viewing a page in https, all links to non-actions (links
to CSS, JS, etc) should be https. Fixes the mixed content warnings that
browsers display."
This reverts commit 20997619b353faa94591800fbfc02bc19a4cdce3.
The commit doesn't take into account having different servers (theme
server, avatar server) and being able to set HTTPS for some but not all.
---
lib/util.php | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)
(limited to 'lib')
diff --git a/lib/util.php b/lib/util.php
index 5b57b79b5..b831859e9 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -750,18 +750,8 @@ function common_local_url($action, $args=null, $params=null, $fragment=null)
return $url;
}
-function common_path($relative, $ssl=null)
+function common_path($relative, $ssl=false)
{
- if($ssl==null) {
- //ssl was not specifically requested
- if( $_SERVER['HTTPS'] && $_SERVER['HTTPS']!="off" ) {
- //currently in https, so stay in https
- $ssl=true;
- } else {
- //not in https, so stay not in https
- $ssl=false;
- }
- }
$pathpart = (common_config('site', 'path')) ? common_config('site', 'path')."/" : '';
if (($ssl && (common_config('site', 'ssl') === 'sometimes'))
--
cgit v1.2.3-54-g00ecf
From 49b701f9ec6d7795147f94c43eaf744a96efb199 Mon Sep 17 00:00:00 2001
From: Zach Copley
Date: Wed, 23 Sep 2009 13:45:51 -0700
Subject: Started refactoring API into individual actions
---
actions/apifriendstimeline.php | 161 +++++++++++++++++++++++++++++++++++++++++
lib/router.php | 16 +++-
lib/twitterapi.php | 127 ++++++++++++++++++++++++++++++--
3 files changed, 297 insertions(+), 7 deletions(-)
create mode 100644 actions/apifriendstimeline.php
(limited to 'lib')
diff --git a/actions/apifriendstimeline.php b/actions/apifriendstimeline.php
new file mode 100644
index 000000000..ea38ec022
--- /dev/null
+++ b/actions/apifriendstimeline.php
@@ -0,0 +1,161 @@
+.
+ *
+ * @category Personal
+ * @package StatusNet
+ * @author Zach Copley
+ * @copyright 2009 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/
+ */
+
+if (!defined('STATUSNET')) {
+ exit(1);
+}
+
+require_once INSTALLDIR.'/lib/twitterapi.php';
+
+class ApifriendstimelineAction extends TwitterapiAction
+{
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+ return true;
+
+ }
+
+ function handle($args) {
+
+ parent::handle($args);
+ common_debug(var_export($args, true));
+
+ if ($this->requiresAuth()) {
+ if ($this->showBasicAuthHeader()) {
+ $this->showTimeline();
+ }
+ } else {
+ $this->showTimeline();
+ }
+ }
+
+ function showTimeline()
+ {
+ common_debug('Auth user = ' . var_export($this->auth_user, true));
+
+ $user = $this->getTargetUser($this->arg('id'));
+
+ if (empty($user)) {
+ $this->clientError(_('No such user!'), 404, $this->arg('format'));
+ return;
+ }
+
+ $profile = $user->getProfile();
+ $sitename = common_config('site', 'name');
+ $title = sprintf(_("%s and friends"), $user->nickname);
+ $taguribase = common_config('integration', 'taguri');
+ $id = "tag:$taguribase:FriendsTimeline:" . $user->id;
+ $link = common_local_url('all',
+ array('nickname' => $user->nickname));
+ $subtitle = sprintf(_('Updates from %1$s and friends on %2$s!'),
+ $user->nickname, $sitename);
+
+ $page = (int)$this->arg('page', 1);
+ $count = (int)$this->arg('count', 20);
+ $max_id = (int)$this->arg('max_id', 0);
+ $since_id = (int)$this->arg('since_id', 0);
+ $since = $this->arg('since');
+
+ if (!empty($this->auth_user) && $this->auth_user->id == $user->id) {
+ $notice = $user->noticeInbox(($page-1)*$count,
+ $count, $since_id, $max_id, $since);
+ } else {
+ $notice = $user->noticesWithFriends(($page-1)*$count,
+ $count, $since_id, $max_id, $since);
+ }
+
+ switch($this->arg('format')) {
+ case 'xml':
+ $this->show_xml_timeline($notice);
+ break;
+ case 'rss':
+ $this->show_rss_timeline($notice, $title, $link, $subtitle);
+ break;
+ case 'atom':
+
+ $target_id = $this->arg('id');
+
+ if (isset($target_id)) {
+ $selfuri = common_root_url() .
+ 'api/statuses/friends_timeline/' .
+ $target_id . '.atom';
+ } else {
+ $selfuri = common_root_url() .
+ 'api/statuses/friends_timeline.atom';
+ }
+ $this->show_atom_timeline($notice, $title, $id, $link,
+ $subtitle, null, $selfuri);
+ break;
+ case 'json':
+ $this->show_json_timeline($notice);
+ break;
+ default:
+ $this->clientError(_('API method not found!'), $code = 404);
+ }
+
+ }
+
+ function requiresAuth()
+ {
+ return true;
+ }
+
+ /**
+ * Is this page read-only?
+ *
+ * @return boolean true
+ */
+
+ function isReadOnly($args)
+ {
+ return true;
+ }
+
+ /**
+ * When was this page last modified?
+ *
+ */
+
+ function lastModified()
+ {
+
+ }
+
+}
\ No newline at end of file
diff --git a/lib/router.php b/lib/router.php
index 2c4d63b0d..0e5fe3a54 100644
--- a/lib/router.php
+++ b/lib/router.php
@@ -262,15 +262,27 @@ class Router
// statuses API
+ $m->connect('api/statuses/friends_timeline.:format',
+ array('action' => 'apifriendstimeline',
+ 'format' => '(xml|json|rss|atom)'));
+
+ $m->connect('api/statuses/friends_timeline/:id.:format',
+ array('action' => 'apifriendstimeline',
+ 'id' => '[a-zA-Z0-9]+',
+ 'format' => '(xml|json|rss|atom)'));
+
+ $m->connect('api/statuses/home_timeline',
+ array('action' => 'apifriendstimeline'));
+
$m->connect('api/statuses/:method',
array('action' => 'api',
'apiaction' => 'statuses'),
- array('method' => '(public_timeline|home_timeline|friends_timeline|user_timeline|update|replies|mentions|show|friends|followers|featured)(\.(atom|rss|xml|json))?'));
+ array('method' => '(public_timeline|user_timeline|update|replies|mentions|show|friends|followers|featured)(\.(atom|rss|xml|json))?'));
$m->connect('api/statuses/:method/:argument',
array('action' => 'api',
'apiaction' => 'statuses'),
- array('method' => '(user_timeline|home_timeline|friends_timeline|replies|mentions|show|destroy|friends|followers)'));
+ array('method' => '(user_timeline|replies|mentions|show|destroy|friends|followers)'));
// users
diff --git a/lib/twitterapi.php b/lib/twitterapi.php
index d199e4dee..ac5c5b423 100644
--- a/lib/twitterapi.php
+++ b/lib/twitterapi.php
@@ -502,7 +502,7 @@ class TwitterapiAction extends Action
$enclosure = $entry['enclosures'][0];
$this->element('enclosure', array('url'=>$enclosure['url'],'type'=>$enclosure['mimetype'],'length'=>$enclosure['size']), null);
}
-
+
if(array_key_exists('tags', $entry)){
foreach($entry['tags'] as $tag){
$this->element('category', null,$tag);
@@ -934,7 +934,7 @@ class TwitterapiAction extends Action
return;
}
- function clientError($msg, $code = 400, $content_type = 'json')
+ function clientError($msg, $code = 400, $format = 'xml')
{
static $status = array(400 => 'Bad Request',
@@ -967,20 +967,23 @@ class TwitterapiAction extends Action
$status_string = $status[$code];
header('HTTP/1.1 '.$code.' '.$status_string);
- if ($content_type == 'xml') {
+ if ($format == 'xml') {
$this->init_document('xml');
$this->elementStart('hash');
$this->element('error', null, $msg);
$this->element('request', null, $_SERVER['REQUEST_URI']);
$this->elementEnd('hash');
$this->end_document('xml');
- } else {
+ } elseif ($format == 'json'){
$this->init_document('json');
$error_array = array('error' => $msg, 'request' => $_SERVER['REQUEST_URI']);
print(json_encode($error_array));
$this->end_document('json');
- }
+ } else {
+ // If user didn't request a useful format, throw a regular client error
+ throw new ClientException($msg, $code);
+ }
}
function init_twitter_rss()
@@ -1063,6 +1066,39 @@ class TwitterapiAction extends Action
}
}
+ function getTargetUser($id)
+ {
+ if (empty($id)) {
+
+ // Twitter supports these other ways of passing the user ID
+ if (is_numeric($this->arg('id'))) {
+ return User::staticGet($this->arg('id'));
+ } else if ($this->arg('id')) {
+ $nickname = common_canonical_nickname($this->arg('id'));
+ return User::staticGet('nickname', $nickname);
+ } else if ($this->arg('user_id')) {
+ // This is to ensure that a non-numeric user_id still
+ // overrides screen_name even if it doesn't get used
+ if (is_numeric($this->arg('user_id'))) {
+ return User::staticGet('id', $this->arg('user_id'));
+ }
+ } else if ($this->arg('screen_name')) {
+ $nickname = common_canonical_nickname($this->arg('screen_name'));
+ return User::staticGet('nickname', $nickname);
+ } else {
+ // Fall back to trying the currently authenticated user
+ return $this->auth_user;
+ }
+
+ } else if (is_numeric($id)) {
+ return User::staticGet($id);
+ } else {
+ $nickname = common_canonical_nickname($id);
+ return User::staticGet('nickname', $nickname);
+ }
+ }
+
+
function get_group($id, $apidata=null)
{
if (empty($id)) {
@@ -1170,4 +1206,85 @@ class TwitterapiAction extends Action
}
}
+ function showBasicAuthHeader()
+ {
+ $this->basicAuthProcessHeader();
+
+ if (!isset($this->auth_user)) {
+ header('WWW-Authenticate: Basic realm="StatusNet API"');
+
+ // show error if the user clicks 'cancel'
+
+ $this->showBasicAuthError();
+ return false;
+
+ } else {
+ $nickname = $this->auth_user;
+ $password = $this->auth_pw;
+ $this->auth_user = common_check_user($nickname, $password);
+
+ if (empty($this->auth_user)) {
+
+ // basic authentication failed
+
+ list($proxy, $ip) = common_client_ip();
+ common_log(LOG_WARNING,
+ "Failed API auth attempt, nickname = $nickname, proxy = $proxy, ip = $ip.");
+ $this->showBasicAuthError();
+ return false;
+ }
+ }
+ return true;
+ }
+
+ function basicAuthProcessHeader()
+ {
+ if (isset($_SERVER['AUTHORIZATION']) || isset($_SERVER['HTTP_AUTHORIZATION'])) {
+ $authorization_header = isset($_SERVER['HTTP_AUTHORIZATION'])? $_SERVER['HTTP_AUTHORIZATION'] : $_SERVER['AUTHORIZATION'];
+ }
+
+ if (isset($_SERVER['PHP_AUTH_USER'])) {
+ $this->auth_user = $_SERVER['PHP_AUTH_USER'];
+ $this->auth_pw = $_SERVER['PHP_AUTH_PW'];
+ } elseif (isset($authorization_header) && strstr(substr($authorization_header, 0, 5), 'Basic')) {
+ // decode the HTTP_AUTHORIZATION header on php-cgi server self
+ // on fcgid server the header name is AUTHORIZATION
+
+ $auth_hash = base64_decode(substr($authorization_header, 6));
+ list($this->auth_user, $this->auth_pw) = explode(':', $auth_hash);
+
+ // set all to null on a empty basic auth request
+ if ($this->auth_user == "") {
+ $this->auth_user = null;
+ $this->auth_pw = null;
+ }
+ } else {
+ $this->auth_user = null;
+ $this->auth_pw = null;
+ }
+ }
+
+ function showBasicAuthError()
+ {
+ header('HTTP/1.1 401 Unauthorized');
+ $msg = 'Could not authenticate you.';
+
+ if ($this->arg('format') == 'xml') {
+ header('Content-Type: application/xml; charset=utf-8');
+ $this->startXML();
+ $this->elementStart('hash');
+ $this->element('error', null, $msg);
+ $this->element('request', null, $_SERVER['REQUEST_URI']);
+ $this->elementEnd('hash');
+ $this->endXML();
+ } elseif ($this->arg('format') == 'json') {
+ header('Content-Type: application/json; charset=utf-8');
+ $error_array = array('error' => $msg, 'request' => $_SERVER['REQUEST_URI']);
+ print(json_encode($error_array));
+ } else {
+ header('Content-type: text/plain');
+ print "$msg\n";
+ }
+ }
+
}
--
cgit v1.2.3-54-g00ecf
From 3449843f839b6c17618b27b031c608860761cd32 Mon Sep 17 00:00:00 2001
From: Evan Prodromou
Date: Wed, 23 Sep 2009 22:24:35 -0400
Subject: use schema tool to create a table
---
lib/schema.php | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 99 insertions(+)
(limited to 'lib')
diff --git a/lib/schema.php b/lib/schema.php
index d3b30aeeb..f49075690 100644
--- a/lib/schema.php
+++ b/lib/schema.php
@@ -110,18 +110,87 @@ class Schema
public function getColumnDef($table, $column)
{
+ $td = $this->getTableDef($table);
+
+ foreach ($td->columns as $cd) {
+ if ($cd->name == $column) {
+ return $cd;
+ }
+ }
+
+ return null;
}
public function getIndexDef($table, $index)
{
+ return null;
}
public function createTable($name, $columns, $indices=null)
{
+ $uniques = array();
+ $primary = array();
+ $indices = array();
+
+ $sql = "CREATE TABLE $name (\n";
+
+ for ($i = 0; $i < count($columns); $i++) {
+
+ $cd =& $columns[$i];
+
+ if ($i > 0) {
+ $sql .= ",\n";
+ }
+
+ $sql .= $this->_columnSql($cd);
+
+ switch ($cd->key) {
+ case 'UNI':
+ $uniques[] = $cd->name;
+ break;
+ case 'PRI':
+ $primary[] = $cd->name;
+ break;
+ case 'MUL':
+ $indices[] = $cd->name;
+ break;
+ }
+ }
+
+ if (count($primary) > 0) { // it really should be...
+ $sql .= ",\nconstraint primary key (" . implode(',', $primary) . ")";
+ }
+
+ foreach ($uniques as $u) {
+ $sql .= ",\nunique index {$name}_{$u}_idx ($u)";
+ }
+
+ foreach ($indices as $i) {
+ $sql .= ",\nindex {$name}_{$i}_idx ($i)";
+ }
+
+ $sql .= "); ";
+
+ common_debug($sql);
+
+ $res =& $this->conn->query($sql);
+
+ if (PEAR::isError($res)) {
+ throw new Exception($res->getMessage());
+ }
+
+ return true;
}
public function dropTable($name)
{
+ $res =& $this->conn->query("DROP TABLE $name");
+
+ if (PEAR::isError($res)) {
+ throw new Exception($res->getMessage());
+ }
+
+ return true;
}
public function createIndex($name, $table, $columns)
@@ -151,6 +220,25 @@ class Schema
return $this->createTable($name, $columns, $indices);
}
}
+
+ function _columnSql($cd)
+ {
+ $sql = "{$cd->name} ";
+
+ if (!empty($cd->size)) {
+ $sql .= "{$cd->type}({$cd->size}) ";
+ } else {
+ $sql .= "{$cd->type} ";
+ }
+
+ if (!empty($cd->default)) {
+ $sql .= "default {$cd->default} ";
+ } else {
+ $sql .= ($cd->nullable) ? "null " : "not null ";
+ }
+
+ return $sql;
+ }
}
class TableDef
@@ -168,6 +256,17 @@ class ColumnDef
public $key;
public $default;
public $extra;
+
+ function __construct($name, $type, $size=null, $nullable=null,
+ $key=null, $default=null, $extra=null) {
+ $this->name = $name;
+ $this->type = $type;
+ $this->size = $size;
+ $this->nullable = $nullable;
+ $this->key = $key;
+ $this->default = $default;
+ $this->extra = $extra;
+ }
}
class IndexDef
--
cgit v1.2.3-54-g00ecf
From a5ed805aeabab3930d066b2777dbab9663bc487f Mon Sep 17 00:00:00 2001
From: Evan Prodromou
Date: Wed, 23 Sep 2009 23:23:13 -0400
Subject: move scripts to just before
---
EVENTS.txt | 6 ++++++
lib/action.php | 19 +++++++++++--------
2 files changed, 17 insertions(+), 8 deletions(-)
(limited to 'lib')
diff --git a/EVENTS.txt b/EVENTS.txt
index 68cb28603..dfaf34a66 100644
--- a/EVENTS.txt
+++ b/EVENTS.txt
@@ -134,3 +134,9 @@ StartAddressData: Allows the site owner to provide additional information about
EndAddressData: At the end of