Browse Source

Add a little helper in the Publish widget when publishing publicly and the blog is configured on presence

pull/1456/head
Timothée Jaussoin 4 months ago
parent
commit
d10d09c44a
  1. 1
      CHANGELOG.md
  2. 25
      app/Widgets/Publish/Publish.php
  3. 6
      app/Widgets/Publish/_publish_blog_presence.tpl
  4. 2
      app/Widgets/Publish/_publish_toggles.tpl
  5. 1
      app/Widgets/Publish/locales.ini
  6. 1
      app/Widgets/Publish/publish.js

1
CHANGELOG.md

@ -16,6 +16,7 @@ v0.31 (master)
* Add WebRTC multi-track support
* Implement Jingle content-modify to refresh the whole SDP and allow simultanous screen sharing
* Add a placeholder if a Post is not accessible without a contact subscription
* Add a little helper in the Publish widget when publishing publicly and the blog is configured on presence
v0.30.1
---------------------------

25
app/Widgets/Publish/Publish.php

@ -4,6 +4,7 @@ namespace App\Widgets\Publish;
use Moxl\Xec\Action\Pubsub\PostPublish;
use Moxl\Xec\Action\Microblog\CommentCreateNode;
use Moxl\Xec\Action\Pubsub\GetConfig;
use Moxl\Xec\Action\Pubsub\Subscribe;
use Movim\Widget\Base;
@ -28,6 +29,7 @@ class Publish extends Base
$this->registerEvent('pubsub_postpublish_handle', 'onPublish');
$this->registerEvent('pubsub_postpublish_errorforbidden', 'onPublishErrorForbidden');
$this->registerEvent('microblog_commentcreatenode_handle', 'onCommentNodeCreated');
$this->registerEvent('pubsub_getconfig_handle', 'onBlogConfig');
$this->addjs('publish.js');
$this->addcss('publish.css');
@ -50,6 +52,16 @@ class Publish extends Base
}
}
public function onBlogConfig($package)
{
$value = $package->content['config']->xpath('//field[@var=\'pubsub#access_model\']/value/text()');
if (is_array($value) && (string)$value[0] == 'presence') {
$view = $this->tpl();
$this->rpc('MovimTpl.fill', '#publish_blog_presence', $view->draw('_publish_blog_presence'));
}
}
public function onPublishErrorForbidden($packet)
{
Toast::send($this->__('publish.publish_error_forbidden'));
@ -375,12 +387,25 @@ class Publish extends Base
$draft->open = $open;
$draft->save();
$this->ajaxCheckPrivacy($id);
Toast::send(($open)
? $this->__('post.public_yes')
: $this->__('post.public_no'));
}
}
public function ajaxCheckPrivacy($id)
{
$draft = $this->user->drafts()->find($id);
if ($draft && $draft->open) {
(new GetConfig)->setNode(AppPost::MICROBLOG_NODE)->request();
} else {
$this->rpc('MovimTpl.fill', '#publish_blog_presence', '');
}
}
public function ajaxToggleCommentsDisabled($id, bool $commentsDisabled)
{
$draft = $this->user->drafts()->find($id);

6
app/Widgets/Publish/_publish_blog_presence.tpl

@ -0,0 +1,6 @@
<span class="primary"></span>
<div>
<span class="supporting">
<i class="material-symbols">info</i> {$c->__('publish.blog_presence')}
</span>
</div>

2
app/Widgets/Publish/_publish_toggles.tpl

@ -26,6 +26,8 @@
</div>
</li>
<li id="publish_blog_presence"></li>
<li>
<span class="primary comments_disabled"
title="{$c->__('post.comments_disabled_title')}">

1
app/Widgets/Publish/locales.ini

@ -20,3 +20,4 @@ draft_saved = Draft saved
rich_editor = Rich text editor
help_hashtag = "Add #hashtags in your title or content to allow your post to be discovered"
publish_error_forbidden = You are not authorized to publish there
blog_presence = "Your blog is only accessible to your subscribers. You can make it accessible to anyone in the settings page."

1
app/Widgets/Publish/publish.js

@ -42,6 +42,7 @@ var Publish = {
MovimUtils.applyAutoheight();
Publish_ajaxOpenlinkPreview(id);
Publish_ajaxCheckPrivacy(id);
},
saveTitle: function () {

Loading…
Cancel
Save