Skip to content

Commit

Permalink
added cssLoader to compress CSS on the fly.
Browse files Browse the repository at this point in the history
library used - Minify. Can also compress JS
  • Loading branch information
guptaaditya13 committed Dec 14, 2015
1 parent 0fd910c commit 32f6d58
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 8 deletions.
32 changes: 32 additions & 0 deletions controller/cssLoader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
require ('resources/minify/src/Minify.php');
require ('resources/minify/src/CSS.php');
require ('resources/minify/src/JS.php');
require ('resources/minify/src/Exception.php');
require ('resources/path-converter/src/Converter.php');
// var_dump(get_declared_classes());
$minifier = new MatthiasMullie\Minify\CSS('assets/css/all.css');

// we can even add another file, they'll then be
// joined in 1 output file

// $sourcePath2 = '/path/to/second/source/css/file.css';

$minifier->add("assets/css/team.css");
$minifier->add("assets/css/style.css");
$minifier->add("assets/css/eventsmain.css");
$minifier->add("assets/css/intro.css");
$minifier->add("assets/css/jquery-ui.structure.min.css");
$minifier->add("assets/css/jquery-ui.min.css");
$minifier->add("assets/css/jquery-ui.theme.min.css");

// or we can just add plain CSS
// $css = 'body { color: #000000; }';
// $minifier->add($css);

// save minified file to disk
// $minifiedPath = '/path/to/minified/css/file.css';
// $minifier->minify($minifiedPath);
header("Content-type: text/css");
echo $minifier->minify();
?>
2 changes: 2 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public function Redirect($url)

if (preg_match($base . '$@', $url)) {
require ('view/index.html');
} elseif ( preg_match($base .'cssLoader/home/?$@', $url, $match ) ) {
require ('controller/cssLoader.php');
} elseif ( preg_match($base .'events/?$@', $url, $match ) ) {
require ('controller/events.php');
} elseif (preg_match($base . 'allEvents/?$@', $url)) {
Expand Down
1 change: 1 addition & 0 deletions resources/minify
Submodule minify added at cecee1
1 change: 1 addition & 0 deletions resources/path-converter
Submodule path-converter added at 95c549
9 changes: 1 addition & 8 deletions view/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,7 @@

<title>Anwesha '16</title>

<link rel="stylesheet" href="assets/css/all.css">
<link rel="stylesheet" href="assets/css/team.css">
<link rel="stylesheet" href="assets/css/style.css">
<link rel="stylesheet" href="assets/css/eventsmain.css">
<link rel="stylesheet" href="assets/css/intro.css">
<link rel="stylesheet" href="assets/css/jquery-ui.structure.min.css">
<link rel="stylesheet" href="assets/css/jquery-ui.min.css">
<link rel="stylesheet" href="assets/css/jquery-ui.theme.min.css">
<link rel="stylesheet" href="cssLoader/home/">


<script src='assets/js/jquery.min.js'></script>
Expand Down

0 comments on commit 32f6d58

Please sign in to comment.