Merge remote-tracking branch 'upstream/nightly' into nightly

This commit is contained in:
www-data 2016-05-17 14:00:39 +02:00
commit 9545219a23
8 changed files with 38 additions and 12 deletions

View File

@ -0,0 +1,20 @@
<?php
if (!defined('GNUSOCIAL')) { exit(1); }
/**
* Download notice attachment
*
* @category Personal
* @package GNUsocial
* @author Mikael Nordfeldth <mmn@hethane.se>
* @license https://www.gnu.org/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link https:/gnu.io/social
*/
class Attachment_downloadAction extends AttachmentAction
{
public function showPage()
{
common_redirect($this->attachment->getUrl(), 302);
}
}

View File

@ -478,6 +478,8 @@ class File extends Managed_DataObject
* @param $width int Max width of thumbnail in pixels. (if null, use common_config values) * @param $width int Max width of thumbnail in pixels. (if null, use common_config values)
* @param $height int Max height of thumbnail in pixels. (if null, square-crop to $width) * @param $height int Max height of thumbnail in pixels. (if null, square-crop to $width)
* @param $crop bool Crop to the max-values' aspect ratio * @param $crop bool Crop to the max-values' aspect ratio
* @param $force_still bool Don't allow fallback to showing original (such as animated GIF)
* @param $upscale mixed Whether or not to scale smaller images up to larger thumbnail sizes. (null = site default)
* *
* @return File_thumbnail * @return File_thumbnail
* *
@ -498,7 +500,7 @@ class File extends Managed_DataObject
return File_thumbnail::byFile($this); return File_thumbnail::byFile($this);
} catch (NoResultException $e) { } catch (NoResultException $e) {
// and if it's not a remote file, it'll be safe to use the locally stored File // and if it's not a remote file, it'll be safe to use the locally stored File
throw new UseFileAsThumbnailException($this->id); throw new UseFileAsThumbnailException($this);
} }
} }
} }

View File

@ -114,7 +114,6 @@ class AccountMover extends QueueHandler
$svcDocUrl = $link->href; $svcDocUrl = $link->href;
if (isset($link['http://apinamespace.org/atom/username'])) { if (isset($link['http://apinamespace.org/atom/username'])) {
$username = $link['http://apinamespace.org/atom/username']; $username = $link['http://apinamespace.org/atom/username'];
break;
} }
} }

View File

@ -132,7 +132,7 @@ class ImageFile
// First some mimetype specific exceptions // First some mimetype specific exceptions
switch ($file->mimetype) { switch ($file->mimetype) {
case 'image/svg+xml': case 'image/svg+xml':
throw new UseFileAsThumbnailException($file->id); throw new UseFileAsThumbnailException($file);
} }
// And we'll only consider it an image if it has such a media type // And we'll only consider it an image if it has such a media type
@ -282,7 +282,11 @@ class ImageFile
} }
if (!file_exists($outpath)) { if (!file_exists($outpath)) {
throw new UseFileAsThumbnailException($this->id); if ($this->fileRecord instanceof File) {
throw new UseFileAsThumbnailException($this->fileRecord);
} else {
throw new UnsupportedMediaException('No local File object exists for ImageFile.');
}
} }
return $outpath; return $outpath;
@ -544,7 +548,7 @@ class ImageFile
} }
fclose($fh); fclose($fh);
return $count > 1; return $count >= 1; // number of animated frames apart from the original image
} }
public function getFileThumbnail($width, $height, $crop, $upscale=false) public function getFileThumbnail($width, $height, $crop, $upscale=false)

View File

@ -223,6 +223,10 @@ class Router
array('action' => 'attachment'), array('action' => 'attachment'),
array('attachment' => '[0-9]+')); array('attachment' => '[0-9]+'));
$m->connect('attachment/:attachment/download',
array('action' => 'attachment_download'),
array('attachment' => '[0-9]+'));
$m->connect('attachment/:attachment/thumbnail', $m->connect('attachment/:attachment/thumbnail',
array('action' => 'attachment_thumbnail'), array('action' => 'attachment_thumbnail'),
array('attachment' => '[0-9]+')); array('attachment' => '[0-9]+'));

View File

@ -34,13 +34,9 @@ class UseFileAsThumbnailException extends UnsupportedMediaException
{ {
public $file = null; public $file = null;
public function __construct($file_id) public function __construct(File $file)
{ {
$this->file = File::getKV('id', $file_id); $this->file = $file;
if (!$this->file instanceof File) {
throw new ServerException('No File ID supplied to exception');
}
parent::__construct('Thumbnail not generated', $this->file->getPath()); parent::__construct('Thumbnail not generated', $this->file->getPath());
} }
} }

View File

@ -219,7 +219,6 @@ class UserActivityStream extends AtomUserNoticeFeed
} }
} catch (Exception $e) { } catch (Exception $e) {
common_log(LOG_ERR, $e->getMessage()); common_log(LOG_ERR, $e->getMessage());
continue;
} }
} }
} }

View File

@ -851,6 +851,8 @@ clear:both;
} }
#attachment_view img, #attachment_view .attachment_player { #attachment_view img, #attachment_view .attachment_player {
height: auto;
width: auto;
max-width:480px; max-width:480px;
max-height:480px; max-height:480px;
} }