浏览代码

Added command to switch between bootswatch.com themes

Sergio Brighenti 6 年之前
父节点
当前提交
632b2df039
共有 2 个文件被更改,包括 32 次插入1 次删除
  1. 29 0
      bin/theme
  2. 3 1
      composer.json

+ 29 - 0
bin/theme

@@ -0,0 +1,29 @@
+#!/usr/bin/env php
+<?php
+
+require 'vendor/autoload.php';
+
+if (php_sapi_name() !== 'cli') {
+	die();
+}
+
+$json = json_decode(file_get_contents('https://bootswatch.com/api/4.json'));
+
+if (!isset($argv[1])) {
+	echo 'Usage: php bin\\theme <theme-name>' . PHP_EOL;
+	echo 'Here a list of available Bootswatch themes:' . PHP_EOL;
+}
+
+foreach ($json->themes as $theme) {
+	if (isset($argv[1]) && $argv[1] === mb_strtolower($theme->name)) {
+        file_put_contents('static/bootstrap/css/bootstrap.min.css', file_get_contents($theme->cssMin));
+		echo "Installed theme {$theme->name}." . PHP_EOL;
+		break;
+	}
+
+	if (!isset($argv[1])) {
+		echo "  - {$theme->name} ({$theme->description})[Preview: {$theme->preview}]" . PHP_EOL;
+	}
+}
+
+exit(0);

+ 3 - 1
composer.json

@@ -8,7 +8,9 @@
     "league/flysystem": "^1.0.45",
     "league/flysystem": "^1.0.45",
     "twig/twig": "~2.0",
     "twig/twig": "~2.0",
     "monolog/monolog": "^1.23",
     "monolog/monolog": "^1.23",
-    "php": ">=7.1"
+    "php": ">=7.1",
+    "ext-json": "*",
+    "ext-gd": "*"
   },
   },
   "autoload": {
   "autoload": {
     "psr-4": {
     "psr-4": {