Browse Source

Remove the public/picture/ directory to use only the main index.php entrypoint

Cleanup and simplify the avatar and picture handling code
Add a CleatTemplatesCache command and call it when starting the daemon
pull/1228/head
Timothée Jaussoin 2 years ago
parent
commit
dbf6af128d
  1. 6
      CHANGELOG.md
  2. 12
      INSTALL.md
  3. 4
      app/Conference.php
  4. 10
      app/Contact.php
  5. 6
      app/Info.php
  6. 10
      app/Roster.php
  7. 92
      app/helpers/UtilsHelper.php
  8. 2
      app/widgets/AdminSessions/adminsessions.tpl
  9. 2
      app/widgets/Avatar/_avatar.tpl
  10. 2
      app/widgets/Avatar/_avatar_form.tpl
  11. 1
      app/widgets/AvatarPlaceholder/AvatarPlaceholder.php
  12. 2
      app/widgets/Blog/Blog.php
  13. 4
      app/widgets/Blog/blog.tpl
  14. 4
      app/widgets/Chat/Chat.php
  15. 2
      app/widgets/Chat/_chat_bubble.tpl
  16. 2
      app/widgets/Chat/_chat_empty.tpl
  17. 2
      app/widgets/Chat/_chat_explore.tpl
  18. 6
      app/widgets/Chat/_chat_header.tpl
  19. 2
      app/widgets/Chats/_chats_item.tpl
  20. 2
      app/widgets/CommunitiesServer/_communitiesserver_ticket.tpl
  21. 4
      app/widgets/CommunityAffiliations/_communityaffiliations.tpl
  22. 2
      app/widgets/CommunityAffiliations/_communityaffiliations_config_content.tpl
  23. 2
      app/widgets/CommunityAffiliations/_communityaffiliations_public_subscriptions_list.tpl
  24. 2
      app/widgets/CommunityAffiliations/_communityaffiliations_subscriptions.tpl
  25. 2
      app/widgets/CommunityConfig/_communityconfig_avatar.tpl
  26. 2
      app/widgets/CommunityData/_communitydata_card.tpl
  27. 2
      app/widgets/CommunityHeader/_communityheader.tpl
  28. 2
      app/widgets/ContactActions/_contactactions_add.tpl
  29. 2
      app/widgets/ContactActions/_contactactions_drawer.tpl
  30. 2
      app/widgets/ContactData/_contactdata_card.tpl
  31. 2
      app/widgets/ContactHeader/_contactheader.tpl
  32. 2
      app/widgets/ContactSubscriptions/_contactsubscriptions.tpl
  33. 8
      app/widgets/Login/login.tpl
  34. 6
      app/widgets/Menu/Menu.php
  35. 2
      app/widgets/Notifications/Notifications.php
  36. 4
      app/widgets/Notifications/_notifications.tpl
  37. 6
      app/widgets/Post/_post.tpl
  38. 4
      app/widgets/Post/_post_card.tpl
  39. 4
      app/widgets/Post/_post_comments.tpl
  40. 4
      app/widgets/Post/_post_prevnext_back.tpl
  41. 2
      app/widgets/Post/_post_reply.tpl
  42. 4
      app/widgets/Post/_post_ticket.tpl
  43. 2
      app/widgets/Presence/_presence.tpl
  44. 2
      app/widgets/Presence/presence.tpl
  45. 2
      app/widgets/Publish/publish.tpl
  46. 2
      app/widgets/Rooms/Rooms.php
  47. 2
      app/widgets/Rooms/_rooms_room.tpl
  48. 2
      app/widgets/RoomsExplore/_roomsexplore_global.tpl
  49. 2
      app/widgets/RoomsExplore/_roomsexplore_local.tpl
  50. 2
      app/widgets/RoomsUtils/_rooms_avatar.tpl
  51. 8
      app/widgets/RoomsUtils/_rooms_drawer.tpl
  52. 2
      app/widgets/Search/_search_results.tpl
  53. 2
      app/widgets/Search/_search_results_contacts.tpl
  54. 2
      app/widgets/Search/_search_roster.tpl
  55. 4
      app/widgets/SendTo/_sendto_article.tpl
  56. 2
      app/widgets/SendTo/_sendto_share.tpl
  57. 2
      app/widgets/SendTo/_sendto_share_contacts.tpl
  58. 4
      app/widgets/Syndication/Syndication.php
  59. 2
      app/widgets/Visio/Visio.php
  60. 2
      app/widgets/Visio/_visio_dialog.tpl
  61. 2
      app/widgets/Visio/visio.tpl
  62. 60
      composer.lock
  63. 1
      daemon.php
  64. 10
      etc/caddy/Caddyfile
  65. 34
      etc/nginx/conf.d/movim.conf
  66. 12
      public/picture/index.php
  67. 36
      src/Movim/Console/ClearTemplatesCache.php
  68. 13
      src/Movim/Console/CompileStickers.php
  69. 4
      src/Movim/Console/DaemonCommand.php
  70. 5
      src/Movim/Route.php

6
CHANGELOG.md

@ -4,6 +4,12 @@ Movim Changelog
v0.23 (trunk)
---------------------------
v0.22.4
---------------------------
* Remove the public/picture/ directory to use only the main index.php entrypoint
* Cleanup and simplify the avatar and picture handling code
* Add a CleatTemplatesCache command and call it when starting the daemon
v0.22.3
---------------------------
* Fix #1220 Use relative path for public/cache/ for JS and CSS files

12
INSTALL.md

@ -213,17 +213,7 @@ Add this to your `nginx.conf` in the `http` section:
fastcgi_cache_key "$scheme$request_method$host$request_uri";
}
Add the following configuration to your Movim virtual-host to enable the cache:
location /picture {
include fastcgi_params;
add_header X-Cache $upstream_cache_status;
fastcgi_ignore_headers "Cache-Control" "Expires" "Set-Cookie";
fastcgi_cache nginx_cache;
fastcgi_cache_key $request_method$host$request_uri;
fastcgi_cache_valid any 7d;
}
And check the related documentation in our nginx example file [movim.conf](https://github.com/movim/movim/blob/master/etc/nginx/conf.d/movim.conf).
#### On Caddy

4
app/Conference.php

@ -214,10 +214,10 @@ class Conference extends Model
return $subject ? $subject->subject : null;
}
public function getPhoto($size = 'm'): string
public function getPicture($size = 'm'): string
{
return $this->contact
? $this->contact->getPhoto($size)
? $this->contact->getPicture($size)
: avatarPlaceholder($this->name);
}

10
app/Contact.php

