mirror of
https://github.com/gtbu/Typesetter-5.3-p8.git
synced 2025-05-09 21:23:14 +02:00
updates : Additional.css and CombineCss
Minimisation only if file is less than 10KB or has more than 2 spaces in the first line (final solution will have a css-parser). This avoids that already minimized big files are a second time minimized
This commit is contained in:
parent
d986d81b7e
commit
91f3999b55
3 changed files with 23 additions and 25 deletions
|
@ -31,7 +31,8 @@ body .messages > div {
|
|||
background-color: #FEF9B0;
|
||||
border: 1px solid #f2e098;
|
||||
border-top: 0 none;
|
||||
box-shadow: 0 0 7px rgba(0, 0, 0, 0.1);
|
||||
-webkit-box-shadow: 0 0 7px rgba(0, 0, 0, 0.1);
|
||||
box-shadow: 0 0 7px rgba(0, 0, 0, 0.1);
|
||||
border-radius: 0 0 7px 7px;
|
||||
resize: both;
|
||||
overflow: auto;
|
||||
|
@ -80,7 +81,8 @@ body .messages a.copy_message {
|
|||
border: 0 none !important;
|
||||
height: 24px;
|
||||
width: 24px;
|
||||
box-sizing: border-box;
|
||||
-webkit-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
body .messages a.close_message {
|
||||
right: 0;
|
||||
|
@ -214,14 +216,12 @@ div.GPAREA {
|
|||
margin-left: -15px;
|
||||
margin-right: -15px;
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.gpRow:before, .gpRow:after {
|
||||
content: '';
|
||||
display: table;
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.gpCol-1, .gpCol-2, .gpCol-3,
|
||||
|
@ -234,7 +234,6 @@ div.GPAREA {
|
|||
padding-right: 15px;
|
||||
margin-bottom: 15px;
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.gpCol-1 { width: 8.33333333%; }
|
||||
|
@ -284,4 +283,4 @@ ul.search_nav_bottom li > * {
|
|||
}
|
||||
.search-matches-count:after {
|
||||
content: ')';
|
||||
}
|
||||
}
|
2
include/css/additional.min.css
vendored
2
include/css/additional.min.css
vendored
|
@ -1 +1 @@
|
|||
.gpclear{clear:both}body .messages{position:absolute;position:fixed;top:0;left:0;right:0;z-index:11010;height:0;overflow:visible;margin-top:-1px}body .messages *{text-align:left;margin:0;padding:0;font-weight:400;color:#333!important}body .messages>div{position:relative;width:700px;min-width:220px;max-width:calc(100% - 40px);min-height:36px;max-height:250px;margin:0 auto;display:block;background-color:#FEF9B0;border:1px solid #f2e098;border-top:0 none;box-shadow:0 0 7px rgb(0 0 0 / .1);border-radius:0 0 7px 7px;resize:both;overflow:auto;overflow-x:visible;overflow-y:auto}body .messages ul{margin:0;padding:4px 15px}body .messages li{list-style:none;padding:0;margin:0;font-size:14px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";line-height:normal;line-height:24px;text-decoration:none;float:none}body .messages li li{list-style:disc;margin-left:2em}body .messages .msg_controls{display:block;position:absolute;position:sticky;top:1px;right:1px;margin:0 0 0 auto!important;z-index:2}body .messages a.close_message,body .messages a.copy_message{position:absolute;top:0;text-decoration:none!important;font-weight:bold!important;color:#666!important;font-size:17px!important;display:none;border:0 none!important;height:24px;width:24px;box-sizing:border-box}body .messages a.close_message{right:0;background:url(../imgs/cancel.png) 50% 50% no-repeat}body .messages a.copy_message{right:24px;background:url(../imgs/copy.png) 50% 50% no-repeat}body .messages a{color:#111!important;text-decoration:underline!important}body .msg_buttons{white-space:nowrap}body .msg_buttons a{display:inline-block;border-radius:3px;padding:0 8px;margin:6px 6px 4px;text-decoration:none!important;border:1px solid rgb(0 0 0 / .15);background:rgb(0 0 0 / .075)}.contactform{margin:0;width:50%}.contactform div.captchaForm{padding:0;margin:0}.contactform label{width:98%;display:block;float:left;clear:left;margin:5px 0}.contactform label span.title{width:30%;display:block;float:left;margin-right:10px}.contactform input,.contactform textarea{padding:5px}.contactform input{float:left;width:60%}.contactform textarea{height:180px;width:98%}.contactform .submit{width:50%;cursor:pointer;margin:12px 0;float:right}.STCLASS .req_script{display:block!important}.STCLASS .without_script{display:none!important}.siteinfo{font-size:85%}.siteinfo a{text-decoration:none}.siteinfo li{list-style:none}.clear{clear:both}.sitemap_xml{float:right}.nodisplay{display:none}div.GPAREA:after{content:'';display:block;height:0!important;clear:both;visibility:hidden;overflow:hidden}div.GPAREA{zoom:1}.cf:before,.cf:after{content:'';display:table}.cf:after{clear:both}.cf{zoom:1}.gpRow img{max-width:100%;height:auto!important}@media screen{.gpRow img{width:auto}}@media (min-width:768px){.gpRow{margin-left:-15px;margin-right:-15px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.gpRow:before,.gpRow:after{content:'';display:table;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.gpCol-1,.gpCol-2,.gpCol-3,.gpCol-4,.gpCol-5,.gpCol-6,.gpCol-7,.gpCol-8,.gpCol-9,.gpCol-10,.gpCol-11,.gpCol-12{float:left;min-height:1px;padding-left:15px;padding-right:15px;margin-bottom:15px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.gpCol-1{width:8.33333333%}.gpCol-2{width:16.66666667%}.gpCol-3{width:25%}.gpCol-4{width:33.33333333%}.gpCol-5{width:41.66666667%}.gpCol-6{width:50%}.gpCol-7{width:58.33333333%}.gpCol-8{width:66.66666667%}.gpCol-9{width:75%}.gpCol-10{width:83.33333333%}.gpCol-11{width:91.66666667%}.gpCol-12{width:100%}}.gp_editing .btn{-webkit-user-select:text;-moz-user-select:text;-ms-user-select:text;user-select:text}ul.search_nav_bottom{list-style:none}ul.search_nav_bottom li{display:inline}ul.search_nav_bottom li>*{display:inline-block;padding-left:.5em;padding-right:.5em}.search-matches-count{font-size:82.5%;font-weight:400}.search-matches-count:before{content:'('}.search-matches-count:after{content:')'}
|
||||
.gpclear{clear:both;}body .messages{position:absolute;position:fixed;top:0;left:0;right:0;z-index:11010;height:0;overflow:visible;margin-top:-1px;}body .messages *{text-align:left;margin:0;padding:0;font-weight:normal;color:#333 !important;}body .messages >div{position:relative;width:700px;min-width:220px;max-width:calc(100% - 40px);min-height:36px;max-height:250px;margin:0 auto;display:block;background-color:#FEF9B0;border:1px solid #f2e098;border-top:0 none;box-shadow:0 0 7px rgba(0,0,0,0.1);border-radius:0 0 7px 7px;resize:both;overflow:auto;overflow-x:visible;overflow-y:auto;}body .messages ul{margin:0;padding:4px 15px;}body .messages li{list-style:none;padding:0;margin:0;font-size:14px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";line-height:normal;line-height:24px;text-decoration:none;float:none;}body .messages li li{list-style:disc;margin-left:2em;}body .messages .msg_controls{display:block;position:absolute;position:sticky;top:1px;right:1px;margin:0 0 0 auto !important;z-index:2;}body .messages a.close_message,body .messages a.copy_message{position:absolute;top:0;text-decoration:none !important;font-weight:bold !important;color:#666 !important;font-size:17px !important;display:none;border:0 none !important;height:24px;width:24px;box-sizing:border-box;}body .messages a.close_message{right:0;background:url('../imgs/cancel.png') 50% 50% no-repeat;}body .messages a.copy_message{right:24px;background:url('../imgs/copy.png') 50% 50% no-repeat;}body .messages a{color:#111 !important;text-decoration:underline !important;}body .msg_buttons{white-space:nowrap;}body .msg_buttons a{display:inline-block;border-radius:3px;padding:0 8px;margin:6px 6px 4px;text-decoration:none !important;border:1px solid rgba(0,0,0,0.15);background:rgba(0,0,0,0.075);}.contactform{margin:0;width:50%;}.contactform div.captchaForm{padding:0;margin:0;}.contactform label{width:98%;display:block;float:left;clear:left;margin:5px 0;}.contactform label span.title{width:30%;display:block;float:left;margin-right:10px;}.contactform input,.contactform textarea{padding:5px;}.contactform input{float:left;width:60%;}.contactform textarea{height:180px;width:98%;}.contactform .submit{width:50%;cursor:pointer;margin:12px 0;float:right;}.STCLASS .req_script{display:block !important;}.STCLASS .without_script{display:none !important;}.siteinfo{font-size:85%;}.siteinfo a{text-decoration:none;}.siteinfo li{list-style:none;}.clear{clear:both;}.sitemap_xml{float:right;}.nodisplay{display:none;}div.GPAREA:after{content:'';display:block;height:0 !important;clear:both;visibility:hidden;overflow:hidden;}div.GPAREA{zoom:1;}.cf:before,.cf:after{content:'';display:table;}.cf:after{clear:both;}.cf{zoom:1}.gpRow img{max-width:100%;height:auto!important;}@media screen{.gpRow img{width:auto;}}@media (min-width:768px){.gpRow{margin-left:-15px;margin-right:-15px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;}.gpRow:before,.gpRow:after{content:'';display:table;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;}.gpCol-1, .gpCol-2, .gpCol-3,.gpCol-4, .gpCol-5, .gpCol-6,.gpCol-7, .gpCol-8, .gpCol-9,.gpCol-10,.gpCol-11,.gpCol-12{float:left;min-height:1px;padding-left:15px;padding-right:15px;margin-bottom:15px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;}.gpCol-1 {width:8.33333333%;}.gpCol-2 {width:16.66666667%;}.gpCol-3 {width:25%;}.gpCol-4 {width:33.33333333%;}.gpCol-5 {width:41.66666667%;}.gpCol-6 {width:50%;}.gpCol-7 {width:58.33333333%;}.gpCol-8 {width:66.66666667%;}.gpCol-9 {width:75%;}.gpCol-10 {width:83.33333333%;}.gpCol-11 {width:91.66666667%;}.gpCol-12 {width:100%;}}.gp_editing .btn{-webkit-user-select:text;-moz-user-select:text;-ms-user-select:text;user-select:text;}ul.search_nav_bottom{list-style:none;}ul.search_nav_bottom li{display:inline;}ul.search_nav_bottom li >*{display:inline-block;padding-left:0.5em;padding-right:0.5em;}.search-matches-count{font-size:82.5%;font-weight:normal;}.search-matches-count:before{content:'(';}.search-matches-count:after{content:')';}
|
|
@ -62,31 +62,30 @@ class CombineCSS {
|
|||
$this->combined_content_raw = $this->prepended_imports . $this->combined_content_raw;
|
||||
|
||||
// --- Final Minification ---
|
||||
if ($this->minify_output) {
|
||||
|
||||
if ($this->minify_output) {
|
||||
try {
|
||||
if (class_exists('\cssmin')) {
|
||||
// --- Start: Check if content looks already minified ---
|
||||
$content_size_bytes = strlen($this->combined_content_raw);
|
||||
$size_limit_bytes = 10 * 1024;
|
||||
$first_chunk = substr($this->combined_content_raw, 0, 15);
|
||||
$space_count = substr_count($first_chunk, ' ');
|
||||
|
||||
if ($space_count < 3) {
|
||||
$this->final_content = $this->combined_content_raw;
|
||||
if ($content_size_bytes >= $size_limit_bytes && $space_count < 3) {
|
||||
$this->final_content = $this->combined_content_raw;
|
||||
} else {
|
||||
$this->final_content = \cssmin::minify($this->combined_content_raw);
|
||||
}
|
||||
|
||||
} else {
|
||||
}
|
||||
} else {
|
||||
$this->final_content = $this->combined_content_raw;
|
||||
}
|
||||
} catch (\Exception $e) { // potential exceptions from cssmin::minify
|
||||
error_log("CSS Minification failed: " . $e->getMessage());
|
||||
$this->final_content = $this->combined_content_raw;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$errorFile = isset($file) ? htmlspecialchars($file) : 'unknown source';
|
||||
trigger_error('CombineCSS: Minification failed for ' . $errorFile . ': ' . $e->getMessage(), E_USER_WARNING);
|
||||
$this->final_content = $this->combined_content_raw; // Fallback to raw content on error
|
||||
}
|
||||
} else {
|
||||
$this->final_content = $this->combined_content_raw;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->final_content = $this->combined_content_raw;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a single CSS file: read, handle imports, fix URLs.
|
||||
|
|
Loading…
Reference in a new issue