We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 1a61a171 authored by Evan Prodromou's avatar Evan Prodromou

Merge branch '0.7.x' into cometplugin

parents a86a0e91 19a21947
......@@ -13,3 +13,6 @@ dataobject.ini
*.rej
.#*
*.swp
.buildpath
.project
.settings
......@@ -59,7 +59,7 @@ class AccesstokenAction extends Action
try {
common_debug('getting request from env variables', __FILE__);
common_remove_magic_from_request();
$req = OAuthRequest::from_request('POST', common_locale_url('accesstoken'));
$req = OAuthRequest::from_request('POST', common_local_url('accesstoken'));
common_debug('getting a server', __FILE__);
$server = omb_oauth_server();
common_debug('fetching the access token', __FILE__);
......
......@@ -130,6 +130,7 @@ class ApiAction extends Action
'statuses/friends_timeline',
'statuses/friends',
'statuses/replies',
'statuses/mentions',
'statuses/followers',
'favorites/favorites');
......
......@@ -107,7 +107,7 @@ class FavoritesrssAction extends Rss10Action
$c = array('url' => common_local_url('favoritesrss',
array('nickname' =>
$user->nickname)),
'title' => sprintf(_("%s favorite notices"), $user->nickname),
'title' => sprintf(_("%s's favorite notices"), $user->nickname),
'link' => common_local_url('showfavorites',
array('nickname' =>
$user->nickname)),
......
......@@ -67,8 +67,8 @@ class OpenidsettingsAction extends AccountSettingsAction
function getInstructions()
{
return _('[OpenID](%%doc.openid%%) lets you log into many sites ' .
' with the same user account. '.
return _('[OpenID](%%doc.openid%%) lets you log into many sites' .
' with the same user account.'.
' Manage your associated OpenIDs from here.');
}
......
......@@ -151,11 +151,11 @@ class RecoverpasswordAction extends Action
$this->element('p', null,
_('If you\'ve forgotten or lost your' .
' password, you can get a new one sent to' .
' the email address you have stored ' .
' the email address you have stored' .
' in your account.'));
} else if ($this->mode == 'reset') {
$this->element('p', null,
_('You\'ve been identified. Enter a ' .
_('You\'ve been identified. Enter a' .
' new password below. '));
}
$this->elementEnd('div');
......
......@@ -74,9 +74,9 @@ class ShowfavoritesAction extends Action
function title()
{
if ($this->page == 1) {
return sprintf(_("%s favorite notices"), $this->user->nickname);
return sprintf(_("%s's favorite notices"), $this->user->nickname);
} else {
return sprintf(_("%s favorite notices, page %d"),
return sprintf(_("%s's favorite notices, page %d"),
$this->user->nickname,
$this->page);
}
......
......@@ -144,10 +144,10 @@ class TwitapistatusesAction extends TwitterapiAction
break;
case 'atom':
if (isset($apidata['api_arg'])) {
$selfuri = $selfuri = common_root_url() .
$selfuri = common_root_url() .
'api/statuses/friends_timeline/' . $apidata['api_arg'] . '.atom';
} else {
$selfuri = $selfuri = common_root_url() .
$selfuri = common_root_url() .
'api/statuses/friends_timeline.atom';
}
$this->show_atom_timeline($notice, $title, $id, $link, $subtitle, null, $selfuri);
......@@ -231,10 +231,10 @@ class TwitapistatusesAction extends TwitterapiAction
break;
case 'atom':
if (isset($apidata['api_arg'])) {
$selfuri = $selfuri = common_root_url() .
$selfuri = common_root_url() .
'api/statuses/user_timeline/' . $apidata['api_arg'] . '.atom';
} else {
$selfuri = $selfuri = common_root_url() .
$selfuri = common_root_url() .
'api/statuses/user_timeline.atom';
}
$this->show_atom_timeline($notice, $title, $id, $link, $subtitle, $suplink, $selfuri);
......@@ -344,7 +344,7 @@ class TwitapistatusesAction extends TwitterapiAction
$this->show($args, $apidata);
}
function replies($args, $apidata)
function mentions($args, $apidata)
{
parent::handle($args);
......@@ -360,11 +360,13 @@ class TwitapistatusesAction extends TwitterapiAction
$profile = $user->getProfile();
$sitename = common_config('site', 'name');
$title = sprintf(_('%1$s / Updates replying to %2$s'), $sitename, $user->nickname);
$title = sprintf(_('%1$s / Updates mentioning %2$s'),
$sitename, $user->nickname);
$taguribase = common_config('integration', 'taguri');
$id = "tag:$taguribase:Replies:".$user->id;
$id = "tag:$taguribase:Mentions:".$user->id;
$link = common_local_url('replies', array('nickname' => $user->nickname));
$subtitle = sprintf(_('%1$s updates that reply to updates from %2$s / %3$s.'), $sitename, $user->nickname, $profile->getBestName());
$subtitle = sprintf(_('%1$s updates that reply to updates from %2$s / %3$s.'),
$sitename, $user->nickname, $profile->getBestName());
if (!$page) {
$page = 1;
......@@ -385,7 +387,8 @@ class TwitapistatusesAction extends TwitterapiAction
$since = strtotime($this->arg('since'));
$notice = $user->getReplies((($page-1)*20), $count, $since_id, $before_id, $since);
$notice = $user->getReplies((($page-1)*20),
$count, $since_id, $before_id, $since);
$notices = array();
while ($notice->fetch()) {
......@@ -400,14 +403,10 @@ class TwitapistatusesAction extends TwitterapiAction
$this->show_rss_timeline($notices, $title, $link, $subtitle);
break;
case 'atom':
if (isset($apidata['api_arg'])) {
$selfuri = $selfuri = common_root_url() .
'api/statuses/replies/' . $apidata['api_arg'] . '.atom';
} else {
$selfuri = $selfuri = common_root_url() .
'api/statuses/replies.atom';
}
$this->show_atom_timeline($notices, $title, $id, $link, $subtitle, null, $selfuri);
$selfuri = common_root_url() .
ltrim($_SERVER['QUERY_STRING'], 'p=');
$this->show_atom_timeline($notices, $title, $id, $link, $subtitle,
null, $selfuri);
break;
case 'json':
$this->show_json_timeline($notices);
......@@ -418,6 +417,11 @@ class TwitapistatusesAction extends TwitterapiAction
}
function replies($args, $apidata)
{
call_user_func(array($this, 'mentions'), $args, $apidata);
}
function show($args, $apidata)
{
parent::handle($args);
......
......@@ -285,7 +285,7 @@ class Notice extends Memcached_DataObject
// Clear the user's cache
$cache = common_memcache();
if (!empty($cache)) {
$cache->delete(common_cache_key('user:notices_with_friends:' . $this->profile_id));
$cache->delete(common_cache_key('notice_inbox:by_user:'.$this->profile_id));
}
$this->blowNoticeCache($blowLast);
$this->blowPublicCache($blowLast);
......@@ -307,9 +307,9 @@ class Notice extends Memcached_DataObject
$member->group_id = $group_inbox->group_id;
if ($member->find()) {
while ($member->fetch()) {
$cache->delete(common_cache_key('user:notices_with_friends:' . $member->profile_id));
$cache->delete(common_cache_key('notice_inbox:by_user:' . $member->profile_id));
if ($blowLast) {
$cache->delete(common_cache_key('user:notices_with_friends:' . $member->profile_id . ';last'));
$cache->delete(common_cache_key('notice_inbox:by_user:' . $member->profile_id . ';last'));
}
}
}
......@@ -352,9 +352,9 @@ class Notice extends Memcached_DataObject
'WHERE subscription.subscribed = ' . $this->profile_id);
while ($user->fetch()) {
$cache->delete(common_cache_key('user:notices_with_friends:' . $user->id));
$cache->delete(common_cache_key('notice_inbox:by_user:'.$user->id));
if ($blowLast) {
$cache->delete(common_cache_key('user:notices_with_friends:' . $user->id . ';last'));
$cache->delete(common_cache_key('notice_inbox:by_user:'.$user->id.';last'));
}
}
$user->free();
......@@ -613,27 +613,80 @@ class Notice extends Memcached_DataObject
return $wrapper;
}
function getStreamByIds($ids)
{
$cache = common_memcache();
if (!empty($cache)) {
$notices = array();
foreach ($ids as $id) {
$notices[] = Notice::staticGet('id', $id);
}
return new ArrayWrapper($notices);
} else {
$notice = new Notice();
$notice->whereAdd('id in (' . implode(', ', $ids) . ')');
$notice->orderBy('id DESC');
$notice->find();
return $notice;
}
}
function publicStream($offset=0, $limit=20, $since_id=0, $before_id=0, $since=null)
{
$ids = Notice::stream(array('Notice', '_publicStreamDirect'),
array(),
'public',
$offset, $limit, $since_id, $before_id, $since);
return Notice::getStreamByIds($ids);
}
function _publicStreamDirect($offset=0, $limit=20, $since_id=0, $before_id=0, $since=null)
{
$notice = new Notice();
$parts = array();
$notice->selectAdd(); // clears it
$notice->selectAdd('id');
$qry = 'SELECT * FROM notice ';
$notice->orderBy('id DESC');
if (!is_null($offset)) {
$notice->limit($offset, $limit);
}
if (common_config('public', 'localonly')) {
$parts[] = 'is_local = 1';
$notice->whereAdd('is_local = 1');
} else {
# -1 == blacklisted
$parts[] = 'is_local != -1';
$notice->whereAdd('is_local != -1');
}
if ($since_id != 0) {
$notice->whereAdd('id > ' . $since_id);
}
if ($parts) {
$qry .= ' WHERE ' . implode(' AND ', $parts);
if ($before_id != 0) {
$notice->whereAdd('id < ' . $before_id);
}
if (!is_null($since)) {
$notice->whereAdd('created > \'' . date('Y-m-d H:i:s', $since) . '\'');
}
$ids = array();
if ($notice->find()) {
while ($notice->fetch()) {
$ids[] = $notice->id;
}
}
return Notice::getStream($qry,
'public',
$offset, $limit, $since_id, $before_id, null, $since);
$notice->free();
$notice = NULL;
return $ids;
}
function addToInboxes()
......@@ -947,4 +1000,59 @@ class Notice extends Memcached_DataObject
array('notice' => $this->id));
}
}
function stream($fn, $args, $cachekey, $offset=0, $limit=20, $since_id=0, $before_id=0, $since=null)
{
$cache = common_memcache();
if (empty($cache) ||
$since_id != 0 || $before_id != 0 || !is_null($since) ||
($offset + $limit) > NOTICE_CACHE_WINDOW) {
return call_user_func_array($fn, array_merge($args, array($offset, $limit, $since_id,
$before_id, $since)));
}
$idkey = common_cache_key($cachekey);
$idstr = $cache->get($idkey);
if (!empty($idstr)) {
// Cache hit! Woohoo!
$window = explode(',', $idstr);
$ids = array_slice($window, $offset, $limit);
return $ids;
}
$laststr = $cache->get($idkey.';last');
if (!empty($laststr)) {
$window = explode(',', $laststr);
$last_id = $window[0];
$new_ids = call_user_func_array($fn, array_merge($args, array(0, NOTICE_CACHE_WINDOW,
$last_id, 0, null)));
$new_window = array_merge($new_ids, $window);
$new_windowstr = implode(',', $new_window);
$result = $cache->set($idkey, $new_windowstr);
$result = $cache->set($idkey . ';last', $new_windowstr);
$ids = array_slice($new_window, $offset, $limit);
return $ids;
}
$window = call_user_func_array($fn, array_merge($args, array(0, NOTICE_CACHE_WINDOW,
0, 0, null)));
$windowstr = implode(',', $window);
$result = $cache->set($idkey, $windowstr);
$result = $cache->set($idkey . ';last', $windowstr);
$ids = array_slice($window, $offset, $limit);
return $ids;
}
}
<?php
/*
* Laconica - a distributed open-source microblogging tool
* Copyright (C) 2008, Controlez-Vous, Inc.
* Copyright (C) 2008, 2009, Control Yourself, Inc.
*
* 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
......@@ -21,7 +21,11 @@ if (!defined('LACONICA')) { exit(1); }
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
class Notice_inbox extends Memcached_DataObject
// We keep 5 pages of inbox notices in memcache, +1 for pagination check
define('INBOX_CACHE_WINDOW', 101);
class Notice_inbox extends Memcached_DataObject
{
###START_AUTOCODE
/* the code below is auto generated do not remove the above tag */
......@@ -38,4 +42,47 @@ class Notice_inbox extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
function stream($user_id, $offset, $limit, $since_id, $before_id, $since)
{
return Notice::stream(array('Notice_inbox', '_streamDirect'),
array($user_id),
'notice_inbox:by_user:'.$user_id,
$offset, $limit, $since_id, $before_id, $since);
}
function _streamDirect($user_id, $offset, $limit, $since_id, $before_id, $since)
{
$inbox = new Notice_inbox();
$inbox->user_id = $user_id;
if ($since_id != 0) {
$inbox->whereAdd('notice_id > ' . $since_id);
}
if ($before_id != 0) {
$inbox->whereAdd('notice_id < ' . $before_id);
}
if (!is_null($since)) {
$inbox->whereAdd('created > \'' . date('Y-m-d H:i:s', $since) . '\'');
}
$inbox->orderBy('notice_id DESC');
if (!is_null($offset)) {
$inbox->limit($offset, $limit);
}
$ids = array();
if ($inbox->find()) {
while ($inbox->fetch()) {
$ids[] = $inbox->notice_id;
}
}
return $ids;
}
}
......@@ -444,21 +444,17 @@ class User extends Memcached_DataObject
'SELECT notice.* ' .
'FROM notice JOIN subscription ON notice.profile_id = subscription.subscribed ' .
'WHERE subscription.subscriber = %d ';
$order = null;
return Notice::getStream(sprintf($qry, $this->id),
'user:notices_with_friends:' . $this->id,
$offset, $limit, $since_id, $before_id,
$order, $since);
} else if ($enabled === true ||
($enabled == 'transitional' && $this->inboxed == 1)) {
$qry =
'SELECT notice.* ' .
'FROM notice JOIN notice_inbox ON notice.id = notice_inbox.notice_id ' .
'WHERE notice_inbox.user_id = %d ';
// NOTE: we override ORDER
$order = null;
$ids = Notice_inbox::stream($this->id, $offset, $limit, $since_id, $before_id, $since);
return Notice::getStreamByIds($ids);
}
return Notice::getStream(sprintf($qry, $this->id),
'user:notices_with_friends:' . $this->id,
$offset, $limit, $since_id, $before_id,
$order, $since);
}
function blowFavesCache()
......
......@@ -128,7 +128,7 @@
var a = document.createElement('A');
a.innerHTML = 'get this';
a.target = '_blank';
a.href = 'http://identica/doc/badge';
a.href = 'http://identi.ca/doc/badge';
$.s.f.appendChild(a);
$.s.appendChild($.s.f);
$.f.getUser();
......
......@@ -166,23 +166,14 @@ $(document).ready(function(){
$("#notice_action-submit").addClass("disabled");
return true;
},
timeout: 7000,
error: function (xhr, textStatus, errorThrown) { $("#form_notice").removeClass("processing");
$("#notice_action-submit").removeAttr("disabled");
$("#notice_action-submit").removeClass("disabled");
if (textStatus == "timeout") {
alert ("Sorry! We had trouble sending your notice. The servers are overloaded. Please try again, and contact the site administrator if this problem persists");
if ($(".error", xhr.responseXML).length > 0) {
$('#form_notice').append(document._importNode($(".error", xhr.responseXML).get(0), true));
}
else {
switch(xhr.status) {
default: case 404:
alert("Sorry! We had trouble sending your notice. Please report the problem to the site administrator if this happens again.");
break;
case 502: case 503: case 504:
alert("Sorry! We had trouble sending your notice. The servers are overloaded. Please try again, and contact the site administrator if this problem persists.");
break;
}
alert("Sorry! We had trouble sending your notice ("+xhr.status+" "+xhr.statusText+"). Please report the problem to the site administrator if this happens again.");
}
},
success: function(xml) { if ($("#error", xml).length > 0) {
......@@ -197,11 +188,15 @@ $(document).ready(function(){
alert(result);
}
else {
$("#notices_primary .notices").prepend(document._importNode($("li", xml).get(0), true));
$("#notices_primary .notice:first").css({display:"none"});
$("#notices_primary .notice:first").fadeIn(2500);
NoticeHover();
NoticeReply();
li = $("li", xml).get(0);
id = li.id;
if ($("#"+li.id).length == 0) {
$("#notices_primary .notices").prepend(document._importNode(li, true));
$("#notices_primary .notice:first").css({display:"none"});
$("#notices_primary .notice:first").fadeIn(2500);
NoticeHover();
NoticeReply();
}
}
$("#notice_data-text").val("");
counter();
......
......@@ -134,9 +134,11 @@ class GalleryAction extends Action
$this->elementStart('li', array('id'=>'filter_tags_item'));
$this->elementStart('form', array('name' => 'bytag',
'id' => 'bytag',
'action' => common_path('?action=' . $this->trimmed('action')),
'method' => 'post'));
$this->dropdown('tag', _('Tag'), $content,
_('Choose a tag to narrow list'), false, $tag);
$this->hidden('nickname', $this->user->nickname);
$this->submit('submit', _('Go'));
$this->elementEnd('form');
$this->elementEnd('li');
......@@ -169,4 +171,4 @@ class GalleryAction extends Action
{
return array();
}
}
\ No newline at end of file
}
......@@ -231,12 +231,12 @@ class Router
$m->connect('api/statuses/:method',
array('action' => 'api',
'apiaction' => 'statuses'),
array('method' => '(public_timeline|friends_timeline|user_timeline|update|replies|friends|followers|featured)(\.(atom|rss|xml|json))?'));
array('method' => '(public_timeline|friends_timeline|user_timeline|update|replies|mentions|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|show|destroy|friends|followers)'));
array('method' => '(user_timeline|friends_timeline|replies|mentions|show|destroy|friends|followers)'));
// users
......
......@@ -74,3 +74,4 @@ class SubPeopleTagCloudSection extends TagCloudSection
$this->out->elementEnd('li');
}
}
......@@ -49,6 +49,14 @@ class SubscribersPeopleSelfTagCloudSection extends SubPeopleTagCloudSection
}
function query() {
return 'select tag, count(tag) as weight from subscription left join profile_tag on tagger = subscriber where subscribed=%d and subscribed != subscriber and tagger = tagged group by tag order by weight desc';
// return 'select tag, count(tag) as weight from subscription left join profile_tag on tagger = subscriber where subscribed=%d and subscribed != subscriber and tagger = tagged group by tag order by weight desc';
return 'select tag, count(tag) as weight from subscription left join profile_tag on tagger = subscriber where subscribed=%d and subscribed != subscriber and tagger = tagged and tag is not null group by tag order by weight desc';
// return 'select tag, count(tag) as weight from subscription left join profile_tag on tagger = subscribed where subscriber=%d and subscribed != subscriber and tagger = tagged and tag is not null group by tag order by weight desc';
}
}
......@@ -53,8 +53,9 @@ class SubscribersPeopleTagCloudSection extends SubPeopleTagCloudSection
return common_local_url('subscribers', array('nickname' => $nickname, 'tag' => $tag));
}
function query() {
return 'select tag, count(tag) as weight from subscription left join profile_tag on subscriber=tagged and subscribed=tagger where subscribed=%d and subscriber != subscribed group by tag order by weight desc';
// return 'select tag, count(tag) as weight from subscription left join profile_tag on subscriber=tagged and subscribed=tagger where subscribed=%d and subscriber != subscribed group by tag order by weight desc';
return 'select tag, count(tag) as weight from subscription left join profile_tag on subscriber=tagged and subscribed=tagger where subscribed=%d and subscriber != subscribed and tag is not null group by tag order by weight desc';
}
}
......@@ -49,6 +49,13 @@ class SubscriptionsPeopleSelfTagCloudSection extends SubPeopleTagCloudSection
}
function query() {
return 'select tag, count(tag) as weight from subscription left join profile_tag on tagger = subscriber where subscribed=%d and subscriber != subscribed and tagger = tagged group by tag order by weight desc';
// return 'select tag, count(tag) as weight from subscription left join profile_tag on tagger = subscriber where subscribed=%d and subscriber != subscribed and tagger = tagged group by tag order by weight desc';
return 'select tag, count(tag) as weight from subscription left join profile_tag on tagger = subscribed where subscriber=%d and subscribed != subscriber and tagger = tagged and tag is not null group by tag order by weight desc';
// return 'select tag, count(tag) as weight from subscription left join profile_tag on tagger = subscriber where subscribed=%d and subscribed != subscriber and tagger = tagged and tag is not null group by tag order by weight desc';
}
}
......@@ -54,6 +54,8 @@ class SubscriptionsPeopleTagCloudSection extends SubPeopleTagCloudSection
}
function query() {
return 'select tag, count(tag) as weight from subscription left join profile_tag on subscriber=tagger and subscribed=tagged where subscriber=%d and subscriber != subscribed group by tag order by weight desc';
// return 'select tag, count(tag) as weight from subscription left join profile_tag on subscriber=tagger and subscribed=tagged where subscriber=%d and subscriber != subscribed group by tag order by weight desc';
return 'select tag, count(tag) as weight from subscription left join profile_tag on subscriber=tagger and subscribed=tagged where subscriber=%d and subscriber != subscribed and tag is not null group by tag order by weight desc';
}
}
......@@ -121,6 +121,12 @@ class LinkbackPlugin extends Plugin
{
$args = array($this->notice->uri, $url);
if (!extension_loaded('xmlrpc')) {
if (!dl('xmlrpc.so')) {
common_log(LOG_ERR, "Can't pingback; xmlrpc extension not available.");
}
}
$request = xmlrpc_encode_request('pingback.ping', $args);
$context = stream_context_create(array('http' => array('method' => "POST",
'header' =>
......@@ -141,7 +147,7 @@ class LinkbackPlugin extends Plugin
}
// Largely cadged from trackback_cls.php by
// Ran Aroussi <ran@blogish.org>, GPL2
// Ran Aroussi <ran@blogish.org>, GPL2 or any later version
// http://phptrackback.sourceforge.net/
function getTrackback($text, $url)
......
#!/usr/bin/env php
<?php
/*
* Laconica - a distributed open-source microblogging tool
* Copyright (C) 2008, Controlez-Vous, Inc.
*
* 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.