Skip to content

Commit

Permalink
update to ver 1.1.12
Browse files Browse the repository at this point in the history
  • Loading branch information
greyaz committed Aug 21, 2024
1 parent c341996 commit 00ff73a
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 90 deletions.
7 changes: 7 additions & 0 deletions Asset/dev/css/other.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.TR #user-section form label[for="form-theme"]{
display: none;
}
.TR #user-section form select#form-theme{
display: none;
}

2 changes: 1 addition & 1 deletion Asset/main.min.css

Large diffs are not rendered by default.

110 changes: 42 additions & 68 deletions Helper/ModeSwitchHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,101 +2,75 @@

namespace Kanboard\Plugin\ThemeRevision\Helper;
use Kanboard\Plugin\ThemeRevision\Helper\BaseHelper;
use MatthiasMullie\Minify;

class ModeSwitchHelper extends BaseHelper
{
private $prdCSSFile = 'plugins/ThemeRevision/Asset/main.min.css';
private $prdCSSFile = '/Asset/main.min.css';
private $devCSSFiles = array(
'plugins/ThemeRevision/Asset/dev/css/basics.css',
'plugins/ThemeRevision/Asset/dev/css/form-components.css',
'plugins/ThemeRevision/Asset/dev/css/table.css',
'plugins/ThemeRevision/Asset/dev/css/layout.css',
'plugins/ThemeRevision/Asset/dev/css/login.css',
'plugins/ThemeRevision/Asset/dev/css/header.css',
'plugins/ThemeRevision/Asset/dev/css/plugins.css',
'plugins/ThemeRevision/Asset/dev/css/switcher-action-filter.css',
'plugins/ThemeRevision/Asset/dev/css/board.css',
'plugins/ThemeRevision/Asset/dev/css/task-detail.css',
'plugins/ThemeRevision/Asset/dev/css/project-overview.css',
'plugins/ThemeRevision/Asset/dev/css/sidebar.css',
'plugins/ThemeRevision/Asset/dev/css/table-list.css',
'plugins/ThemeRevision/Asset/dev/css/board-task-list.css',
'plugins/ThemeRevision/Asset/dev/css/activity-and-comment.css',
'plugins/ThemeRevision/Asset/dev/css/modal.css',
'plugins/ThemeRevision/Asset/dev/css/markdown.css',
'plugins/ThemeRevision/Asset/dev/css/break-points.css'
'/Asset/dev/css/basics.css',
'/Asset/dev/css/form-components.css',
'/Asset/dev/css/table.css',
'/Asset/dev/css/layout.css',
'/Asset/dev/css/login.css',
'/Asset/dev/css/header.css',
'/Asset/dev/css/plugins.css',
'/Asset/dev/css/switcher-action-filter.css',
'/Asset/dev/css/board.css',
'/Asset/dev/css/task-detail.css',
'/Asset/dev/css/project-overview.css',
'/Asset/dev/css/sidebar.css',
'/Asset/dev/css/table-list.css',
'/Asset/dev/css/board-task-list.css',
'/Asset/dev/css/activity-and-comment.css',
'/Asset/dev/css/modal.css',
'/Asset/dev/css/markdown.css',
'/Asset/dev/css/other.css',
'/Asset/dev/css/break-points.css'
);

public function productionMode(){
if(!file_exists($this->prdCSSFile)){
$file = fopen($this->prdCSSFile, "w");
$prdCSSFile = $this->getPluginPath().$this->prdCSSFile;

if(!file_exists($prdCSSFile)){
$file = fopen($prdCSSFile, "w");
fwrite($file, $this->minifyCSS());
fclose($file);
}
$this->getPlugin()->hook->on('template:layout:css', array('template' => $this->prdCSSFile));
$this->getPlugin()->hook->on('template:layout:css', array('template' => 'plugins/ThemeRevision'.$this->prdCSSFile));
}

public function developmentMode(){
if(file_exists($this->prdCSSFile)){
unlink($this->prdCSSFile);
$prdCSSFile = $this->getPluginPath().$this->prdCSSFile;

if(file_exists($prdCSSFile)){
unlink($prdCSSFile);
}
foreach ($this->devCSSFiles as $value)
{
$this->getPlugin()->hook->on('template:layout:css', array('template' => $value));
$this->getPlugin()->hook->on('template:layout:css', array('template' => 'plugins/ThemeRevision'.$value));
}
}

private function getPluginPath(){
$arr = explode("/", __DIR__);
$arr = array_slice($arr, 0, -1);
return implode("/", $arr);
}

private function getAllCSSContents(){
$str = '';
foreach ($this->devCSSFiles as $value)
{
$str = $str.file_get_contents($value);
$str = $str.file_get_contents($this->getPluginPath().$value);
}
return $str;
}

// Code comes from Rodrigo54. https://gist.github.com/Rodrigo54/93169db48194d470188f
private function minifyCSS(){
$input = $this->getAllCSSContents();
if(trim($input) === "") return $input;

return preg_replace(
array(
// Remove comment(s)
'#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s',
// Remove unused white-space(s)
'#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si',
// Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0`
'#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si',
// Replace `:0 0 0 0` with `:0`
'#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i',
// Replace `background-position:0` with `background-position:0 0`
'#(background-position):0(?=[;\}])#si',
// Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space
'#(?<=[\s:,\-])0+\.(\d+)#s',
// Minify string value
'#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si',
'#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si',
// Minify HEX color code
'#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i',
// Replace `(border|outline):none` with `(border|outline):0`
'#(?<=[\{;])(border|outline):none(?=[;\}\!])#',
// Remove empty selector(s)
'#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s'
),
array(
'$1',
'$1$2$3$4$5$6$7',
'$1',
':0',
'$1:0 0',
'.$1',
'$1$3',
'$1$2$4$5',
'$1$2$3',
'$1:0',
'$1$2'
),
$input);
$css = $this->getAllCSSContents();
$minifier = new Minify\CSS();
$minifier->add($css);
return $minifier->minify();
}
}
4 changes: 2 additions & 2 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ public function getPluginName() {
}

public function getPluginAuthor() {
return 'greyaz';
return 'Greyaz';
}

public function getPluginVersion() {
return '1.1.11';
return '1.1.12';
}

public function getPluginDescription() {
Expand Down
8 changes: 2 additions & 6 deletions Template/layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,10 @@
<?php if (isset($board_public_refresh_interval)): ?>
<meta http-equiv="refresh" content="<?= $board_public_refresh_interval ?>">
<?php endif ?>

<?= $this->asset->colorCss() ?>
<?= $this->asset->css('assets/css/vendor.min.css') ?>
<?php if (! isset($not_editable)): ?>
<?= $this->asset->css('assets/css/'.$this->user->getTheme().'.min.css') ?>
<?php else: ?>
<?= $this->asset->css('assets/css/light.min.css') ?>
<?php endif ?>
<?= $this->asset->css('assets/css/light.min.css') ?>
<?= $this->asset->css('assets/css/print.min.css', true, 'print') ?>
<?= $this->asset->customCss() ?>

Expand Down
26 changes: 14 additions & 12 deletions Template/settings/configs/color_update_notice.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
<?php if (!empty($color_diffs)): ?>
<form method="post" action="<?= $this->url->href('PluginConfigsController', 'dismiss', array('plugin' => 'ThemeRevision')) ?>">
<fieldset>
<p class="alert alert-warning"><b><?= t('Notice') ?></b><br><?= t('Some colors have been changed after last upgrading.') ?></p>
<?php foreach($color_diffs as $paletteName=>$paletteValue): ?>
<p style="clear: both;">
<legend><?= t(ucwords(str_replace("_", " ", $paletteName))) ?></legend>
<?php foreach($paletteValue as $colorName=>$colorValue): ?><span style="float: left;margin-right: 2rem;margin-bottom: 1rem;width: 12rem;">
<?= $colorName ?><br>
<?php if ($colorValue['old']): ?>
<del style="border-left: 1rem solid <?= $colorValue['old'] ?>;padding: 0 .5rem;"><?= $colorValue['old'] ?></del><br>
<?php endif ?>
<?php if ($colorValue['new']): ?>
<span style="border-left: 1rem solid <?= $colorValue['new'] ?>;padding: 0 .5rem;"><?= $colorValue['new'] ?></span>
<?php endif ?>
</span><?php endforeach; ?>
</p>
<p style="clear: both;">
<legend><?= t(ucwords(str_replace("_", " ", $paletteName))) ?></legend>
<?php foreach($paletteValue as $colorName=>$colorValue): ?><span style="float: left;margin-right: 2rem;margin-bottom: 1rem;width: 12rem;">
<?= $colorName ?><br>
<?php if ($colorValue['old']): ?>
<del style="border-left: 1rem solid <?= $colorValue['old'] ?>;padding: 0 .5rem;"><?= $colorValue['old'] ?></del><br>
<?php endif ?>
<?php if ($colorValue['new']): ?>
<span style="border-left: 1rem solid <?= $colorValue['new'] ?>;padding: 0 .5rem;"><?= $colorValue['new'] ?></span>
<?php endif ?>
</span><?php endforeach; ?>
</p>
<?php endforeach; ?>
</fieldset>
<p><input type="submit" class="btn btn-red" value="<?= t('Dismiss') ?>"></p>
</form>
<?php endif ?>
2 changes: 1 addition & 1 deletion Template/user/header_dropdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
'show',
array('plugin' => 'ThemeRevision', 'user_id' => $this->user->getId())
) ?>
</li>
</li>

0 comments on commit 00ff73a

Please sign in to comment.