Browse Source

- Add a first bunch of scripts to package a .deb

- Add a CMake script
- Fix Emoji issue in the Chat widget
pull/16/head
Jaussoin Timothée 10 years ago
parent
commit
b4b859299c
  1. 47
      CMakeLists.txt
  2. 4
      app/helpers/StringHelper.php
  3. 4
      app/models/contact/Contact.php
  4. 25
      app/widgets/Chat/Chat.php
  5. BIN
      app/widgets/Roster/img/clients/adium.png
  6. BIN
      app/widgets/Roster/img/clients/empathy.png
  7. BIN
      app/widgets/Roster/img/clients/gajim.png
  8. BIN
      app/widgets/Roster/img/clients/gtalk.png
  9. BIN
      app/widgets/Roster/img/clients/ichat.png
  10. BIN
      app/widgets/Roster/img/clients/miranda.png
  11. BIN
      app/widgets/Roster/img/clients/pidgin.png
  12. BIN
      app/widgets/Roster/img/clients/psi.png
  13. BIN
      app/widgets/Roster/img/clients/qip.png
  14. BIN
      app/widgets/Roster/img/clients/xabber.png
  15. 21
      debian/config
  16. 6
      debian/etc/apache2/conf-available/movim.conf
  17. 152
      debian/postinst
  18. 25
      debian/postrm
  19. 6
      debian/templates

47
CMakeLists.txt

@ -0,0 +1,47 @@
project(movim)
cmake_minimum_required(VERSION 2.8)
exec_program("cat ../VERSION | cut -d . -f 1 2>/dev/null"
OUTPUT_VARIABLE MOVIM_VERSION_MAJOR)
exec_program("cat ../VERSION | cut -d . -f 2 2>/dev/null"
OUTPUT_VARIABLE MOVIM_VERSION_MINOR)
exec_program("bzr revno 2>/dev/null"
OUTPUT_VARIABLE MOVIM_VERSION_PATCH)
set(VERSION_MAJOR "${MOVIM_VERSION_MAJOR}")
set(VERSION_MINOR "${MOVIM_VERSION_MINOR}")
set(VERSION_PATCH "${MOVIM_VERSION_PATCH}")
#install(DIRECTORY "config" DESTINATION "/etc/${CMAKE_PROJECT_NAME}")
install(DIRECTORY "debian/etc" DESTINATION "/")
install(DIRECTORY "app" DESTINATION "/usr/share/${CMAKE_PROJECT_NAME}")
install(DIRECTORY "src" DESTINATION "/usr/share/${CMAKE_PROJECT_NAME}")
install(DIRECTORY "system" DESTINATION "/usr/share/${CMAKE_PROJECT_NAME}")
install(DIRECTORY "lib" DESTINATION "/var/lib/${CMAKE_PROJECT_NAME}")
install(DIRECTORY "locales" DESTINATION "/var/lib/${CMAKE_PROJECT_NAME}")
install(DIRECTORY "themes" DESTINATION "/var/lib/${CMAKE_PROJECT_NAME}")
install(DIRECTORY "vendor" DESTINATION "/var/lib/${CMAKE_PROJECT_NAME}" REGEX ".git" EXCLUDE)
install(FILES index.php bootstrap.php daemon.php linker.php mud.php "VERSION" DESTINATION "/usr/share/${CMAKE_PROJECT_NAME}")
install(FILES "config/db.example.inc.php" DESTINATION "/etc/${CMAKE_PROJECT_NAME}")
# package settings
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Kick Ass Social Network, decentralized and fully based on XMPP ")
set(CPACK_PACKAGE_VENDOR "Jaussoin Timothée")
set(CPACK_PACKAGE_CONTACT "edhelas@movim.eu")
set(CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${VERSION_PATCH}")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}_${VERSION}")
set(ACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}_${VERSION}")
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "Movim is a kickass distributed social networking platform that protect your privacy an comes with a set of awesome features.")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "php5 (>= 5.4.0), php5-gd (>= 5.4.0), php5-curl (>= 5.4.0), php5-imagick (>= 3.0.0), dbconfig-common(>= 1.8.0)")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Jaussoin Timothée")
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://movim.eu/")
SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/debian/config;${CMAKE_CURRENT_SOURCE_DIR}/debian/postinst;${CMAKE_CURRENT_SOURCE_DIR}/debian/postrm;${CMAKE_CURRENT_SOURCE_DIR}/debian/templates;")
set(PACK "DEB" CACHE STRING "Generate a Package")
set(CPACK_GENERATOR ${PACK})
include(CPack)

