forked from GNUsocial/gnu-social
[CORE][UI] Made attachment actions and its subactions be able to identify attachments by id and by filehash. Changed the url stored in the DB to be attachment//view
This commit is contained in:
parent
9536f2a909
commit
aa5c6bbf08
@ -1,4 +1,4 @@
|
||||
# GNU social 1.24.x
|
||||
# GNU social 1.25.x
|
||||
(c) 2010-2019 Free Software Foundation, Inc
|
||||
|
||||
This is the README file for GNU social, the free
|
||||
|
@ -59,8 +59,10 @@ class AttachmentAction extends ManagedAction
|
||||
{
|
||||
parent::prepare($args);
|
||||
|
||||
if ($id = $this->trimmed('attachment')) {
|
||||
if (!empty($id = $this->trimmed('attachment'))) {
|
||||
$this->attachment = File::getKV($id);
|
||||
} elseif (!empty($filehash = $this->trimmed('filehash'))) {
|
||||
$this->attachment = File::getByHash($filehash);
|
||||
}
|
||||
|
||||
if (!$this->attachment instanceof File) {
|
||||
|
@ -614,7 +614,7 @@ class File extends Managed_DataObject
|
||||
if ($use_local !== false) {
|
||||
if (is_string($this->filename) || !empty($this->filename)) {
|
||||
// A locally stored file, so let's generate a URL for our instance.
|
||||
return getAttachmentViewUrl();
|
||||
return $this->getAttachmentViewUrl();
|
||||
}
|
||||
if ($use_local) {
|
||||
// if the file wasn't stored locally (has filename) and we require a local URL
|
||||
|
@ -32,7 +32,7 @@ defined('GNUSOCIAL') || die();
|
||||
define('GNUSOCIAL_ENGINE', 'GNU social');
|
||||
define('GNUSOCIAL_ENGINE_URL', 'https://www.gnu.org/software/social/');
|
||||
|
||||
define('GNUSOCIAL_BASE_VERSION', '1.24.1');
|
||||
define('GNUSOCIAL_BASE_VERSION', '1.25.0');
|
||||
define('GNUSOCIAL_LIFECYCLE', 'dev'); // 'dev', 'alpha[0-9]+', 'beta[0-9]+', 'rc[0-9]+', 'release'
|
||||
|
||||
define('GNUSOCIAL_VERSION', GNUSOCIAL_BASE_VERSION . '-' . GNUSOCIAL_LIFECYCLE);
|
||||
|
@ -161,7 +161,7 @@ class MediaFile
|
||||
// Well, let's just continue below.
|
||||
}
|
||||
|
||||
$fileurl = File::url($this->filename);
|
||||
$fileurl = common_local_url('attachment_view', array('filehash' => $this->filehash));
|
||||
|
||||
$file = new File;
|
||||
|
||||
|
@ -219,21 +219,17 @@ class Router
|
||||
array('q' => '.+'));
|
||||
$m->connect('search/notice/rss', array('action' => 'noticesearchrss'));
|
||||
|
||||
$m->connect('attachment/:attachment',
|
||||
array('action' => 'attachment'),
|
||||
array('attachment' => '[0-9]+'));
|
||||
|
||||
$m->connect('attachment/:attachment/view',
|
||||
array('action' => 'attachment_view'),
|
||||
array('attachment' => '[0-9]+'));
|
||||
|
||||
$m->connect('attachment/:attachment/download',
|
||||
array('action' => 'attachment_download'),
|
||||
array('attachment' => '[0-9]+'));
|
||||
|
||||
$m->connect('attachment/:attachment/thumbnail',
|
||||
array('action' => 'attachment_thumbnail'),
|
||||
array('attachment' => '[0-9]+'));
|
||||
foreach (['' => 'attachment',
|
||||
'/view' => 'attachment_view',
|
||||
'/download' => 'attachment_download',
|
||||
'/thumbnail' => 'attachment_thumbnail'] as $postfix => $action) {
|
||||
foreach (['attachment' => '[0-9]+',
|
||||
'filehash' => '[A-Za-z0-9._-]+'] as $type => $match) {
|
||||
$m->connect("attachment/:{$type}{$postfix}",
|
||||
['action' => $action],
|
||||
[$type => $match]);
|
||||
}
|
||||
}
|
||||
|
||||
$m->connect('notice/new?replyto=:replyto&inreplyto=:inreplyto',
|
||||
array('action' => 'newnotice'),
|
||||
|
Loading…
Reference in New Issue
Block a user