diff --git a/CHANGELOG b/CHANGELOG index cecd7da..339f727 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,7 +1,7 @@ **Changelog** 1.7 2016-? -- Update to movim 0.9 git2016-02-25 +- Update to movim 0.9 git2016-03-06 - conf/nginx.conf : disable the Yunohost logo 1.6.1 2016-02-12 diff --git a/README.md b/README.md index 4277bf6..50f1ad3 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Movim is a decentralized social network, written in PHP and HTML5 and based on t It is recommended to use a "valid" certificate to use Movim, auto-signed is sometimes problematic. You might want to take a look a StartSSL or Let's Encrypt. -Provided Movim version : 0.9 git2016-02-25 +Provided Movim version : 0.9 git2016-03-06 Please read CHANGELOG. diff --git a/sources/app/assets/js/movim_tpl.js b/sources/app/assets/js/movim_tpl.js index ef5f46f..38c85e7 100644 --- a/sources/app/assets/js/movim_tpl.js +++ b/sources/app/assets/js/movim_tpl.js @@ -112,11 +112,15 @@ var MovimTpl = { return (selector.scrollHeight - Math.floor(selector.scrollTop) === selector.clientHeight); } }, - scrollPanel : function() { + scrollPanel : function(time) { var selector = document.querySelector('main section > div:first-child:nth-last-child(2) ~ div div'); + if(typeof time == 'undefined') time = 0; + if(selector != null) { - selector.scrollTop = selector.scrollHeight; + setTimeout(function() { + selector.scrollTop = selector.scrollHeight; + }, time); } }, scrollPanelTop : function() { diff --git a/sources/app/helpers/StringHelper.php b/sources/app/helpers/StringHelper.php index cf3ff4c..1ea7f95 100644 --- a/sources/app/helpers/StringHelper.php +++ b/sources/app/helpers/StringHelper.php @@ -99,7 +99,7 @@ function prepareString($string, $large = false, $preview = false) { $string = addUrls($string, $preview); // We remove all the style attributes - $string = preg_replace_callback( + /*$string = preg_replace_callback( '/(<[^>]+) style=".*?"/i', function($match) { return $match[1]; }, $string @@ -136,7 +136,7 @@ function prepareString($string, $large = false, $preview = false) { '#<[/]?ss[^>]*>#is', function ($match) { return ''; }, ' ' . $string - ); + );*/ // We add some smileys... $emoji = MovimEmoji::getInstance(); diff --git a/sources/app/models/message/Message.php b/sources/app/models/message/Message.php index 451493f..881947f 100644 --- a/sources/app/models/message/Message.php +++ b/sources/app/models/message/Message.php @@ -127,7 +127,6 @@ class Message extends Model { $this->published = gmdate('Y-m-d H:i:s', strtotime($parent->delay->attributes()->stamp)); else $this->published = gmdate('Y-m-d H:i:s'); - $this->delivered = gmdate('Y-m-d H:i:s'); } } diff --git a/sources/app/models/message/MessageDAO.php b/sources/app/models/message/MessageDAO.php index 276cdd7..f8cc3de 100644 --- a/sources/app/models/message/MessageDAO.php +++ b/sources/app/models/message/MessageDAO.php @@ -11,7 +11,7 @@ class MessageDAO extends SQL { html = :html, published = :published, delivered = :delivered, - edited = 1 + edited = :edited where session = :session and id = :id @@ -25,6 +25,7 @@ class MessageDAO extends SQL { 'id' => $message->id, 'session' => $message->session, 'jidto' => $message->jidto, + 'edited' => $message->edited, 'jidfrom' => $message->jidfrom, 'body' => $message->body, 'html' => $message->html, @@ -91,6 +92,25 @@ class MessageDAO extends SQL { return $this->run('Message'); } + function getId($id) + { + $this->_sql = ' + select * from message + where session = :session + and id = :id + limit 1'; + + $this->prepare( + 'Message', + array( + 'session' => $this->_user, + 'id' => $id + ) + ); + + return $this->run('Message', 'item'); + } + function getLastItem($to) { $this->_sql = ' diff --git a/sources/app/views/page.tpl b/sources/app/views/page.tpl index d8a0527..c52c776 100644 --- a/sources/app/views/page.tpl +++ b/sources/app/views/page.tpl @@ -49,6 +49,6 @@ widget('Dialog');?> widget('Notification');?> content();?> - + diff --git a/sources/app/widgets/Blog/blog.tpl b/sources/app/widgets/Blog/blog.tpl index 5b15d9e..08d10a5 100644 --- a/sources/app/widgets/Blog/blog.tpl +++ b/sources/app/widgets/Blog/blog.tpl @@ -47,10 +47,11 @@ - + diff --git a/sources/app/widgets/Chat/Chat.php b/sources/app/widgets/Chat/Chat.php index dd67cce..e60ce38 100644 --- a/sources/app/widgets/Chat/Chat.php +++ b/sources/app/widgets/Chat/Chat.php @@ -25,6 +25,7 @@ class Chat extends WidgetBase $this->addcss('chat.css'); $this->registerEvent('carbons', 'onMessage'); $this->registerEvent('message', 'onMessage'); + $this->registerEvent('receipt', 'onMessage'); $this->registerEvent('mamresult', 'onMessageHistory'); $this->registerEvent('composing', 'onComposing'); $this->registerEvent('paused', 'onPaused'); @@ -255,7 +256,6 @@ class Chat extends WidgetBase } else { $m->id = Uuid::uuid4(); $m->published = gmdate('Y-m-d H:i:s'); - $m->delivered = gmdate('Y-m-d H:i:s'); } $session = \Sessionx::start(); @@ -571,7 +571,7 @@ class Chat extends WidgetBase RPC::call('Chat.setBubbles', $left, $right, $room); RPC::call('Chat.appendMessages', $messages); - RPC::call('MovimTpl.scrollPanel'); + RPC::call('MovimTpl.scrollPanel', 100); } function prepareMessage(&$message) diff --git a/sources/app/widgets/Chat/_chat.tpl b/sources/app/widgets/Chat/_chat.tpl index 950d5c6..9dccced 100644 --- a/sources/app/widgets/Chat/_chat.tpl +++ b/sources/app/widgets/Chat/_chat.tpl @@ -111,9 +111,10 @@ state = 0; Chat.sendMessage(this.dataset.jid, {if="$muc"}true{else}false{/if}); return false; - } else if(event.keyCode == 38) { + } else if(event.keyCode == 38 && this.value == '') { Chat_ajaxLast(this.dataset.jid); - } else if(event.keyCode == 40) { + } else if(event.keyCode == 40 + && (this.value == '' || Chat.edit == true)) { Chat.clearReplace(); } else { {if="!$muc"} diff --git a/sources/app/widgets/Chat/chat.js b/sources/app/widgets/Chat/chat.js index e37232b..b916842 100644 --- a/sources/app/widgets/Chat/chat.js +++ b/sources/app/widgets/Chat/chat.js @@ -158,6 +158,10 @@ var Chat = { info.innerHTML = ' ' + info.innerHTML; } + if(message.delivered) { + info.innerHTML = ' ' + info.innerHTML; + } + if(prepend) { Chat.date = message.published; var discussion = document.querySelector('#chat_widget div.contained'); @@ -169,7 +173,8 @@ var Chat = { var scrollDiff = discussion.scrollHeight - Chat.lastScroll; discussion.scrollTop += scrollDiff; Chat.lastScroll = discussion.scrollHeight; - } else if(message.edited) { + } else if(message.edited + || message.delivered) { var elem = document.getElementById(message.id); if(elem) elem.parentElement.replaceChild(bubble, elem); @@ -179,7 +184,7 @@ var Chat = { movim_append(id, bubble.outerHTML); } - bubble.querySelector('div.bubble').className = 'bubble'; + //bubble.querySelector('div.bubble').className = 'bubble'; if(bubble.className.indexOf('oppose') > -1 && prepend == null) MovimTpl.scrollPanel(); diff --git a/sources/app/widgets/Chats/Chats.php b/sources/app/widgets/Chats/Chats.php index af7570d..17bae86 100644 --- a/sources/app/widgets/Chats/Chats.php +++ b/sources/app/widgets/Chats/Chats.php @@ -88,7 +88,8 @@ class Chats extends WidgetBase $g->setJid(echapJid($jid)); if(!empty($messages)) { - $g->setStart(strtotime($messages[0]->published)); + // We add a little delay of 10sec to prevent some sync issues + $g->setStart(strtotime($messages[0]->published)+10); } $g->request(); diff --git a/sources/app/widgets/Groups/Groups.php b/sources/app/widgets/Groups/Groups.php index 00e5bb6..6e3dde2 100644 --- a/sources/app/widgets/Groups/Groups.php +++ b/sources/app/widgets/Groups/Groups.php @@ -96,7 +96,10 @@ class Groups extends WidgetBase function ajaxDisco($server) { - if(!$this->validateServer($server)) return; + if(!$this->validateServer($server)) { + Notification::append(null, $this->__('groups.disco_error')); + return; + } $r = new Items; $r->setTo($server)->request(); @@ -191,9 +194,8 @@ class Groups extends WidgetBase */ private function validateServer($server) { - $validate_server = Validator::stringType()->noWhitespace()->length(6, 40); - if(!$validate_server->validate($server)) return false; - else return true; + $validate_server = Validator::noWhitespace()->alnum('.')->length(6, 40); + return ($validate_server->validate($server)); } function display() diff --git a/sources/app/widgets/Post/_post_comments.tpl b/sources/app/widgets/Post/_post_comments.tpl index 461debf..424712f 100644 --- a/sources/app/widgets/Post/_post_comments.tpl +++ b/sources/app/widgets/Post/_post_comments.tpl @@ -32,7 +32,7 @@

