Browse Source

Load widgets correctly based on hasUpload and hasPubsub features

master
Timothée Jaussoin 3 weeks ago
parent
commit
b8d57eb4fb
  1. 4
      app/Views/admin.tpl
  2. 18
      app/Views/chat.tpl
  3. 4
      app/Views/community.tpl
  4. 6
      app/Views/configuration.tpl
  5. 2
      app/Views/contact.tpl
  6. 2
      app/Views/explore.tpl
  7. 4
      app/Views/help.tpl
  8. 10
      app/Views/news.tpl
  9. 4
      app/Views/post.tpl
  10. 10
      app/Views/publish.tpl
  11. 4
      app/Views/subscriptions.tpl
  12. 39
      app/Widgets/Chat/chat.js
  13. 24
      app/Widgets/CommunityConfig/CommunityConfig.php
  14. 12
      app/Widgets/Draw/_draw.tpl
  15. 22
      app/Widgets/Navigation/navigation.tpl
  16. 24
      app/Widgets/Publish/publish.js
  17. 26
      app/Widgets/PublishStories/PublishStories.php
  18. 6
      app/Widgets/Snap/Snap.php

4
app/Views/admin.tpl

@ -1,4 +1,5 @@
<?php $this->widget('Search');?>
<?php $this->widget('Upload');?>
<?php $this->widget('Onboarding');?>
<?php $this->widget('Notifications');?>
@ -35,7 +36,6 @@
</div>
</main>
<?php if (me()->hasPubsub()) { ?>
<?php $this->widget('Upload');?>
<?php if (isLogged() && me()->hasPubsub() && me()->hasUpload()) { ?>
<?php $this->widget('PublishStories');?>
<?php } ?>

18
app/Views/chat.tpl

@ -21,7 +21,7 @@
<a class="button action color" onclick="Search_ajaxRequest(true)">
<i class="material-symbols">add</i>
</a>
<?php if (me()->hasPubsub()) { ?>
<?php if (me()->hasPubsub() && me()->hasUpload()) { ?>
<?php $this->widget('Stories');?>
<?php } ?>
<?php $this->widget('Chats');?>
@ -30,12 +30,16 @@
</div>
</main>
<?php $this->widget('Dictaphone');?>
<?php $this->widget('Snap');?>
<?php if (me()->hasPubsub()) { ?>
<?php $this->widget('PublishStories');?>
<?php $this->widget('StoriesViewer');?>
<?php if (me()->hasUpload()) { ?>
<?php $this->widget('Dictaphone');?>
<?php $this->widget('Snap');?>
<?php $this->widget('Draw');?>
<?php if (me()->hasPubsub()) { ?>
<?php $this->widget('PublishStories');?>
<?php $this->widget('StoriesViewer');?>
<?php } ?>
<?php } ?>
<?php $this->widget('Tabs');?>
<?php $this->widget('Draw');?>
<?php $this->widget('RoomsExplore');?>

4
app/Views/community.tpl

@ -58,6 +58,6 @@
<?php } ?>
</main>
<?php if (isLogged() && me()->hasPubsub()) { ?>
<?php if (isLogged() && me()->hasPubsub() && me()->hasUpload()) { ?>
<?php $this->widget('PublishStories');?>
<?php } ?>
<?php } ?>

6
app/Views/configuration.tpl

@ -1,4 +1,5 @@
<?php $this->widget('Search');?>
<?php $this->widget('Upload');?>
<?php $this->widget('Onboarding');?>
<?php $this->widget('Notifications');?>
<?php if(me()->hasOMEMO()) $this->widget('ChatOmemo');?>
@ -40,7 +41,6 @@
</div>
</main>
<?php if (me()->hasPubsub()) { ?>
<?php $this->widget('Upload');?>
<?php if (me()->hasPubsub() && me()->hasUpload()) { ?>
<?php $this->widget('PublishStories');?>
<?php } ?>
<?php } ?>

2
app/Views/contact.tpl

@ -27,7 +27,7 @@
</div>
</main>
<?php if (me()->hasPubsub()) { ?>
<?php if (me()->hasPubsub() && me()->hasUpload()) { ?>
<?php $this->widget('PublishStories');?>
<?php $this->widget('StoriesViewer');?>
<?php } ?>

2
app/Views/explore.tpl

@ -55,6 +55,6 @@
</div>
</main>
<?php if (me()->hasPubsub()) { ?>
<?php if (me()->hasPubsub() && me()->hasUpload()) { ?>
<?php $this->widget('PublishStories');?>
<?php } ?>

4
app/Views/help.tpl

@ -1,4 +1,5 @@
<?php $this->widget('Search');?>
<?php $this->widget('Upload');?>
<?php $this->widget('Notifications');?>
<?php if(me()->hasOMEMO()) $this->widget('ChatOmemo');?>
@ -30,7 +31,6 @@
</div>
</main>
<?php if (me()->hasPubsub()) { ?>
<?php $this->widget('Upload');?>
<?php if ( me()->hasPubsub() && me()->hasUpload()) { ?>
<?php $this->widget('PublishStories');?>
<?php } ?>

10
app/Views/news.tpl

@ -23,9 +23,11 @@
</div>
</main>
<?php $this->widget('Snap');?>
<?php $this->widget('Draw');?>
<?php if (me()->hasUpload()) { ?>
<?php $this->widget('Snap');?>
<?php $this->widget('Draw');?>
<?php if (me()->hasPubsub()) { ?>
<?php $this->widget('PublishStories');?>
<?php if (me()->hasPubsub()) { ?>
<?php $this->widget('PublishStories');?>
<?php } ?>
<?php } ?>

4
app/Views/post.tpl

@ -20,4 +20,6 @@
<?php $this->widget('Post');?>
</main>
<?php $this->widget('PublishStories');?>
<?php if (me()->hasPubsub() && me()->hasUpload()) { ?>
<?php $this->widget('PublishStories');?>
<?php } ?>

10
app/Views/publish.tpl

@ -19,6 +19,10 @@
</div>
</main>
<?php $this->widget('Snap');?>
<?php $this->widget('Draw');?>
<?php $this->widget('PublishStories');?>
<?php if (me()->hasUpload()) { ?>
<?php $this->widget('Snap');?>
<?php $this->widget('Draw');?>
<?php if (me()->hasPubsub()) { ?>
<?php $this->widget('PublishStories');?>
<?php } ?>
<?php } ?>

4
app/Views/subscriptions.tpl

@ -1,4 +1,5 @@
<?php $this->widget('Search');?>
<?php $this->widget('Upload');?>
<?php $this->widget('Notifications');?>
<?php $this->widget('SendTo');?>
@ -27,7 +28,6 @@
</div>
</main>
<?php if (me()->hasPubsub()) { ?>
<?php $this->widget('Upload');?>
<?php if (me()->hasPubsub() && me()->hasUpload()) { ?>
<?php $this->widget('PublishStories');?>
<?php } ?>

39
app/Widgets/Chat/chat.js

@ -1710,24 +1710,27 @@ MovimEvents.registerWindow('resize', 'chat', () => Chat.scrollRestore());
MovimEvents.registerWindow('loaded', 'chat', () => {
if (MovimUtils.isMobile()) Chat.touchEvents();
Upload.initiate((file) => {
if (MovimUtils.urlParts().page == 'chat'
&& (typeof (PublishStories) == 'undefined' || PublishStories.main == undefined)) {
Upload.prependName = 'chat';
}
});
Upload.attach((file) => {
if (MovimUtils.urlParts().page == 'chat'
&& (typeof (PublishStories) == 'undefined' || PublishStories.main == undefined)) {
Chat_ajaxHttpDaemonSendMessage(
Chat.getTextarea().dataset.jid,
false,
Boolean(Chat.getTextarea().dataset.muc),
file
);
}
});
if (typeof Upload != 'undefined') {
Upload.initiate((file) => {
if (MovimUtils.urlParts().page == 'chat'
&& (typeof (PublishStories) == 'undefined' || PublishStories.main == undefined)) {
Upload.prependName = 'chat';
}
});
Upload.attach((file) => {
if (MovimUtils.urlParts().page == 'chat'
&& (typeof (PublishStories) == 'undefined' || PublishStories.main == undefined)) {
Chat_ajaxHttpDaemonSendMessage(
Chat.getTextarea().dataset.jid,
false,
Boolean(Chat.getTextarea().dataset.muc),
file
);
}
});
}
// Really early panel showing in case we have a JID
var parts = MovimUtils.urlParts();

24
app/Widgets/CommunityConfig/CommunityConfig.php

@ -57,7 +57,7 @@ class CommunityConfig extends Base
{
$this->toast(
$packet->content ??
$this->__('communityaffiliation.config_error')
$this->__('communityaffiliation.config_error')
);
}
@ -69,8 +69,8 @@ class CommunityConfig extends Base
$view = $this->tpl();
$view->assign('info', \App\Info::where('server', $origin)
->where('node', $node)
->first());
->where('node', $node)
->first());
Dialog::fill($view->draw('_communityconfig_avatar'));
}
@ -81,7 +81,7 @@ class CommunityConfig extends Base
return;
}
$key = $origin.$node.'avatar';
$key = $origin . $node . 'avatar';
$p = new Image;
$p->fromBase64($form->photobin->value);
@ -93,10 +93,10 @@ class CommunityConfig extends Base
$r = new AvatarSet;
$r->setTo($origin)
->setNode($node)
->setUrl(Image::getOrCreate($key, false, false, 'jpeg', true))
->setData($p->toBase())
->request();
->setNode($node)
->setUrl(Image::getOrCreate($key, false, false, 'jpeg', true))
->setData($p->toBase())
->request();
}
public function ajaxGetConfig($origin, $node, $advanced = false)
@ -107,7 +107,7 @@ class CommunityConfig extends Base
$r = new GetConfig;
$r->setTo($origin)
->setNode($node);
->setNode($node);
if ($advanced) {
$r->enableAdvanced();
@ -124,8 +124,8 @@ class CommunityConfig extends Base
$r = new SetConfig;
$r->setTo($origin)
->setNode($node)
->setData(formToArray($data))
->request();
->setNode($node)
->setData(formToArray($data))
->request();
}
}

12
app/Widgets/Draw/_draw.tpl

@ -6,7 +6,7 @@
<div class="draw-actions">
<ul class="list middle">
<li id="draw-clear">
<span class="primary active icon bubble color gray">
<span class="primary active icon bubble color transparent">
<i class="material-symbols">delete</i>
</span>
</li>
@ -14,17 +14,17 @@
<br />
<ul class="list draw-widths">
<li data-width="small">
<span class="primary active icon bubble color bgray">
<span class="primary active icon bubble color transparent">
<i class="material-symbols">brush</i>
</span>
</li>
<li data-width="medium">
<span class="primary active icon bubble color bgray">
<span class="primary active icon bubble color transparent">
<i class="material-symbols">brush</i>
</span>
</li>
<li data-width="big">
<span class="primary active icon bubble color bgray">
<span class="primary active icon bubble color transparent">
<i class="material-symbols">brush</i>
</span>
</li>
@ -57,8 +57,8 @@
</ul>
<ul class="list">
<li class="draw-eraser">
<span class="primary active icon bubble color bgray">
<i class="material-symbols">crop_landscape</i>
<span class="primary active icon bubble color transparent">
<i class="material-symbols">ink_eraser</i>
</span>
</li>
</ul>

22
app/Widgets/Navigation/navigation.tpl

@ -51,16 +51,18 @@
</div>
</li>
<li onclick="PublishStories_ajaxOpen()"
title="{$c->__('page.publish')}"
>
<span class="primary icon">
<i class="material-symbols">web_stories</i>
</span>
<div>
<p class="normal">{$c->__('stories.publish')}</p>
</div>
</li>
{if="$c->me->hasUpload()"}
<li onclick="PublishStories_ajaxOpen()"
title="{$c->__('page.publish')}"
>
<span class="primary icon">
<i class="material-symbols">web_stories</i>
</span>
<div>
<p class="normal">{$c->__('stories.publish')}</p>
</div>
</li>
{/if}
{/if}
</ul>

24
app/Widgets/Publish/publish.js

@ -104,15 +104,17 @@ MovimWebsocket.attach(() => {
});
MovimEvents.registerWindow('loaded', 'publish', () => {
Upload.attach((file) => {
if (MovimUtils.urlParts().page == 'publish') {
Publish_ajaxAddUpload(document.querySelector('#publish input[name=id]').value, file.id);
}
});
Upload.initiate((file) => {
if (MovimUtils.urlParts().page == 'publish') {
Upload.prependName = 'post';
}
});
if (typeof Upload != 'undefined') {
Upload.attach((file) => {
if (MovimUtils.urlParts().page == 'publish') {
Publish_ajaxAddUpload(document.querySelector('#publish input[name=id]').value, file.id);
}
});
Upload.initiate((file) => {
if (MovimUtils.urlParts().page == 'publish') {
Upload.prependName = 'post';
}
});
}
});

26
app/Widgets/PublishStories/PublishStories.php

@ -15,8 +15,10 @@ class PublishStories extends Base
{
$this->registerEvent('pubsub_postpublish_handle', 'onPublish');
$this->addjs('publishstories.js');
$this->addcss('publishstories.css');
if ($this->me->hasUpload()) {
$this->addjs('publishstories.js');
$this->addcss('publishstories.css');
}
}
public function onPublish(Packet $packet)
@ -30,9 +32,9 @@ class PublishStories extends Base
if (!Post::where('server', $to)->where('node', $node)->where('nodeid', $id)->exists()) {
$gi = new GetItem;
$gi->setTo($to)
->setNode($node)
->setId($id)
->request();
->setNode($node)
->setId($id)
->request();
}
$this->rpc('MovimUtils.reload', $this->route('chat'));
@ -63,13 +65,13 @@ class PublishStories extends Base
$publish = new PostPublish;
$publish->setTo($this->me->id)
->setNode(Post::STORIES_NODE)
->setId(generateUUID())
->setFrom($this->me->id)
->setTitle($form->title->value)
->addImage($upload->geturl, 'story', 'image/jpeg')
->setTags(getHashtags(htmlspecialchars($form->title->value)))
->request();
->setNode(Post::STORIES_NODE)
->setId(generateUUID())
->setFrom($this->me->id)
->setTitle($form->title->value)
->addImage($upload->geturl, 'story', 'image/jpeg')
->setTags(getHashtags(htmlspecialchars($form->title->value)))
->request();
}
public function display()

6
app/Widgets/Snap/Snap.php

@ -8,7 +8,9 @@ class Snap extends Base
{
public function load()
{
$this->addjs('snap.js');
$this->addcss('snap.css');
if ($this->me->hasUpload()) {
$this->addjs('snap.js');
$this->addcss('snap.css');
}
}
}
Loading…
Cancel
Save