From e3776c06c37cc197709dac60892604dfea894ac2 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Mon, 29 Nov 2010 01:34:36 +0100 Subject: Remove enc=utf-8 in VIM modeline as it is not allowed in VIM 7.3 As of VIM 7.3 it is no longer possible to specify the encoding in the modeline. This gives an error message whenever such a file is opened, thus this commit removes the enc setting from the modeline. --- bin/indexer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/indexer.php b/bin/indexer.php index 48e98b571..67254fa88 100755 --- a/bin/indexer.php +++ b/bin/indexer.php @@ -163,4 +163,4 @@ function _quietecho($msg) { if(!$QUIET) echo $msg; } -//Setup VIM: ex: et ts=2 enc=utf-8 : +//Setup VIM: ex: et ts=2 : -- cgit v1.2.3 From c0470665eec5d52d0e7da72e5ba8fd76b931247d Mon Sep 17 00:00:00 2001 From: "Martin 'E.T.' Misuth" Date: Tue, 5 Oct 2010 17:01:13 +0200 Subject: Added striplangs.php script, with which you can strip out unused languages out of DW to make it smaller (eg. FTP upload) --- bin/striplangs.php | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 bin/striplangs.php (limited to 'bin') diff --git a/bin/striplangs.php b/bin/striplangs.php new file mode 100644 index 000000000..a53fe580f --- /dev/null +++ b/bin/striplangs.php @@ -0,0 +1,143 @@ +#!/usr/bin/php +get($short); + if ( is_null($arg) ) { + $arg = $OPTS->get($long); + } + return $arg; +} + +function processPlugins($path, $keep_langs) { + if (is_dir($path)) { + $entries = scandir($path); + + foreach ($entries as $entry) { + if ($entry != "." && $entry != "..") { + if ( is_dir($path.'\\'.$entry) ) { + + $plugin_langs = $path.'\\'.$entry.'\\lang'; + + if ( is_dir( $plugin_langs ) ) { + stripDirLangs($plugin_langs, $keep_langs); + } + } + } + } + } +} + +function stripDirLangs($path, $keep_langs) { + $dir = dir($path); + + while(($cur_dir = $dir->read()) !== false) { + if( $cur_dir != '.' and $cur_dir != '..' and is_dir($path.'\\'.$cur_dir)) { + + if ( !in_array($cur_dir, $keep_langs, true ) ) { + killDir($path.'\\'.$cur_dir); + } + } + } + $dir->close(); +} + +function killDir($dir) { + if (is_dir($dir)) { + $entries = scandir($dir); + + foreach ($entries as $entry) { + if ($entry != "." && $entry != "..") { + if ( is_dir($dir.'\\'.$entry) ) { + killDir($dir.'\\'.$entry); + } else { + unlink($dir.'\\'.$entry); + } + } + } + reset($entries); + rmdir($dir); + } +} +#------------------------------------------------------------------------------ + +// handle options +$short_opts = 'hxk:e'; +$long_opts = array('help', 'examples', 'keep=','english'); + +$OPTS = Doku_Cli_Opts::getOptions(__FILE__, $short_opts, $long_opts); + +if ( $OPTS->isError() ) { + fwrite( STDERR, $OPTS->getMessage() . "\n"); + exit(1); +} + +// handle '--examples' option +$show_examples = ( $OPTS->has('x') or $OPTS->has('examples') ) ? true : false; + +// handle '--help' option +if ( $OPTS->has('h') or $OPTS->has('help') ) { + usage($show_examples); + exit(0); +} + +// handle both '--keep' and '--english' options +if ( $OPTS->has('k') or $OPTS->has('keep') ) { + $preserved_langs = getSuppliedArgument($OPTS,'k','keep'); + $langs = explode(',', $preserved_langs); + + // ! always enforce 'en' lang when using '--keep' (DW relies on it) + if ( !isset($langs['en']) ) { + $langs[]='en'; + } +} elseif ( $OPTS->has('e') or $OPTS->has('english') ) { + // '--english' was specified strip everything besides 'en' + $langs = array ('en'); +} else { + // no option was specified, print usage but don't do anything as + // this run might not be intented + usage(); + print "\n + ERROR + No option specified, use either -h -x to get more info, + or -e to strip every language besides english.\n"; + exit(1); +} + +// Kill all language directories in /inc/lang and /lib/plugins besides those in $langs array +stripDirLangs(realpath(dirname(__FILE__).'/../inc/lang'), $langs); +processPlugins(realpath(dirname(__FILE__).'/../lib/plugins'), $langs); \ No newline at end of file -- cgit v1.2.3 From 79e197ef89cfb21cb763883243e6338d92ab28c7 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Mon, 29 Nov 2010 20:41:17 +0100 Subject: use forward slashes as path separator in striplangs.php --- bin/striplangs.php | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) (limited to 'bin') diff --git a/bin/striplangs.php b/bin/striplangs.php index a53fe580f..288859c6a 100644 --- a/bin/striplangs.php +++ b/bin/striplangs.php @@ -1,5 +1,10 @@ #!/usr/bin/php + */ if ('cli' != php_sapi_name()) die(); #------------------------------------------------------------------------------ @@ -16,20 +21,20 @@ function usage($show_examples = false) { OPTIONS -h, --help get this help -x, --examples get also usage examples - -k, --keep comma separated list of languages, -e is always implied + -k, --keep comma separated list of languages, -e is always implied -e, --english keeps english, dummy to use without -k"; if ( $show_examples ) { print "\n EXAMPLES - Strips all languages, but keeps 'en' and 'de': + Strips all languages, but keeps 'en' and 'de': striplangs -k de Strips all but 'en','ca-valencia','cs','de','is','sk': striplangs --keep ca-valencia,cs,de,is,sk - + Strips all but 'en': striplangs -e - + No option specified, prints usage and throws error: striplangs\n"; } @@ -49,16 +54,16 @@ function processPlugins($path, $keep_langs) { foreach ($entries as $entry) { if ($entry != "." && $entry != "..") { - if ( is_dir($path.'\\'.$entry) ) { - - $plugin_langs = $path.'\\'.$entry.'\\lang'; - + if ( is_dir($path.'/'.$entry) ) { + + $plugin_langs = $path.'/'.$entry.'/lang'; + if ( is_dir( $plugin_langs ) ) { stripDirLangs($plugin_langs, $keep_langs); } } } - } + } } } @@ -66,15 +71,15 @@ function stripDirLangs($path, $keep_langs) { $dir = dir($path); while(($cur_dir = $dir->read()) !== false) { - if( $cur_dir != '.' and $cur_dir != '..' and is_dir($path.'\\'.$cur_dir)) { + if( $cur_dir != '.' and $cur_dir != '..' and is_dir($path.'/'.$cur_dir)) { if ( !in_array($cur_dir, $keep_langs, true ) ) { - killDir($path.'\\'.$cur_dir); + killDir($path.'/'.$cur_dir); } } } $dir->close(); -} +} function killDir($dir) { if (is_dir($dir)) { @@ -82,13 +87,13 @@ function killDir($dir) { foreach ($entries as $entry) { if ($entry != "." && $entry != "..") { - if ( is_dir($dir.'\\'.$entry) ) { - killDir($dir.'\\'.$entry); + if ( is_dir($dir.'/'.$entry) ) { + killDir($dir.'/'.$entry); } else { - unlink($dir.'\\'.$entry); + unlink($dir.'/'.$entry); } } - } + } reset($entries); rmdir($dir); } @@ -119,11 +124,11 @@ if ( $OPTS->has('h') or $OPTS->has('help') ) { if ( $OPTS->has('k') or $OPTS->has('keep') ) { $preserved_langs = getSuppliedArgument($OPTS,'k','keep'); $langs = explode(',', $preserved_langs); - + // ! always enforce 'en' lang when using '--keep' (DW relies on it) if ( !isset($langs['en']) ) { $langs[]='en'; - } + } } elseif ( $OPTS->has('e') or $OPTS->has('english') ) { // '--english' was specified strip everything besides 'en' $langs = array ('en'); @@ -140,4 +145,4 @@ if ( $OPTS->has('k') or $OPTS->has('keep') ) { // Kill all language directories in /inc/lang and /lib/plugins besides those in $langs array stripDirLangs(realpath(dirname(__FILE__).'/../inc/lang'), $langs); -processPlugins(realpath(dirname(__FILE__).'/../lib/plugins'), $langs); \ No newline at end of file +processPlugins(realpath(dirname(__FILE__).'/../lib/plugins'), $langs); -- cgit v1.2.3