Merge branch '1.0.x' of git://gitorious.org/statusnet/mainline

This commit is contained in:
Ian Denhardt 2010-08-13 18:01:33 -04:00
commit 70c3532996
14 changed files with 233 additions and 47 deletions

4
README
View File

@ -43,6 +43,10 @@ on status.net is identical to the software available for download, so
you can move back and forth between a hosted version or a version you can move back and forth between a hosted version or a version
installed on your own servers. installed on your own servers.
A commercial software subscription is available from StatusNet Inc. It
includes 24-hour technical support and developer support. More
information at http://status.net/contact or email sales@status.net.
License License
======= =======

View File

@ -161,7 +161,7 @@ class NewnoticeAction extends Action
$replyto = intval($this->trimmed('inreplyto')); $replyto = intval($this->trimmed('inreplyto'));
if ($replyto) { if ($replyto) {
$options['replyto'] = $replyto; $options['reply_to'] = $replyto;
} }
$upload = null; $upload = null;

View File

@ -240,6 +240,14 @@ class File_redirection extends Memcached_DataObject
} else if (is_string($redir_data)) { } else if (is_string($redir_data)) {
// The file is a known redirect target. // The file is a known redirect target.
$file = File::staticGet('url', $redir_data); $file = File::staticGet('url', $redir_data);
if (empty($file)) {
// @fixme should we save a new one?
// this case was triggering sometimes for redirects
// with unresolvable targets; found while fixing
// "can't linkify" bugs with shortened links to
// SSL sites with cert issues.
return null;
}
$file_id = $file->id; $file_id = $file->id;
} }
} else { } else {

View File

@ -245,6 +245,8 @@ class Notice extends Memcached_DataObject
if (!empty($options)) { if (!empty($options)) {
$options = $options + $defaults; $options = $options + $defaults;
extract($options); extract($options);
} else {
extract($defaults);
} }
if (!isset($is_local)) { if (!isset($is_local)) {

View File

@ -845,7 +845,10 @@ function common_linkify($url) {
} elseif (is_string($longurl_data)) { } elseif (is_string($longurl_data)) {
$longurl = $longurl_data; $longurl = $longurl_data;
} else { } else {
throw new ServerException("Can't linkify url '$url'"); // Unable to reach the server to verify contents, etc
// Just pass the link on through for now.
common_log(LOG_ERR, "Can't linkify url '$url'");
$longurl = $url;
} }
} }
$attrs = array('href' => $canon, 'title' => $longurl, 'rel' => 'external'); $attrs = array('href' => $canon, 'title' => $longurl, 'rel' => 'external');

154
plugins/EchoPlugin.php Normal file
View File

