summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/Console/CssCommand.php126
-rw-r--r--app/ServiceProvider/CommandProvider.php2
2 files changed, 128 insertions, 0 deletions
diff --git a/app/Console/CssCommand.php b/app/Console/CssCommand.php
new file mode 100644
index 00000000..f141519e
--- /dev/null
+++ b/app/Console/CssCommand.php
@@ -0,0 +1,126 @@
+<?php
+
+namespace Kanboard\Console;
+
+use MatthiasMullie\Minify;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+$path = __DIR__ . '/../../libs';
+require_once $path . '/minify/src/Minify.php';
+require_once $path . '/minify/src/CSS.php';
+require_once $path . '/minify/src/JS.php';
+require_once $path . '/minify/src/Exception.php';
+require_once $path . '/minify/src/Exceptions/BasicException.php';
+require_once $path . '/minify/src/Exceptions/FileImportException.php';
+require_once $path . '/minify/src/Exceptions/IOException.php';
+require_once $path . '/path-converter/src/ConverterInterface.php';
+require_once $path . '/path-converter/src/Converter.php';
+
+/**
+ * Class CssCommand
+ *
+ * @package Kanboard\Console
+ * @author Frederic Guillot
+ */
+class CssCommand extends BaseCommand
+{
+ const CSS_SRC_PATH = 'assets/css/src/';
+ const CSS_VENDOR_PATH = 'assets/vendor/';
+ const CSS_DIST_PATH = 'assets/css/';
+
+ private $appFiles = [
+ 'variables.css',
+ 'base.css',
+ 'links.css',
+ 'titles.css',
+ 'table.css',
+ 'table_drag_and_drop.css',
+ 'table_list.css',
+ 'form.css',
+ 'input_addon.css',
+ 'icon.css',
+ 'alert.css',
+ 'button.css',
+ 'tooltip.css',
+ 'dropdown.css',
+ 'accordion.css',
+ 'select_dropdown.css',
+ 'suggest_menu.css',
+ 'modal.css',
+ 'pagination.css',
+ 'header.css',
+ 'logo.css',
+ 'page_header.css',
+ 'sidebar.css',
+ 'avatar.css',
+ 'file_upload.css',
+ 'thumbnails.css',
+ 'color_picker.css',
+ 'filter_box.css',
+ 'project.css',
+ 'views.css',
+ 'dashboard.css',
+ 'board.css',
+ 'task_board.css',
+ 'task_icons.css',
+ 'task_category.css',
+ 'task_date.css',
+ 'task_tags.css',
+ 'task_summary.css',
+ 'task_form.css',
+ 'comment.css',
+ 'subtasks.css',
+ 'task_links.css',
+ 'text_editor.css',
+ 'markdown.css',
+ 'panel.css',
+ 'activity_stream.css',
+ 'user_mention.css',
+ 'slideshow.css',
+ 'list_items.css',
+ 'bulk_change.css',
+ ];
+
+ private $printFiles = [
+ 'print.css',
+ ];
+
+ private $vendorFiles = [
+ 'jquery-ui/jquery-ui.min.css',
+ 'jqueryui-timepicker-addon/jquery-ui-timepicker-addon.min.css',
+ 'select2/css/select2.min.css',
+ 'font-awesome/css/font-awesome.min.css',
+ 'c3/c3.min.css',
+ ];
+
+ protected function configure()
+ {
+ $this
+ ->setName('css')
+ ->setDescription('Minify CSS')
+ ;
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $this->minifyFiles(self::CSS_SRC_PATH, $this->appFiles, 'app.min.css');
+ $this->minifyFiles(self::CSS_SRC_PATH, $this->printFiles, 'print.min.css');
+ $this->minifyFiles(self::CSS_VENDOR_PATH, $this->vendorFiles, 'vendor.min.css');
+ }
+
+ private function minifyFiles($folder, array $files, $destination)
+ {
+ $minifier = new Minify\CSS();
+
+ foreach ($files as $file) {
+ $filename = $folder. $file;
+ if (! file_exists($filename)) {
+ die("$filename not found\n");
+ }
+ $minifier->add($filename);
+ }
+
+ $minifier->minify(self::CSS_DIST_PATH . $destination);
+ }
+}
diff --git a/app/ServiceProvider/CommandProvider.php b/app/ServiceProvider/CommandProvider.php
index 70968306..77c8b395 100644
--- a/app/ServiceProvider/CommandProvider.php
+++ b/app/ServiceProvider/CommandProvider.php
@@ -24,6 +24,7 @@ use Kanboard\Console\TaskTriggerCommand;
use Kanboard\Console\TransitionExportCommand;
use Kanboard\Console\VersionCommand;
use Kanboard\Console\WorkerCommand;
+use Kanboard\Console\CssCommand;
use Pimple\Container;
use Pimple\ServiceProviderInterface;
use Symfony\Component\Console\Application;
@@ -67,6 +68,7 @@ class CommandProvider implements ServiceProviderInterface
$application->add(new DatabaseMigrationCommand($container));
$application->add(new DatabaseVersionCommand($container));
$application->add(new VersionCommand($container));
+ $application->add(new CssCommand($container));
$container['cli'] = $application;
return $container;