mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-20 07:15:13 +00:00
Merge branch 'nomadic' of codeberg.org:streams/streams into nomadic
This commit is contained in:
commit
af8f6e7461
2 changed files with 21 additions and 18 deletions
|
@ -9,6 +9,7 @@ use Code\Lib\Apps;
|
||||||
use Code\Lib\Activity;
|
use Code\Lib\Activity;
|
||||||
use Code\Access\AccessControl;
|
use Code\Access\AccessControl;
|
||||||
use Code\Access\PermissionLimits;
|
use Code\Access\PermissionLimits;
|
||||||
|
use Code\Lib\Channel;
|
||||||
use Code\Lib\Time;
|
use Code\Lib\Time;
|
||||||
use Code\Web\HTTPHeaders;
|
use Code\Web\HTTPHeaders;
|
||||||
use Code\Daemon\Run;
|
use Code\Daemon\Run;
|
||||||
|
@ -266,7 +267,7 @@ function photo_upload($channel, $observer, $args)
|
||||||
'rel' => 'alternate',
|
'rel' => 'alternate',
|
||||||
'mediaType' => $type,
|
'mediaType' => $type,
|
||||||
'summary' => $alt_desc,
|
'summary' => $alt_desc,
|
||||||
'href' => z_root() . '/photo/' . $photo_hash . '-0.' . $ph->getExt(),
|
'href' => Channel::getDidResolver($channel) . '/photo/' . $photo_hash . '-0.' . $ph->getExt(),
|
||||||
'width' => $width,
|
'width' => $width,
|
||||||
'height' => $height
|
'height' => $height
|
||||||
];
|
];
|
||||||
|
@ -290,7 +291,7 @@ function photo_upload($channel, $observer, $args)
|
||||||
'rel' => 'alternate',
|
'rel' => 'alternate',
|
||||||
'mediaType' => $type,
|
'mediaType' => $type,
|
||||||
'summary' => $alt_desc,
|
'summary' => $alt_desc,
|
||||||
'href' => z_root() . '/photo/' . $photo_hash . '-1.' . $ph->getExt(),
|
'href' => Channel::getDidResolver($channel) . '/photo/' . $photo_hash . '-1.' . $ph->getExt(),
|
||||||
'width' => $ph->getWidth(),
|
'width' => $ph->getWidth(),
|
||||||
'height' => $ph->getHeight()
|
'height' => $ph->getHeight()
|
||||||
];
|
];
|
||||||
|
@ -309,7 +310,7 @@ function photo_upload($channel, $observer, $args)
|
||||||
'rel' => 'alternate',
|
'rel' => 'alternate',
|
||||||
'mediaType' => $type,
|
'mediaType' => $type,
|
||||||
'summary' => $alt_desc,
|
'summary' => $alt_desc,
|
||||||
'href' => z_root() . '/photo/' . $photo_hash . '-2.' . $ph->getExt(),
|
'href' => Channel::getDidResolver($channel) . '/photo/' . $photo_hash . '-2.' . $ph->getExt(),
|
||||||
'width' => $ph->getWidth(),
|
'width' => $ph->getWidth(),
|
||||||
'height' => $ph->getHeight()
|
'height' => $ph->getHeight()
|
||||||
];
|
];
|
||||||
|
@ -328,7 +329,7 @@ function photo_upload($channel, $observer, $args)
|
||||||
'rel' => 'alternate',
|
'rel' => 'alternate',
|
||||||
'mediaType' => $type,
|
'mediaType' => $type,
|
||||||
'summary' => $alt_desc,
|
'summary' => $alt_desc,
|
||||||
'href' => z_root() . '/photo/' . $photo_hash . '-3.' . $ph->getExt(),
|
'href' => Channel::getDidResolver($channel) . '/photo/' . $photo_hash . '-3.' . $ph->getExt(),
|
||||||
'width' => $ph->getWidth(),
|
'width' => $ph->getWidth(),
|
||||||
'height' => $ph->getHeight()
|
'height' => $ph->getHeight()
|
||||||
];
|
];
|
||||||
|
@ -356,7 +357,7 @@ function photo_upload($channel, $observer, $args)
|
||||||
'type' => 'Link',
|
'type' => 'Link',
|
||||||
'rel' => 'about',
|
'rel' => 'about',
|
||||||
'mediaType' => 'text/html',
|
'mediaType' => 'text/html',
|
||||||
'href' => z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo_hash
|
'href' => Channel::getDidResolver($channel) . '/photos/image/' . $photo_hash
|
||||||
];
|
];
|
||||||
|
|
||||||
$item_hidden = (($visible) ? 0 : 1 );
|
$item_hidden = (($visible) ? 0 : 1 );
|
||||||
|
@ -389,12 +390,12 @@ function photo_upload($channel, $observer, $args)
|
||||||
$height = $url[1]['height'];
|
$height = $url[1]['height'];
|
||||||
$tag = (($r1) ? '[zmg width="' . $width . '" height="' . $height . '"' . $alt . ']' : '[zmg' . $alt . ']');
|
$tag = (($r1) ? '[zmg width="' . $width . '" height="' . $height . '"' . $alt . ']' : '[zmg' . $alt . ']');
|
||||||
|
|
||||||
$author_link = '[zrl=' . z_root() . '/channel/' . $channel['channel_address'] . ']' . $channel['channel_name'] . '[/zrl]';
|
$author_link = '[zrl=' . Channel::getDidResolver($channel) . ']' . $channel['channel_name'] . '[/zrl]';
|
||||||
|
|
||||||
$photo_link = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo_hash . ']' . t('a new photo') . '[/zrl]';
|
$photo_link = '[zrl=' . Channel::getDidResolver($channel) . '/photos/image/' . $photo_hash . ']' . t('a new photo') . '[/zrl]';
|
||||||
|
|
||||||
if (array_path_exists('/directory/hash',$args)) {
|
if (array_path_exists('/directory/hash',$args)) {
|
||||||
$album_link = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/album/' . $args['directory']['hash'] . ']' . ((strlen($album)) ? $album : '/') . '[/zrl]';
|
$album_link = '[zrl=' . Channel::getDidResolver($channel) . '/photos/album/' . $args['directory']['hash'] . ']' . ((strlen($album)) ? $album : '/') . '[/zrl]';
|
||||||
$activity_format = sprintf(t('%1$s posted %2$s to %3$s', 'photo_upload'), $author_link, $photo_link, $album_link);
|
$activity_format = sprintf(t('%1$s posted %2$s to %3$s', 'photo_upload'), $author_link, $photo_link, $album_link);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -405,8 +406,8 @@ function photo_upload($channel, $observer, $args)
|
||||||
|
|
||||||
// If uploaded into a post, this is the text that is returned to the webapp for inclusion in the post.
|
// If uploaded into a post, this is the text that is returned to the webapp for inclusion in the post.
|
||||||
|
|
||||||
$obj_body = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo_hash . ']'
|
$obj_body = '[zrl=' . Channel::getDidResolver($channel) . '/photos/image/' . $photo_hash . ']'
|
||||||
. $tag . z_root() . "/photo/{$photo_hash}-{$scale}." . $ph->getExt() . '[/zmg]'
|
. $tag . Channel::getDidResolver($channel) . "/photo/{$photo_hash}-{$scale}." . $ph->getExt() . '[/zmg]'
|
||||||
. '[/zrl]';
|
. '[/zrl]';
|
||||||
|
|
||||||
$attribution = (Activity::actorEncode(($visitor) ?: $channel, false));
|
$attribution = (Activity::actorEncode(($visitor) ?: $channel, false));
|
||||||
|
@ -430,7 +431,7 @@ function photo_upload($channel, $observer, $args)
|
||||||
|
|
||||||
if ($public) {
|
if ($public) {
|
||||||
$object['to'] = [ ACTIVITY_PUBLIC_INBOX ];
|
$object['to'] = [ ACTIVITY_PUBLIC_INBOX ];
|
||||||
$object['cc'] = [ z_root() . '/followers/' . $channel['channel_address'] ];
|
$object['cc'] = [ Channel::getDidResolver($channel) . '/followers' ];
|
||||||
} else {
|
} else {
|
||||||
$object['to'] = Activity::map_acl(array_merge($ac, ['item_private' => 1]));
|
$object['to'] = Activity::map_acl(array_merge($ac, ['item_private' => 1]));
|
||||||
}
|
}
|
||||||
|
@ -438,8 +439,8 @@ function photo_upload($channel, $observer, $args)
|
||||||
$target = [
|
$target = [
|
||||||
'type' => 'orderedCollection',
|
'type' => 'orderedCollection',
|
||||||
'name' => ((strlen($album)) ? $album : '/'),
|
'name' => ((strlen($album)) ? $album : '/'),
|
||||||
'id' => z_root() . '/album/' . $channel['channel_address'] . ((isset($args['folder'])) ? '/' . $args['folder'] : EMPTY_STR),
|
'id' => Channel::getDidResolver($channel) . '/album/' . ((isset($args['folder'])) ? '/' . $args['folder'] : EMPTY_STR),
|
||||||
'attributedTo' => z_root() . '/channel/' . $channel['channel_address'],
|
'attributedTo' => Channel::getDidResolver($channel),
|
||||||
];
|
];
|
||||||
|
|
||||||
$post_tags = [];
|
$post_tags = [];
|
||||||
|
@ -515,7 +516,7 @@ function photo_upload($channel, $observer, $args)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$uuid = new_uuid();
|
$uuid = new_uuid();
|
||||||
$mid = z_root() . '/item/' . $uuid;
|
$mid = Channel::getDidResolver($channel) . '/item/' . $uuid;
|
||||||
|
|
||||||
$object['id'] = $mid;
|
$object['id'] = $mid;
|
||||||
|
|
||||||
|
@ -559,7 +560,7 @@ function photo_upload($channel, $observer, $args)
|
||||||
$arr['term'] = $post_tags;
|
$arr['term'] = $post_tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
$arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . urlencode($arr['mid']);
|
$arr['plink'] = $arr['mid'];
|
||||||
|
|
||||||
if ($lat || $lon) {
|
if ($lat || $lon) {
|
||||||
$arr['lat'] = floatval($lat);
|
$arr['lat'] = floatval($lat);
|
||||||
|
@ -721,7 +722,7 @@ function photos_albums_list($channel, $observer, $sort_key = 'display_path', $di
|
||||||
'shorttext' => (($album['album']) ? ellipsify($album['album'], 28) : '/'),
|
'shorttext' => (($album['album']) ? ellipsify($album['album'], 28) : '/'),
|
||||||
'jstext' => (($album['album']) ? addslashes($album['album']) : '/'),
|
'jstext' => (($album['album']) ? addslashes($album['album']) : '/'),
|
||||||
'total' => $album['total'],
|
'total' => $album['total'],
|
||||||
'url' => z_root() . '/photos/' . $channel['channel_address'] . '/album/' . $album['folder'],
|
'url' => Channel::getDidResolver($channel) . '/photos/album/' . $album['folder'],
|
||||||
'urlencode' => urlencode($album['album']),
|
'urlencode' => urlencode($album['album']),
|
||||||
'bin2hex' => $album['folder']
|
'bin2hex' => $album['folder']
|
||||||
];
|
];
|
||||||
|
@ -795,7 +796,7 @@ function photos_list_photos($channel, $observer, $album = '')
|
||||||
|
|
||||||
if ($r) {
|
if ($r) {
|
||||||
for ($x = 0; $x < count($r); $x++) {
|
for ($x = 0; $x < count($r); $x++) {
|
||||||
$r[$x]['src'] = z_root() . '/photo/' . $r[$x]['resource_id'] . '-' . $r[$x]['imgscale'];
|
$r[$x]['src'] = Channel::getDidResolver($channel) . '/photo/' . $r[$x]['resource_id'] . '-' . $r[$x]['imgscale'];
|
||||||
}
|
}
|
||||||
$ret['success'] = true;
|
$ret['success'] = true;
|
||||||
$ret['photos'] = $r;
|
$ret['photos'] = $r;
|
||||||
|
|
|
@ -78,6 +78,8 @@ class Apresolver extends Controller
|
||||||
|
|
||||||
$partialPaths = [
|
$partialPaths = [
|
||||||
'/files/' => '/cloud/' . $channel['channel_address'],
|
'/files/' => '/cloud/' . $channel['channel_address'],
|
||||||
|
'/photos/' => '/photos/' . $channel['channel_address'],
|
||||||
|
'/album/' => '/album/' . $channel['channel_address'],
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($systemPaths as $index => $localPath) {
|
foreach ($systemPaths as $index => $localPath) {
|
||||||
|
@ -89,7 +91,7 @@ class Apresolver extends Controller
|
||||||
foreach ($partialPaths as $index => $localPath) {
|
foreach ($partialPaths as $index => $localPath) {
|
||||||
if (str_starts_with($path, $index)) {
|
if (str_starts_with($path, $index)) {
|
||||||
$suffix = substr($path, strlen($index));
|
$suffix = substr($path, strlen($index));
|
||||||
return $localPath . $suffix;
|
return $localPath . '/' . ltrim($suffix, '/');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $path;
|
return $path;
|
||||||
|
|
Loading…
Reference in a new issue