@ -126,18 +126,16 @@ class Contact extends Model
unset($this->photobin);
}
public function getPhoto($size = 'm'): string
public function getPicture($size = 'm'): string
{
return (!empty($this->id) && $url = getPhoto($this->id, $size))
? $url
: avatarPlaceholder($this->id);
return getPicture($this->id, $this->id, $size);
}
public function getBanner($size = 'xxl')
{
$banner = !empty($this->id) ? getPhoto($this->id . '_banner', $size) : null;
$banner = !empty($this->id) ? getPicture($this->id . '_banner', $size) : null;
return $banner == null ? $this->getPhoto($size) : $banner;
return $banner == null ? $this->getPicture($size) : $banner;
}
public function setLocation($item)

6
app/Info.php

@ -201,11 +201,9 @@ class Info extends Model
return $identityType ? $identityType->type : null;
}
public function getPhoto($size = 'm'): string
public function getPicture($size = 'm'): string
{
return (isset($this->attributes['avatarhash']) && $url = getPhoto($this->attributes['avatarhash'], $size))
? $url
: avatarPlaceholder($this->node);
return getPicture($this->attributes['avatarhash'], $this->node, $size);
}
public function getDeviceIcon()

10
app/Roster.php

@ -91,18 +91,16 @@ class Roster extends Model
cleanupId($this->group);
}
public function getPhoto($size = 'm'): string
public function getPicture($size = 'm'): string
{
return (!empty($this->jid) && $url = getPhoto($this->jid, $size))
? $url
: avatarPlaceholder($this->truename);
return getPicture($this->jid, $this->truename, $size);
}
public function getBanner($size = 'xxl')
{
$banner = !empty($this->id) ? getPhoto($this->id . '_banner', $size) : null;
$banner = !empty($this->id) ? getPicture($this->id . '_banner', $size) : null;
return $banner == null ? $this->getPhoto($size) : $banner;
return $banner == null ? $this->getPicture($size) : $banner;
}
public function getTruenameAttribute()

92
app/helpers/UtilsHelper.php

