From c3e7628712b92ef4293fd18778cb624db95f012f Mon Sep 17 00:00:00 2001 From: src386 Date: Thu, 14 Apr 2016 13:55:24 +0200 Subject: [PATCH] update to movim upstream --- CHANGELOG | 2 +- README.md | 2 +- sources/CHANGELOG.md | 3 + sources/app/widgets/Avatar/Avatar.php | 2 +- sources/app/widgets/Avatar/avatar.js | 3 - sources/app/widgets/Chat/chat.css | 17 +- sources/composer.json | 4 +- sources/composer.lock | 74 +++++++- sources/daemon.php | 2 +- sources/mud.php | 179 +----------------- sources/src/Movim/Console/ConfigCommand.php | 79 ++++++++ sources/src/Movim/Console/DatabaseCommand.php | 45 +++++ 12 files changed, 217 insertions(+), 195 deletions(-) create mode 100644 sources/src/Movim/Console/ConfigCommand.php create mode 100644 sources/src/Movim/Console/DatabaseCommand.php diff --git a/CHANGELOG b/CHANGELOG index 04655c5..64469a5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,7 +1,7 @@ **Changelog** 1.8 2016? -- Update to movim 0.9 git2016-04-12 +- Update to movim 0.9 git2016-04-14 1.7.1 2016-30-30 - Update to movim 0.9 git2016-03-30 diff --git a/README.md b/README.md index bddedee..6bc7b8c 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-04-12 +Provided Movim version : 0.9 git2016-04-14 Please read CHANGELOG. diff --git a/sources/CHANGELOG.md b/sources/CHANGELOG.md index 21cd034..c55db9d 100644 --- a/sources/CHANGELOG.md +++ b/sources/CHANGELOG.md @@ -3,6 +3,9 @@ Movim Changelog v0.9.1 (trunk) --------------------------- + * Moving values from Sessionx to Session + * Using chart.js for the statistics + * Refactor the "public" system for the Posts * CSS fixes * Add Last Message Edition support * Improve Post discovery in the News page diff --git a/sources/app/widgets/Avatar/Avatar.php b/sources/app/widgets/Avatar/Avatar.php index a030230..e44ed6b 100644 --- a/sources/app/widgets/Avatar/Avatar.php +++ b/sources/app/widgets/Avatar/Avatar.php @@ -88,7 +88,7 @@ class Avatar extends \Movim\Widget\Base ->request(); } - function ajaxGetForm() + function ajaxDisplay() { $cd = new \modl\ContactDAO(); $me = $cd->get(); diff --git a/sources/app/widgets/Avatar/avatar.js b/sources/app/widgets/Avatar/avatar.js index 57f5094..b55f633 100644 --- a/sources/app/widgets/Avatar/avatar.js +++ b/sources/app/widgets/Avatar/avatar.js @@ -50,9 +50,6 @@ var Avatar = { } } -MovimWebsocket.attach(function() { - Avatar_ajaxGetForm(); -}); /* function showVideo(){ navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia; diff --git a/sources/app/widgets/Chat/chat.css b/sources/app/widgets/Chat/chat.css index 6e54c16..c720464 100644 --- a/sources/app/widgets/Chat/chat.css +++ b/sources/app/widgets/Chat/chat.css @@ -11,15 +11,14 @@ position: fixed; bottom: 0; background-color: white; - width: 70%; + width: 65%; max-width: 100%; border-top: 1px solid rgba(0, 0, 0, 0.12); } #chat_widget .chat_box ul { - margin: 0 auto; - max-width: 100rem; - margin-left: calc(45% - 49rem); + margin: 0; + max-width: 100%; } #chat_widget .chat_box form { @@ -53,6 +52,10 @@ right: 2rem; } +#chat_widget .contained ul { + overflow-x: hidden; +} + /* Chatroom */ #chat_widget ul.simple { @@ -172,11 +175,7 @@ table.emojis td:hover { @media screen and (max-width: 1024px) { #chat_widget .chat_box { - width: 100%; left: 0; - } - - #chat_widget .chat_box ul { - margin-left: auto; + width: 100%; } } diff --git a/sources/composer.json b/sources/composer.json index d1b5330..3018897 100644 --- a/sources/composer.json +++ b/sources/composer.json @@ -14,6 +14,7 @@ "monolog/monolog": "1.8.*", "rain/raintpl": "dev-master", "michelf/php-markdown": "1.4.*@dev", + "movim/modl": "dev-master", "movim/sasl2": "dev-master", "movim/moxl": "dev-master", @@ -26,12 +27,13 @@ "react/socket-client": "dev-master", "react/stream": "0.4.3", "react/http": "dev-master", + "react/promise-timer": "^1.1", "stojg/crop": "dev-master", "forxer/Gravatar": "~1.2", "respect/validation": "1.0.*", "ezyang/htmlpurifier": "^4.7", "ramsey/uuid": "^3.2", - "react/promise-timer": "^1.1" + "symfony/console": "^3.0" } } diff --git a/sources/composer.lock b/sources/composer.lock index 8eedbbd..2852266 100644 --- a/sources/composer.lock +++ b/sources/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "959957c08a6e0a7b09d5b3bccf6f6979", - "content-hash": "958b7ab7a85b3465f8038d6848504ff1", + "hash": "03f969c6eb107a15b0b5239da2d3c76e", + "content-hash": "bfebdd8e42854b5a00c9d5dc776a6212", "packages": [ { "name": "cboden/ratchet", @@ -439,16 +439,16 @@ }, { "name": "guzzlehttp/psr7", - "version": "1.2.3", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "2e89629ff057ebb49492ba08e6995d3a6a80021b" + "reference": "31382fef2889136415751badebbd1cb022a4ed72" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/2e89629ff057ebb49492ba08e6995d3a6a80021b", - "reference": "2e89629ff057ebb49492ba08e6995d3a6a80021b", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/31382fef2889136415751badebbd1cb022a4ed72", + "reference": "31382fef2889136415751badebbd1cb022a4ed72", "shasum": "" }, "require": { @@ -493,7 +493,7 @@ "stream", "uri" ], - "time": "2016-02-18 21:54:00" + "time": "2016-04-13 19:56:01" }, { "name": "heyupdate/emoji", @@ -1636,6 +1636,66 @@ ], "time": "2015-12-03 05:49:01" }, + { + "name": "symfony/console", + "version": "v3.0.4", + "source": { + "type": "git", + "url": "https://github.com/symfony/console.git", + "reference": "6b1175135bc2a74c08a28d89761272de8beed8cd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/console/zipball/6b1175135bc2a74c08a28d89761272de8beed8cd", + "reference": "6b1175135bc2a74c08a28d89761272de8beed8cd", + "shasum": "" + }, + "require": { + "php": ">=5.5.9", + "symfony/polyfill-mbstring": "~1.0" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/event-dispatcher": "~2.8|~3.0", + "symfony/process": "~2.8|~3.0" + }, + "suggest": { + "psr/log": "For using the console logger", + "symfony/event-dispatcher": "", + "symfony/process": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Console\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Console Component", + "homepage": "https://symfony.com", + "time": "2016-03-16 17:00:50" + }, { "name": "symfony/event-dispatcher", "version": "v3.0.4", diff --git a/sources/daemon.php b/sources/daemon.php index 0662c41..e004968 100755 --- a/sources/daemon.php +++ b/sources/daemon.php @@ -40,7 +40,7 @@ if($infos != null) { } 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; } diff --git a/sources/mud.php b/sources/mud.php index 64fbc83..0c2ec16 100755 --- a/sources/mud.php +++ b/sources/mud.php @@ -5,178 +5,15 @@ require __DIR__ . '/vendor/autoload.php'; define('DOCUMENT_ROOT', dirname(__FILE__)); use Movim\Bootstrap; +use Movim\Console\DatabaseCommand; +use Movim\Console\ConfigCommand; +use Symfony\Component\Console\Application; + $bootstrap = new Bootstrap(); $bootstrap->boot(); -$argsize = count($argv); -if($argsize == 1) { - echo -colorize("Welcome to Mud - Movim Unified Doer +$application = new Application; +$application->add(new DatabaseCommand); +$application->add(new ConfigCommand); +$application->run(); -Here some requests you can do with me :", 'green')." -- ".colorize("getloc", 'yellow')." grab all the translations in Movim and generate a global locale file -- ".colorize("comploc", 'yellow')." compile the current locales to a simple PHP array to boost Movim execution -- ".colorize("comptz", 'yellow')." compile the timezones -- ".colorize("db", 'yellow')." create/update the database -- ".colorize("config", 'yellow')." set the configuration of Movim (separated by commas and colons) eg. info:Test,description:Hop - "; - -} elseif($argsize == 2) { - switch ($argv[1]) { - case 'getloc': - getloc(); - break; - /*case 'comploc': - comploc(); - break;*/ - case 'comptz': - comptz(); - break; - case 'config': - echo colorize("You need to pass an argument", 'red'); - break; - case 'db': - $md = Modl\Modl::getInstance(); - $infos = $md->check(); - - if($infos == null) { - echo colorize("Nothing to do\n", 'green'); - } else { - echo colorize("The database need to be updated\n", 'green'); - foreach($infos as $i) { - echo colorize($i."\n", 'blue'); - } - } - break; - } -} elseif($argsize == 3) { - switch ($argv[1]) { - case 'config': - config($argv[2]); - break; - case 'db': - if($argv[2] == 'set') { - $md = Modl\Modl::getInstance(); - $md->check(true); - echo colorize("Database updated\n", 'green'); - } - break; - } -} - -function config($values) { - echo colorize("Movim configuration setter\n", 'green'); - - $cd = new \Modl\ConfigDAO(); - $config = $cd->get(); - - $values = explode(',', $values); - foreach($values as $value) { - $exp = explode(':', $value); - $key = $exp[0]; - array_shift($exp); - $value = implode(':', $exp); - - if(property_exists($config, $key)) { - $old = $config->$key; - $config->$key = $value; - - $cd->set($config); - echo colorize("The configuration key ", 'yellow'). - colorize($key, 'red'). - colorize(" has been updated from ", 'yellow'). - colorize($old, 'blue'). - colorize(" to ", 'yellow'). - colorize($value, 'blue')."\n"; - } - } -} - -function getloc() { - echo colorize("Locales grabber\n", 'green'); - - // We look for all the ini files - $inifiles = glob(WIDGETS_PATH.'*/*.ini'); - array_push($inifiles, LOCALES_PATH . 'locales.ini'); - - $locales = CACHE_PATH.'locales.php'; - $pot = CACHE_PATH.'messages.pot'; - - // We create the cache file - $out = " $value) { - $out .= "t(\"$value\");\n"; - } - } - - $fp = fopen($locales, 'w'); - fwrite($fp, $out); - fclose($fp); - - echo "File $locales created\n"; - - // And we run gettext on it - exec("xgettext -e --no-wrap -kt -o $pot -L PHP $locales "); - - echo "File $pot created\n"; -} - -function comploc() { - echo colorize("Locales compiler\n", 'green'); - - $folder = CACHE_PATH.'/locales/'; - - if(!file_exists($folder)) { - $bool = mkdir($folder); - if(!$bool) { - echo colorize("The locales cache folder can't be created", 'red'); - exit; - } - } else - echo colorize("Folder already exist, don't re-create it\n", 'red'); - - - $langs = loadLangArray(); - foreach($langs as $key => $value) { - $langarr = parseLangFile(DOCUMENT_ROOT . '/locales/' . $key . '.po'); - - $out = ' $msgstr) - if($msgid != '') - $out .= '"'.$msgid.'" => "'. $msgstr . '",'."\n"; - - $out .= ');'; - - $fp = fopen($folder.$key.'.php', 'w'); - fwrite($fp, $out); - fclose($fp); - - echo "- $key compiled\n"; - } -} - -function comptz() { - $file = HELPERS_PATH.'TimezoneList.php'; - $tz = generateTimezoneList(); - - $out = ' $value) - $out .= '"'.$key.'" => "'. $value . '",'."\n"; - - $out .= ');'; - - $fp = fopen($file, 'w'); - fwrite($fp, $out); - fclose($fp); - - echo "- Timezones compiled in $file\n"; -} - -echo "\n"; diff --git a/sources/src/Movim/Console/ConfigCommand.php b/sources/src/Movim/Console/ConfigCommand.php new file mode 100644 index 0000000..0b8f1d4 --- /dev/null +++ b/sources/src/Movim/Console/ConfigCommand.php @@ -0,0 +1,79 @@ +setName('config') + ->setDescription('Change the configuration') + ->addOption( + 'info', + null, + InputOption::VALUE_REQUIRED, + 'Content of the info box on the login page' + ) + ->addOption( + 'username', + null, + InputOption::VALUE_REQUIRED, + 'Username for the admin area' + ) + ->addOption( + 'password', + null, + InputOption::VALUE_REQUIRED, + 'Password for the admin area' + ) + ->addOption( + 'timezone', + null, + InputOption::VALUE_REQUIRED, + 'The server timezone' + ) + ->addOption( + 'loglevel', + null, + InputOption::VALUE_REQUIRED, + 'The server loglevel, default 0' + ) + ->addOption( + 'locale', + null, + InputOption::VALUE_REQUIRED, + 'The server main locale' + ) + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $cd = new \Modl\ConfigDAO(); + $config = $cd->get(); + + foreach($input->getOptions() as $key => $value) { + if(property_exists($config, $key) && isset($value)) { + if($key == 'password') $value = sha1($value); + + $old = $config->$key; + $config->$key = $value; + + $cd->set($config); + $output->writeln( + 'The configuration key '. + $key. + ' has been updated from '. + $old. + ' to '. + $value); + } + } + } +} diff --git a/sources/src/Movim/Console/DatabaseCommand.php b/sources/src/Movim/Console/DatabaseCommand.php new file mode 100644 index 0000000..eb8c71d --- /dev/null +++ b/sources/src/Movim/Console/DatabaseCommand.php @@ -0,0 +1,45 @@ +setName('db') + ->setDescription('Database updater') + ->addOption( + 'set', + 's', + InputOption::VALUE_NONE, + 'Will apply updates on the database' + ) + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $md = \Modl\Modl::getInstance(); + + if($input->getOption('set')) { + $md->check(true); + $output->writeln('Database updated'); + } else { + $toDo = $md->check(); + if($toDo != null) { + $output->writeln('The database needs to be updated'); + foreach($toDo as $do) { + $output->writeln(''.$do.''); + } + } else { + $output->writeln('Nothing to do here'); + } + } + } +}