Browse Source

Save the count of articles in the Infos table

Display the count in CommunitiesServer and CommunityData
Redesign CommunityData
Add a "Add" button when configuring affiliations for a Community
Update the dependencies
Add support for index in Pubsub GetItems in Moxl
pull/684/head
Timothée Jaussoin 7 years ago
parent
commit
77d58832cb
  1. 6
      app/widgets/CommunitiesServer/_communitiesserver.tpl
  2. 11
      app/widgets/CommunityAffiliations/_communityaffiliations_config_content.tpl
  3. 17
      app/widgets/CommunityData/CommunityData.php
  4. 20
      app/widgets/CommunityData/_communitydata.tpl
  5. 10
      composer.lock
  6. 21
      database/migrations/20180807210349_add_items_to_infos_table.php
  7. 11
      lib/moxl/src/Moxl/Stanza/Pubsub.php
  8. 19
      lib/moxl/src/Moxl/Xec/Action/Pubsub/GetItems.php
  9. 1
      themes/material/css/listn.css

6
app/widgets/CommunitiesServer/_communitiesserver.tpl

@ -67,10 +67,10 @@
</span>
</p>
<p>
{if="$value->num > 0"}
{$c->__('communitydata.num', $value->num)}
{if="$value->items > 0"}
{$value->items} <i class="material-icons">receipt</i>
{/if}
{if="$value->occupants > 0 && $value->num > 0"}
{if="$value->occupants > 0 && $value->items > 0"}
-
{/if}
{if="$value->occupants > 0"}

11
app/widgets/CommunityAffiliations/_communityaffiliations_config_content.tpl

@ -51,9 +51,6 @@
<p>{$c->__('button.add')}</p>
</li>
<li>
<span class="primary icon gray">
<i class="material-icons">add</i>
</span>
<form name="addaffiliation">
<div>
<datalist id="jid_list" style="display: none;">
@ -68,7 +65,7 @@
</div>
<div>
<div class="select">
<select name="role" id="role" onchange="CommunityAffiliations.update('addaffiliation')">
<select name="role" id="role" onchange="">
{loop="$roles"}
{if="$value == 'none'"}
<option
@ -86,6 +83,12 @@
</div>
<label for="role">Role</label>
</div>
<p>
<a href="#" onclick="CommunityAffiliations.update('addaffiliation')"
class="button green color">
{$c->__('button.add')}
</a>
</p>
</form>
</li>
</ul>

17
app/widgets/CommunityData/CommunityData.php

@ -21,13 +21,16 @@ class CommunityData extends \Movim\Widget\Base
public function prepareData($origin, $node)
{
$view = $this->tpl();
$view->assign('info', \App\Info::where('server', $origin)
->where('node', $node)
->first());
$view->assign('num', \App\Post::where('server', $origin)
->where('node', $node)
->count());
$info = \App\Info::where('server', $origin)
->where('node', $node)
->first();
$view->assign('info', $info);
$view->assign('num', ($info->items > 0)
? $info->items
: \App\Post::where('server', $origin)
->where('node', $node)
->count());
return $view->draw('_communitydata');
}

20
app/widgets/CommunityData/_communitydata.tpl

@ -1,14 +1,14 @@
<br />
{if="$info"}
<ul class="list block middle">
<ul class="list block middle flex">
{if="$info->logo"}
<li class="large">
<li class="block large">
<p class="center">
<img src="{$info->getLogo()}" style="max-width: 100%"/>
</p>
</li>
{/if}
<li class="large">
<li class="block large">
<p class="normal center line" title="{$info->name}">{$info->name}</p>
{if="$info->description != null && trim($info->description) != ''"}
<p class="center" title="{$info->description}">{$info->description}</p>
@ -33,15 +33,13 @@
</span>
<p class="normal">{$c->__('communitydata.num', $num)}</p>
</li>
</ul>
<ul class="list middle active">
{if="$info->related"}
{$related = $info->related}
<li onclick="MovimUtils.redirect('{$c->route('chat', [$related->server,'room'])}')">
<span class="primary icon bubble color
{$related->name|stringToColor}">
{$related->name|firstLetterCapitalize}
<li onclick="MovimUtils.redirect('{$c->route('chat', [$related->server,'room'])}')"
class="block large active">
<span class="primary icon bubble">
<i class="material-icons">forum</i>
</span>
<span class="control icon">
@ -66,8 +64,8 @@
</li>
{/if}
<a href="{$c->route('node', [$info->server, $info->node])}" target="_blank" class="block">
<li>
<a href="{$c->route('node', [$info->server, $info->node])}" target="_blank" class="block large">
<li class="active">
<span class="primary icon">
<i class="material-icons">wifi_tethering</i>
</span>