@ -104,7 +104,7 @@ function listOpcacheCompilableFiles(): array
$files = [];
foreach (['vendor', 'app', 'src'] as $dir) {
$directory = new \RecursiveDirectoryIterator(DOCUMENT_ROOT.'/'. $dir);
$directory = new \RecursiveDirectoryIterator(DOCUMENT_ROOT . '/' . $dir);
$iterator = new \RecursiveIteratorIterator($directory);
$regex = new \RegexIterator($iterator, '/^.+\.php$/i', \RecursiveRegexIterator::GET_MATCH);
@ -162,9 +162,9 @@ function getClientTypes()
*/
function resolveInfos($postCollection)
{
$serverNodes = $postCollection->map(function($item) {
$serverNodes = $postCollection->map(function ($item) {
return ['server' => $item->server, 'node' => $item->node];
})->unique(fn ($item) => $item['server'].$item['node']);
})->unique(fn ($item) => $item['server'] . $item['node']);
if ($serverNodes->isNotEmpty()) {
$first = $serverNodes->first();
@ -180,10 +180,10 @@ function resolveInfos($postCollection)
]);
});
$infos = $infos->get()->keyBy(fn ($item) => $item['server'].$item['node']);
$infos = $infos->get()->keyBy(fn ($item) => $item['server'] . $item['node']);
$postCollection->map(function($item) use ($infos) {
$item->info = $infos->get($item->server.$item->node);
$postCollection->map(function ($item) use ($infos) {
$item->info = $infos->get($item->server . $item->node);
return $item;
});
@ -191,7 +191,9 @@ function resolveInfos($postCollection)
}
}
/** Form to array */
/**
* Form to array
*/
function formToArray(stdClass $form): array
{
$values = [];
@ -204,9 +206,9 @@ function formToArray(stdClass $form): array
}
/**
* Return a picture with a specific size
* Return the picture or fallback to the placeholder
*/
function getPhoto(string $key, string $size = 'm'): ?string
function getPicture(?string $key, string $placeholder, string $size = 'm')
{
$sizes = [
'xxl' => [1280, 300],
@ -217,7 +219,9 @@ function getPhoto(string $key, string $size = 'm'): ?string
'o' => [false, false]
];
return Image::getOrCreate($key, $sizes[$size][0], $sizes[$size][1]);
return (!empty($key) && $url = Image::getOrCreate($key, $sizes[$size][0], $sizes[$size][1]))
? $url
: avatarPlaceholder($placeholder);
}
/**
@ -634,7 +638,6 @@ function generateKey($size)
return $hash;
}
//define('DEFAULT_HTTP_USER_AGENT', 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://google.com/bot.html)');
define('DEFAULT_HTTP_USER_AGENT', 'Mozilla/5.0 (Android 4.4; Mobile; rv:41.0) Gecko/41.0 Firefox/41.0');
/**
@ -777,25 +780,6 @@ function protectPicture($url)
return \Movim\Route::urlize('picture', false, ['type' => 'picture', 'url' => urlencode($url)]);
}
/*
* @desc Copy the stickers in the public cache
*/
function compileStickers(): int
{
$count = 0;
foreach (glob(PUBLIC_PATH . '/stickers/*/*.png', GLOB_NOSORT) as $path) {
$key = basename($path, '.png');
if ($key != 'icon') {
$count++;
copy($path, PUBLIC_CACHE_PATH.hash(Image::$hash, $key).'_o.png');
}
}
return $count;
}
/*
* @desc Translate something
*/
@ -816,10 +800,10 @@ function getBrowser(string $userAgent): ?string
$t = strtolower($userAgent);
$t = ' ' . $t;
if (strpos($t, 'opera' )) return 'Opera';
elseif (strpos($t, 'edge' )) return 'Edge';
elseif (strpos($t, 'chrome' )) return 'Chrome';
elseif (strpos($t, 'safari' )) return 'Safari';
if (strpos($t, 'opera')) return 'Opera';
elseif (strpos($t, 'edge')) return 'Edge';
elseif (strpos($t, 'chrome')) return 'Chrome';
elseif (strpos($t, 'safari')) return 'Safari';
elseif (strpos($t, 'firefox')) return 'Firefox';
}
@ -828,27 +812,27 @@ function getBrowser(string $userAgent): ?string
*/
function getPlatform(string $userAgent): ?string
{
$oses = [
'/windows nt 10/i' => 'Windows 10',
'/windows nt 6.3/i' => 'Windows 8.1',
'/windows nt 6.2/i' => 'Windows 8',
'/windows nt 6.1/i' => 'Windows 7',
'/windows nt 6.0/i' => 'Windows Vista',
'/macintosh|mac os x/i' => 'Mac OS X',
'/mac_powerpc/i' => 'Mac OS 9',
'/linux/i' => 'Linux',
'/ubuntu/i' => 'Ubuntu',
'/iphone/i' => 'iPhone',
'/ipod/i' => 'iPod',
'/ipad/i' => 'iPad',
'/android/i' => 'Android',
'/blackberry/i' => 'BlackBerry',
'/webos/i' => 'Mobile'
$oses = [
'/windows nt 10/i' => 'Windows 10',
'/windows nt 6.3/i' => 'Windows 8.1',
'/windows nt 6.2/i' => 'Windows 8',
'/windows nt 6.1/i' => 'Windows 7',
'/windows nt 6.0/i' => 'Windows Vista',
'/macintosh|mac os x/i' => 'Mac OS X',
'/mac_powerpc/i' => 'Mac OS 9',
'/linux/i' => 'Linux',
'/ubuntu/i' => 'Ubuntu',
'/iphone/i' => 'iPhone',
'/ipod/i' => 'iPod',
'/ipad/i' => 'iPad',
'/android/i' => 'Android',
'/blackberry/i' => 'BlackBerry',
'/webos/i' => 'Mobile'
];
foreach ($oses as $regex => $value) {
if (preg_match($regex, $userAgent)) {
foreach ($oses as $regex => $value) {
if (preg_match($regex, $userAgent)) {
return $value;
}
}
}
}
}

2
app/widgets/AdminSessions/adminsessions.tpl

@ -17,7 +17,7 @@
<i class="material-icons">chevron_right</i>
</span>
<span class="primary icon bubble">
<img src="{$user->getPhoto()}">
<img src="{$user->getPicture()}">
</span>
<div>
<p class="line" title="{$user->id}">

2
app/widgets/Avatar/_avatar.tpl

@ -2,7 +2,7 @@
<li class="block active" onclick="Avatar_ajaxGetForm()">
<span
class="primary icon bubble color {$me->jid|stringToColor}"
style="background-image: url({$me->getPhoto()})">
style="background-image: url({$me->getPicture()})">
</span>
<span class="control icon gray">
<i class="material-icons">chevron_right</i>

2
app/widgets/Avatar/_avatar_form.tpl

@ -1,6 +1,6 @@
<section class="scroll">
<form name="avatarform">
<img class="avatar" src="{$me->getPhoto('o') ?? ''}">
<img class="avatar" src="{$me->getPicture('o') ?? ''}">
<div class="placeholder">
<i class="material-icons">image</i>
<h1>{$c->__('avatar.missing')}</h1>

1
app/widgets/AvatarPlaceholder/AvatarPlaceholder.php

@ -7,6 +7,7 @@ class AvatarPlaceholder extends \Movim\Widget\Base
public function display()
{
$id = urldecode($this->get('id'));
$size = $this->get('size');
$letters = firstLetterCapitalize((new Slugify())->slugify($id));
header_remove('Content-Type');

2
app/widgets/Blog/Blog.php

@ -87,7 +87,7 @@ class Blog extends Base
$this->title = __('blog.title', $this->_contact->truename);
$this->description = $this->_contact->description;
$avatar = $this->_contact->getPhoto('l');
$avatar = $this->_contact->getPicture('l');
if ($avatar) {
$this->image = $avatar;
}

4
app/widgets/Blog/blog.tpl

@ -17,7 +17,7 @@
<i class="material-icons">person</i>
</span>
<span class="primary icon bubble on_mobile">
<img src="{$contact->getPhoto('m')}">
<img src="{$contact->getPicture('m')}">
</span>
<span class="control icon active" onclick="MovimUtils.openInNew('{$c->route('feed', $contact->jid)}')">
<i class="material-icons">rss_feed</i>
@ -63,7 +63,7 @@
<li>
{if="$item"}
<span class="primary icon bubble">
<img src="{$item->getPhoto('m')}"/>
<img src="{$item->getPicture('m')}"/>
</span>
{else}
<span class="primary icon gray">

4
app/widgets/Chat/Chat.php

@ -197,7 +197,7 @@ class Chat extends \Movim\Widget\Base
$message->encrypted && is_array($message->omemoheader)
? "🔒 " . substr($message->omemoheader['payload'], 0, strlen($message->omemoheader['payload']) / 2)
: $rawbody,
$contact->getPhoto(),
$contact->getPicture(),
4,
$this->route('chat', $contact->jid),
null,
@ -220,7 +220,7 @@ class Chat extends \Movim\Widget\Base
? $conference->name
: $from,
$message->resource . ': ' . $rawbody,
$conference->getPhoto(),
$conference->getPicture(),
4,
$this->route('chat', [$contact->jid, 'room'])
);

2
app/widgets/Chat/_chat_bubble.tpl

@ -7,7 +7,7 @@
{if="$me == null"}
<a href="#" onclick="ChatActions_ajaxGetContact('{$contact->jid|echapJS}')">
{/if}
<img src="{$contact->getPhoto()}">
<img src="{$contact->getPicture()}">
{if="$me == null"}</a>{/if}
</span>
{/if}

2
app/widgets/Chat/_chat_empty.tpl

@ -18,7 +18,7 @@
{if="$value->presence"}
status {$value->presence->presencekey}
{/if}">
<img src="{$value->getPhoto()}">
<img src="{$value->getPicture()}">
</span>
<div>
<p class="line" title="{$value->truename}">

2
app/widgets/Chat/_chat_explore.tpl

@ -27,7 +27,7 @@
<i class="material-icons">comment</i>
</span>
<span class="primary icon bubble {if="$value->value"}status {$presencestxt[$value->value]}{/if}">
<img src="{$value->getPhoto('m')}">
<img src="{$value->getPicture('m')}">
</span>
<div>
<p class="normal line">

6
app/widgets/Chat/_chat_header.tpl

@ -10,7 +10,7 @@
<span class="primary icon bubble active
{if="!$conference->connected"}disabled{/if}"
onclick="RoomsUtils_ajaxShowSubject('{$jid|echapJS}')">
<img src="{$conference->getPhoto()}">
<img src="{$conference->getPicture()}">
{else}
<span class="primary icon bubble active"
onclick="RoomsUtils_ajaxShowSubject('{$jid|echapJS}')">
@ -37,7 +37,7 @@
title="{$c->__('page.communities')} · {$related->name}"
onclick="MovimUtils.reload('{$c->route('community', [$related->server, $related->node])}')"
class="control icon bubble active small">
<img src="{$related->getPhoto('m')}"/>
<img src="{$related->getPicture('m')}"/>
</span>
{/if}
@ -181,7 +181,7 @@
<span class="primary icon bubble active
{if="$roster && $roster->presence"}status {$roster->presence->presencekey}{/if}"
onclick="ChatActions_ajaxGetContact('{$contact->jid|echapJS}')">
<img src="{if="$roster"}{$roster->getPhoto()}{else}{$contact->getPhoto()}{/if}">
<img src="{if="$roster"}{$roster->getPicture()}{else}{$contact->getPicture()}{/if}">
</span>
{$call = false}

2
app/widgets/Chats/_chats_item.tpl

@ -17,7 +17,7 @@
"
{if="$count > 0"}data-counter="{$count}"{/if}
>
<img src="{if="$roster"}{$roster->getPhoto('m')}{else}{$contact->getPhoto('m')}{/if}">
<img src="{if="$roster"}{$roster->getPicture('o')}{else}{$contact->getPicture('o')}{/if}">
</span>
<div>

2
app/widgets/CommunitiesServer/_communitiesserver_ticket.tpl

@ -13,7 +13,7 @@
{/if}
<span class="primary icon thumb">
<img loading="lazy" src="{$community->getPhoto('m')}"/>
<img loading="lazy" src="{$community->getPicture('m')}"/>
</span>
<div>
<p class="line">

4
app/widgets/CommunityAffiliations/_communityaffiliations.tpl

@ -55,7 +55,7 @@
<li title="{$contact->jid}"
onclick="MovimUtils.reload('{$c->route('contact', $contact->jid)}')">
<span class="primary icon bubble">
<img src="{$contact->getPhoto('m')}">
<img src="{$contact->getPicture('m')}">
</span>
<div>
<p>{$contact->truename}</p>
@ -78,7 +78,7 @@
<li title="{$contact->jid}"
onclick="MovimUtils.reload('{$c->route('contact', $contact->jid)}')">
<span class="primary icon bubble">
<img src="{$contact->getPhoto('m')}">
<img src="{$contact->getPicture('m')}">
</span>
<div>
<p>{$contact->truename}</p>

2
app/widgets/CommunityAffiliations/_communityaffiliations_config_content.tpl

@ -7,7 +7,7 @@
{$contact = $c->getContact($value['jid'])}
<li title="{$contact->jid}">
<span class="primary icon bubble">
<img src="{$contact->getPhoto('m')}">
<img src="{$contact->getPicture('m')}">
</span>
<form name="{$contact->jid}">
<input type="hidden" name="jid" value="{$contact->jid}"/>

2
app/widgets/CommunityAffiliations/_communityaffiliations_public_subscriptions_list.tpl

@ -12,7 +12,7 @@
</span>
{if="$value->contact"}
<span class="primary icon bubble small">
<img src="{$value->contact->getPhoto('m')}">
<img src="{$value->contact->getPicture('m')}">
</span>
<div>
<p class="normal">{$value->contact->truename}</p>

2
app/widgets/CommunityAffiliations/_communityaffiliations_subscriptions.tpl

@ -12,7 +12,7 @@
{$contact = $c->getContact($value->jid)}
<li>
<span class="primary icon bubble">
<img src="{$contact->getPhoto('m')}">
<img src="{$contact->getPicture('m')}">
</span>
<div>
<p class="normal line">

2
app/widgets/CommunityConfig/_communityconfig_avatar.tpl

@ -1,6 +1,6 @@
<section class="scroll">
<form name="avatarcommunity">
<img class="avatar" src="{$info->getPhoto('o') ?? ''}">
<img class="avatar" src="{$info->getPicture('o') ?? ''}">
<div class="placeholder">
<i class="material-icons">image</i>
<h1>{$c->__('avatar.missing')}</h1>

2
app/widgets/CommunityData/_communitydata_card.tpl

@ -2,7 +2,7 @@
<li class="block large">
<div>
<p class="center all">
<img class="avatar" src="{$info->getPhoto('l')}"/>
<img class="avatar" src="{$info->getPicture('l')}"/>
</p>
</div>
</li>

2
app/widgets/CommunityHeader/_communityheader.tpl

@ -17,7 +17,7 @@
{if="$info != null"}
<span class="primary icon bubble active"
onclick="MovimUtils.reload('{$c->route('community', [$server, $info->node])}')">
<img src="{$info->getPhoto('l')}"/>
<img src="{$info->getPicture('l')}"/>
</span>
{/if}
<div>

2
app/widgets/ContactActions/_contactactions_add.tpl

@ -3,7 +3,7 @@
<ul class="list thick">
<li>
<span class="primary icon bubble">
<img src="{$contact->getPhoto()}">
<img src="{$contact->getPicture()}">
</span>
<div>
<p class="line">

2
app/widgets/ContactActions/_contactactions_drawer.tpl

@ -9,7 +9,7 @@
class="primary icon bubble active
{if="$roster && $roster->presence"}status {$roster->presence->presencekey}{/if}
">
<img src="{if="$roster"}{$roster->getPhoto()}{else}{$contact->getPhoto()}{/if}">
<img src="{if="$roster"}{$roster->getPicture()}{else}{$contact->getPicture()}{/if}">
</span>
{/if}
{if="!$contact->isFromMuc()"}

2
app/widgets/ContactData/_contactdata_card.tpl

@ -2,7 +2,7 @@
<li class="block large">
<div>
<p class="center all">
<img src="{if="$roster"}{$roster->getPhoto('xl')}{else}{$contact->getPhoto('xl')}{/if}" class="avatar">
<img src="{if="$roster"}{$roster->getPicture('xl')}{else}{$contact->getPicture('xl')}{/if}" class="avatar">
</p>
</div>
</li>

2
app/widgets/ContactHeader/_contactheader.tpl

@ -44,7 +44,7 @@
<i class="material-icons">arrow_back</i>
</span>
<span class="primary icon bubble active" onclick="ContactActions_ajaxGetDrawer('{$contact->id|echapJS}')">
<img src="{if="$roster"}{$roster->getPhoto('m')}{else}{$contact->getPhoto('m')}{/if}">
<img src="{if="$roster"}{$roster->getPicture('m')}{else}{$contact->getPicture('m')}{/if}">
</span>
<div>
<p class="line active" onclick="ContactActions_ajaxGetDrawer('{$contact->id|echapJS}')">

2
app/widgets/ContactSubscriptions/_contactsubscriptions.tpl

@ -13,7 +13,7 @@
<li title="{$value->server} - {$value->node}">
{if="$value->info"}
<span class="primary icon bubble">
<img src="{$value->info->getPhoto('m')}"/>
<img src="{$value->info->getPicture('m')}"/>
</span>
{else}
<span class="primary icon bubble color {$value->node|stringToColor}">

8
app/widgets/Login/login.tpl

@ -29,12 +29,12 @@
<ul class="list middle invite">
<li>
<span class="primary icon bubble">
<img src="{$contact->getPhoto('m')}">
<img src="{$contact->getPicture('m')}">
</span>
{if="$invitation->room && $invitation->room->getPhoto('m')"}
{if="$invitation->room && $invitation->room->getPicture('m')"}
<span class="primary icon bubble">
<img src="{$invitation->room->getPhoto('m')}">
<img src="{$invitation->room->getPicture('m')}">
</span>
{/if}
<div>
@ -126,7 +126,7 @@
</span>
{if="$contact"}
<span class="primary icon bubble small">
<img src="{$contact->getPhoto()}">
<img src="{$contact->getPicture()}">
</span>
{else}
<span class="primary icon bubble small color {$value->id|stringToColor}">

6
app/widgets/Menu/Menu.php

@ -93,7 +93,7 @@ class Menu extends Base
'comments',
($post->isLike()) ? '❤️ ' .$contact->truename : $post->title,
'📝 ' . $parent->title,
$contact->getPhoto(),
$contact->getPicture(),
4
);
}
@ -111,7 +111,7 @@ class Menu extends Base
'news',
'📝 ' . $contact->truename,
$title,
$contact->getPhoto(),
$contact->getPicture(),
4,
$this->route('post', [$post->server, $post->node, $post->nodeid]),
$this->route('contact', $post->server)
@ -128,7 +128,7 @@ class Menu extends Base
if ($info->name) {
$title = $info->name;
}
$logo = $info->getPhoto('l');
$logo = $info->getPicture('l');
}
Notif::append(

2
app/widgets/Notifications/Notifications.php

@ -52,7 +52,7 @@ class Notifications extends Base
'invite|' . $from,
$contact->truename,
$this->__('invitations.wants_to_talk', $contact->truename),
$contact->getPhoto(),
$contact->getPicture(),
4
);
}