{if="$value->contentraw"} - {$value->contentraw} + {$value->contentraw|prepareString} {else} {$value->title} {/if} diff --git a/sources/app/widgets/Rooms/_rooms_list.tpl b/sources/app/widgets/Rooms/_rooms_list.tpl index aa70f75..19ff2f5 100644 --- a/sources/app/widgets/Rooms/_rooms_list.tpl +++ b/sources/app/widgets/Rooms/_rooms_list.tpl @@ -1,7 +1,7 @@

{$c->__('chatrooms.users')}


-
    +
      {$presence = getPresencesTxt()} {loop="$list"}
    • last > 60"} inactive{/if}" diff --git a/sources/app/widgets/Roster/_roster_search.tpl b/sources/app/widgets/Roster/_roster_search.tpl index 7ff4c4b..acae0a3 100644 --- a/sources/app/widgets/Roster/_roster_search.tpl +++ b/sources/app/widgets/Roster/_roster_search.tpl @@ -1,5 +1,5 @@
      -

      {$c->__('roster.search')}

      +

      {$c->__('roster.search_pod')}

      • diff --git a/sources/app/widgets/Roster/locales.ini b/sources/app/widgets/Roster/locales.ini index 813073a..bb0c2e8 100644 --- a/sources/app/widgets/Roster/locales.ini +++ b/sources/app/widgets/Roster/locales.ini @@ -16,3 +16,4 @@ added = Contact added updated = Contact updated deleted = Contact deleted search = Search in your contacts +search_pod = Search a contact diff --git a/sources/app/widgets/Stickers/Stickers.php b/sources/app/widgets/Stickers/Stickers.php index 78e7654..d2a7e1d 100644 --- a/sources/app/widgets/Stickers/Stickers.php +++ b/sources/app/widgets/Stickers/Stickers.php @@ -25,7 +25,7 @@ class Stickers extends WidgetBase list($c, $ext) = explode('@', $cid); list($sh, $key) = explode('+', $c); - $base64 = base64_encode(file_get_contents(dirname(__FILE__).'/stickers/'.$key.'.png')); + $base64 = base64_encode(file_get_contents(dirname(__FILE__).'/stickers/'.$key.'.png')); $a = new Answer; $a->setTo($to) @@ -63,7 +63,6 @@ class Stickers extends WidgetBase $m->body = 'A Stickers has been sent using Movim'; $m->published = gmdate('Y-m-d H:i:s'); - $m->delivered = gmdate('Y-m-d H:i:s'); $session = \Sessionx::start(); @@ -122,6 +121,6 @@ class Stickers extends WidgetBase function display() { - + } } diff --git a/sources/linker.php b/sources/linker.php index b46a353..039c45a 100644 --- a/sources/linker.php +++ b/sources/linker.php @@ -99,7 +99,7 @@ $stdin_behaviour = function ($data) use (&$conn, $loop, &$buffer, &$connector, & if(!empty($xml) && $conn) { //$timestamp = time(); $conn->write(trim($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"); } } } else { @@ -148,7 +148,7 @@ $xmpp_behaviour = function (React\Stream\Stream $stream) use (&$conn, $loop, &$s $restart = true; } - fwrite(STDERR, colorize($message, 'yellow')." : ".colorize('received', 'green')."\n"); + #fwrite(STDERR, colorize($message, 'yellow')." : ".colorize('received', 'green')."\n"); #fwrite(STDERR, colorize(getenv('sid'), 'yellow')." widgets : ".\sizeToCleanSize(memory_get_usage())."\n"); \Moxl\API::clear(); @@ -182,7 +182,7 @@ $xmpp_behaviour = function (React\Stream\Stream $stream) use (&$conn, $loop, &$s if(!empty($xml)) { //$timestamp = time(); $conn->write(trim($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"); } \Moxl\API::clear(); diff --git a/sources/system/controllers/BaseController.php b/sources/system/controllers/BaseController.php index 84c80ba..ea87875 100644 --- a/sources/system/controllers/BaseController.php +++ b/sources/system/controllers/BaseController.php @@ -81,7 +81,7 @@ class BaseController { } else { $built = $content->build($this->name); $this->page->setContent($built); - echo $this->page->build('page'); + echo $this->page->build('page', $this->public); } } } diff --git a/sources/system/template/TplPageBuilder.php b/sources/system/template/TplPageBuilder.php index f6f3263..afbea70 100644 --- a/sources/system/template/TplPageBuilder.php +++ b/sources/system/template/TplPageBuilder.php @@ -3,7 +3,7 @@ /** * @file TplPageBuilder.php * This file is part of Movim. - * + * * @brief This class is the templating engine for movim. It also handles themes. * * @author Timothée jaussoin @@ -32,7 +32,7 @@ class TplPageBuilder $cd = new \Modl\ConfigDAO(); $config = $cd->get(); $this->theme = $config->theme; - + } function viewsPath($file) @@ -65,11 +65,11 @@ class TplPageBuilder . $this->linkFile($file, true) . "\" type=\"text/css\" />\n"; } - + /** * Actually generates the page from templates. */ - function build($view) + function build($view, $public = false) { $this->_view = $view; $template = $this->_view.'.tpl'; @@ -78,8 +78,14 @@ class TplPageBuilder require($this->viewsPath($template)); $outp = ob_get_clean(); + + $scripts = $this->printCss(); + if(!$public) { + $scripts .= $this->printScripts(); + } + $outp = str_replace('<%scripts%>', - $this->printCss() . $this->printScripts(), + $scripts, $outp); return $outp;