Merge branch 'nightly' of https://git.gnu.io/gnu/gnu-social into nightly

Conflicts:
	lib/util.php
This commit is contained in:
vinzv 2016-09-02 11:32:49 +02:00
commit 845a0f8e2d
37 changed files with 139 additions and 210 deletions

View File

@ -170,12 +170,6 @@ class AllAction extends ShowstreamAction
}
$ibs->show();
}
// XXX: make this a little more convenient
if (!common_config('performance', 'high')) {
$pop = new InboxTagCloudSection($this, $this->target);
$pop->show();
}
}
}

View File

@ -132,9 +132,5 @@ class AttachmentAction extends ManagedAction
function showSections() {
$ns = new AttachmentNoticeSection($this);
$ns->show();
if (!common_config('performance', 'high')) {
$atcs = new AttachmentTagCloudSection($this);
$atcs->show();
}
}
}

View File

@ -42,7 +42,7 @@ if (!defined('GNUSOCIAL')) { exit(1); }
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
class GroupbyidAction extends ManagedAction
class GroupbyidAction extends ShowgroupAction
{
/** group we're viewing. */
protected $group = null;
@ -55,10 +55,10 @@ class GroupbyidAction extends ManagedAction
protected function doPreparation()
{
$this->group = User_group::getByID($this->arg('id'));
}
$this->target = $this->group->getProfile();
public function showPage()
{
common_redirect($this->group->homeUrl(), 303);
if ($this->target->isLocal()) {
common_redirect($this->target->getUrl());
}
}
}

View File