4
app/widgets/Notifications/_notifications.tpl

@ -9,7 +9,7 @@
</ul>
<ul id="notifications_invitations" class="list middle divided spaced">{loop="$invitations"}<li id="invitation-{$value->jid|cleanupId}" data-jid="{$value->jid}">
<span class="primary icon bubble active" onclick="MovimUtils.reload('{$c->route('contact', $value->jid)}'); Drawer.clear();">
<img src="{$value->getPhoto()}">
<img src="{$value->getPicture()}">
</span>
<span class="control icon green active" title="{$c->__('button.accept')}" onclick="Notifications_ajaxAccept('{$value->jid|echapJS}');">
<i class="material-icons">check</i>
@ -53,7 +53,7 @@
{if="$value->contact"}
<span class="primary icon bubble">
<a href="{$c->route('contact', $value->contact->jid)}">
<img src="{$value->contact->getPhoto()}">
<img src="{$value->contact->getPicture()}">
</a>
</span>
{else}

6
app/widgets/Post/_post.tpl

@ -50,7 +50,7 @@
{if="$post->contact"}
<span class="icon primary bubble">
<a href="#" onclick="Post_ajaxGetContact('{$contact->jid}')">
<img src="{$contact->getPhoto('m')}">
<img src="{$contact->getPicture('m')}">
</a>
</span>
{else}
@ -65,7 +65,7 @@
<span class="primary icon bubble active"
onclick="MovimUtils.reload('{$c->route('community', [$post->server, $post->node])}')"
>
<img src="{$info->getPhoto('l')}"/>
<img src="{$info->getPicture('l')}"/>
</span>
{else}
<span class="primary icon bubble color {$post->node|stringToColor} active"
@ -154,7 +154,7 @@
<a href="{$c->route('contact', $post->contact->jid)}">
<ul class="list active middle">
<li>
<span class="primary icon bubble" style="background-image: url('{$post->contact->getPhoto('m')}');">
<span class="primary icon bubble" style="background-image: url('{$post->contact->getPicture('m')}');">
<i class="material-icons">loop</i>
</span>
<span class="control icon">