4
app/helpers/StringHelper.php

@ -58,7 +58,7 @@ class MovimEmoji
function prepareString($string, $large = false, $preview = false) {
// Add missing links
$string = preg_replace_callback(
"/([\w\"'>]+\:\/\/[\w-?&;#+%~=\.\/\@]+[\w\/])/", function ($match) use($preview) {
"/([\w\"'>]+\:\/\/[\w-?&;#+%:~=\.\/\@]+[\w\/])/", function ($match) use($preview) {
if(!in_array(substr($match[0], 0, 1), array('>', '"', '\''))) {
if($preview) {
$embed = Embed\Embed::create($match[0]);
@ -66,6 +66,8 @@ function prepareString($string, $large = false, $preview = false) {
&& $embed->images[0]['width'] <= 1024
&& $embed->images[0]['height'] <= 1024) {
$content = '<img src="'.$match[0].'"/>';
} elseif($embed->type == 'link') {
$content = $embed->title . ' - ' . $embed->providerName;
} else {
$content = $match[0];
}

4
app/models/contact/Contact.php

@ -417,12 +417,12 @@ class Contact extends Model {
}
function isOld() {
if(strtotime($this->updated) < mktime( // We update the 3 days old vcards
if(strtotime($this->updated) < mktime( // We update the 1 day old vcards
0,
0,
0,
gmdate("m"),
gmdate("d")-3,
gmdate("d")-1,
gmdate("Y")
)
) {

25
app/widgets/Chat/Chat.php

@ -252,7 +252,7 @@ class Chat extends WidgetBase
$m->jidfrom = $to;
}
$m->body = rawurldecode($message);
$m->html = prepareString($m->body, false, true);
$m->published = gmdate('Y-m-d H:i:s');
@ -263,25 +263,26 @@ class Chat extends WidgetBase
$md->set($m);
}
/* Is it really clean ? */
$packet = new Moxl\Xec\Payload\Packet;
$packet->content = $m;
$this->onMessage($packet/*, true*/);
if($resource != false) {
$to = $to . '/' . $resource;
}
// We decode URL codes to send the correct message to the XMPP server
$m = new Publish;
$m->setTo($to);
$m->setContent(htmlspecialchars(rawurldecode($message)));
$p = new Publish;
$p->setTo($to);
//$p->setHTML($m->html);
$p->setContent(htmlspecialchars($m->body));
if($muc) {
$m->setMuc();
$p->setMuc();
}
$m->request();
$p->request();
/* Is it really clean ? */
$packet = new Moxl\Xec\Payload\Packet;
$packet->content = $m;
$this->onMessage($packet/*, true*/);
}
/**
@ -484,7 +485,7 @@ class Chat extends WidgetBase
function prepareMessage(&$message)
{
if(isset($message->html)) {
$message->body = prepareString($message->html);
$message->body = $message->html;
} else {
$message->body = prepareString(htmlentities($message->body , ENT_COMPAT,'UTF-8'));
}

BIN
app/widgets/Roster/img/clients/adium.png

Before

Width: 34  |  Height: 28  |  Size: 1.7 KiB

BIN
app/widgets/Roster/img/clients/empathy.png

Before

Width: 34  |  Height: 28  |  Size: 1.2 KiB

BIN
app/widgets/Roster/img/clients/gajim.png

Before

Width: 34  |  Height: 28  |  Size: 870 B

BIN
app/widgets/Roster/img/clients/gtalk.png

Before

Width: 34  |  Height: 28  |  Size: 1.3 KiB

BIN
app/widgets/Roster/img/clients/ichat.png

Before

Width: 34  |  Height: 28  |  Size: 1.1 KiB

BIN
app/widgets/Roster/img/clients/miranda.png

Before

Width: 34  |  Height: 28  |  Size: 1.2 KiB

BIN
app/widgets/Roster/img/clients/pidgin.png

Before

Width: 34  |  Height: 28  |  Size: 1.6 KiB

BIN
app/widgets/Roster/img/clients/psi.png

Before

Width: 34  |  Height: 28  |  Size: 1.4 KiB

BIN
app/widgets/Roster/img/clients/qip.png

Before

Width: 34  |  Height: 28  |  Size: 1.4 KiB

BIN
app/widgets/Roster/img/clients/xabber.png

Before

Width: 34  |  Height: 28  |  Size: 1.4 KiB

21
debian/config

@ -0,0 +1,21 @@
#!/bin/sh
set -e
. /usr/share/debconf/confmodule
if [ -f /usr/share/dbconfig-common/dpkg/config ]; then
. /usr/share/dbconfig-common/dpkg/config
dbc_dbtypes="pgsql, mysql"
dbc_authmethod_user="password"
. /usr/share/dbconfig-common/dpkg/config
dbc_go movim $@
fi
db_input high movim/httpserver || true
db_go || true
exit 0

6
debian/etc/apache2/conf-available/movim.conf

@ -0,0 +1,6 @@
Alias /movim/ /usr/share/movim/
<Directory /usr/share/movim/>
DirectoryIndex index.php
Options +FollowSymLinks -Indexes
</Directory>

152
debian/postinst

@ -0,0 +1,152 @@
#!/bin/sh
httpserver_init() {
db_get movim/httpserver
httpservers="$RET"
for httpserver in $httpservers; do
httpserver=${httpserver%,}
#if [ "$httpserver" = "nginx" ] ; then
# nginx_install
#else
apache_install $1 $httpserver
#fi
done
}
apache_install() {
server="apache2"
CONF="movim"
COMMON_STATE=$(dpkg-query -f '${Status}' -W 'apache2.2-common' 2>/dev/null | awk '{print $3}' || true)
if [ -e /usr/share/apache2/apache2-maintscript-helper ] ; then
. /usr/share/apache2/apache2-maintscript-helper
apache2_invoke enconf $CONF || exit $?
elif [ "$COMMON_STATE" = "installed" ] || [ "$COMMON_STATE" = "unpacked" ] ; then
[ -d /etc/apache2/conf.d/ ] && [ ! -L /etc/apache2/conf.d/$CONF.conf ] \
&& ln -s ../conf-available/$CONF.conf /etc/apache2/conf.d/$CONF.conf
reload_server $server
fi
}
#nginx_install() {
#server="apache2"
#CONF="movim"
#COMMON_STATE=$(dpkg-query -f '${Status}' -W 'apache2.2-common' 2>/dev/null | awk '{print $3}' || true)
#if [ -e /usr/share/apache2/apache2-maintscript-helper ] ; then
#. /usr/share/apache2/apache2-maintscript-helper
#apache2_invoke enconf $CONF || exit $?
#elif [ "$COMMON_STATE" = "installed" ] || [ "$COMMON_STATE" = "unpacked" ] ; then
#[ -d /etc/apache2/conf.d/ ] && [ ! -L /etc/apache2/conf.d/$CONF.conf ] \
#&& ln -s ../conf-available/$CONF.conf /etc/apache2/conf.d/$CONF.conf
#reload_server $server
#fi
#}
#
# fixperms 0644 /usr/share/movim
#
fixperms () {
PERMS="$1"
FILE="$2"
chmod ${PERMS} "${FILE}"
}
#
# fixownership user:group /var/cache/movim
#
fixownership ()
{
OWNER="$1"
FILE="$2"
chown ${OWNER} "${FILE}"
}
reload_server() {
server=$1
if [ -x /usr/sbin/invoke-rc.d ]; then
invoke-rc.d $server reload 3>/dev/null || true
else
/etc/init.d/$server reload 3>/dev/null || true
fi
}
. /usr/share/debconf/confmodule
db_get movim/debconf_install
if [ "$RET" = false ]; then
exit 0;
fi
. /usr/share/dbconfig-common/dpkg/postinst
dbc_go movim $@
if [ "$dbc_dbtype" == 'mysql' ]; then
dbport='3306'
else
dbport='5432'
fi
# We create the Movim configuration file
#touch /etc/movim/db.inc.php
echo "<?php
# This is the database configuration of Movim
# You need to copy an rename this file to 'db.inc.php' and complete the values
\$conf = array(
# The type can be 'pgsql' or 'mysql'
'type' => '$dbc_dbtype',
# The database username
'username' => '$dbc_dbuser',
# The password
'password' => '$dbc_dbpass',
# Where can we find the database ?
'host' => 'localhost',
# The port number, 3306 for MySQL and 5432 for PostGreSQL
'port' => $dbport,
# The database name
'database' => '$dbc_dbname'
);
" > /etc/movim/db.inc.php
httpserver_init $1
# We create some links
ln -s /etc/movim/ /usr/share/movim/config 2>/dev/null
ln -s /var/lib/movim/lib /usr/share/movim/ 2>/dev/null
ln -s /var/lib/movim/locales /usr/share/movim/ 2>/dev/null
ln -s /var/lib/movim/themes /usr/share/movim/ 2>/dev/null
ln -s /var/lib/movim/vendor /usr/share/movim/ 2>/dev/null
# We create the cache folder
mkdir /var/cache/movim 2>/dev/null
ln -s /var/cache/movim /usr/share/movim/cache 2>/dev/null
fixperms 0775 /var/cache/movim
fixownership "root:www-data" /var/cache/movim
# We create the user folder
mkdir /var/cache/movim/users 2>/dev/null
ln -s /var/cache/movim/users /usr/share/movim/users 2>/dev/null
fixperms 0775 /var/cache/movim/users
fixownership "root:www-data" /var/cache/movim/users
# We create the log folder
mkdir /var/log/movim 2>/dev/null
ln -s /var/log/movim /usr/share/movim/log 2>/dev/null
fixperms 0775 /var/log/movim
fixownership "root:www-data" /var/log/movim
# Fix rights
fixperms 0775 /usr/share/movim
fixownership "root:www-data" /usr/share/movim
fixperms 0775 /usr/share/movim/daemon.php
fixownership "root:www-data" /usr/share/movim/daemon.php
# And we install/update the Movim database
echo "Creating and/or updating the Movim database… please be patient"
chmod +x /usr/share/movim/mud.php
/usr/share/movim/mud.php db set
# We clean some log created by the install to prevent issues
rm /usr/share/movim/log/* /usr/share/movim/cache/*

25
debian/postrm

@ -0,0 +1,25 @@
#!/bin/sh
if [ "$1" = "remove" ] || [ "$1" = "purge" ] ; then
CONF="movim"
COMMON_STATE=$(dpkg-query -f '${Status}' -W 'apache2.2-common' 2>/dev/null | awk '{print $3}' || true)
if [ -e /usr/share/apache2/apache2-maintscript-helper ] ; then
. /usr/share/apache2/apache2-maintscript-helper
apache2_invoke disconf $CONF || exit $?
elif [ "$COMMON_STATE" = "installed" ] || [ "$COMMON_STATE" = "unpacked" ] ; then
[ ! -L /etc/apache2/conf.d/$CONF.conf ] || rm /etc/apache2/conf.d/$CONF.conf
fi
if [ "$1" = purge ]; then
rm -rf /var/cache/movim /etc/movim /usr/share/movim /var/log/movim
fi
fi
if [ -f /usr/share/debconf/confmodule ]; then
. /usr/share/debconf/confmodule
fi
if [ -f /usr/share/dbconfig-common/dpkg/postrm ]; then
. /usr/share/dbconfig-common/dpkg/postrm
dbc_go movim $@
fi

6
debian/templates

@ -0,0 +1,6 @@
Template: movim/httpserver
Type: multiselect
Choices: apache2
Description: Web server to reconfigure automatically:
Please choose the web server that should be automatically configured
to run Movim.
Loading…
Cancel
Save