10
composer.lock

@ -1369,16 +1369,16 @@
},
{
"name": "nesbot/carbon",
"version": "1.32.0",
"version": "1.33.0",
"source": {
"type": "git",
"url": "https://github.com/briannesbitt/Carbon.git",
"reference": "64563e2b9f69e4db1b82a60e81efa327a30ff343"
"reference": "55667c1007a99e82030874b1bb14d24d07108413"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/64563e2b9f69e4db1b82a60e81efa327a30ff343",
"reference": "64563e2b9f69e4db1b82a60e81efa327a30ff343",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/55667c1007a99e82030874b1bb14d24d07108413",
"reference": "55667c1007a99e82030874b1bb14d24d07108413",
"shasum": ""
},
"require": {
@ -1420,7 +1420,7 @@
"datetime",
"time"
],
"time": "2018-07-05T06:59:26+00:00"
"time": "2018-08-07T08:39:47+00:00"
},
{
"name": "paragonie/random_compat",

21
database/migrations/20180807210349_add_items_to_infos_table.php

@ -0,0 +1,21 @@
<?php
use Movim\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddItemsToInfosTable extends Migration
{
public function up()
{
$this->schema->table('infos', function(Blueprint $table) {
$table->integer('items')->default(0);
});
}
public function down()
{
$this->schema->table('infos', function(Blueprint $table) {
$table->dropColumn('items');
});
}
}

11
lib/moxl/src/Moxl/Stanza/Pubsub.php

@ -330,14 +330,21 @@ class Pubsub
\Moxl\API::request($xml);
}
static function getItems($to, $node, $paging = 10, $after = false, $before = 'empty')
static function getItems($to, $node, $paging = 10, $after = false, $before = 'empty', $skip = 0)
{
$dom = new \DOMDocument('1.0', 'UTF-8');
$pubsub = $dom->createElementNS('http://jabber.org/protocol/pubsub', 'pubsub');
$items = $dom->createElement('items');
$items->setAttribute('node', $node);
if ($after) {
if ($skip != 0) {
$set = $dom->createElement('set');
$set->setAttribute('xmlns', 'http://jabber.org/protocol/rsm');
$set->appendChild($dom->createElement('index', $skip));
$set->appendChild($dom->createElement('max', $paging));
$pubsub->appendChild($set);
} elseif ($after) {
$set = $dom->createElement('set');
$set->setAttribute('xmlns', 'http://jabber.org/protocol/rsm');
$set->appendChild($dom->createElement('after', $after));

19
lib/moxl/src/Moxl/Xec/Action/Pubsub/GetItems.php

@ -14,13 +14,14 @@ class GetItems extends Errors
protected $_paging;
protected $_after;
protected $_before;
protected $_skip;
protected $_paginated = false;
public function request()
{
$this->store();
Pubsub::getItems($this->_to, $this->_node, $this->_paging, $this->_after, $this->_before);
Pubsub::getItems($this->_to, $this->_node, $this->_paging, $this->_after, $this->_before, $this->_skip);
}
public function setAfter($after)
@ -37,6 +38,13 @@ class GetItems extends Errors
return $this;
}
public function setSkip($skip = 0)
{
$this->_skip = $skip;
$this->_paginated = true;
return $this;
}
public function handle($stanza, $parent = false)
{
$ids = [];
@ -66,6 +74,15 @@ class GetItems extends Errors
$first = (string)$stanza->pubsub->set->first;
$last = (string)$stanza->pubsub->set->last;
$count = (string)$stanza->pubsub->set->count;
$info = \App\Info::where('server', $this->_to)
->where('node', $this->_node)
->first();
if ($info) {
$info->items = $count;
$info->save();
}
}
$this->pack([

1
themes/material/css/listn.css

@ -34,6 +34,7 @@ ul.list li > *:not(p, .hide, form) {
ul.list.active li:hover:not(.subheader),
ul.list.active.all li:hover,
ul.list li.active:hover,
ul.list.active li.active:not(.subheader),
ul.tabs > li:hover,
ul.list li > span.active:hover {

Loading…
Cancel
Save