4
app/widgets/Post/_post_card.tpl

@ -8,7 +8,7 @@
{elseif="$post->isMicroblog()"}
{if="$post->contact"}
<span class="primary icon bubble">
<img src="{$post->contact->getPhoto('m')}"/>
<img src="{$post->contact->getPicture('m')}"/>
</span>
{else}
<span class="primary icon bubble color {$post->aid|stringToColor}">
@ -18,7 +18,7 @@
{else}
{if="$post->info != null"}
<span class="primary icon bubble">
<img src="{$post->info->getPhoto('l')}"/>
<img src="{$post->info->getPicture('l')}"/>
</span>
{else}
<span class="primary icon bubble color {$post->node|stringToColor}">

4
app/widgets/Post/_post_comments.tpl

@ -51,10 +51,10 @@
{if="$value->contact"}
<span class="primary icon bubble small">
{if="$public"}
<img src="{$value->contact->getPhoto('s')}">
<img src="{$value->contact->getPicture('s')}">
{else}
<a href="{$c->route('contact', $value->contact->jid)}">
<img src="{$value->contact->getPhoto('s')}">
<img src="{$value->contact->getPicture('s')}">
</a>
{/if}
</span>

4
app/widgets/Post/_post_prevnext_back.tpl

@ -11,7 +11,7 @@
{if="$post->isMicroblog()"}
{if="$post->contact"}
<span class="primary icon bubble">
<img src="{$post->contact->getPhoto('m')}">
<img src="{$post->contact->getPicture('m')}">
</span>
<div>
<p class="normal line">
@ -33,7 +33,7 @@
{else}
{if="$info"}
<span class="primary icon bubble">
<img src="{$info->getPhoto('m')}"/>
<img src="{$info->getPicture('m')}"/>
</span>
<div>
<p class="line normal">

2
app/widgets/Post/_post_reply.tpl

@ -11,7 +11,7 @@
<i class="material-icons flip-hor">reply</i>
</span>
{elseif="$reply->isMicroblog() && $reply->contact"}
<span class="primary icon bubble gray" style="background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0.3) 100%), url({$reply->contact->getPhoto('l')});">
<span class="primary icon bubble gray" style="background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0.3) 100%), url({$reply->contact->getPicture('l')});">
<i class="material-icons">reply</i>
</span>
{/if}

4
app/widgets/Post/_post_ticket.tpl

@ -21,7 +21,7 @@
{elseif="!$post->contact"}
<span class="control icon bubble">
{if="$post->info"}
<img src="{$post->info->getPhoto('m')}">
<img src="{$post->info->getPicture('m')}">
{else}
<img src="{$post->node|avatarPlaceholder}">
{/if}
@ -41,7 +41,7 @@
<p>
{if="$post->contact"}
<span class="icon bubble tiny">
<img src="{$post->contact->getPhoto()}">
<img src="{$post->contact->getPicture()}">
</span>
<a href="{$c->route('contact', $post->contact->jid)}">
{$post->contact->truename}

2
app/widgets/Presence/_presence.tpl

@ -5,7 +5,7 @@
{if="$presence->value != null"}{$presencetxt[$presence->value]}{/if}
{if="$me->hasLocation()"} location{/if}
">
<img src="{$me->getPhoto('m')}">
<img src="{$me->getPicture('m')}">
</span>
<span class="control icon active"
onclick="Presence_ajaxAskLogout()"