@ -27,12 +27,7 @@
* @link http://status.net/
*/
if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
require_once(INSTALLDIR.'/lib/profilelist.php');
require_once INSTALLDIR.'/lib/publicgroupnav.php';
if (!defined('GNUSOCIAL)')) { exit(1); }
/**
* List of group members
@ -52,15 +47,6 @@ class GroupmembersAction extends GroupAction
return true;
}
protected function prepare(array $args=array())
{
parent::prepare($args);
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
return true;
}
function title()
{
if ($this->page == 1) {

View File

@ -86,12 +86,6 @@ class PublicAction extends SitestreamAction
$ibs->show();
}
$p = Profile::current();
if (!common_config('performance', 'high')) {
$cloud = new PublicTagCloudSection($this);
$cloud->show();
}
$feat = new FeaturedUsersSection($this);
$feat->show();
}

View File

@ -76,79 +76,15 @@ class ShowgroupAction extends GroupAction
}
}
/**
* Prepare the action
*
* Reads and validates arguments and instantiates the attributes.
*
* @param array $args $_REQUEST args
*
* @return boolean success flag
*/
protected function prepare(array $args=array())
public function getStream()
{
parent::prepare($args);
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
if ($this->scoped instanceof Profile && $this->scoped->isLocal() && $this->scoped->getUser()->streamModeOnly()) {
$stream = new GroupNoticeStream($this->group, $this->scoped);
} else {
$stream = new ThreadingGroupNoticeStream($this->group, $this->scoped);
}
$this->notice = $stream->getNotices(($this->page-1)*NOTICES_PER_PAGE,
NOTICES_PER_PAGE + 1);
common_set_returnto($this->selfUrl());
return true;
}
/**
* Handle the request
*
* Shows a profile for the group, some controls, and a list of
* group notices.
*
* @return void
*/
protected function handle()
{
parent::handle();
$this->showPage();
}
/**
* Show the page content
*
* Shows a group profile and a list of group notices
*/
function showContent()
{
$this->showGroupNotices();
}
/**
* Show the group notices
*
* @return void
*/
function showGroupNotices()
{
if ($this->scoped instanceof Profile && $this->scoped->isLocal() && $this->scoped->getUser()->streamModeOnly()) {
$nl = new PrimaryNoticeList($this->notice, $this, array('show_n'=>NOTICES_PER_PAGE));
} else {
$nl = new ThreadedNoticeList($this->notice, $this, $this->scoped);
}
$cnt = $nl->show();
$this->pagination($this->page > 1,
$cnt > NOTICES_PER_PAGE,
$this->page,
'showgroup',
array('nickname' => $this->group->nickname));
return $stream;
}
/**

View File

@ -251,15 +251,6 @@ class ShowstreamAction extends NoticestreamAction
$this->elementEnd('div');
}
function showSections()
{
parent::showSections();
if (!common_config('performance', 'high')) {
$cloud = new PersonalTagCloudSection($this->target, $this);
$cloud->show();
}
}
function noticeFormOptions()
{
$options = parent::noticeFormOptions();

View File

@ -34,7 +34,7 @@ class TagAction extends ManagedAction
$this->tag = common_canonical_tag($taginput);
if (empty($this->tag)) {
common_redirect(common_local_url('publictagcloud'), 301);
throw new ClientException(_('No valid tag data.'));
}
// after common_canonical_tag we have a lowercase, no-specials tag string

View File

@ -2623,6 +2623,13 @@ class Notice extends Managed_DataObject
return !empty($this->repeat_of);
}
public function isRepeated()
{
$n = new Notice();
$n->repeat_of = $this->getID();
return $n->find() && $n->N > 0;
}
/**
* Get the list of hash tags saved with this notice.
*

View File

@ -35,7 +35,7 @@ if (!defined('GNUSOCIAL')) { exit(1); }
*/
class Attachment extends AttachmentListItem
{
function showLink() {
function showNoticeAttachment() {
if (Event::handle('StartShowAttachmentLink', array($this->out, $this->attachment))) {
$this->out->elementStart('div', array('id' => 'attachment_view',
'class' => 'h-entry'));

View File

@ -86,28 +86,26 @@ class AttachmentListItem extends Widget
}
function linkAttr() {
return array('class' => 'attachment',
return array(
'class' => 'u-url',
'href' => $this->attachment->getAttachmentUrl(),
'id' => 'attachment-' . $this->attachment->getID(),
'title' => $this->linkTitle());
}
function showLink() {
$this->out->elementStart('a', $this->linkAttr());
$this->out->element('span', null, $this->linkTitle());
$this->showRepresentation();
$this->out->elementEnd('a');
}
function showNoticeAttachment()
{
$this->showLink();
$this->showRepresentation();
}
function showRepresentation() {
$enclosure = $this->attachment->getEnclosure();
if (Event::handle('StartShowAttachmentRepresentation', array($this->out, $this->attachment))) {
$this->out->elementStart('label');
$this->out->element('a', $this->linkAttr(), $this->title());
$this->out->elementEnd('label');
if (!empty($enclosure->mimetype)) {
// First, prepare a thumbnail if it exists.
$thumb = null;

View File

@ -95,11 +95,14 @@ class DBQueueManager extends QueueManager
} catch (NoQueueHandlerException $e) {
$this->noHandlerFound($qi, $rep);
return true;
} catch (NoResultException $e) {
$this->_log(LOG_ERR, "[{$qi->transport}:$rep] ".get_class($e).' thrown ('._ve($e->getMessage()).'), ignoring queue_item '._ve($qi->getID()));
$result = true;
} catch (AlreadyFulfilledException $e) {
$this->_log(LOG_ERR, "[{$qi->transport}:$rep] AlreadyFulfilledException thrown: {$e->getMessage()}");
$this->_log(LOG_ERR, "[{$qi->transport}:$rep] ".get_class($e).' thrown ('._ve($e->getMessage()).'), ignoring queue_item '._ve($qi->getID()));
$result = true;
} catch (Exception $e) {
$this->_log(LOG_ERR, "[{$qi->transport}:$rep] Exception thrown: {$e->getMessage()}");
$this->_log(LOG_ERR, "[{$qi->transport}:$rep] Exception (".get_class($e).') thrown: '._ve($e->getMessage()));
$result = false;
}

View File

@ -40,25 +40,23 @@ define('MEMBERS_PER_SECTION', 27);
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
class GroupAction extends Action
class GroupAction extends ShowstreamAction
{
protected $group;
protected function prepare(array $args=array())
protected function doPreparation()
{
parent::prepare($args);
$nickname_arg = $this->arg('nickname');
$nickname = common_canonical_nickname($nickname_arg);
// Permanent redirect on non-canonical nickname
if ($nickname_arg != $nickname) {
if ($nickname_arg !== $nickname) {
$args = array('nickname' => $nickname);
if ($this->page != 1) {
$args['page'] = $this->page;
}
common_redirect(common_local_url('showgroup', $args), 301);
common_redirect(common_local_url($this->getActionName(), $args), 301);
}
if (!$nickname) {
@ -79,15 +77,16 @@ class GroupAction extends Action
} else {
common_log(LOG_NOTICE, "Couldn't find local group for nickname '$nickname'");
// TRANS: Client error displayed if no remote group with a given name was found requesting group page.
$this->clientError(_('No such group.'), 404);
throw new ClientException(_('No such group.'), 404);
}
}
$this->group = User_group::getKV('id', $local->group_id);
$this->target = $this->group->getProfile();
if (!$this->group instanceof User_group) {
// TRANS: Client error displayed if no local group with a given name was found requesting group page.
$this->clientError(_('No such group.'), 404);
throw new ClientException(_('No such group.'), 404);
}
}
@ -105,18 +104,12 @@ class GroupAction extends Action
function showSections()
{
$this->showMembers();
$cur = common_current_user();
if ($cur && $cur->isAdmin($this->group)) {
if ($this->scoped instanceof Profile && $this->scoped->isAdmin($this->group)) {
$this->showPending();
$this->showBlocked();
}
$this->showAdmins();
if (!common_config('performance', 'high')) {
$cloud = new GroupTagCloudSection($this, $this->group);
$cloud->show();
}
}
/**

View File

@ -31,11 +31,6 @@ if (!defined('GNUSOCIAL')) { exit(1); }
class InlineAttachmentListItem extends AttachmentListItem
{
function showLink() {
$this->out->element('a', $this->linkAttr(), $this->title());
$this->showRepresentation();
}
/**
* start a single notice.
*
@ -45,7 +40,10 @@ class InlineAttachmentListItem extends AttachmentListItem
{
// XXX: RDFa
// TODO: add notice_type class e.g., notice_video, notice_image
$this->out->elementStart('li', array('class' => 'inline-attachment'));
$this->out->elementStart('li',
array('class' => 'inline-attachment',
'id' => 'attachment-' . $this->attachment->getID(),
));
}
/**

View File

@ -286,7 +286,7 @@ class NoticeListItem extends Widget
$this->out->elementStart('ul', 'addressees');
$first = true;
foreach ($pa as $addr) {
$this->out->elementStart('li', 'h-card');
$this->out->elementStart('li');
$text = $addr['text'];
unset($addr['text']);
$this->out->element('a', $addr, $text);
@ -304,12 +304,12 @@ class NoticeListItem extends Widget
$attentions = $this->getAttentionProfiles();
foreach ($attentions as $attn) {
$class = $attn->isGroup() ? 'group' : 'account';
$profileurl = $attn->getUri();
if (common_valid_http_url($profileurl)) {
$class .= ' u-uid';
if ($attn->isGroup()) {
$class = 'group';
$profileurl = common_local_url('groupbyid', array('id' => $attn->getGroup()->getID()));
} else {
$profileurl = $attn->getUrl();
$class = 'account';
$profileurl = common_local_url('userbyid', array('id' => $attn->getID()));
}
$this->pa[] = array('href' => $profileurl,
'title' => $attn->getNickname(),

View File

@ -55,7 +55,7 @@ abstract class ProfileAction extends ManagedAction
$nickname = common_canonical_nickname($nickname_arg);
// Permanent redirect on non-canonical nickname
if ($nickname_arg != $nickname) {
if ($nickname_arg !== $nickname) {
$args = array('nickname' => $nickname);
if ($this->arg('page') && $this->arg('page') != 1) {
$args['page'] = $this->arg['page'];
@ -83,7 +83,7 @@ abstract class ProfileAction extends ManagedAction
// this will call ->doPreparation() which child classes use to set $this->target
parent::prepare($args);
if ($this->target->hasRole(Profile_role::SILENCED)
if ($this->target->isPerson() && $this->target->hasRole(Profile_role::SILENCED)
&& (!$this->scoped instanceof Profile || !$this->scoped->hasRight(Right::SILENCEUSER))) {
throw new ClientException(_('This profile has been silenced by site moderators'), 403);
}

View File

@ -77,13 +77,6 @@ class PublicGroupNav extends Menu
// TRANS: Menu item title in search group navigation panel.
_('User groups'), $this->actionName == 'groups', 'nav_groups');
if (!common_config('performance', 'high')) {
// TRANS: Menu item in search group navigation panel.
$this->out->menuItem(common_local_url('publictagcloud'), _m('MENU','Recent tags'),
// TRANS: Menu item title in search group navigation panel.
_('Recent tags'), $this->actionName == 'publictagcloud', 'nav_recent-tags');
}
if (count(common_config('nickname', 'featured')) > 0) {
// TRANS: Menu item in search group navigation panel.
$this->out->menuItem(common_local_url('featured'), _m('MENU','Featured'),

View File

@ -260,12 +260,6 @@ class Router
array('action' => 'userbyid'),
array('id' => '[0-9]+'));
if (!common_config('performance', 'high')) {
$m->connect('tags/', array('action' => 'publictagcloud'));
$m->connect('tag/', array('action' => 'publictagcloud'));
$m->connect('tags', array('action' => 'publictagcloud'));
$m->connect('tag', array('action' => 'publictagcloud'));
}
$m->connect('tag/:tag/rss',
array('action' => 'tagrss'),
array('tag' => self::REGEX_TAG));

View File

@ -581,9 +581,6 @@ function common_canonical_email($email)
return $email;
}
<<<<<<< HEAD
function common_purify($html, array $args=array())
=======
function common_to_alphanumeric($str)
{
$filtered = preg_replace('/[^A-Za-z0-9]\s*/', '', $str);
@ -593,8 +590,7 @@ function common_to_alphanumeric($str)
return $filtered;
}
function common_purify($html)
>>>>>>> upstream/master
function common_purify($html, array $args=array())
{
require_once INSTALLDIR.'/extlib/HTMLPurifier/HTMLPurifier.auto.php';

View File

@ -176,7 +176,7 @@ class OembedPlugin extends Plugin
}
$file->setTitle($oembed_data->title);
} catch (Exception $e) {
common_log(LOG_WARN, sprintf(__METHOD__.': %s thrown when getting oEmbed data: %s', get_class($e), _ve($e->getMessage())));
common_log(LOG_WARNING, sprintf(__METHOD__.': %s thrown when getting oEmbed data: %s', get_class($e), _ve($e->getMessage())));
return true;
}

View File

@ -2,7 +2,6 @@
float: left;
margin-bottom: 1ex;
margin-right: 1em;
padding-bottom: 1ex;
}
.p-author.oembed {

View File

@ -0,0 +1,70 @@
<?php
/**
* GNU social plugin for "tag clouds" in the UI
*
* @category UI
* @package GNUsocial
* @author Mikael Nordfeldth <mmn@hethane.se>
* @copyright 2016 Free Software Foundation, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
* @link http://gnu.io/social/
*/
if (!defined('GNUSOCIAL')) { exit(1); }
class TagCloudPlugin extends Plugin {
public function onRouterInitialized(URLMapper $m)
{
$m->connect('tags/', array('action' => 'publictagcloud'));
$m->connect('tag/', array('action' => 'publictagcloud'));
$m->connect('tags', array('action' => 'publictagcloud'));
$m->connect('tag', array('action' => 'publictagcloud'));
}
public function onEndPublicGroupNav(Menu $menu)
{
// TRANS: Menu item in search group navigation panel.
$menu->out->menuItem(common_local_url('publictagcloud'), _m('MENU','Recent tags'),
// TRANS: Menu item title in search group navigation panel.
_('Recent tags'), $menu->actionName === 'publictagcloud', 'nav_recent-tags');
}
public function onEndShowSections(Action $action)
{
$cloud = null;
switch (true) {
case $action instanceof AllAction:
$cloud = new InboxTagCloudSection($action, $action->getTarget());
break;
case $action instanceof AttachmentAction:
$cloud = new AttachmentTagCloudSection($action);
break;
case $action instanceof PublicAction:
$cloud = new PublicTagCloudSection($action);
break;
case $action instanceof ShowstreamAction:
$cloud = new PersonalTagCloudSection($action, $action->getTarget());
break;
case $action instanceof GroupAction:
$cloud = new GroupTagCloudSection($action, $action->getGroup());
}
if (!is_null($cloud)) {
$cloud->show();
}
}
public function onPluginVersion(array &$versions)
{
$versions[] = array('name' => 'TagCloud',
'version' => GNUSOCIAL_VERSION,
'author' => 'Mikael Nordfeldth',
'homepage' => 'https://gnu.io/social',
'description' =>
// TRANS: Plugin description.
_m('Adds tag clouds to stream pages'));
return true;
}
}

View File

@ -42,7 +42,7 @@ class PersonalTagCloudSection extends TagCloudSection
{
protected $profile = null;
function __construct(Profile $profile, HTMLOutputter $out=null)
function __construct(HTMLOutputter $out, Profile $profile)
{
parent::__construct($out);
$this->profile = $profile;

View File

@ -35,7 +35,7 @@ class WebFingerPlugin extends Plugin
const OAUTH_REQUEST_TOKEN_REL = 'http://apinamespace.org/oauth/request_token';
const OAUTH_AUTHORIZE_REL = 'http://apinamespace.org/oauth/authorize';
public function onRouterInitialized($m)
public function onRouterInitialized(URLMapper $m)
{
$m->connect('.well-known/host-meta', array('action' => 'hostmeta'));
$m->connect('.well-known/host-meta.:format',

View File

@ -812,24 +812,34 @@ position:static;
.notice.h-entry .attachments {
position: relative;
margin-bottom: 1em;
list-style-type: none;
}
.notice.h-entry .attachments > * {
.notice.h-entry .attachments > li {
clear: both;
background-color: #f9f9f9;
border: 1px lightgrey solid;
margin-bottom: 1ex;
padding: 1ex 1ex 0 1ex;
overflow: auto;
text-align: center;
position: relative;
}
.notice.h-entry .attachments .inline-attachment > article {
text-align: left;
}
.notice.h-entry .attachments .inline-attachment > * {
height: auto;
margin-bottom: 1ex;
max-width: 100%;
}
.notice.h-entry .attachments .inline-attachment > a {
.notice.h-entry .attachments .inline-attachment > label {
font-size: 0.8em;
line-height: 16px;
height: 16px;
}
.notice.h-entry .attachments .inline-attachment > img {
display: block;
}
#attachments {
clear:both;

View File

@ -1193,35 +1193,6 @@ body#outbox #core ul.messages .notice:before {
/* notices etc */
.notice .h-entry {
overflow:visible;
}
.notice.h-entry .attachments {
clear: both;
margin-top: -16px;
position: relative;
top: 0;
z-index: 1;
}
.notice .attachments .inline-attachment {
color: transparent;
font-size: 0;
line-height: 0;
list-style: none outside none;
margin-bottom: 0;
}
.notice .attachments .inline-attachment img {
color: transparent;
font-size: 0;
line-height: 0;
list-style: none outside none;
margin-bottom: 0;
padding-top:20px;
}
#page_notice {
clear: both;
margin-bottom: 18px;