diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..402378e
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,4 @@
+*
+!compiler.php
+!src
+!docker/docker-startup.sh
diff --git a/docker/Dockerfile b/Dockerfile
similarity index 76%
rename from docker/Dockerfile
rename to Dockerfile
index 6547fe8..1462156 100644
--- a/docker/Dockerfile
+++ b/Dockerfile
@@ -24,9 +24,13 @@ RUN echo "Set disable_coredump false" > /etc/sudo.conf
# prepare files
RUN rm -rf /var/www/html && \
mkdir -p /usr/local/share/webapps/ifm && \
- ln -s /var/www /usr/local/share/webapps/ifm/www
-COPY ifm.php /usr/local/share/webapps/ifm/index.php
-COPY docker-startup.sh /usr/local/bin
+ ln -s /var/www /usr/local/share/webapps/ifm/www && \
+ mkdir -p /usr/src/ifm
+COPY compiler.php src/ /usr/src/ifm/
+RUN /usr/src/ifm/compiler.php --languages=all && \
+ cp /usr/src/ifm/dist/simple.ifm.php /usr/local/share/webapps/ifm/index.php
+
+COPY docker/docker-startup.sh /usr/local/bin
# start php server
WORKDIR /usr/local/share/webapps/ifm
diff --git a/compiler.php b/compiler.php
index f0ba522..83bce43 100755
--- a/compiler.php
+++ b/compiler.php
@@ -6,21 +6,20 @@
* This script compiles all sources into one single file.
*/
-chdir( realpath( dirname( __FILE__ ) ) );
+chdir(realpath(dirname(__FILE__)));
// output files and common attrs
-define( "IFM_CDN", false );
-define( "IFM_VERSION", "v2.6.1" );
-define( "IFM_RELEASE_DIR", "dist/");
-define( "IFM_STANDALONE", "ifm.php" );
-define( "IFM_STANDALONE_GZ", "ifm.min.php" );
-define( "IFM_LIB", "libifm.php" );
+define("IFM_CDN", false);
+define("IFM_VERSION", "v2.6.1" );
+define("IFM_RELEASE_DIR", "dist/");
+define("IFM_STANDALONE", "ifm.php" );
+define("IFM_STANDALONE_GZ", "ifm.min.php" );
+define("IFM_LIB", "libifm.php" );
-if( IFM_CDN ){
+if (IFM_CDN)
$IFM_ASSETS = "src/assets.cdn.part";
-} else {
+else
$IFM_ASSETS = "src/assets.part";
-}
// php source files
$IFM_SRC_PHP = array(
@@ -30,14 +29,38 @@ $IFM_SRC_PHP = array(
);
// get options
-$options = getopt( null, array( "language::" ) );
+$options = getopt(null, array("language::", "languages::", "cdn::"));
// process languages
-$vars['languages'] = isset( $options['language'] ) ? explode( ',', $options['language'] ) : array( "en", "ru" );
+$langs = array_unique(array_merge(explode(",", join(",", [$options['language']])), explode(",", join(",", [$options['languages']]))));
+print_r($langs);
+if (in_array("all", $langs)) {
+ $available_languages = array_map(
+ function($i) { return str_replace("src/i18n/", "", str_replace(".json", "", $i)); },
+ glob("src/i18n/*.json")
+ );
+ // default language is english, if not given
+ if ($langs[0] == 'all' || !file_exists($lang[0]))
+ $default_lang = "en";
+ else
+ $default_lang = $lang[0];
+
+ unset($available_langs[array_search($default_lang, $available_langs)]);
+ $include_langs = array_merge($default_lang, $available_langs);
+}
+
+print_r($options['language']);
+print_r($include_langs);
+die();
+
+
+// process languages
+$vars['languages'] = isset($options['language']) ? explode(',', $options['language']) : ["all"];
$vars['defaultlanguage'] = $vars['languages'][0];
+
$vars['languageincludes'] = "";
-foreach( $vars['languages'] as $l ) {
- if( file_exists( "src/i18n/".$l.".json" ) )
+foreach ($vars['languages'] as $l)
+ if (file_exists("src/i18n/".$l.".json"))
$vars['languageincludes'] .=
'$i18n["'.$l.'"] = <<<\'f00bar\'' . "\n"
. file_get_contents( "src/i18n/".$l.".json" ) . "\n"
@@ -45,11 +68,8 @@ foreach( $vars['languages'] as $l ) {
. '$i18n["'.$l.'"] = json_decode( $i18n["'.$l.'"], true );' . "\n" ;
else
print "WARNING: Language file src/i18n/".$l.".json not found.\n";
-}
-/**
- * Concat PHP Files
- */
+// Concat PHP Files
$compiled = array( "