2
app/widgets/Presence/presence.tpl

@ -1,7 +1,7 @@
<ul class="list navigation thick active" id="presence_widget" dir="ltr">
<li>
<span class="primary icon bubble color status">
<img src="{$me->getPhoto()}">
<img src="{$me->getPicture()}">
</span>
<div>
<p class="line bold"><br /></p>

2
app/widgets/Publish/publish.tpl

@ -35,7 +35,7 @@
{if="$icon != null"}
<span class="primary icon bubble">
<img src="{$icon->getPhoto('l')}"/>
<img src="{$icon->getPicture('l')}"/>
</span>
{else}
<span class="primary icon bubble color {$draft->node|stringToColor}">

2
app/widgets/Rooms/Rooms.php

@ -144,7 +144,7 @@ class Rooms extends Base
$this->rpc(
'MovimTpl.fill',
'#' . cleanupId($room.'_rooms_primary'),
$this->prepareRoomCounter($conference, $conference->getPhoto())
$this->prepareRoomCounter($conference, $conference->getPicture())
);
$unread = ($conference->unreads_count > 0 || $conference->quoted_count > 0);

2
app/widgets/Rooms/_rooms_room.tpl

@ -9,7 +9,7 @@
">
<span class="primary icon bubble small"
id="{$conference->conference|cleanupId}-rooms-primary"
style="background-image: url({$conference->getPhoto()});">
style="background-image: url({$conference->getPicture()});">
{autoescape="off"}
{$c->prepareRoomCounter($conference, true)}
{/autoescape}

2
app/widgets/RoomsExplore/_roomsexplore_global.tpl

@ -8,7 +8,7 @@
<li title="{$value.jid}">
{if="$vcards->has($value['jid'])"}
<span class="primary icon bubble"
style="background-image: url({$vcards->get($value['jid'])->getPhoto()});">
style="background-image: url({$vcards->get($value['jid'])->getPicture()});">
</span>
{else}
<span class="primary icon bubble color {$value.name|stringToColor}">

2
app/widgets/RoomsExplore/_roomsexplore_local.tpl

@ -8,7 +8,7 @@
<li title="{$value->server}">
{if="$vcards->has($value->server)"}
<span class="primary icon bubble"
style="background-image: url({$vcards->get($value->server)->getPhoto()});">
style="background-image: url({$vcards->get($value->server)->getPicture()});">
</span>
{else}
<span class="primary icon bubble color {$value->name|stringToColor}">

2
app/widgets/RoomsUtils/_rooms_avatar.tpl

@ -1,6 +1,6 @@
<section class="scroll">
<form name="avatarroom">
<img class="avatar" src="{$room->getPhoto('o') ?? ''}">
<img class="avatar" src="{$room->getPicture('o') ?? ''}">
<div class="placeholder">
<i class="material-icons">image</i>
<h1>{$c->__('avatar.missing')}</h1>

8
app/widgets/RoomsUtils/_rooms_drawer.tpl

@ -1,11 +1,11 @@
<section class="scroll">
<header class="big"
style="background-image: linear-gradient(to bottom, rgba(23,23,23,0.8) 0%, rgba(23,23,23,0.5) 100%), url('{$conference->getPhoto('xxl')}');"
style="background-image: linear-gradient(to bottom, rgba(23,23,23,0.8) 0%, rgba(23,23,23,0.5) 100%), url('{$conference->getPicture('xxl')}');"
>
<ul class="list thick">
<li>
<span class="primary icon bubble active"
style="background-image: url({$conference->getPhoto()});">
style="background-image: url({$conference->getPicture()});">
</span>
<span title="{$c->__('chatroom.config')}"
class="control icon active"
@ -196,7 +196,7 @@
<li title="{$value->truename}">
{if="$value->contact"}
<span class="primary icon bubble small status {if="$presence"}{$presence->presencekey}{/if}">
<img loading="lazy" src="{$value->contact->getPhoto('s')}">
<img loading="lazy" src="{$value->contact->getPicture('s')}">
</span>
{else}
<span class="primary icon bubble small color {$value->jid|stringToColor} status {if="$presence"}{$presence->presencekey}{/if}">
@ -352,7 +352,7 @@
<li title="{$value->truename}">
{if="$value->contact"}
<span class="primary icon bubble small">
<img loading="lazy" src="{$value->contact->getPhoto('s')}">
<img loading="lazy" src="{$value->contact->getPicture('s')}">
</span>
{else}
<span class="primary icon bubble small color {$value->jid|stringToColor}">

2
app/widgets/Search/_search_results.tpl

@ -44,7 +44,7 @@
title="{$value->server} - {$value->node}"
>
<span class="primary icon bubble">
<img src="{$value->getPhoto('m')}"/>
<img src="{$value->getPicture('m')}"/>
</span>
<span class="control icon gray">
<i class="material-icons">chevron_right</i>

2
app/widgets/Search/_search_results_contacts.tpl

@ -8,7 +8,7 @@
{loop="$users"}
<li class="block active" title="{$value->jid}" onclick="MovimUtils.reload('{$c->route('contact', $value->jid)}'); Drawer.clear();">
<span class="primary icon bubble {if="$value->value"}status {$presencestxt[$value->value]}{/if}">
<img src="{$value->getPhoto()}">
<img src="{$value->getPicture()}">
</span>
<div>
<p class="normal line">

2
app/widgets/Search/_search_roster.tpl

@ -19,7 +19,7 @@
status {$value->presence->presencekey}
{/if}"
onclick="MovimUtils.reload('{$c->route('contact', $value->jid)}'); Drawer.clear();">
<img loading="lazy" src="{$value->getPhoto('m')}">
<img loading="lazy" src="{$value->getPicture('m')}">
</span>
{if="$value->presences->count() > 0"}

4
app/widgets/SendTo/_sendto_article.tpl

@ -37,7 +37,7 @@
</li>
<li>
<span class="primary icon bubble">
<img src="{$me->getPhoto()}">
<img src="{$me->getPicture()}">
</span>
<span class="control icon active gray divided"
onclick="MovimUtils.reload('{$c->route('publish', [$c->getUser()->id, 'urn:xmpp:microblog:0', '', $post->server, $post->node, $post->nodeid])}'); Drawer.clear()">
@ -63,7 +63,7 @@
>
{if="$value->info"}
<span class="primary icon bubble">
<img src="{$value->info->getPhoto('m')}"/>
<img src="{$value->info->getPicture('m')}"/>
</span>
{else}
<span class="primary icon bubble color {$value->node|stringToColor}">

2
app/widgets/SendTo/_sendto_share.tpl

