Browse Source

- Display the comments on the microblog posts

- Optimize the roster loading performance (img src)
- Fix the Contact templete padding
pull/16/head
Jaussoin Timothée 11 years ago
parent
commit
61f7a1b67e
  1. 6
      app/models/postn/PostnDAO.php
  2. 2
      app/views/contact.tpl
  3. 5
      app/widgets/Contact/_contact.tpl
  4. 4
      app/widgets/Contact/_contact_edit.tpl
  5. 31
      app/widgets/Post/Post.php
  6. 5
      app/widgets/Post/_post.tpl
  7. 15
      app/widgets/Post/_post_comments.tpl
  8. 1
      app/widgets/Post/locales.ini
  9. 14
      app/widgets/Roster/roster.js
  10. 11
      app/widgets/Roster/roster.tpl
  11. 6
      linker.php
  12. 1
      themes/material/css/list.css

6
app/models/postn/PostnDAO.php

@ -247,6 +247,8 @@ class PostnDAO extends SQL {
left outer join contact on postn.aid = contact.jid
left outer join privacy on postn.nodeid = privacy.pkey
where postn.session = :session
and postn.node not like \'urn:xmpp:microblog:0:comments/%\'
and postn.node not like \'urn:xmpp:inbox\'
order by postn.published desc';
if($limitr)
@ -441,8 +443,8 @@ class PostnDAO extends SQL {
postn.jid = subscription.server and
postn.node = subscription.node
where postn.session = :session
and postn.node not like \'urn:xmpp:microblog:0:comments/%\'
and postn.node not like \'urn:xmpp:inbox\'
and postn.node not like \'urn:xmpp:microblog:0:comments/%\'
and postn.node not like \'urn:xmpp:inbox\'
and subscription is not null
order by postn.published desc
limit 1 offset 0';

2
app/views/contact.tpl

@ -10,7 +10,7 @@
<?php $this->widget('Roster');?>
</div>
<div id="contact_widget">
<?php //$this->widget('Notifs');?>
<?php $this->widget('Notifs');?>
<?php //$this->widget('Tabs');?>
<?php $this->widget('Contact');?>
</div>

5
app/widgets/Contact/_contact.tpl

@ -9,9 +9,8 @@
</li>
</ul>
</header>
<br />
<ul>
<li class="subheader"></li>
{if="$contact->delay != null"}
<li class="condensed block">
<span class="icon brown"><i class="md md-restore"></i></span>
@ -107,8 +106,8 @@
<div class="clear"></div>
{if="$contact->adrlocality != null || $contact->adrcountry != null"}
<br />
<ul>
<li class="subheader"></li>
<li class="subheader">{$c->__('position.legend')}</li>
{if="$contact->adrlocality != null"}

4
app/widgets/Contact/_contact_edit.tpl

@ -11,7 +11,7 @@
<label for="alias">{$c->__('edit.alias')}</label>
</div>
<div>
<datalist id="group" style="display: none;">
<datalist id="group_list" style="display: none;">
{if="is_array($groups)"}
{loop="$groups"}
<option value="{$value}"/>
@ -20,7 +20,7 @@
</datalist>
<input
name="group"
list="group"
list="group_list"
id="group"
class="tiny"
placeholder="{$c->__('edit.group')}"

31
app/widgets/Post/Post.php

@ -18,10 +18,13 @@
* See COPYING for licensing information.
*/
use Moxl\Xec\Action\Microblog\CommentsGet;
class Post extends WidgetCommon
{
function load()
{
$this->registerEvent('microblog_commentsget_handle', 'onComments');
}
function ajaxGetPost($id)
@ -33,6 +36,31 @@ class Post extends WidgetCommon
RPC::call('movim_fill', 'post_widget', $html);
}
function ajaxGetComments($jid, $id)
{
$c = new CommentsGet;
$c->setTo($jid)
->setId($id)
->request();
}
function onComments($packet)
{
$nodeid = $packet->content;
$p = new \Modl\ContactPostn();
$p->nodeid = $nodeid;
$pd = new \Modl\PostnDAO();
$comments = $pd->getComments($p);
$view = $this->tpl();
$view->assign('comments', $comments);
$html = $view->draw('_post_comments', true);
//$html = $this->prepareComments($comments);
RPC::call('movim_fill', 'comments', $html);
}
function prepareEmpty()
{
$view = $this->tpl();
@ -63,6 +91,9 @@ class Post extends WidgetCommon
$view = $this->tpl();
if(isset($p)) {
if(isset($p->commentplace)) {
$this->ajaxGetComments($p->commentplace, $p->nodeid);
}
$view->assign('post', $p);
$view->assign('attachements', $p->getAttachements());
return $view->draw('_post', true);

5
app/widgets/Post/_post.tpl

@ -47,6 +47,9 @@
class="enclosure"
type="{$value.type}"
target="_blank">
<span class="icon small gray">
<span class="md md-attach-file"></span>
</span>
<span>{$value.href}</span>
</a>
</li>
@ -54,4 +57,6 @@
{/if}
</ul>
</footer>
<div id="comments"></div>
</article>

15
app/widgets/Post/_post_comments.tpl

@ -0,0 +1,15 @@
<ul class="divided middle">
<li class="subheader">{$c->__('post.comments')}</li>
{loop="$comments"}
<li class="condensed">
<span class="icon bubble">
<img src="{$value->getContact()->getPhoto('xs', $value->aid)}"/>
</span>
<span class="info">{$value->published|strtotime|prepareDate}</span>
<span>{$value->getContact()->getTrueName()}</span>
<p>
{$value->content}
</p>
</li>
{/loop}
</ul>

1
app/widgets/Post/locales.ini

@ -1,2 +1,3 @@
post.news_feed = 'News Feed'
post.comments = 'Comments'
post.placeholder = 'Discover and register to the groups you are interested in'

14
app/widgets/Roster/roster.js

@ -237,12 +237,6 @@ var jidAvalCompare = function(a, b) {
return n ? n < 0 ? -1 : 1 : 0;
};
/* === Old functions still in use === */
MovimWebsocket.attach(function(){
Roster_ajaxGetRoster();
});
var Roster = {
init : function() {
var search = document.querySelector('#rostersearch');
@ -301,6 +295,12 @@ var Roster = {
}
},
clearSearch: function() {
var search = document.querySelector('#rostersearch');
search.value = '';
search.oninput();
},
setFound : function(jid) {
document.querySelector('input[name=searchjid]').value = jid;
},
@ -310,11 +310,13 @@ var Roster = {
/*recalculated at each click*/
var it = document.querySelectorAll('#rosterlist div > li:not(.subheader)');
Roster.reset(it);
Roster.clearSearch();
movim_add_class(e, 'active');
},
}
MovimWebsocket.attach(function() {
Roster_ajaxGetRoster();
Notification.notifs_key = 'contacts';
Roster.refresh();
});

11
app/widgets/Roster/roster.tpl

@ -24,8 +24,8 @@
id="{{::myjid.ajid}}"
class="{{myjid.ajiditems.rosterview.inactive}} action"
ng-attr-title="{{rosterCtrl.getContactTitle(myjid.ajiditems)}}"
ng-class="{condensed: myjid.ajiditems.status != '' && myjid.ajiditems.status != null }"
ng-class="rosterCtrl.getContactClient(myjid.ajiditems)" >
ng-class="{condensed: myjid.ajiditems.status != '' && myjid.ajiditems.status != null }">
<!--ng-class="rosterCtrl.getContactClient(myjid.ajiditems)"-- >-->
<div
class="action"
ng-if="myjid.ajiditems.rosterview.tune != '' || myjid.ajiditems.rosterview.type != '' "
@ -36,12 +36,15 @@
<i ng-if="myjid.ajiditems.rosterview.tune" class="md md-play-arrow"></i>
</div>
<span class="icon bubble status {{myjid.ajiditems.rosterview.presencetxt}}">
<span
class="icon bubble status {{myjid.ajiditems.rosterview.presencetxt}}"
style="background-image: url({{::myjid.ajiditems.rosterview.avatar}})">
<!--
<img
class="avatar"
ng-src="{{::myjid.ajiditems.rosterview.avatar}}"
alt="avatar"
/>
/>-->
</span>
<!--<div class="chat on"></div>-->
{{myjid.ajiditems.rosterview.name}}

6
linker.php

@ -45,7 +45,7 @@ $connector($config->websocketurl, array('xmpp'))->then(function($conn) use (&$st
$conn->on('message', function($message) use ($conn, $loop) {
if($message != '') {
#fwrite(STDERR, colorize($message, 'yellow')." : ".colorize('received', 'green')."\n");
fwrite(STDERR, colorize($message, 'yellow')." : ".colorize('received', 'green')."\n");
if($message == '</stream:stream>') {
$conn->close();
@ -76,7 +76,7 @@ $connector($config->websocketurl, array('xmpp'))->then(function($conn) use (&$st
}
if(!empty($xml)) {
#fwrite(STDERR, colorize(trim($xml), 'yellow')." : ".colorize('sent to XMPP', 'green')."\n");
fwrite(STDERR, colorize(trim($xml), 'yellow')." : ".colorize('sent to XMPP', 'green')."\n");
$conn->send(trim($xml));
}
}
@ -118,7 +118,7 @@ $connector($config->websocketurl, array('xmpp'))->then(function($conn) use (&$st
\Moxl\API::clear();
if(!empty($xml)) {
#fwrite(STDERR, colorize(trim($xml), 'yellow')." : ".colorize('sent to XMPP', 'green')."\n");
fwrite(STDERR, colorize(trim($xml), 'yellow')." : ".colorize('sent to XMPP', 'green')."\n");
$conn->send(trim($xml));
}

1
themes/material/css/list.css

@ -82,6 +82,7 @@ ul li.condensed p,
ul.thin li.condensed p,
ul.thick li.condensed p {
line-height: 2.5rem;
margin-bottom: 0;
}
ul li > p {

Loading…
Cancel
Save