1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/movim_ynh.git synced 2024-09-03 19:46:19 +02:00

update to movim 0.9 git2016-02-12

This commit is contained in:
Xavier ROOT 2016-02-12 10:02:32 +01:00
parent 8fb1bb594f
commit 0c4eae3aff
27 changed files with 123 additions and 51 deletions

View file

@ -1,5 +1,8 @@
**Changelog** **Changelog**
1.6.1 2016-02-12
- Update to movim 0.9 git2016-01-27
1.6 2016-01-27 1.6 2016-01-27
- Update to movim 0.9 git2016-01-27 - Update to movim 0.9 git2016-01-27
- Repository moved to Movim organization on github - Repository moved to Movim organization on github

View file

@ -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. 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-01-27 Provided Movim version : 0.9 git2016-02-12
Please read CHANGELOG. Please read CHANGELOG.

View file

@ -1,7 +1,11 @@
Movim Changelog Movim Changelog
================ ================
v0.9 (trunk) v0.9.1 (trunk)
---------------------------
* CSS fixes
v0.9
--------------------------- ---------------------------
* New User Interface for the whole project * New User Interface for the whole project
* Removed BOSH connections and introduce pure XMPP TLS connections * Removed BOSH connections and introduce pure XMPP TLS connections

View file

@ -1 +1 @@
0.9 0.9.1dev

View file