@ -22,7 +22,7 @@
{loop="$conferences"}
<li>
<span class="primary icon bubble small">
<img src="{$value->getPhoto()}">
<img src="{$value->getPicture()}">
</span>
<span class="control icon active gray" onclick="SendTo_ajaxSend('{$value->conference|echapJS}', {'uri': '{$uri}'}, true, '{$openlink}');">

2
app/widgets/SendTo/_sendto_share_contacts.tpl

@ -11,7 +11,7 @@
{else}
status {$value->presence->presencekey}
{/if}">
<img src="{$value->getPhoto('m')}">
<img src="{$value->getPicture('m')}">
</span>
<span class="control icon active gray" onclick="SendTo_ajaxSend('{$value->jid|echapJS}', {'uri': '{$uri}'}, false, '{$openlink}')">
<i class="material-icons">send</i>

4
app/widgets/Syndication/Syndication.php

@ -59,9 +59,9 @@ class Syndication extends Base
$name->appendChild($dom->createTextNode($contact->truename));
$author->appendChild($dom->createElement('uri', $this->route('blog', $from)));
if ($contact->getPhoto('l')) {
if ($contact->getPicture('l')) {
$logo = $dom->createElement('logo');
$logo->appendChild($dom->createTextNode($contact->getPhoto('l')));
$logo->appendChild($dom->createTextNode($contact->getPicture('l')));
$feed->appendChild($logo);
}

2
app/widgets/Visio/Visio.php

@ -104,7 +104,7 @@ class Visio extends Base
'call',
$contact->truename,
$this->__('visio.calling'),
$contact->getPhoto(),
$contact->getPicture(),
5,
null,
null,

2
app/widgets/Visio/_visio_dialog.tpl

@ -3,7 +3,7 @@
<li>
<div>
<p class="center">
<img src="{$contact->getPhoto('l')}">
<img src="{$contact->getPicture('l')}">
</p>
<p class="normal center">
{if="$withvideo"}

2
app/widgets/Visio/visio.tpl

@ -68,7 +68,7 @@
<div>
<div id="remote_level">
<div class="avatar">
<img src="{$contact->getPhoto('l')}">
<img src="{$contact->getPicture('l')}">
</div>
</div>
<p class="normal center">{$contact->truename}</p>

60
composer.lock

@ -63,16 +63,16 @@
},
{
"name": "cakephp/core",
"version": "4.4.15",
"version": "4.4.16",
"source": {
"type": "git",
"url": "https://github.com/cakephp/core.git",
"reference": "ded708dbeb10a27ffcb4e3a87d1ceec33614ad63"
"reference": "b101e59c4c04587c7552f66388c9fbdeadc339c6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/cakephp/core/zipball/ded708dbeb10a27ffcb4e3a87d1ceec33614ad63",
"reference": "ded708dbeb10a27ffcb4e3a87d1ceec33614ad63",
"url": "https://api.github.com/repos/cakephp/core/zipball/b101e59c4c04587c7552f66388c9fbdeadc339c6",
"reference": "b101e59c4c04587c7552f66388c9fbdeadc339c6",
"shasum": ""
},
"require": {
@ -119,20 +119,20 @@
"issues": "https://github.com/cakephp/cakephp/issues",
"source": "https://github.com/cakephp/core"
},
"time": "2023-05-16T13:58:50+00:00"
"time": "2023-08-04T21:00:40+00:00"
},
{
"name": "cakephp/database",
"version": "4.4.15",
"version": "4.4.16",
"source": {
"type": "git",
"url": "https://github.com/cakephp/database.git",
"reference": "752e3dfa61be055bf9d360880f00ab4ccfea6d1e"
"reference": "b1456297c9aaefca463a17d571426509fb2999d0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/cakephp/database/zipball/752e3dfa61be055bf9d360880f00ab4ccfea6d1e",
"reference": "752e3dfa61be055bf9d360880f00ab4ccfea6d1e",
"url": "https://api.github.com/repos/cakephp/database/zipball/b1456297c9aaefca463a17d571426509fb2999d0",
"reference": "b1456297c9aaefca463a17d571426509fb2999d0",
"shasum": ""
},
"require": {
@ -175,11 +175,11 @@
"issues": "https://github.com/cakephp/cakephp/issues",
"source": "https://github.com/cakephp/database"
},
"time": "2023-04-28T21:24:39+00:00"
"time": "2023-08-04T04:23:09+00:00"
},
{
"name": "cakephp/datasource",
"version": "4.4.15",
"version": "4.4.16",
"source": {
"type": "git",
"url": "https://github.com/cakephp/datasource.git",
@ -237,7 +237,7 @@
},
{
"name": "cakephp/utility",
"version": "4.4.15",
"version": "4.4.16",
"source": {
"type": "git",
"url": "https://github.com/cakephp/utility.git",
@ -296,16 +296,16 @@
},
{
"name": "cocur/slugify",
"version": "v4.3.0",
"version": "v4.4.0",
"source": {
"type": "git",
"url": "https://github.com/cocur/slugify.git",
"reference": "652234ef5f1be844a2ae1c36ad1b4c88b05160f9"
"reference": "4c6ed14a087ca061b220ffda640c07644946e2a0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/cocur/slugify/zipball/652234ef5f1be844a2ae1c36ad1b4c88b05160f9",
"reference": "652234ef5f1be844a2ae1c36ad1b4c88b05160f9",
"url": "https://api.github.com/repos/cocur/slugify/zipball/4c6ed14a087ca061b220ffda640c07644946e2a0",
"reference": "4c6ed14a087ca061b220ffda640c07644946e2a0",
"shasum": ""
},
"require": {
@ -364,9 +364,9 @@
],
"support": {
"issues": "https://github.com/cocur/slugify/issues",
"source": "https://github.com/cocur/slugify/tree/v4.3.0"
"source": "https://github.com/cocur/slugify/tree/v4.4.0"
},
"time": "2022-12-07T19:48:48+00:00"
"time": "2023-08-05T09:42:11+00:00"
},
{
"name": "composer/ca-bundle",
@ -1594,16 +1594,16 @@
},
{
"name": "guzzlehttp/promises",
"version": "2.0.0",
"version": "2.0.1",
"source": {
"type": "git",
"url": "https://github.com/guzzle/promises.git",
"reference": "3a494dc7dc1d7d12e511890177ae2d0e6c107da6"
"reference": "111166291a0f8130081195ac4556a5587d7f1b5d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/promises/zipball/3a494dc7dc1d7d12e511890177ae2d0e6c107da6",
"reference": "3a494dc7dc1d7d12e511890177ae2d0e6c107da6",
"url": "https://api.github.com/repos/guzzle/promises/zipball/111166291a0f8130081195ac4556a5587d7f1b5d",
"reference": "111166291a0f8130081195ac4556a5587d7f1b5d",
"shasum": ""
},
"require": {
@ -1657,7 +1657,7 @@
],
"support": {
"issues": "https://github.com/guzzle/promises/issues",
"source": "https://github.com/guzzle/promises/tree/2.0.0"
"source": "https://github.com/guzzle/promises/tree/2.0.1"
},
"funding": [
{
@ -1673,20 +1673,20 @@
"type": "tidelift"
}
],
"time": "2023-05-21T13:50:22+00:00"
"time": "2023-08-03T15:11:55+00:00"
},
{
"name": "guzzlehttp/psr7",
"version": "2.5.0",
"version": "2.6.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/psr7.git",
"reference": "b635f279edd83fc275f822a1188157ffea568ff6"
"reference": "8bd7c33a0734ae1c5d074360512beb716bef3f77"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/b635f279edd83fc275f822a1188157ffea568ff6",
"reference": "b635f279edd83fc275f822a1188157ffea568ff6",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/8bd7c33a0734ae1c5d074360512beb716bef3f77",
"reference": "8bd7c33a0734ae1c5d074360512beb716bef3f77",
"shasum": ""
},
"require": {
@ -1773,7 +1773,7 @@
],
"support": {
"issues": "https://github.com/guzzle/psr7/issues",
"source": "https://github.com/guzzle/psr7/tree/2.5.0"
"source": "https://github.com/guzzle/psr7/tree/2.6.0"
},
"funding": [
{
@ -1789,7 +1789,7 @@
"type": "tidelift"
}
],
"time": "2023-04-17T16:11:26+00:00"
"time": "2023-08-03T15:06:02+00:00"
},
{
"name": "illuminate/bus",

1
daemon.php

@ -11,6 +11,7 @@ $bootstrap->boot(true);
$application = new Application;
$application->add(new Movim\Console\ConfigCommand);
$application->add(new Movim\Console\ClearTemplatesCache);
$application->add(new Movim\Console\DaemonCommand);
$application->add(new Movim\Console\EmojisToJsonCommand);
$application->add(new Movim\Console\CompileLanguages);

10
etc/caddy/Caddyfile

@ -25,16 +25,8 @@ your.domain.tld {
}
}
handle /picture/* {
reverse_proxy unix//run/php/php-fpm.sock {
transport fastcgi {
env SCRIPT_FILENAME /path-to/movim/public/picture/index.php
}
}
}
handle /ws/* {
reverse_proxy localhost:8080
# This part of the configuration is generated when launching the daemon in the console output
}
#Security options you can ignore or delete

34
etc/nginx/conf.d/movim.conf

@ -2,34 +2,32 @@ server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
# Where Movim public directory is setup
root /var/www/movim/public;
location / {
index index.php;
add_header Access-Control-Allow-Origin *;
index index.php;
if (!-e $request_filename) {
rewrite ^/(.*) /index.php?query=$1 last;
}
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
# Define a server side cache for the proxyfied pictures
# Optional but strongly recommended, ask nginx to cache every URL starting with "/picture"
location /picture {
try_files $uri $uri/ /index.php$is_args$args;
#location /picture {
# include fastcgi_params;
# add_header X-Cache $upstream_cache_status;
# fastcgi_ignore_headers "Cache-Control" "Expires" "Set-Cookie";
# fastcgi_cache nginx_cache;
# fastcgi_cache_key $request_method$host$request_uri;
# fastcgi_cache_valid any 7d;
#}
add_header X-Cache $upstream_cache_status;
fastcgi_ignore_headers "Cache-Control" "Expires" "Set-Cookie";
fastcgi_cache nginx_cache;
fastcgi_cache_key $request_method$host$request_uri;
fastcgi_cache_valid any 7d;
}
location ~ \.php$ {
include fastcgi_params;
# Pass everything to PHP FastCGI, at the discretion of the administrator
# include snippets/fastcgi-php.conf
}
location /ws/ {
# This part of the configuration is generated when launching the daemon
# This part of the configuration is generated when launching the daemon in the console output
}
}

12
public/picture/index.php

@ -1,12 +0,0 @@
<?php
require '../../vendor/autoload.php';
use Movim\Bootstrap;
use Movim\Controller\Front;
$bootstrap = new Bootstrap;
$bootstrap->boot();
$rqst = new Front;
$rqst->handle('picture');

36
src/Movim/Console/ClearTemplatesCache.php

@ -0,0 +1,36 @@
<?php
/*
* SPDX-FileCopyrightText: 2023 Jaussoin Timothée
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Movim\Console;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class ClearTemplatesCache extends Command
{
protected function configure()
{
$this
->setName('clearTemplatesCache')
->setDescription('Clear the internal templates cache');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
foreach (glob(
CACHE_PATH .
'*.rtpl.php',
GLOB_NOSORT
) as $cacheFile) {
@unlink($cacheFile);
}
$output->writeln('<info>Template cache cleared</info>');
return 0;
}
}

13
src/Movim/Console/CompileStickers.php

@ -6,6 +6,7 @@
namespace Movim\Console;
use Movim\Image;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@ -21,7 +22,17 @@ class CompileStickers extends Command
protected function execute(InputInterface $input, OutputInterface $output)
{
$count = compileStickers();
$count = 0;
foreach (glob(PUBLIC_PATH . '/stickers/*/*.png', GLOB_NOSORT) as $path) {
$key = basename($path, '.png');
if ($key != 'icon') {
$count++;
copy($path, PUBLIC_CACHE_PATH . hash(Image::$hash, $key) . '_o.png');
}
}
$output->writeln('<info>'.$count.' stickers compiled</info>');
return 0;
}

4
src/Movim/Console/DaemonCommand.php

@ -74,6 +74,10 @@ class DaemonCommand extends Command
$output->writeln('<info>php daemon.php setAdmin {jid}</info>' . "\n");
}
$clearTemplatesCache = new \React\ChildProcess\Process('exec php daemon.php clearTemplatesCache');
$clearTemplatesCache->start($loop);
$clearTemplatesCache->on('exit', fn ($out) => $output->writeln('<info>Templates cache cleared</info>'));
$compileLanguages = new \React\ChildProcess\Process('exec php daemon.php compileLanguages');
$compileLanguages->start($loop);
$compileLanguages->on('exit', fn ($out) => $output->writeln('<info>Compiled po files</info>'));

5
src/Movim/Route.php

@ -125,10 +125,7 @@ class Route extends Base
if (isset($routes[$page])) {
$uri = BASE_URI . $page;
// Specific case for picture that is in a subdirectory for caching purposes
if ($page == 'picture') {
$uri = BASE_URI . $page . '/';
} elseif ($params != false) {
if ($params != false) {
if (is_array($params)) {
foreach ($params as $value) {
$uri .= '/' . rawurlencode($value ?? '');

Loading…
Cancel
Save