@ -0,0 +1,154 @@
<?php
/**
* StatusNet, the distributed open-source microblogging tool
*
* Plugin to add Echo/JS-Kit commenting to notice pages
*
* PHP version 5
*
* LICENCE: This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @category Plugin
* @package StatusNet
* @author Zach Copley <zach@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/
*/
if (!defined('STATUSNET')) {
exit(1);
}
/**
* Plugin to use Echo (formerly JS-Kit)
*
* This plugin adds an Echo commenting widget to each notice page on
* your site. To get it to work, first you'll have to sign up for Echo
* (a commercial service) and register your site's URL.
*
* http://aboutecho.com/
*
* Once you've done that it's pretty straight forward to turn the
* plugin on, just add:
*
* addPlugin('Echo');
*
* to your config.php. The defaults should work OK with the default
* theme, but there are a lot of options to customize the look and
* feel of the comment widget. You can control both the CSS for the
* div that contains the widget, as well as the CSS for the widget
* itself via config parameters that can be passed into the plugin.
* See below for a more complex example:
*
* // Custom stylesheet for Echo commenting widget
* // See: http://wiki.js-kit.com/Skinning-Guide#UsingCSSnbsptocustomizefontsandcolors
* $stylesheet = <<<ENDOFCSS
* .js-CommentsArea { width: 400px; }
* .jsk-HeaderWrapper { display: none; }
* .jsk-ItemUserAvatar { display: none; }
* .jsk-ItemBody { margin-left: -48px; }
* .js-kit-avatars-wrapper { display: none; }
* .js-kit-nonLoggedUserInfo { margin-left: -75px; }
* .js-singleViaLinkWrapper { display: none; }
* .js-CommentsSkin-echo div.jsk-ThreadWrapper { padding: 0px; }
* .js-singleCommentAdminStar { display: none !important; }
* .js-singleCommentName { margin-right: 1em; }
* .js-kit-miniProfile { background-color:#FFFFFF; }
* .jskit-MenuContainer { background-color:#FFFFFF; }
* .jskit-MenuItemMO { background-color: #EDEDED; }
* .jsk-CommentFormButton { display: none; }
* .js-singleCommentReplyable { display: none; }
* .jsk-CommentFormSurface { display: none; }
* .js-kit-tab-follow { display: none; }
* ENDOFCSS;
*
* addPlugin(
* 'Echo',
* array
* (
* // div_css is the css for the div containing the comment widget
* 'div_css' => 'width:675px; padding-top:10px; position:relative; float:left;',
* // stylesheet is the CSS for the comment widget itself
* 'stylesheet' => $stylesheet
* )
* );
*
* @category Plugin
* @package StatusNet
* @author Zach Copley <zach@status.net>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*
* @see Event
*/
class EchoPlugin extends Plugin
{
// NOTE: The Echo documentation says that this script will change on
// a per site basis, but I think that's incorrect. It always seems to
// be the same.
public $script = 'http://cdn.js-kit.com/scripts/comments.js';
function onEndShowScripts($action)
{
if (get_class($action) == 'ShownoticeAction') {
$action->script($this->script);
}
return true;
}
function onEndShowContentBlock($action)
{
if (get_class($action) == 'ShownoticeAction') {
$attrs = array();
$attrs['class'] = 'js-kit-comments';
$attrs['permalink'] = $action->notice->uri;
$attrs['uniq'] = $action->notice->id;
// NOTE: there are some other attributes that could be useful
// http://wiki.js-kit.com/Echo-Behavior
if (empty($this->div_css)) {
// This CSS seems to work OK with the default theme
$attrs['style'] = 'width:675px; padding-top:10px; position:relative; float:left;';
} else {
$attrs['style'] = $this->css;
}
$action->element('div', $attrs, null);
}
}
function onEndShowStyles($action)
{
if (get_class($action) == 'ShownoticeAction' && !empty($this->stylesheet)) {
$action->style($this->stylesheet);
}
}
function onPluginVersion(&$versions)
{
$versions[] = array('name' => 'Echo',
'version' => STATUSNET_VERSION,
'author' => 'Zach Copley',
'homepage' => 'http://status.net/wiki/Plugin:Echo',
'rawdescription' =>
_m('Use <a href="http://aboutecho.com/">Echo</a>'.
' to add commenting to notice pages.'));
return true;
}
}

View File

