diff --git a/README.md b/README.md index 393f3dc..bb8afef 100644 --- a/README.md +++ b/README.md @@ -5,10 +5,21 @@ Movim is a decentralized social network, written in PHP and HTML5 and based on t Warning: BETA. -Current Movim version : 20150820. +Current Movim version : 20150821. **Changelog** +0.8b 2015-08-23 +- Added language selection : ar, de, es, it, ja, nl, ru +- Fix URL in manifest.json (was https://https://...) +- Public/Private policy changed. The SSO portal is not used anymore + But when a pod is marked as "private", only accounts with @yourdomain.com are able to connect. + This change was necessary for public content (blog) +- Add dedicated php-fpm pool for Movim +- Protect /log and /config properly +- Update to upstream Movim 20150821 +- Fix #6 and #7 + 0.7b 2015-08-20 - Update to upstream Movim 20150820 to fix #5 diff --git a/TODO b/TODO deleted file mode 100644 index e69de29..0000000 diff --git a/conf/nginx.conf b/conf/nginx.conf index e282b51..e8f9d0c 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -10,7 +10,7 @@ location PATHTOCHANGE { location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; - fastcgi_pass unix:/var/run/php5-fpm.sock; + fastcgi_pass unix:/var/run/php5-fpm-movim.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param REMOTE_USER $remote_user; @@ -31,11 +31,12 @@ location ~ ^PATHTOCHANGE/ws/ { proxy_send_timeout 86400s; proxy_redirect off; } - -# Include SSOWAT user panel. - include conf.d/yunohost_panel.conf.inc; } -location ~ ^PATHTOCHANGE/(log|\.ht) { - deny all; -} +location ~ /\.ht { + deny all; + } + +location ~ /(config|log)$ { + return 403; + } diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf new file mode 100644 index 0000000..5c18954 --- /dev/null +++ b/conf/php-fpm.conf @@ -0,0 +1,15 @@ +[movim] +listen = /var/run/php5-fpm-movim.sock +listen.owner = www-data +listen.group = www-data +listen.mode = 0600 +user = movim +group = movim + +pm = dynamic +pm.max_children = 5 +pm.start_servers = 2 +pm.min_spare_servers = 1 +pm.max_spare_servers = 3 +chdir = /var/www/movim +php_admin_value[open_basedir] = none diff --git a/manifest.json b/manifest.json index ad0378d..474c159 100644 --- a/manifest.json +++ b/manifest.json @@ -8,7 +8,7 @@ "maintainer": { "name": "src386", "email": "soyouz@src386.org", - "url": "http://https://github.com/src386" + "url": "http://github.com/src386" }, "multi_instance": "false", "arguments": { @@ -56,7 +56,7 @@ "en": "Pod language", "fr": "Langue du pod" }, - "choices" : ["en", "fr"], + "choices" : ["ar", "de", "en", "es", "fr", "it", "ja", "nl", "ru"], "default" : "en" }, { diff --git a/scripts/install b/scripts/install index 6c19c0f..371a7d7 100644 --- a/scripts/install +++ b/scripts/install @@ -12,13 +12,13 @@ port=$7 # Check domain/path availability sudo yunohost app checkurl $domain$path -a movim if [[ ! $? -eq 0 ]]; then -exit 1 + exit 1 fi # Check port availability sudo yunohost app checkport $port if [[ ! $? -eq 0 ]]; then -exit 1 + exit 1 fi # Check user availability @@ -30,15 +30,17 @@ fi # Check password not empty if [[ -z "$password" ]]; then printf "Error empty admin password, aborting" -exit 1 + exit 1 fi +# Save parameters sudo yunohost app setting movim admin -v $admin sudo yunohost app setting movim public_site -v $public_site sudo yunohost app setting movim port -v $port +sudo yunohost app setting movim path -v $path # Generate random password -db_pwd=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{24\}\).*/\1/p') +db_pwd=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[[:alnum:]]') # Use 'movim' as database name and user db_user=movim @@ -54,18 +56,18 @@ sudo apt-get install php5-gd php5-curl php5-imagick php5-cli -y final_path=/var/www/movim sudo mkdir -p $final_path sudo cp -a ../sources/* $final_path +sudo cp $final_path/config/db.example.inc.php $final_path/config/db.inc.php # Create movim system user and set permissions sudo useradd -d /var/www/movim -s /bin/sh movim sudo chown -R movim:www-data $final_path -sudo chmod -R 770 $final_path +sudo chmod -R 750 $final_path # Install PHP dependencies sudo su -c "curl -sS https://getcomposer.org/installer | php -- --install-dir=$final_path" movim sudo su -c "cd $final_path && php composer.phar install" movim # Movim configuration -sudo cp $final_path/config/db.example.inc.php $final_path/config/db.inc.php sudo sed -i "s@'username' => 'username'@'username' => '$db_user'@g" $final_path/config/db.inc.php sudo sed -i "s@'password' => 'password'@'password' => '$db_pwd'@g" $final_path/config/db.inc.php sudo sed -i "s@/ws/@$path/ws/@g" $final_path/app/assets/js/movim_websocket.js @@ -76,6 +78,10 @@ sudo su -c "cd $final_path && php mud.php config environment:production" movim sudo su -c "cd $final_path && php mud.php config timezone:`cat /etc/timezone`" movim sudo su -c "cd $final_path && php mud.php config username:$admin" movim sudo su -c "cd $final_path && php mud.php config password:`echo -n $password | sha1sum | awk '{print $1}'`" movim +if [ $public_site = "No" ]; +then + sudo su -c "cd $final_path && php mud.php config xmppwhitelist:$domain" movim +fi sudo yunohost app addaccess movim -u $admin # Copy init script or systemd service @@ -95,22 +101,20 @@ else sudo /etc/init.d/movim start fi +# php-fpm configuration +sudo cp ../conf/php-fpm.conf /etc/php5/fpm/pool.d/movim.conf + # Nginx configuration sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf sed -i "s@YHPORT@$port@g" ../conf/nginx.conf +sed -i "s@//ws/@/ws/@g" ../conf/nginx.conf # Avoid duplicate / sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/movim.conf # SSOwat Configuration sudo yunohost app setting movim skipped_uris -v "/" -if [ $public_site = "No" ]; -then - sudo yunohost app setting movim protected_uris -v "/" -else - sudo yunohost app setting movim protected_uris -v "/?q=admin" -fi sudo yunohost app ssowatconf # Start Movim -sudo service nginx reload sudo service php5-fpm restart +sudo service nginx reload diff --git a/scripts/upgrade b/scripts/upgrade index eddd07e..57bf11a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -4,20 +4,20 @@ path=$(sudo yunohost app setting movim path) domain=$(sudo yunohost app setting movim domain) port=$(sudo yunohost app setting movim port) +public_site=$(sudo yunohost app setting movim public_site) # Install Movim files final_path=/var/www/movim sudo cp -a ../sources/* $final_path -#sudo chown -R www-data: $final_path # Create movim user if not exists and set permissions if grep -q movim /etc/passwd; then sudo chown -R movim:www-data $final_path - sudo chmod -R 770 $final_path + sudo chmod -R 750 $final_path else sudo useradd -s /bin/sh -d $final_path movim sudo chown -R movim:www-data $final_path - sudo chmod -R 770 $final_path + sudo chmod -R 750 $final_path fi # Update PHP dependencies @@ -27,6 +27,15 @@ sudo su -c "cd $final_path && php composer.phar install" movim # Movim configuration sudo sed -i "s@/ws/@$path/ws/@g" $final_path/app/assets/js/movim_websocket.js +# Update xmppwhitelist if private +if [ $public_site = "No" ]; +then + sudo su -c "cd $final_path && php mud.php config xmppwhitelist:$domain" movim +fi + +# Delete obsolete SSO conf +sudo yunohost app setting movim protected_uris -d + # Update init scripts sudo sed -i "s@YHURL@$domain$path@g" ../conf/movim.{service,init} sudo sed -i "s@YHDIR@$final_path@g" ../conf/movim.{service,init} @@ -47,6 +56,18 @@ else sudo /etc/init.d/movim start fi +# Update php-fpm configuration +sudo cp ../conf/php-fpm.conf /etc/php5/fpm/pool.d/movim.conf + +# Nginx configuration +sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf +sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf +sed -i "s@YHPORT@$port@g" ../conf/nginx.conf +sed -i "s@//ws/@/ws/@g" ../conf/nginx.conf # Avoid duplicate / +sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/movim.conf + # Reload sudo yunohost app ssowatconf sudo service movim restart +sudo service php5-fpm restart +sudo service nginx reload diff --git a/sources/app/helpers/StringHelper.php b/sources/app/helpers/StringHelper.php index 3bd3ff3..3a6edce 100644 --- a/sources/app/helpers/StringHelper.php +++ b/sources/app/helpers/StringHelper.php @@ -224,7 +224,12 @@ function cleanJid($jid) */ function explodeJid($jid) { - list($jid, $resource) = explode('/', $jid); + $arr = explode('/', $jid); + $jid = $arr[0]; + + if(isset($arr[1])) $resource = $arr[1]; + else $resource = null; + list($username, $server) = explode('@', $jid); return array( diff --git a/sources/app/models/contact/Contact.php b/sources/app/models/contact/Contact.php index ae332cd..d657101 100644 --- a/sources/app/models/contact/Contact.php +++ b/sources/app/models/contact/Contact.php @@ -261,7 +261,7 @@ class Contact extends Model { public function setVcard4($vcard) { if(isset($vcard->bday->date)) $this->date = (string)$vcard->bday->date; - if($empty($this->date)) + if(empty($this->date)) $this->date = null; $this->name = (string)$vcard->nickname->text; diff --git a/sources/app/widgets/Chat/chat.css b/sources/app/widgets/Chat/chat.css index 3477028..b4c0dfd 100644 --- a/sources/app/widgets/Chat/chat.css +++ b/sources/app/widgets/Chat/chat.css @@ -1,7 +1,7 @@ #chat_header.encrypted:after{ content: ""; display: inline-block; - font-family: "Material Design Iconic Font"; + font-family: "Material Design Iconic Font"; content: "\f041"; font-size: 2.5rem; margin-left: 1rem; @@ -19,7 +19,7 @@ #chat_widget .chat_box ul { margin: 0 auto; max-width: 100rem; - margin-left: calc(50% - 51rem); + margin-left: calc(45% - 49rem); } #chat_widget .chat_box form { diff --git a/sources/app/widgets/Chat/chat.js b/sources/app/widgets/Chat/chat.js index 9531754..afa727d 100644 --- a/sources/app/widgets/Chat/chat.js +++ b/sources/app/widgets/Chat/chat.js @@ -121,6 +121,13 @@ var Chat = { } } +MovimWebsocket.attach(function() { + var jid = document.querySelector('#chat_widget').dataset.jid; + if(jid) { + Chat_ajaxGet(jid); + } +}); + Upload.attach(function() { var textarea = document.querySelector('#chat_textarea'); textarea.value = Upload.get + ' ' + textarea.value; diff --git a/sources/app/widgets/Chat/chat.tpl b/sources/app/widgets/Chat/chat.tpl index a21c0aa..2d520c6 100644 --- a/sources/app/widgets/Chat/chat.tpl +++ b/sources/app/widgets/Chat/chat.tpl @@ -1,10 +1,3 @@ -
+
{$c->prepareEmpty()} - {if="$jid"} - - {/if}
diff --git a/sources/app/widgets/Chats/Chats.php b/sources/app/widgets/Chats/Chats.php index 1c8c823..6c3f920 100644 --- a/sources/app/widgets/Chats/Chats.php +++ b/sources/app/widgets/Chats/Chats.php @@ -15,6 +15,8 @@ class Chats extends WidgetBase $this->registerEvent('carbons', 'onMessage'); $this->registerEvent('message', 'onMessage'); $this->registerEvent('presence', 'onPresence', 'chat'); + $this->registerEvent('composing', 'onComposing'); + $this->registerEvent('paused', 'onPaused'); } function onMessage($packet) @@ -56,6 +58,29 @@ class Chats extends WidgetBase } } + function onComposing($array) + { + $this->setState($array, $this->__('chats.composing')); + } + + function onPaused($array) + { + $this->setState($array, $this->__('chats.paused')); + } + + private function setState($array, $message) + { + list($from, $to) = $array; + if($from == $this->user->getLogin()) { + $jid = $to; + } else { + $jid = $from; + } + + RPC::call('movim_replace', $jid.'_chat_item', $this->prepareChat($jid, $message)); + RPC::call('Chats.refresh'); + } + /** * @brief Get history */ @@ -67,7 +92,7 @@ class Chats extends WidgetBase $messages = $md->getContact(echapJid($jid), 0, 1); $g = new \Moxl\Xec\Action\MAM\Get; - $g->setJid($jid); + $g->setJid(echapJid($jid)); if(!empty($messages)) { $g->setStart(strtotime($messages[0]->published)); @@ -156,7 +181,7 @@ class Chats extends WidgetBase return $view->draw('_chats', true); } - function prepareChat($jid) + function prepareChat($jid, $status = null) { if(!$this->validateJid($jid)) return; @@ -180,6 +205,8 @@ class Chats extends WidgetBase $view->assign('caps', null); } + $view->assign('status', $status); + $m = $md->getContact($jid, 0, 1); if(isset($m)) { $view->assign('message', $m[0]); diff --git a/sources/app/widgets/Chats/_chats_item.tpl b/sources/app/widgets/Chats/_chats_item.tpl index 798f6b9..cb566fd 100644 --- a/sources/app/widgets/Chats/_chats_item.tpl +++ b/sources/app/widgets/Chats/_chats_item.tpl @@ -26,12 +26,16 @@ {/if} {$contact->getTrueName()} - {if="isset($message)"} - {$message->published|strtotime|prepareDate} - {if="preg_match('#^\?OTR#', $message->body)"} -

{$c->__('message.encrypted')}

- {else} -

{$message->body|prepareString|strip_tags}

+ {if="isset($status)"} +

{$status}

+ {else} + {if="isset($message)"} + {$message->published|strtotime|prepareDate} + {if="preg_match('#^\?OTR#', $message->body)"} +

{$c->__('message.encrypted')}

+ {else} +

{$message->body|prepareString|strip_tags}

+ {/if} {/if} {/if} diff --git a/sources/app/widgets/Chats/locales.ini b/sources/app/widgets/Chats/locales.ini index 46e51c3..18770ee 100644 --- a/sources/app/widgets/Chats/locales.ini +++ b/sources/app/widgets/Chats/locales.ini @@ -4,6 +4,8 @@ empty = Open a new conversation by clicking on the plus button bello add = Chat with a contact frequent = Frequent contacts more = Load more contacts +composing = Composing... +paused = Paused... [message] encrypted = Encrypted message diff --git a/sources/app/widgets/Roster/roster.tpl b/sources/app/widgets/Roster/roster.tpl index 6e7b6de..58cf12d 100644 --- a/sources/app/widgets/Roster/roster.tpl +++ b/sources/app/widgets/Roster/roster.tpl @@ -1,5 +1,5 @@
-