@ -405,7 +405,7 @@ class Contact extends Model {
$json = json_decode(requestURL($uri, 2)); $json = json_decode(requestURL($uri, 2));
if($json->album) { if(isset($json->album)) {
$json->album->url = $json->album->image[2]->{'#text'}; $json->album->url = $json->album->image[2]->{'#text'};
return $json->album; return $json->album;
} }

View file

@ -255,6 +255,20 @@ class SessionxDAO extends SQL {
return $this->run('Sessionx'); return $this->run('Sessionx');
} }
function deleteEmpty() {
$this->_sql = '
delete from sessionx
where
active = 0';
$this->prepare(
'Sessionx',
array()
);
return $this->run('Sessionx');
}
/*function clean() { /*function clean() {
$this->_sql = ' $this->_sql = '
delete from sessionx delete from sessionx

View file

@ -438,6 +438,7 @@ class Chat extends WidgetBase
$view->assign('emoji', prepareString('😀')); $view->assign('emoji', prepareString('😀'));
$view->assign('muc', $muc); $view->assign('muc', $muc);
$view->assign('anon', false);
if($muc) { if($muc) {
$md = new \Modl\MessageDAO; $md = new \Modl\MessageDAO;

View file

@ -105,6 +105,9 @@
data-jid="{$jid}" data-jid="{$jid}"
onkeypress=" onkeypress="
if(event.keyCode == 13) { if(event.keyCode == 13) {
if(event.shiftKey) {
return;
}
state = 0; state = 0;
Chat.sendMessage(this.dataset.jid, {if="$muc"}true{else}false{/if}); Chat.sendMessage(this.dataset.jid, {if="$muc"}true{else}false{/if});
return false; return false;

View file

@ -91,7 +91,7 @@ var Chat = {
message.body = message.body.substr(4); message.body = message.body.substr(4);
} }
bubble.querySelector('p.message').innerHTML = message.body; bubble.querySelector('p.message').innerHTML = message.body.replace(/\r\n?|\n/g, '<br />');
bubble.querySelector('span.info').innerHTML = message.publishedPrepared; bubble.querySelector('span.info').innerHTML = message.publishedPrepared;
bubble.querySelector('p.user').className = 'user ' + message.color; bubble.querySelector('p.user').className = 'user ' + message.color;
@ -133,7 +133,7 @@ var Chat = {
} }
if(bubble) { if(bubble) {
bubble.querySelector('div.bubble > p').innerHTML = message.body; bubble.querySelector('div.bubble > p').innerHTML = message.body.replace(/\r\n?|\n/g, '<br />');
bubble.querySelector('div.bubble > span.info').innerHTML = message.publishedPrepared; bubble.querySelector('div.bubble > span.info').innerHTML = message.publishedPrepared;

View file

@ -205,7 +205,11 @@ class Chats extends WidgetBase
$view->assign('message', $m[0]); $view->assign('message', $m[0]);
} }
return $view->draw('_chats_item', true); $html = $view->draw('_chats_item', true);
unset($view);
return $html;
} }
private function validateJid($jid) private function validateJid($jid)

View file

@ -37,14 +37,13 @@ class Contact extends WidgetBase
{ {
if(!$this->validateJid($jid)) return; if(!$this->validateJid($jid)) return;
$html = $this->prepareContact($jid); $html = $this->prepareContact($jid, $page);
$r = new GetItems; $r = new GetItems;
$r->setTo($jid) $r->setTo($jid)
->setNode('urn:xmpp:microblog:0') ->setNode('urn:xmpp:microblog:0')
->request(); ->request();
Header::fill($header);
RPC::call('movim_fill', 'contact_widget', $html); RPC::call('movim_fill', 'contact_widget', $html);
RPC::call('MovimTpl.showPanel'); RPC::call('MovimTpl.showPanel');
RPC::call('MovimTpl.scrollHeaders'); RPC::call('MovimTpl.scrollHeaders');
@ -168,7 +167,7 @@ class Contact extends WidgetBase
} }
} }
function prepareContact($jid) function prepareContact($jid, $page = 0)
{ {
if(!$this->validateJid($jid)) return; if(!$this->validateJid($jid)) return;
@ -196,6 +195,7 @@ class Contact extends WidgetBase
$presencestxt = getPresencesTxt(); $presencestxt = getPresencesTxt();
$view->assign('page', $page);
$view->assign('edit', $view->assign('edit',
$this->call( $this->call(
'ajaxEditContact', 'ajaxEditContact',

View file

@ -16,6 +16,12 @@ class Dialog extends WidgetBase
} }
} }
public function ajaxClear()
{
RPC::call('movim_remove_class', '#dialog', 'scroll');
RPC::call('MovimTpl.fill', '#dialog', '');
}
function display() function display()
{ {
} }

View file

@ -7,7 +7,6 @@ var Dialog = {
return false; return false;
}, },
clear : function() { clear : function() {
movim_remove_class('#dialog', 'scroll'); Dialog_ajaxClear();
document.querySelector('#dialog').innerHTML = '';
} }
} }

View file

@ -198,6 +198,7 @@ class Group extends WidgetBase
RPC::call('MovimTpl.fill', '#group_widget.'.stringToUri($server.'_'.$node), $html); RPC::call('MovimTpl.fill', '#group_widget.'.stringToUri($server.'_'.$node), $html);
RPC::call('Group.enableVideos'); RPC::call('Group.enableVideos');
unset($html);
} }

View file

@ -299,7 +299,7 @@
<p> <p>
{$value->getContact()->getTrueName()} {$value->getContact()->getTrueName()}
</p> </p>
<p> <p class="all">
<span class="info">{$value->published|strtotime|prepareDate}</span> <span class="info">{$value->published|strtotime|prepareDate}</span>
{if="$value->title"} {if="$value->title"}
{$value->title} {$value->title}

View file

@ -1,14 +1,14 @@
<div id="share_widget"> <div id="share_widget">
<ul class="thick"> <ul class="list thick">
{if="isset($url)"} {if="isset($url)"}
<li class="condensed action"> <li>
<div class="action"> <span class="control icon gray">
<i class="zmdi zmdi-link"></i> <i class="zmdi zmdi-link"></i>
</div> </span>
<span class="icon bubble blue color"> <span class="primary icon bubble blue color">
<i class="zmdi zmdi-share"></i> <i class="zmdi zmdi-share"></i>
</span> </span>
<span>{$c->__('page.share')}</span> <p>{$c->__('page.share')}</p>
<p>{$c->__('share.success')}</p> <p>{$c->__('share.success')}</p>
<p><a href="{$url}">{$url}</a></p> <p><a href="{$url}">{$url}</a></p>
</li> </li>
@ -17,11 +17,11 @@
movim_redirect('{$c->route('news')}'); movim_redirect('{$c->route('news')}');
</script> </script>
{else} {else}
<li class="condensed"> <li>
<span class="icon bubble orange color"> <span class="primary icon bubble orange color">
<i class="zmdi zmdi-alert-triangle"></i> <i class="zmdi zmdi-alert-triangle"></i>
</span> </span>
<span>{$c->__('page.share')}</span> <p>{$c->__('page.share')}</p>
<p>{$c->__('share.error')}</p> <p>{$c->__('share.error')}</p>
</li> </li>
{/if} {/if}

View file

@ -338,4 +338,13 @@ class Bootstrap {
$db = Modl\Modl::getInstance(); $db = Modl\Modl::getInstance();
$db->setUser($user->getLogin()); $db->setUser($user->getLogin());
} }
public function getWidgets() {
// Return a list of interesting widgets to load (to save memory)
return["Account","AccountNext","Ack","AdHoc","Avatar","Bookmark","Chat",
"Chats","Config","Contact","Dialog","Group","Groups","Header","Init",
"Login","LoginAnonymous","Menu","Notifs","Post","Presence","Publish",
"Rooms","Roster","Upload","Vcard4"];
}
} }

View file

@ -39,7 +39,6 @@ if($infos != null) {
echo colorize("\nTo update the database run\n", 'green'); echo colorize("\nTo update the database run\n", 'green');
echo colorize("php mud.php db set\n", 'purple'); echo colorize("php mud.php db set\n", 'purple');
exit; exit;
break;
} }
$loop = Factory::create(); $loop = Factory::create();

View file

@ -23,7 +23,7 @@ fwrite(STDERR, colorize(getenv('sid'), 'yellow')." widgets before : ".\sizeToCle
// We load and register all the widgets // We load and register all the widgets
$wrapper = WidgetWrapper::getInstance(); $wrapper = WidgetWrapper::getInstance();
$wrapper->registerAll(true); $wrapper->registerAll($bootstrap->getWidgets());
fwrite(STDERR, colorize(getenv('sid'), 'yellow')." widgets : ".\sizeToCleanSize(memory_get_usage())."\n"); fwrite(STDERR, colorize(getenv('sid'), 'yellow')." widgets : ".\sizeToCleanSize(memory_get_usage())."\n");
@ -33,11 +33,20 @@ $parser = new \Moxl\Parser;
$buffer = ''; $buffer = '';
$timestamp = time();
function handleSSLErrors($errno, $errstr) { function handleSSLErrors($errno, $errstr) {
fwrite(STDERR, colorize(getenv('sid'), 'yellow')." : ".colorize($errstr, 'red')."\n"); fwrite(STDERR, colorize(getenv('sid'), 'yellow')." : ".colorize($errstr, 'red')."\n");
} }
$stdin_behaviour = function ($data) use (&$conn, $loop, &$buffer, &$connector, &$xmpp_behaviour, &$parser) { // Temporary linker killer
$loop->addPeriodicTimer(5, function() use(&$conn, &$timestamp) {
if($timestamp < time() - 3600*2) {
$conn->close();
}
});
$stdin_behaviour = function ($data) use (&$conn, $loop, &$buffer, &$connector, &$xmpp_behaviour, &$parser, &$timestamp) {
if(substr($data, -1) == "") { if(substr($data, -1) == "") {
$messages = explode("", $buffer . substr($data, 0, -1)); $messages = explode("", $buffer . substr($data, 0, -1));
$buffer = ''; $buffer = '';
@ -53,6 +62,10 @@ $stdin_behaviour = function ($data) use (&$conn, $loop, &$buffer, &$connector, &
} elseif($msg->func == 'unregister') { } elseif($msg->func == 'unregister') {
\Moxl\Stanza\Stream::end(); \Moxl\Stanza\Stream::end();
} elseif($msg->func == 'register') { } elseif($msg->func == 'register') {
if(is_resource($conn->stream)) {
$conn->stream->close();
}
$cd = new \Modl\ConfigDAO(); $cd = new \Modl\ConfigDAO();
$config = $cd->get(); $config = $cd->get();
@ -83,6 +96,7 @@ $stdin_behaviour = function ($data) use (&$conn, $loop, &$buffer, &$connector, &
\Moxl\API::clear(); \Moxl\API::clear();
if(!empty($xml) && $conn) { if(!empty($xml) && $conn) {
//$timestamp = time();
$conn->write(trim($xml)); $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");
} }
@ -92,7 +106,7 @@ $stdin_behaviour = function ($data) use (&$conn, $loop, &$buffer, &$connector, &
} }
}; };
$xmpp_behaviour = function (React\Stream\Stream $stream) use (&$conn, $loop, &$stdin, $stdin_behaviour, $parser) { $xmpp_behaviour = function (React\Stream\Stream $stream) use (&$conn, $loop, &$stdin, $stdin_behaviour, $parser, &$timestamp) {
$conn = $stream; $conn = $stream;
fwrite(STDERR, colorize(getenv('sid'), 'yellow')." : ".colorize('linker launched', 'blue')."\n"); fwrite(STDERR, colorize(getenv('sid'), 'yellow')." : ".colorize('linker launched', 'blue')."\n");
fwrite(STDERR, colorize(getenv('sid'), 'yellow')." launched : ".\sizeToCleanSize(memory_get_usage())."\n"); fwrite(STDERR, colorize(getenv('sid'), 'yellow')." launched : ".\sizeToCleanSize(memory_get_usage())."\n");
@ -102,7 +116,7 @@ $xmpp_behaviour = function (React\Stream\Stream $stream) use (&$conn, $loop, &$s
// We define a huge buffer to prevent issues with SSL streams, see https://bugs.php.net/bug.php?id=65137 // We define a huge buffer to prevent issues with SSL streams, see https://bugs.php.net/bug.php?id=65137
$conn->bufferSize = 1024*32; $conn->bufferSize = 1024*32;
$conn->on('data', function($message) use (&$conn, $loop, $parser) { $conn->on('data', function($message) use (&$conn, $loop, $parser, &$timestamp) {
if(!empty($message)) { if(!empty($message)) {
$restart = false; $restart = false;
@ -139,6 +153,8 @@ $xmpp_behaviour = function (React\Stream\Stream $stream) use (&$conn, $loop, &$s
\Moxl\API::clear(); \Moxl\API::clear();
\RPC::clear(); \RPC::clear();
$timestamp = time();
if(!$parser->parse($message)) { if(!$parser->parse($message)) {
fwrite(STDERR, colorize(getenv('sid'), 'yellow')." ".$parser->getError()."\n"); fwrite(STDERR, colorize(getenv('sid'), 'yellow')." ".$parser->getError()."\n");
} }
@ -163,6 +179,7 @@ $xmpp_behaviour = function (React\Stream\Stream $stream) use (&$conn, $loop, &$s
$xml = \Moxl\API::commit(); $xml = \Moxl\API::commit();
if(!empty($xml)) { if(!empty($xml)) {
//$timestamp = time();
$conn->write(trim($xml)); $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");
} }

View file

@ -94,7 +94,7 @@ class Core implements MessageComponentInterface {
public function onMessage(ConnectionInterface $from, $msg) public function onMessage(ConnectionInterface $from, $msg)
{ {
$sid = $this->getSid($from); $sid = $this->getSid($from);
if($sid != null) { if($sid != null && isset($this->sessions[$sid])) {
$this->sessions[$sid]->messageIn($from, $msg); $this->sessions[$sid]->messageIn($from, $msg);
} }
} }
@ -102,9 +102,12 @@ class Core implements MessageComponentInterface {
public function onClose(ConnectionInterface $conn) public function onClose(ConnectionInterface $conn)
{ {
$sid = $this->getSid($conn); $sid = $this->getSid($conn);
if($sid != null) { if($sid != null && isset($this->sessions[$sid])) {
$this->sessions[$sid]->detach($conn); $this->sessions[$sid]->detach($conn);
$this->closeEmptySession($sid);
if($this->sessions[$sid]->process == null) {
unset($this->sessions[$sid]);
}
} }
} }
@ -112,26 +115,24 @@ class Core implements MessageComponentInterface {
{ {
$this->loop->addPeriodicTimer(5, function() { $this->loop->addPeriodicTimer(5, function() {
foreach($this->sessions as $sid => $session) { foreach($this->sessions as $sid => $session) {
if((time()-$session->timestamp > $this->cleanerdelay*3600) if($session->countClients() == 0
|| ($session->countClients() == 0 && $session->registered == null) {
&& $session->registered == null)) {
$session->killLinker(); $session->killLinker();
$this->closeEmptySession($sid); }
if($session->process == null) {
unset($this->sessions[$sid]);
} }
} }
$this->cleanupDBSessions();
}); });
} }
private function closeEmptySession($sid) private function cleanupDBSessions()
{ {
// No WebSockets and no linker ? We close the whole session $sd = new \Modl\SessionxDAO();
if($this->sessions[$sid]->countClients() == 0 $sd->deleteEmpty();
&& ($this->sessions[$sid]->process == null)) {
$sd = new \Modl\SessionxDAO();
$sd->delete($sid);
unset($this->sessions[$sid]);
}
} }
public function onError(ConnectionInterface $conn, \Exception $e) public function onError(ConnectionInterface $conn, \Exception $e)

View file

@ -48,7 +48,7 @@ class Session {
// Launching the linker // Launching the linker
$this->process = new \React\ChildProcess\Process( $this->process = new \React\ChildProcess\Process(
'exec php linker.php', 'exec php linker.php ' . $this->sid,
null, null,
array( array(
'sid' => $this->sid, 'sid' => $this->sid,

View file

@ -104,6 +104,7 @@ class Picture {
$im->setImageCompressionQuality(95); $im->setImageCompressionQuality(95);
$im->setInterlaceScheme(Imagick::INTERLACE_PLANE); $im->setInterlaceScheme(Imagick::INTERLACE_PLANE);
$im->writeImage($path); $im->writeImage($path);
$im->clear();
} }
} catch (ImagickException $e) { } catch (ImagickException $e) {
error_log($e->getMessage()); error_log($e->getMessage());
@ -135,6 +136,6 @@ class Picture {
$im->setInterlaceScheme(Imagick::INTERLACE_PLANE); $im->setInterlaceScheme(Imagick::INTERLACE_PLANE);
$im->writeImage($path); $im->writeImage($path);
$im->clear();
} }
} }

View file

@ -21,6 +21,8 @@ function createEmailPic($jid, $email) {
$canvas->setImageFormat('PNG'); $canvas->setImageFormat('PNG');
$canvas->writeImage($cachefile); $canvas->writeImage($cachefile);
$canvas->clear();
} catch (ImagickException $e) { } catch (ImagickException $e) {
error_log($e->getMessage()); error_log($e->getMessage());
} }

View file

@ -140,7 +140,7 @@ class WidgetBase
function display() {} function display() {}
/** /**
* àdesc Return the template's HTML code * @desc Return the template's HTML code
*/ */
function draw() function draw()
{ {

View file

@ -26,6 +26,7 @@ class WidgetWrapper
private $_widgets = array(); private $_widgets = array();
private $_events = array(); private $_events = array();
private $_eventWidgets = array();
private $_view = ''; // The current page where the widget is displayed private $_view = ''; // The current page where the widget is displayed
@ -49,7 +50,12 @@ class WidgetWrapper
if(is_dir(APP_PATH ."widgets/".$widget_dir) && if(is_dir(APP_PATH ."widgets/".$widget_dir) &&
$widget_dir != '..' && $widget_dir != '..' &&
$widget_dir != '.') { $widget_dir != '.') {
if($load) $this->loadWidget($widget_dir, true);
if($load != false
&& in_array($widget_dir, $load)) {
$this->loadWidget($widget_dir, true);
}
array_push($this->_widgets, $widget_dir); array_push($this->_widgets, $widget_dir);
} }
} }
@ -111,6 +117,7 @@ class WidgetWrapper
$this->_events[$key] = array($name); $this->_events[$key] = array($name);
} }
} }
array_push($this->_eventWidgets, $name);
} }
} else { } else {
if($this->_view != '') { if($this->_view != '') {

View file

@ -90,7 +90,8 @@ article section content div.quote {
display: block; display: block;
border-radius: 2px; border-radius: 2px;
border: 1px solid rgba(0, 0, 0, 0.12); border: 1px solid rgba(0, 0, 0, 0.12);
padding: 2rem; padding: 1rem 2rem;
margin-bottom: 1rem;
box-sizing: border-box; box-sizing: border-box;
} }

View file

@ -60,7 +60,7 @@ ul.list li > .primary.small {
margin-top: -1.5rem; margin-top: -1.5rem;
} }
ul.list > li > *:not(.counter):not(span):not(.bubble), ul.list > li > *:not(.counter):not(span):not(.bubble):not(.button),
ul.list li.subheader p { ul.list li.subheader p {
width: 100%; width: 100%;
box-sizing: border-box; box-sizing: border-box;
@ -127,7 +127,7 @@ ul.list li > p:nth-last-of-type(2) + p {
ul.list li > p:nth-last-of-type(3) + p.all, ul.list li > p:nth-last-of-type(3) + p.all,
ul.list li > p:nth-last-of-type(2) + p.all { ul.list li > p:nth-last-of-type(2) + p.all {
max-height: auto; max-height: 100%;
} }
/* Subheader */ /* Subheader */