@ -61,7 +61,7 @@ class GroupsalmonAction extends SalmonAction
function handlePost() function handlePost()
{ {
// @fixme process all objects? // @fixme process all objects?
switch ($this->act->objects[0]->type) { switch ($this->activity->objects[0]->type) {
case ActivityObject::ARTICLE: case ActivityObject::ARTICLE:
case ActivityObject::BLOGENTRY: case ActivityObject::BLOGENTRY:
case ActivityObject::NOTE: case ActivityObject::NOTE:
@ -74,7 +74,7 @@ class GroupsalmonAction extends SalmonAction
// Notice must be to the attention of this group // Notice must be to the attention of this group
$context = $this->act->context; $context = $this->activity->context;
if (empty($context->attention)) { if (empty($context->attention)) {
throw new ClientException("Not to the attention of anyone."); throw new ClientException("Not to the attention of anyone.");

View File

@ -55,10 +55,10 @@ class UsersalmonAction extends SalmonAction
*/ */
function handlePost() function handlePost()
{ {
common_log(LOG_INFO, "Received post of '{$this->act->objects[0]->id}' from '{$this->act->actor->id}'"); common_log(LOG_INFO, "Received post of '{$this->activity->objects[0]->id}' from '{$this->activity->actor->id}'");
// @fixme: process all activity objects? // @fixme: process all activity objects?
switch ($this->act->objects[0]->type) { switch ($this->activity->objects[0]->type) {
case ActivityObject::ARTICLE: case ActivityObject::ARTICLE:
case ActivityObject::BLOGENTRY: case ActivityObject::BLOGENTRY:
case ActivityObject::NOTE: case ActivityObject::NOTE:
@ -72,7 +72,7 @@ class UsersalmonAction extends SalmonAction
// Notice must either be a) in reply to a notice by this user // Notice must either be a) in reply to a notice by this user
// or b) to the attention of this user // or b) to the attention of this user
$context = $this->act->context; $context = $this->activity->context;
if (!empty($context->replyToID)) { if (!empty($context->replyToID)) {
$notice = Notice::staticGet('uri', $context->replyToID); $notice = Notice::staticGet('uri', $context->replyToID);
@ -92,7 +92,7 @@ class UsersalmonAction extends SalmonAction
throw new ClientException("Not to anyone in reply to anything!"); throw new ClientException("Not to anyone in reply to anything!");
} }
$existing = Notice::staticGet('uri', $this->act->objects[0]->id); $existing = Notice::staticGet('uri', $this->activity->objects[0]->id);
if (!empty($existing)) { if (!empty($existing)) {
common_log(LOG_ERR, "Not saving notice '{$existing->uri}'; already exists."); common_log(LOG_ERR, "Not saving notice '{$existing->uri}'; already exists.");
@ -143,7 +143,7 @@ class UsersalmonAction extends SalmonAction
function handleFavorite() function handleFavorite()
{ {
$notice = $this->getNotice($this->act->objects[0]); $notice = $this->getNotice($this->activity->objects[0]);
$profile = $this->ensureProfile()->localProfile(); $profile = $this->ensureProfile()->localProfile();
$old = Fave::pkeyGet(array('user_id' => $profile->id, $old = Fave::pkeyGet(array('user_id' => $profile->id,
@ -164,7 +164,7 @@ class UsersalmonAction extends SalmonAction
*/ */
function handleUnfavorite() function handleUnfavorite()
{ {
$notice = $this->getNotice($this->act->objects[0]); $notice = $this->getNotice($this->activity->objects[0]);
$profile = $this->ensureProfile()->localProfile(); $profile = $this->ensureProfile()->localProfile();
$fave = Fave::pkeyGet(array('user_id' => $profile->id, $fave = Fave::pkeyGet(array('user_id' => $profile->id,

View File

@ -445,10 +445,13 @@ class Ostatus_profile extends Memcached_DataObject
* @param DOMElement $feed for context * @param DOMElement $feed for context
* @param string $source identifier ("push" or "salmon") * @param string $source identifier ("push" or "salmon")
*/ */
public function processEntry($entry, $feed, $source) public function processEntry($entry, $feed, $source)
{ {
$activity = new Activity($entry, $feed); $activity = new Activity($entry, $feed);
if (Event::handle('StartHandleFeedEntry', array($activity))) {
// @todo process all activity objects // @todo process all activity objects
switch ($activity->objects[0]->type) { switch ($activity->objects[0]->type) {
case ActivityObject::ARTICLE: case ActivityObject::ARTICLE:
@ -456,15 +459,18 @@ class Ostatus_profile extends Memcached_DataObject
case ActivityObject::NOTE: case ActivityObject::NOTE:
case ActivityObject::STATUS: case ActivityObject::STATUS:
case ActivityObject::COMMENT: case ActivityObject::COMMENT:
case null:
if ($activity->verb == ActivityVerb::POST) {
$this->processPost($activity, $source);
} else {
common_log(LOG_INFO, "Ignoring activity with unrecognized verb $activity->verb");
}
break; break;
default: default:
throw new ClientException("Can't handle that kind of post."); throw new ClientException("Can't handle that kind of post.");
} }
if ($activity->verb == ActivityVerb::POST) { Event::handle('EndHandleFeedEntry', array($activity));
$this->processPost($activity, $source);
} else {
common_log(LOG_INFO, "Ignoring activity with unrecognized verb $activity->verb");
} }
} }
@ -496,8 +502,11 @@ class Ostatus_profile extends Memcached_DataObject
} else if ($actor->id) { } else if ($actor->id) {
// We have an ActivityStreams actor with an explicit ID that doesn't match the feed owner. // We have an ActivityStreams actor with an explicit ID that doesn't match the feed owner.
// This isn't what we expect from mainline OStatus person feeds! // This isn't what we expect from mainline OStatus person feeds!
// Group feeds go down another path, with different validation. // Group feeds go down another path, with different validation...
throw new Exception("Got an actor '{$actor->title}' ({$actor->id}) on single-user feed for {$this->uri}"); // Most likely this is a plain ol' blog feed of some kind which
// doesn't match our expectations. We'll take the entry, but ignore
// the <author> info.
common_log(LOG_WARNING, "Got an actor '{$actor->title}' ({$actor->id}) on single-user feed for {$this->uri}");
} else { } else {
// Plain <author> without ActivityStreams actor info. // Plain <author> without ActivityStreams actor info.
// We'll just ignore this info for now and save the update under the feed's identity. // We'll just ignore this info for now and save the update under the feed's identity.

View File

@ -114,9 +114,10 @@ class DiscoveryHints {
static function _hcard($body, $url) static function _hcard($body, $url)
{ {
// DOMDocument::loadHTML may throw warnings on unrecognized elements. // DOMDocument::loadHTML may throw warnings on unrecognized elements,
// and notices on unrecognized namespaces.
$old = error_reporting(error_reporting() & ~E_WARNING); $old = error_reporting(error_reporting() & ~(E_WARNING | E_NOTICE));
$doc = new DOMDocument(); $doc = new DOMDocument();
$doc->loadHTML($body); $doc->loadHTML($body);

View File

@ -196,8 +196,9 @@ class FeedDiscovery
*/ */
function discoverFromHTML($url, $body) function discoverFromHTML($url, $body)
{ {
// DOMDocument::loadHTML may throw warnings on unrecognized elements. // DOMDocument::loadHTML may throw warnings on unrecognized elements,
$old = error_reporting(error_reporting() & ~E_WARNING); // and notices on unrecognized namespaces.
$old = error_reporting(error_reporting() & ~(E_WARNING | E_NOTICE));
$dom = new DOMDocument(); $dom = new DOMDocument();
$ok = $dom->loadHTML($body); $ok = $dom->loadHTML($body);
error_reporting($old); error_reporting($old);

View File

@ -47,7 +47,6 @@ class SalmonAction extends Action
$xml = file_get_contents('php://input'); $xml = file_get_contents('php://input');
// Check the signature // Check the signature
$salmon = new Salmon; $salmon = new Salmon;
if (!$salmon->verifyMagicEnv($xml)) { if (!$salmon->verifyMagicEnv($xml)) {
@ -59,7 +58,6 @@ class SalmonAction extends Action
$xml = $magic_env->unfold($env); $xml = $magic_env->unfold($env);
} }
$dom = DOMDocument::loadXML($xml); $dom = DOMDocument::loadXML($xml);
if ($dom->documentElement->namespaceURI != Activity::ATOM || if ($dom->documentElement->namespaceURI != Activity::ATOM ||
$dom->documentElement->localName != 'entry') { $dom->documentElement->localName != 'entry') {
@ -67,7 +65,7 @@ class SalmonAction extends Action
$this->clientError(_m('Salmon post must be an Atom entry.')); $this->clientError(_m('Salmon post must be an Atom entry.'));
} }
$this->act = new Activity($dom->documentElement); $this->activity = new Activity($dom->documentElement);
return true; return true;
} }
@ -79,9 +77,9 @@ class SalmonAction extends Action
{ {
StatusNet::setApi(true); // Send smaller error pages StatusNet::setApi(true); // Send smaller error pages
common_log(LOG_DEBUG, "Got a " . $this->act->verb); common_log(LOG_DEBUG, "Got a " . $this->activity->verb);
if (Event::handle('StartHandleSalmon', array($this->activity))) { if (Event::handle('StartHandleSalmon', array($this->activity))) {
switch ($this->act->verb) switch ($this->activity->verb)
{ {
case ActivityVerb::POST: case ActivityVerb::POST:
$this->handlePost(); $this->handlePost();
@ -164,12 +162,12 @@ class SalmonAction extends Action
*/ */
function handleUpdateProfile() function handleUpdateProfile()
{ {
$oprofile = Ostatus_profile::getActorProfile($this->act); $oprofile = Ostatus_profile::getActorProfile($this->activity);
if ($oprofile) { if ($oprofile) {
common_log(LOG_INFO, "Got a profile-update ping from $oprofile->uri"); common_log(LOG_INFO, "Got a profile-update ping from $oprofile->uri");
$oprofile->updateFromActivityObject($this->act->actor); $oprofile->updateFromActivityObject($this->activity->actor);
} else { } else {
common_log(LOG_INFO, "Ignoring profile-update ping from unknown " . $this->act->actor->id); common_log(LOG_INFO, "Ignoring profile-update ping from unknown " . $this->activity->actor->id);
} }
} }
@ -178,10 +176,10 @@ class SalmonAction extends Action
*/ */
function ensureProfile() function ensureProfile()
{ {
$actor = $this->act->actor; $actor = $this->activity->actor;
if (empty($actor->id)) { if (empty($actor->id)) {
common_log(LOG_ERR, "broken actor: " . var_export($actor, true)); common_log(LOG_ERR, "broken actor: " . var_export($actor, true));
common_log(LOG_ERR, "activity with no actor: " . var_export($this->act, true)); common_log(LOG_ERR, "activity with no actor: " . var_export($this->activity, true));
throw new Exception("Received a salmon slap from unidentified actor."); throw new Exception("Received a salmon slap from unidentified actor.");
} }
@ -191,6 +189,6 @@ class SalmonAction extends Action
function saveNotice() function saveNotice()
{ {
$oprofile = $this->ensureProfile(); $oprofile = $this->ensureProfile();
return $oprofile->processPost($this->act, 'salmon'); return $oprofile->processPost($this->activity, 'salmon');
} }
} }

View File

@ -92,7 +92,13 @@ abstract class BaseMirrorAction extends Action
*/ */
protected function profileForFeed($url) protected function profileForFeed($url)
{ {
try {
// Maybe we got a web page?
$oprofile = Ostatus_profile::ensureProfileURL($url); $oprofile = Ostatus_profile::ensureProfileURL($url);
} catch (Exception $e) {
// Direct feed URL?
$oprofile = Ostatus_profile::ensureFeedURL($url);
}
if ($oprofile->isGroup()) { if ($oprofile->isGroup()) {
$this->clientError(_m("Can't mirror a StatusNet group at this time.")); $this->clientError(_m("Can't mirror a StatusNet group at this time."));
} }

View File

@ -94,15 +94,15 @@ function do_translatewiki_plugin($basedir, $plugin)
BASIC: BASIC:
id: out-statusnet-{$pluginlc} id: out-statusnet-{$pluginlc}
label: StatusNet - {$plugin} label: StatusNet - {$plugin}
description: "{{int:bw-desc-statusnet-plugin-{$pluginlc}}}"
namespace: NS_STATUSNET namespace: NS_STATUSNET
description: "{{int:bw-desc-statusnet-plugin}}"
class: FileBasedMessageGroup
display: out/statusnet/{$pluginlc} display: out/statusnet/{$pluginlc}
class: GettextMessageGroup
FILES: FILES:
class: GettextFFS class: GettextFFS
sourcePattern: %GROUPROOT%/plugins/{$plugin}/locale/%CODE%/LC_MESSAGES/{$plugin}.po sourcePattern: %GROUPROOT%/statusnet/plugins/{$plugin}/locale/{$plugin}.pot
targetPattern: plugins/{$plugin}/locale/%CODE%/LC_MESSAGES/{$plugin}.po targetPattern: statusnet/plugins/{$plugin}/locale/%CODE%/LC_MESSAGES/{$plugin}.po
codeMap: codeMap:
en-gb: en_GB en-gb: en_GB
no: nb no: nb