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

Commit 79e732bd authored by Evan Prodromou's avatar Evan Prodromou

Merge branch '0.8.x' into twitterpriv

parents 19d39b20 c14c9e1a
avatar/*
background/*
files/*
file/*
_darcs/*
......
......@@ -1223,6 +1223,7 @@ supported: an array of mime types you accept to store and distribute,
like 'image/gif', 'video/mpeg', 'audio/mpeg', etc. Make sure you
setup your server to properly reckognize the types you want to
support.
uploads: false to disable uploading files with notices (true by default).
For quotas, be sure you've set the upload_max_filesize and post_max_size
in php.ini to be large enough to handle your upload. In httpd.conf
......@@ -1246,6 +1247,14 @@ Options for group functionality.
maxaliases: maximum number of aliases a group can have. Default 3. Set
to 0 or less to prevent aliases in a group.
oohembed
--------
oEmbed endpoint for multimedia attachments (links in posts).
endpoint: oohembed endpoint using http://oohembed.com/ software.
Troubleshooting
===============
......
......@@ -98,48 +98,6 @@ class AttachmentAction extends Action
return $a->title();
}
/**
* Last-modified date for page
*
* When was the content of this page last modified? Based on notice,
* profile, avatar.
*
* @return int last-modified date as unix timestamp
*/
/*
function lastModified()
{
return max(strtotime($this->notice->created),
strtotime($this->profile->modified),
($this->avatar) ? strtotime($this->avatar->modified) : 0);
}
*/
/**
* An entity tag for this page
*
* Shows the ETag for the page, based on the notice ID and timestamps
* for the notice, profile, and avatar. It's weak, since we change
* the date text "one hour ago", etc.
*
* @return string etag
*/
/*
function etag()
{
$avtime = ($this->avatar) ?
strtotime($this->avatar->modified) : 0;
return 'W/"' . implode(':', array($this->arg('action'),
common_language(),
$this->notice->id,
strtotime($this->notice->created),
strtotime($this->profile->modified),
$avtime)) . '"';
}
*/
/**
* Handle input
*
......
......@@ -74,46 +74,5 @@ class Attachment_ajaxAction extends AttachmentAction
}
$this->elementEnd('div');
}
/**
* Last-modified date for page
*
* When was the content of this page last modified? Based on notice,
* profile, avatar.
*
* @return int last-modified date as unix timestamp
*/
/*
function lastModified()
{
return max(strtotime($this->notice->created),
strtotime($this->profile->modified),
($this->avatar) ? strtotime($this->avatar->modified) : 0);
}
*/
/**
* An entity tag for this page
*
* Shows the ETag for the page, based on the notice ID and timestamps
* for the notice, profile, and avatar. It's weak, since we change
* the date text "one hour ago", etc.
*
* @return string etag
*/
/*
function etag()
{
$avtime = ($this->avatar) ?
strtotime($this->avatar->modified) : 0;
return 'W/"' . implode(':', array($this->arg('action'),
common_language(),
$this->notice->id,
strtotime($this->notice->created),
strtotime($this->profile->modified),
$avtime)) . '"';
}
*/
}
......@@ -125,16 +125,18 @@ class BlockAction extends Action
function areYouSureForm()
{
$id = $this->profile->id;
$this->elementStart('form', array('id' => 'block-' . $id,
'method' => 'post',
'class' => 'form_settings form_entity_block',
'action' => common_local_url('block')));
$this->elementStart('fieldset');
$this->hidden('token', common_session_token());
$this->element('legend', _('Block user'));
$this->element('p', null,
_('Are you sure you want to block this user? '.
'Afterwards, they will be unsubscribed from you, '.
'unable to subscribe to you in the future, and '.
'you will not be notified of any @-replies from them.'));
$this->elementStart('form', array('id' => 'block-' . $id,
'method' => 'post',
'class' => 'block',
'action' => common_local_url('block')));
$this->hidden('token', common_session_token());
$this->element('input', array('id' => 'blockto-' . $id,
'name' => 'blockto',
'type' => 'hidden',
......@@ -144,8 +146,9 @@ class BlockAction extends Action
$this->hidden($k, $v);
}
}
$this->submit('no', _('No'));
$this->submit('yes', _('Yes'));
$this->submit('form_action-no', _('No'), 'submit form_action-primary', 'no', _("Do not block this user from this group"));
$this->submit('form_action-yes', _('Yes'), 'submit form_action-secondary', 'yes', _('Block this user from this group'));
$this->elementEnd('fieldset');
$this->elementEnd('form');
}
......
This diff is collapsed.
......@@ -32,7 +32,7 @@ if (!defined('LACONICA')) {
exit(1);
}
require_once(INSTALLDIR.'/lib/profilelist.php');
require_once INSTALLDIR.'/lib/profilelist.php';
require_once INSTALLDIR.'/lib/publicgroupnav.php';
/**
......@@ -107,7 +107,6 @@ class FeaturedAction extends Action
$featured_nicks = common_config('nickname', 'featured');
if (count($featured_nicks) > 0) {
$quoted = array();
......@@ -136,7 +135,7 @@ class FeaturedAction extends Action
$cnt = $profile->find();
if ($cnt > 0) {
$featured = new ProfileList($profile, null, $this);
$featured = new ProfileList($profile, $this);
$featured->show();
}
......
......@@ -151,17 +151,19 @@ class GroupblockAction extends Action
function areYouSureForm()
{
$id = $this->profile->id;
$this->elementStart('form', array('id' => 'block-' . $id,
'method' => 'post',
'class' => 'form_settings form_entity_block',
'action' => common_local_url('groupblock')));
$this->elementStart('fieldset');
$this->hidden('token', common_session_token());
$this->element('legend', null, _('Block user'));
$this->element('p', null,
sprintf(_('Are you sure you want to block user "%s" from the group "%s"? '.
'They will be removed from the group, unable to post, and '.
'unable to subscribe to the group in the future.'),
$this->profile->getBestName(),
$this->group->getBestName()));
$this->elementStart('form', array('id' => 'block-' . $id,
'method' => 'post',
'class' => 'block',
'action' => common_local_url('groupblock')));
$this->hidden('token', common_session_token());
$this->hidden('blockto-' . $this->profile->id,
$this->profile->id,
'blockto');
......@@ -173,8 +175,9 @@ class GroupblockAction extends Action
$this->hidden($k, $v);
}
}
$this->submit('no', _('No'));
$this->submit('yes', _('Yes'));
$this->submit('form_action-no', _('No'), 'submit form_action-primary', 'no', _("Do not block this user from this group"));
$this->submit('form_action-yes', _('Yes'), 'submit form_action-secondary', 'yes', _('Block this user from this group'));
$this->elementEnd('fieldset');
$this->elementEnd('form');
}
......
......@@ -19,7 +19,7 @@
if (!defined('LACONICA')) { exit(1); }
class InviteAction extends Action
class InviteAction extends CurrentUserDesignAction
{
var $mode = null;
var $error = null;
......
......@@ -231,7 +231,6 @@ class NewnoticeAction extends Action
if (isset($mimetype)) {
$this->storeFile($notice, $mimetype);
}
$this->saveUrls($notice);
common_broadcast_notice($notice);
if ($this->boolean('ajax')) {
......@@ -284,24 +283,6 @@ class NewnoticeAction extends Action
}
}
/** save all urls in the notice to the db
*
* follow redirects and save all available file information
* (mimetype, date, size, oembed, etc.)
*
* @param class $notice Notice to pull URLs from
*
* @return void
*/
function saveUrls($notice, $uploaded = null) {
common_replace_urls_callback($notice->content, array($this, 'saveUrl'), $notice->id);
}
function saveUrl($data) {
list($url, $notice_id) = $data;
$zzz = File::processNew($url, $notice_id);
}
/**
* Show an Ajax-y error message
*
......
......@@ -124,7 +124,7 @@ class PeopletagAction extends Action
$profile->query(sprintf($qry, $this->tag, $lim));
$pl = new ProfileList($profile, null, $this);
$pl = new ProfileList($profile, $this);
$cnt = $pl->show();
$this->pagination($this->page > 1,
......
......@@ -45,9 +45,8 @@ require_once INSTALLDIR.'/lib/feedlist.php';
* @link http://laconi.ca/
*/
class RepliesAction extends Action
class RepliesAction extends OwnerDesignAction
{
var $user = null;
var $page = null;
/**
......
......@@ -45,7 +45,7 @@ require_once INSTALLDIR.'/lib/feedlist.php';
* @link http://laconi.ca/
*/
class ShowfavoritesAction extends Action
class ShowfavoritesAction extends CurrentUserDesignAction
{
/** User we're getting the faves of */
var $user = null;
......
......@@ -370,7 +370,7 @@ class ShowstreamAction extends ProfileAction
{
$notice = empty($this->tag)
? $this->user->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1)
: $this->user->getTaggedNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1, 0, 0, null, $this->tag);
: $this->user->getTaggedNotices($this->tag, ($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1, 0, 0, null);
$pnl = new ProfileNoticeList($notice, $this);
$cnt = $pnl->show();
......
......@@ -34,6 +34,11 @@ class TwitapifavoritesAction extends TwitterapiAction
$user = $this->get_user($apidata['api_arg'], $apidata);
if (empty($user)) {
if ($apidata['content-type'] == 'xml') {
$this->show_single_xml_status($notice);
} elseif ($apidata['content-type'] == 'json') {
$this->show_single_json_status($notice);
}
$this->clientError('Not Found', 404, $apidata['content-type']);
return;
}
......@@ -91,7 +96,6 @@ class TwitapifavoritesAction extends TwitterapiAction
// Check for RESTfulness
if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) {
// XXX: Twitter just prints the err msg, no XML / JSON.
$this->clientError(_('This method requires a POST or DELETE.'),
400, $apidata['content-type']);
return;
......@@ -102,10 +106,9 @@ class TwitapifavoritesAction extends TwitterapiAction
return;
}
$user = $apidata['user']; // Always the auth user
$user = $apidata['user']; // Always the auth user
$notice_id = $apidata['api_arg'];
$notice = Notice::staticGet($notice_id);
$notice = Notice::staticGet($notice_id);
if (empty($notice)) {
$this->clientError(_('No status found with that ID.'),
......@@ -115,7 +118,7 @@ class TwitapifavoritesAction extends TwitterapiAction
// XXX: Twitter lets you fave things repeatedly via api.
if ($user->hasFave($notice)) {
$this->clientError(_('This notice is already a favorite!'),
$this->clientError(_('This status is already a favorite!'),
403, $apidata['content-type']);
return;
}
......@@ -123,7 +126,7 @@ class TwitapifavoritesAction extends TwitterapiAction
$fave = Fave::addNew($user, $notice);
if (empty($fave)) {
$this->serverError(_('Could not create favorite.'));
$this->clientError(_('Could not create favorite.'));
return;
}
......@@ -141,7 +144,55 @@ class TwitapifavoritesAction extends TwitterapiAction
function destroy($args, $apidata)
{
parent::handle($args);
$this->serverError(_('API method under construction.'), $code=501);
// Check for RESTfulness
if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) {
$this->clientError(_('This method requires a POST or DELETE.'),
400, $apidata['content-type']);
return;
}
if (!in_array($apidata['content-type'], array('xml', 'json'))) {
$this->clientError(_('API method not found!'), $code = 404);
return;
}
$user = $apidata['user']; // Always the auth user
$notice_id = $apidata['api_arg'];
$notice = Notice::staticGet($notice_id);
if (empty($notice)) {
$this->clientError(_('No status found with that ID.'),
404, $apidata['content-type']);
return;
}
$fave = new Fave();
$fave->user_id = $this->id;
$fave->notice_id = $notice->id;
if (!$fave->find(true)) {
$this->clientError(_('That status is not a favorite!'),
403, $apidata['content-type']);
return;
}
$result = $fave->delete();
if (!$result) {
common_log_db_error($fave, 'DELETE', __FILE__);
$this->clientError(_('Could not delete favorite.'), 404);
return;
}
$user->blowFavesCache();
if ($apidata['content-type'] == 'xml') {
$this->show_single_xml_status($notice);
} elseif ($apidata['content-type'] == 'json') {
$this->show_single_json_status($notice);
}
}
// XXX: these two funcs swiped from faves.
......
......@@ -46,9 +46,8 @@ require_once INSTALLDIR.'/lib/grouplist.php';
* @link http://laconi.ca/
*/
class UsergroupsAction extends Action
class UsergroupsAction extends OwnerDesignAction
{
var $user = null;
var $page = null;
var $profile = null;
......
<?php
/*
* Laconica - the distributed open-source microblogging tool
* Copyright (C) 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
* 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/>.
*/
if (!defined('LACONICA')) {
exit(1);
}
define('BACKGROUND_ON', 1);
define('BACKGROUND_OFF', 2);
define('BACKGROUND_TILE', 4);
/**
* Table Definition for design
*/
require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
require_once INSTALLDIR . '/lib/webcolor.php';
class Design extends Memcached_DataObject
{
###START_AUTOCODE
/* the code below is auto generated do not remove the above tag */
public $__table = 'design'; // table name
public $id; // int(4) primary_key not_null
public $backgroundcolor; // int(4)
public $contentcolor; // int(4)
public $sidebarcolor; // int(4)
public $textcolor; // int(4)
public $linkcolor; // int(4)
public $backgroundimage; // varchar(255)
public $disposition; // tinyint(1) default_1
/* Static get */
function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Design',$k,$v); }
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
function showCSS($out)
{
try {
$bgcolor = new WebColor($this->backgroundcolor);
$ccolor = new WebColor($this->contentcolor);
$sbcolor = new WebColor($this->sidebarcolor);
$tcolor = new WebColor($this->textcolor);
$lcolor = new WebColor($this->linkcolor);
} catch (WebColorException $e) {
// This shouldn't happen
common_log(LOG_ERR, "Unable to create color for design $id.",
__FILE__);
}
$css = 'body { background-color: #' . $bgcolor->hexValue() . ' }' . "\n";
$css .= '#content, #site_nav_local_views .current a { background-color: #';
$css .= $ccolor->hexValue() . '} '."\n";
$css .= '#aside_primary { background-color: #'. $sbcolor->hexValue() . ' }' . "\n";
$css .= 'html body { color: #'. $tcolor->hexValue() . ' }'. "\n";
$css .= 'a { color: #' . $lcolor->hexValue() . ' }' . "\n";
if (!empty($this->backgroundimage) &&
$this->disposition & BACKGROUND_ON) {
$repeat = ($this->disposition & BACKGROUND_TILE) ?
'background-repeat:repeat;' :
'background-repeat:no-repeat;';
$css .= 'body { background-image:url(' .
Design::url($this->backgroundimage) .
'); ' . $repeat . ' }' . "\n";
}
$out->element('style', array('type' => 'text/css'), $css);
}
static function filename($id, $extension, $extra=null)
{
return $id . (($extra) ? ('-' . $extra) : '') . $extension;
}
static function path($filename)
{
$dir = common_config('background', 'dir');
if ($dir[strlen($dir)-1] != '/') {
$dir .= '/';
}
return $dir . $filename;
}
static function url($filename)
{
$path = common_config('background', 'path');
if ($path[strlen($path)-1] != '/') {
$path .= '/';
}
if ($path[0] != '/') {
$path = '/'.$path;
}
$server = common_config('background', 'server');
if (empty($server)) {
$server = common_config('site', 'server');
}
// XXX: protocol
return 'http://'.$server.$path.$filename;
}
function setDisposition($on, $off, $tile)
{
if ($on) {
$this->disposition |= BACKGROUND_ON;
} else {
$this->disposition &= ~BACKGROUND_ON;
}
if ($off) {
$this->disposition |= BACKGROUND_OFF;
} else {
$this->disposition &= ~BACKGROUND_OFF;
}
if ($tile) {
$this->disposition |= BACKGROUND_TILE;
} else {
$this->disposition &= ~BACKGROUND_TILE;
}
}
}
......@@ -79,7 +79,6 @@ class File extends Memcached_DataObject
&& ('text/html' === substr($redir_data['type'], 0, 9))
&& ($oembed_data = File_oembed::_getOembed($given_url))
&& isset($oembed_data['json'])) {
File_oembed::saveNew($oembed_data['json'], $file_id);
}
return $x;
......@@ -98,7 +97,6 @@ class File extends Memcached_DataObject
if ($redir_url === $given_url) {
$x = File::saveNew($redir_data, $given_url);
$file_id = $x->id;
} else {
$x = File::processNew($redir_url, $notice_id);
$file_id = $x->id;
......
......@@ -53,7 +53,7 @@ class File_oembed extends Memcached_DataObject