html5-starter 0.1.4b → 0.1.8b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +11 -113
- data/stylesheets/html5-boilerplate/_fonts.scss +4 -4
- data/stylesheets/html5-boilerplate/_handheld.scss +3 -3
- data/stylesheets/html5-boilerplate/_helpers.scss +14 -7
- data/stylesheets/html5-boilerplate/_print.scss +2 -2
- data/stylesheets/html5-boilerplate/_reset.scss +8 -8
- data/stylesheets/html5-boilerplate/_styles.scss +16 -31
- data/templates/project/files/404.html +37 -21
- data/templates/project/files/apple-touch-icon-114x114-precomposed.png +0 -0
- data/templates/project/files/apple-touch-icon-57x57-precomposed.png +0 -0
- data/templates/project/files/apple-touch-icon-72x72-precomposed.png +0 -0
- data/templates/project/files/apple-touch-icon-precomposed.png +0 -0
- data/templates/project/files/apple-touch-icon.png +0 -0
- data/templates/project/files/build/build.xml +813 -628
- data/templates/project/files/build/config/buildinfo.properties +5 -0
- data/templates/project/files/build/config/default.properties +22 -21
- data/templates/project/files/build/config/project.properties +9 -8
- data/templates/project/files/build/createproject.sh +29 -52
- data/templates/project/files/build/runbuildscript.bat +5 -0
- data/templates/project/files/build/tools/htmlcompressor-1.1.jar +0 -0
- data/templates/project/files/build/tools/{yuicompressor-2.4.2.jar → yuicompressor-2.4.5.jar} +0 -0
- data/templates/project/files/gitignore.txt +6 -0
- data/templates/project/files/htaccess +71 -8
- data/templates/project/index.html +30 -31
- data/templates/project/javascripts/libs/dd_belatedpng.js +1 -1
- data/templates/project/javascripts/libs/{jquery-1.5.0.js → jquery-1.5.1.js} +549 -409
- data/templates/project/javascripts/libs/jquery-1.5.1.min.js +16 -0
- data/templates/project/javascripts/libs/modernizr-1.7.min.js +2 -0
- data/templates/project/javascripts/plugins.js +3 -1
- data/templates/project/manifest.rb +22 -59
- data/templates/project/style.scss +17 -0
- metadata +15 -44
- data/templates/project/files/build/config/build.properties +0 -3
- data/templates/project/files/build/tools/css-compressor/CSSCompression.php +0 -465
- data/templates/project/files/build/tools/css-compressor/changelog.txt +0 -22
- data/templates/project/files/build/tools/css-compressor/cli.php +0 -101
- data/templates/project/files/build/tools/css-compressor/helpers/hex2short-colors.json +0 -39
- data/templates/project/files/build/tools/css-compressor/helpers/hex2short-safe.json +0 -16
- data/templates/project/files/build/tools/css-compressor/helpers/long2hex-colors.json +0 -127
- data/templates/project/files/build/tools/css-compressor/lib/Cleanup.php +0 -218
- data/templates/project/files/build/tools/css-compressor/lib/Color.php +0 -199
- data/templates/project/files/build/tools/css-compressor/lib/Combine/Aural.php +0 -109
- data/templates/project/files/build/tools/css-compressor/lib/Combine/Background.php +0 -107
- data/templates/project/files/build/tools/css-compressor/lib/Combine/Border.php +0 -98
- data/templates/project/files/build/tools/css-compressor/lib/Combine/BorderOutline.php +0 -109
- data/templates/project/files/build/tools/css-compressor/lib/Combine/BorderRadius.php +0 -262
- data/templates/project/files/build/tools/css-compressor/lib/Combine/Font.php +0 -125
- data/templates/project/files/build/tools/css-compressor/lib/Combine/List.php +0 -104
- data/templates/project/files/build/tools/css-compressor/lib/Combine/MarginPadding.php +0 -190
- data/templates/project/files/build/tools/css-compressor/lib/Combine.php +0 -191
- data/templates/project/files/build/tools/css-compressor/lib/Compress.php +0 -212
- data/templates/project/files/build/tools/css-compressor/lib/Control.php +0 -236
- data/templates/project/files/build/tools/css-compressor/lib/Exception.php +0 -32
- data/templates/project/files/build/tools/css-compressor/lib/Format.php +0 -187
- data/templates/project/files/build/tools/css-compressor/lib/Individuals.php +0 -307
- data/templates/project/files/build/tools/css-compressor/lib/Numeric.php +0 -103
- data/templates/project/files/build/tools/css-compressor/lib/Option.php +0 -133
- data/templates/project/files/build/tools/css-compressor/lib/Organize.php +0 -149
- data/templates/project/files/build/tools/css-compressor/lib/Selectors.php +0 -245
- data/templates/project/files/build/tools/css-compressor/lib/Setup.php +0 -292
- data/templates/project/files/build/tools/css-compressor/lib/Trim.php +0 -213
- data/templates/project/files/build/tools/css-compressor/license.txt +0 -21
- data/templates/project/files/build/tools/htmlcompressor-0.9.8.jar +0 -0
- data/templates/project/files/google.yml +0 -22
- data/templates/project/files/lighttpd.conf +0 -149
- data/templates/project/files/mime.types +0 -80
- data/templates/project/files/nginx.conf +0 -108
- data/templates/project/files/web.config +0 -207
- data/templates/project/javascripts/libs/jquery-1.5.0.min.js +0 -16
- data/templates/project/javascripts/libs/modernizr-1.6.min.js +0 -30
@@ -1,104 +0,0 @@
|
|
1
|
-
<?php
|
2
|
-
/**
|
3
|
-
* CSS Compressor [VERSION]
|
4
|
-
* [DATE]
|
5
|
-
* Corey Hart @ http://www.codenothing.com
|
6
|
-
*/
|
7
|
-
|
8
|
-
Class CSSCompression_Combine_List
|
9
|
-
{
|
10
|
-
/**
|
11
|
-
* Combine Patterns
|
12
|
-
*
|
13
|
-
* @class Control: Compression Controller
|
14
|
-
* @class Combine: Combine Controller
|
15
|
-
* @param (regex) rlist: List style matching
|
16
|
-
* @param (array) groupings: Group of list combinationals
|
17
|
-
*/
|
18
|
-
private $Control;
|
19
|
-
private $Combine;
|
20
|
-
private $rlist = "/(^|(?<!\\\);)list-style-(type|position|image):(.*?)((?<!\\\);|$)/";
|
21
|
-
private $groupings = array(
|
22
|
-
array( 'type', 'position', 'image' ),
|
23
|
-
array( 'type', 'position' ),
|
24
|
-
array( 'type', 'image' ),
|
25
|
-
array( 'position', 'image' ),
|
26
|
-
array( 'type' ),
|
27
|
-
array( 'position' ),
|
28
|
-
array( 'image' ),
|
29
|
-
);
|
30
|
-
|
31
|
-
/**
|
32
|
-
* Stash a reference to the controller & combiner
|
33
|
-
*
|
34
|
-
* @param (class) control: CSSCompression Controller
|
35
|
-
* @param (class) combine: CSSCompression Combiner
|
36
|
-
*/
|
37
|
-
public function __construct( CSSCompression_Control $control, CSSCompression_Combine $combine ) {
|
38
|
-
$this->Control = $control;
|
39
|
-
$this->Combine = $combine;
|
40
|
-
}
|
41
|
-
|
42
|
-
/**
|
43
|
-
* Combines multiple list style props into single definition
|
44
|
-
*
|
45
|
-
* @param (string) val: Rule Set
|
46
|
-
*/
|
47
|
-
public function combine( $val ) {
|
48
|
-
// If replacement string found, run it on all declarations
|
49
|
-
if ( ( $replace = $this->replace( $val ) ) !== false ) {
|
50
|
-
$pos = 0;
|
51
|
-
while ( preg_match( $this->rlist, $val, $match, PREG_OFFSET_CAPTURE, $pos ) ) {
|
52
|
-
$colon = strlen( $match[ 1 ][ 0 ] );
|
53
|
-
$val = substr_replace( $val, $replace, $match[ 0 ][ 1 ] + $colon, strlen( $match[ 0 ][ 0 ] ) - $colon );
|
54
|
-
$pos = $match[ 0 ][ 1 ] + strlen( $replace ) - $colon - 1;
|
55
|
-
$replace = '';
|
56
|
-
}
|
57
|
-
}
|
58
|
-
|
59
|
-
// Return converted val
|
60
|
-
return $val;
|
61
|
-
}
|
62
|
-
|
63
|
-
/**
|
64
|
-
* Build the replacement string for list props
|
65
|
-
*
|
66
|
-
* @param (string) val: Rule Set
|
67
|
-
*/
|
68
|
-
private function replace( $val ) {
|
69
|
-
$storage = array();
|
70
|
-
$pos = 0;
|
71
|
-
|
72
|
-
// Find all possible occurences and build the replacement
|
73
|
-
while ( preg_match( $this->rlist, $val, $match, PREG_OFFSET_CAPTURE, $pos ) ) {
|
74
|
-
$storage[ $match[ 2 ][ 0 ] ] = $match[ 3 ][ 0 ];
|
75
|
-
$pos = $match[ 0 ][ 1 ] + strlen( $match[ 0 ][ 0 ] ) - 1;
|
76
|
-
}
|
77
|
-
|
78
|
-
// Run background checks and get replacement str
|
79
|
-
foreach ( $this->groupings as $props ) {
|
80
|
-
if ( $replace = $this->Combine->searchDefinitions( 'list-style', $storage, $props ) ) {
|
81
|
-
return $replace;
|
82
|
-
}
|
83
|
-
}
|
84
|
-
|
85
|
-
return false;
|
86
|
-
}
|
87
|
-
|
88
|
-
/**
|
89
|
-
* Access to private methods for testing
|
90
|
-
*
|
91
|
-
* @param (string) method: Method to be called
|
92
|
-
* @param (array) args: Array of paramters to be passed in
|
93
|
-
*/
|
94
|
-
public function access( $method, $args ) {
|
95
|
-
if ( method_exists( $this, $method ) ) {
|
96
|
-
return call_user_func_array( array( $this, $method ), $args );
|
97
|
-
}
|
98
|
-
else {
|
99
|
-
throw new CSSCompression_Exception( "Unknown method in List Class - " . $method );
|
100
|
-
}
|
101
|
-
}
|
102
|
-
};
|
103
|
-
|
104
|
-
?>
|
@@ -1,190 +0,0 @@
|
|
1
|
-
<?php
|
2
|
-
/**
|
3
|
-
* CSS Compressor [VERSION]
|
4
|
-
* [DATE]
|
5
|
-
* Corey Hart @ http://www.codenothing.com
|
6
|
-
*/
|
7
|
-
|
8
|
-
Class CSSCompression_Combine_MarginPadding
|
9
|
-
{
|
10
|
-
/**
|
11
|
-
* Combine Patterns
|
12
|
-
*
|
13
|
-
* @class Control: Compression Controller
|
14
|
-
* @class Combine: Combine Controller
|
15
|
-
* @param (regex) rspace: Checks for space without an escape '\' character before it
|
16
|
-
* @param (regex) rmp: Margin/Padding matching
|
17
|
-
* @param (regex) rmpbase: Margin/Padding base match
|
18
|
-
*/
|
19
|
-
private $Control;
|
20
|
-
private $Combine;
|
21
|
-
private $rspace = "/(?<!\\\)\s/";
|
22
|
-
private $rmp = "/(^|(?<!\\\);)(margin|padding)-(top|right|bottom|left):(.*?)((?<!\\\);|$)/";
|
23
|
-
private $rmpbase = "/(^|(?<!\\\);)(margin|padding):(.*?)((?<!\\\);|$)/";
|
24
|
-
|
25
|
-
/**
|
26
|
-
* Stash a reference to the controller & combiner
|
27
|
-
*
|
28
|
-
* @param (class) control: CSSCompression Controller
|
29
|
-
* @param (class) combine: CSSCompression Combiner
|
30
|
-
*/
|
31
|
-
public function __construct( CSSCompression_Control $control, CSSCompression_Combine $combine ) {
|
32
|
-
$this->Control = $control;
|
33
|
-
$this->Combine = $combine;
|
34
|
-
}
|
35
|
-
|
36
|
-
/**
|
37
|
-
* Combines multiple directional properties of
|
38
|
-
* margin/padding into single definition.
|
39
|
-
*
|
40
|
-
* @param (string) val: Rule Set
|
41
|
-
*/
|
42
|
-
public function combine( $val ) {
|
43
|
-
$val = $this->expand( $val );
|
44
|
-
$storage = $this->storage( $val );
|
45
|
-
$pos = 0;
|
46
|
-
|
47
|
-
// Now rebuild the string replacing all instances of margin/padding if shorthand exists
|
48
|
-
while ( preg_match( $this->rmp, $val, $match, PREG_OFFSET_CAPTURE, $pos ) ) {
|
49
|
-
$prop = $match[ 2 ][ 0 ];
|
50
|
-
if ( isset( $storage[ $prop ] ) ) {
|
51
|
-
$colon = strlen( $match[ 1 ][ 0 ] );
|
52
|
-
$val = substr_replace( $val, $storage[ $prop ], $match[ 0 ][ 1 ] + $colon, strlen( $match[ 0 ][ 0 ] ) - $colon );
|
53
|
-
$pos = $match[ 0 ][ 1 ] + strlen( $storage[ $prop ] ) - $colon - 1;
|
54
|
-
$storage[ $prop ] = '';
|
55
|
-
}
|
56
|
-
else {
|
57
|
-
$pos = $match[ 0 ][ 1 ] + strlen( $match[ 0 ][ 0 ] ) - 1;
|
58
|
-
}
|
59
|
-
}
|
60
|
-
|
61
|
-
// Return converted val
|
62
|
-
return $val;
|
63
|
-
}
|
64
|
-
|
65
|
-
/**
|
66
|
-
* Build the storage object for iteration
|
67
|
-
*
|
68
|
-
* @param (string) val: Rule Set
|
69
|
-
*/
|
70
|
-
private function storage( $val ) {
|
71
|
-
$storage = array();
|
72
|
-
$pos = 0;
|
73
|
-
|
74
|
-
// Find all possible occurences of margin/padding and mark their directional value
|
75
|
-
while ( preg_match( $this->rmp, $val, $match, PREG_OFFSET_CAPTURE, $pos ) ) {
|
76
|
-
if ( ! isset( $storage[ $match[ 2 ][ 0 ] ] ) ) {
|
77
|
-
$storage[ $match[ 2 ][ 0 ] ] = array( $match[ 3 ][ 0 ] => $match[ 4 ][ 0 ] );
|
78
|
-
}
|
79
|
-
|
80
|
-
// Override double written properties
|
81
|
-
$storage[ $match[ 2 ][ 0 ] ][ $match[ 3 ][ 0 ] ] = $match[ 4 ][ 0 ];
|
82
|
-
$pos = $match[ 0 ][ 1 ] + strlen( $match[ 0 ][ 0 ] ) - 1;
|
83
|
-
}
|
84
|
-
|
85
|
-
// Go through each tag for possible combination
|
86
|
-
foreach ( $storage as $tag => $arr ) {
|
87
|
-
// Only combine if all 4 definitions are found
|
88
|
-
if ( count( $arr ) == 4 && ! $this->Combine->checkUncombinables( $arr ) ) {
|
89
|
-
// All 4 are the same
|
90
|
-
if ( $arr['top'] == $arr['bottom'] && $arr['left'] == $arr['right'] && $arr['top'] == $arr['left'] ) {
|
91
|
-
$storage[ $tag ] = "$tag:" . $arr['top'] . ';';
|
92
|
-
}
|
93
|
-
// Opposites are the same
|
94
|
-
else if ( $arr['top'] == $arr['bottom'] && $arr['left'] == $arr['right'] ) {
|
95
|
-
$storage[ $tag ] = "$tag:" . $arr['top'] . ' ' . $arr['left'] . ';';
|
96
|
-
}
|
97
|
-
// 3-point directional
|
98
|
-
else if ( $arr['right'] == $arr['left'] ) {
|
99
|
-
$storage[ $tag ] = "$tag:" . $arr['top'] . ' ' . $arr['right'] . ' ' . $arr['bottom'] . ';';
|
100
|
-
}
|
101
|
-
// none are the same, but can still use shorthand notation
|
102
|
-
else {
|
103
|
-
$storage[ $tag ] = "$tag:" . $arr['top'] . ' ' . $arr['right'] . ' ' . $arr['bottom'] . ' ' . $arr['left'] . ';';
|
104
|
-
}
|
105
|
-
}
|
106
|
-
else {
|
107
|
-
unset( $storage[ $tag ] );
|
108
|
-
}
|
109
|
-
}
|
110
|
-
|
111
|
-
return $storage;
|
112
|
-
}
|
113
|
-
|
114
|
-
/**
|
115
|
-
* Explodes shorthanded margin/padding properties for later combination
|
116
|
-
*
|
117
|
-
* @param (string) val: Rule set
|
118
|
-
*/
|
119
|
-
private function expand( $val ) {
|
120
|
-
$pos = 0;
|
121
|
-
while ( preg_match( $this->rmpbase, $val, $match, PREG_OFFSET_CAPTURE, $pos ) ) {
|
122
|
-
$replace = '';
|
123
|
-
$prop = $match[ 2 ][ 0 ];
|
124
|
-
$value = preg_split( $this->rspace, trim( $match[ 3 ][ 0 ] ) );
|
125
|
-
$positions = array(
|
126
|
-
'top' => 0,
|
127
|
-
'right' => 0,
|
128
|
-
'bottom' => 0,
|
129
|
-
'left' => 0
|
130
|
-
);
|
131
|
-
|
132
|
-
// Skip uncombinables
|
133
|
-
if ( $this->Combine->checkUncombinables( $value ) ) {
|
134
|
-
$pos = $match[ 0 ][ 1 ] + strlen( $match[ 0 ][ 0 ] );
|
135
|
-
continue;
|
136
|
-
}
|
137
|
-
|
138
|
-
// Each position needs a value
|
139
|
-
switch ( count( $value ) ) {
|
140
|
-
case 1:
|
141
|
-
$positions['top'] = $positions['right'] = $positions['bottom'] = $positions['left'] = $value[ 0 ];
|
142
|
-
break;
|
143
|
-
case 2:
|
144
|
-
$positions['top'] = $positions['bottom'] = $value[ 0 ];
|
145
|
-
$positions['right'] = $positions['left'] = $value[ 1 ];
|
146
|
-
break;
|
147
|
-
case 3:
|
148
|
-
$positions['top'] = $value[ 0 ];
|
149
|
-
$positions['right'] = $positions['left'] = $value[ 1 ];
|
150
|
-
$positions['bottom'] = $value[ 2 ];
|
151
|
-
break;
|
152
|
-
case 4:
|
153
|
-
$positions['top'] = $value[ 0 ];
|
154
|
-
$positions['right'] = $value[ 1 ];
|
155
|
-
$positions['bottom'] = $value[ 2 ];
|
156
|
-
$positions['left'] = $value[ 3 ];
|
157
|
-
break;
|
158
|
-
default:
|
159
|
-
continue;
|
160
|
-
}
|
161
|
-
|
162
|
-
// Build the replacement
|
163
|
-
foreach ( $positions as $p => $v ) {
|
164
|
-
$replace .= "$prop-$p:$v;";
|
165
|
-
}
|
166
|
-
$colon = strlen( $match[ 1 ][ 0 ] );
|
167
|
-
$val = substr_replace( $val, $replace, $match[ 0 ][ 1 ] + $colon, strlen( $match[ 0 ][ 0 ] ) - $colon );
|
168
|
-
$pos = $match[ 0 ][ 1 ] + strlen( $replace ) - $colon - 1;
|
169
|
-
}
|
170
|
-
|
171
|
-
return $val;
|
172
|
-
}
|
173
|
-
|
174
|
-
/**
|
175
|
-
* Access to private methods for testing
|
176
|
-
*
|
177
|
-
* @param (string) method: Method to be called
|
178
|
-
* @param (array) args: Array of paramters to be passed in
|
179
|
-
*/
|
180
|
-
public function access( $method, $args ) {
|
181
|
-
if ( method_exists( $this, $method ) ) {
|
182
|
-
return call_user_func_array( array( $this, $method ), $args );
|
183
|
-
}
|
184
|
-
else {
|
185
|
-
throw new CSSCompression_Exception( "Unknown method in MarginPadding Class - " . $method );
|
186
|
-
}
|
187
|
-
}
|
188
|
-
};
|
189
|
-
|
190
|
-
?>
|
@@ -1,191 +0,0 @@
|
|
1
|
-
<?php
|
2
|
-
/**
|
3
|
-
* CSS Compressor [VERSION]
|
4
|
-
* [DATE]
|
5
|
-
* Corey Hart @ http://www.codenothing.com
|
6
|
-
*/
|
7
|
-
|
8
|
-
Class CSSCompression_Combine
|
9
|
-
{
|
10
|
-
/**
|
11
|
-
* Combine Patterns
|
12
|
-
*
|
13
|
-
* @class Control: Compression Controller
|
14
|
-
* @param (string) token: Copy of the injection token
|
15
|
-
* @param (array) options: Reference to options
|
16
|
-
* @param (regex) rspace: Checks for space without an escape '\' character before it
|
17
|
-
* @param (regex) rslash: Checks for unescaped slash character
|
18
|
-
* @param (regex) rimportant: Checking props for uncombinables
|
19
|
-
* @param (array) methods: List of options with their corresponding class
|
20
|
-
*/
|
21
|
-
private $Control;
|
22
|
-
private $token = '';
|
23
|
-
private $options = array();
|
24
|
-
private $rspace = "/(?<!\\\)\s/";
|
25
|
-
private $rslash = "/(?<!\\\)\//";
|
26
|
-
private $rimportant = "/inherit|\!important|\!ie|(?<!\\\)\s/i";
|
27
|
-
private $methods = array(
|
28
|
-
'csw-combine' => 'BorderOutline',
|
29
|
-
'border-radius-combine' => 'BorderRadius',
|
30
|
-
'border-combine' => 'Border',
|
31
|
-
'mp-combine' => 'MarginPadding',
|
32
|
-
'background-combine' => 'Background',
|
33
|
-
'auralcp-combine' => 'Aural',
|
34
|
-
'font-combine' => 'Font',
|
35
|
-
'list-combine' => 'List',
|
36
|
-
);
|
37
|
-
|
38
|
-
/**
|
39
|
-
* Sub Comination Classes
|
40
|
-
*
|
41
|
-
* @class BorderOutline: Handles Color/Style/With combinations of border/outline properties
|
42
|
-
* @class BorderRadius: Handles border-radius combinations
|
43
|
-
* @class Border: Handles normal border combinations
|
44
|
-
* @class MarginPadding: Handles margin/padding combinations
|
45
|
-
* @class Background: Handles background combinations
|
46
|
-
* @class Aural: Handles aural combinations
|
47
|
-
* @class Font: Handles font combinations
|
48
|
-
* @class List: Handles list combinations
|
49
|
-
* @param (array) subcombines: Array holding all subcombination classes
|
50
|
-
*/
|
51
|
-
public $BorderOutline;
|
52
|
-
public $BorderRadius;
|
53
|
-
public $Border;
|
54
|
-
public $MarginPadding;
|
55
|
-
public $Background;
|
56
|
-
public $Aural;
|
57
|
-
public $Font;
|
58
|
-
public $List;
|
59
|
-
private $subcombines = array(
|
60
|
-
'BorderOutline',
|
61
|
-
'BorderRadius',
|
62
|
-
'Border',
|
63
|
-
'MarginPadding',
|
64
|
-
'Background',
|
65
|
-
'Aural',
|
66
|
-
'Font',
|
67
|
-
'List',
|
68
|
-
);
|
69
|
-
|
70
|
-
/**
|
71
|
-
* Stash a reference to the controller on each instantiation
|
72
|
-
*
|
73
|
-
* @param (class) control: CSSCompression Controller
|
74
|
-
*/
|
75
|
-
public function __construct( CSSCompression_Control $control ) {
|
76
|
-
$this->Control = $control;
|
77
|
-
$this->token = CSSCompression::TOKEN;
|
78
|
-
$this->options = &$control->Option->options;
|
79
|
-
|
80
|
-
// Include classes if not already done so
|
81
|
-
if ( ! class_exists( "CSSCompression_Combine_Border", false ) ) {
|
82
|
-
$path = dirname(__FILE__) . '/Combine/';
|
83
|
-
foreach ( $this->subcombines as $class ) {
|
84
|
-
require( $path . $class . '.php' );
|
85
|
-
}
|
86
|
-
}
|
87
|
-
|
88
|
-
// Instantiate each sub combine
|
89
|
-
foreach ( $this->subcombines as $class ) {
|
90
|
-
$full = "CSSCompression_Combine_$class";
|
91
|
-
$this->$class = new $full( $control, $this );
|
92
|
-
}
|
93
|
-
}
|
94
|
-
|
95
|
-
/**
|
96
|
-
* Reads through each detailed package and checks for cross defn combinations
|
97
|
-
*
|
98
|
-
* @param (array) selectors: Array of selectors
|
99
|
-
* @param (array) details: Array of details
|
100
|
-
*/
|
101
|
-
public function combine( &$selectors = array(), &$details = array() ) {
|
102
|
-
foreach ( $details as $i => &$value ) {
|
103
|
-
if ( isset( $selectors[ $i ] ) && strpos( $selectors[ $i ], $this->token ) === 0 ) {
|
104
|
-
continue;
|
105
|
-
}
|
106
|
-
|
107
|
-
foreach ( $this->methods as $option => $class ) {
|
108
|
-
if ( $this->options[ $option ] ) {
|
109
|
-
$value = $this->$class->combine( $value );
|
110
|
-
}
|
111
|
-
}
|
112
|
-
}
|
113
|
-
|
114
|
-
return array( $selectors, $details );
|
115
|
-
}
|
116
|
-
|
117
|
-
/**
|
118
|
-
* Helper function to ensure flagged words don't get
|
119
|
-
* overridden
|
120
|
-
*
|
121
|
-
* @param (mixed) obj: Array/String of definitions to be checked
|
122
|
-
*/
|
123
|
-
public function checkUncombinables( $obj ) {
|
124
|
-
if ( is_array( $obj ) ) {
|
125
|
-
foreach ( $obj as $item ) {
|
126
|
-
if ( preg_match( $this->rimportant, $item ) ) {
|
127
|
-
return true;
|
128
|
-
}
|
129
|
-
}
|
130
|
-
return false;
|
131
|
-
}
|
132
|
-
else {
|
133
|
-
return preg_match( $this->rimportant, $obj );
|
134
|
-
}
|
135
|
-
}
|
136
|
-
|
137
|
-
/**
|
138
|
-
* Helper function to ensure all values of search array
|
139
|
-
* exist within the storage array
|
140
|
-
*
|
141
|
-
* @param (string) prop: CSS Property
|
142
|
-
* @param (array) storage: Array of definitions found
|
143
|
-
* @param (array) search: Array of definitions requred
|
144
|
-
*/
|
145
|
-
public function searchDefinitions( $prop, $storage, $search ) {
|
146
|
-
// Return if storage & search don't match
|
147
|
-
if ( count( $storage ) != count( $search ) ) {
|
148
|
-
return false;
|
149
|
-
}
|
150
|
-
|
151
|
-
$str = "$prop:";
|
152
|
-
foreach ( $search as $value ) {
|
153
|
-
if ( ! isset( $storage[ $value ] ) || $this->checkUncombinables( $storage[ $value ] ) ) {
|
154
|
-
return false;
|
155
|
-
}
|
156
|
-
$str .= $storage[ $value ] . ' ';
|
157
|
-
}
|
158
|
-
return trim( $str ) . ';';
|
159
|
-
}
|
160
|
-
|
161
|
-
/**
|
162
|
-
* Access to private methods for testing
|
163
|
-
*
|
164
|
-
* @param (string) subclass: Name of subclass to focus on
|
165
|
-
* @param (string) method: Method to be called
|
166
|
-
* @param (array) args: Array of paramters to be passed in
|
167
|
-
*/
|
168
|
-
public function access( $subclass, $method, $args ) {
|
169
|
-
if ( $subclass == 'Combine' ) {
|
170
|
-
if ( method_exists( $this, $method ) ) {
|
171
|
-
if ( $method == 'combine' ) {
|
172
|
-
return $this->combine( $args[ 0 ], $args[ 1 ] );
|
173
|
-
}
|
174
|
-
else {
|
175
|
-
return call_user_func_array( array( $this, $method ), $args );
|
176
|
-
}
|
177
|
-
}
|
178
|
-
else {
|
179
|
-
throw new CSSCompression_Exception( "Unknown method in Combine Class - " . $method );
|
180
|
-
}
|
181
|
-
}
|
182
|
-
else if ( in_array( $subclass, $this->subcombines ) ) {
|
183
|
-
return $this->$subclass->access( $method, $args );
|
184
|
-
}
|
185
|
-
else {
|
186
|
-
throw new CSSCompression_Exception( "Unknown Sub Combine Class - " . $subclass );
|
187
|
-
}
|
188
|
-
}
|
189
|
-
};
|
190
|
-
|
191
|
-
?>
|
@@ -1,212 +0,0 @@
|
|
1
|
-
<?php
|
2
|
-
/**
|
3
|
-
* CSS Compressor [VERSION]
|
4
|
-
* [DATE]
|
5
|
-
* Corey Hart @ http://www.codenothing.com
|
6
|
-
*/
|
7
|
-
|
8
|
-
Class CSSCompression_Compress
|
9
|
-
{
|
10
|
-
/**
|
11
|
-
* Trim Patterns
|
12
|
-
*
|
13
|
-
* @param (array) options: Reference to options
|
14
|
-
* @param (array) stats: Reference to stats
|
15
|
-
* @param (regex) rsemicolon: Checks for semicolon without an escape '\' character before it
|
16
|
-
* @param (regex) rcolon: Checks for colon without an escape '\' character before it
|
17
|
-
* @param (regex) rspace: Checks for space without an escape '\' character before it
|
18
|
-
*/
|
19
|
-
private $options = array();
|
20
|
-
private $stats = array();
|
21
|
-
private $rsemicolon = "/(?<!\\\);/";
|
22
|
-
private $rcolon = "/(?<!\\\):/";
|
23
|
-
private $rspace = "/(?<!\\\)\s/";
|
24
|
-
|
25
|
-
/**
|
26
|
-
* Other inner classes that get used within compression
|
27
|
-
*
|
28
|
-
* @class Control: Compression Controller
|
29
|
-
* @class Trim: Trim Instance
|
30
|
-
* @class Setup: Setup Instance
|
31
|
-
* @class Format: Formatting Instance
|
32
|
-
* @class Combine: Combine Instance
|
33
|
-
* @class Cleanup: Cleanup Instance
|
34
|
-
* @class Organize: Organize Instance
|
35
|
-
* @class Selectors: Selectors Instance
|
36
|
-
* @param (array) others: List of above classes for copying
|
37
|
-
*/
|
38
|
-
private $Control;
|
39
|
-
private $Trim;
|
40
|
-
private $Setup;
|
41
|
-
private $Format;
|
42
|
-
private $Combine;
|
43
|
-
private $Cleanup;
|
44
|
-
private $Organize;
|
45
|
-
private $Selectors;
|
46
|
-
private $others = array(
|
47
|
-
'Trim',
|
48
|
-
'Setup',
|
49
|
-
'Format',
|
50
|
-
'Combine',
|
51
|
-
'Cleanup',
|
52
|
-
'Organize',
|
53
|
-
'Selectors',
|
54
|
-
);
|
55
|
-
|
56
|
-
/**
|
57
|
-
* Stash a reference to the controller on each instantiation
|
58
|
-
*
|
59
|
-
* @param (class) control: CSSCompression Controller
|
60
|
-
*/
|
61
|
-
public function __construct( CSSCompression_Control $control ) {
|
62
|
-
$this->Control = $control;
|
63
|
-
$this->options = &$control->Option->options;
|
64
|
-
$this->stats = &$control->stats;
|
65
|
-
|
66
|
-
foreach ( $this->others as $class ) {
|
67
|
-
$this->$class = $control->$class;
|
68
|
-
}
|
69
|
-
}
|
70
|
-
|
71
|
-
/**
|
72
|
-
* Centralized function to run css compression.
|
73
|
-
*
|
74
|
-
* @param (string) css: Stylesheet to compresss
|
75
|
-
*/
|
76
|
-
public function compress( $css ) {
|
77
|
-
$setup = $this->setup( $css );
|
78
|
-
$setup = $this->rulesets( $setup );
|
79
|
-
$css = $this->readability( $setup );
|
80
|
-
|
81
|
-
// Attach plea to top of page with unknown blocks
|
82
|
-
if ( $this->options['add-unknown'] && count( $setup['unknown'] ) ) {
|
83
|
-
$css = "/*\nThere are unknown blocks in the sheet, please please please open an issue with your sheet attached to it:\n"
|
84
|
-
. "https://github.com/codenothing/css-compressor/issues\n"
|
85
|
-
. "Thank You --\n\n"
|
86
|
-
. implode( "\n", $setup['unknown'] )
|
87
|
-
. "\n*/\n"
|
88
|
-
. $css;
|
89
|
-
}
|
90
|
-
|
91
|
-
// Mark final file size
|
92
|
-
$this->stats['after']['size'] = strlen( $css = trim( $css ) );
|
93
|
-
|
94
|
-
// Return compressed css
|
95
|
-
return $css;
|
96
|
-
}
|
97
|
-
|
98
|
-
/**
|
99
|
-
* Runs css through initial setup handlers
|
100
|
-
*
|
101
|
-
* @param (string) css: Sheet to compress
|
102
|
-
*/
|
103
|
-
private function setup( $css ) {
|
104
|
-
// Initial stats
|
105
|
-
$this->stats['before']['time'] = microtime( true );
|
106
|
-
$this->stats['before']['size'] = strlen( $css );
|
107
|
-
|
108
|
-
// Initial trimming
|
109
|
-
$css = $this->Trim->trim( $css );
|
110
|
-
|
111
|
-
// Do a little tokenizing, compress each property individually
|
112
|
-
$setup = $this->Setup->setup( $css );
|
113
|
-
|
114
|
-
// Mark number of selectors pre-combine
|
115
|
-
$this->stats['before']['selectors'] = count( $setup['selectors'] );
|
116
|
-
|
117
|
-
return $setup;
|
118
|
-
}
|
119
|
-
|
120
|
-
/**
|
121
|
-
* Focus compressions on each rule set
|
122
|
-
*
|
123
|
-
* @param (array) setup: Array containing selectors and rule sets
|
124
|
-
*/
|
125
|
-
private function rulesets( $setup ) {
|
126
|
-
// Do selector specific compressions
|
127
|
-
$this->Selectors->selectors( $setup['selectors'] );
|
128
|
-
|
129
|
-
// Look at each group of properties as a whole, and compress/combine similiar definitions
|
130
|
-
$this->Combine->combine( $setup['selectors'], $setup['details'] );
|
131
|
-
|
132
|
-
// If order isn't important, run comination functions before and after compressions to catch all instances
|
133
|
-
// Be sure to prune before hand for higher chance of matching
|
134
|
-
if ( $this->options['organize'] ) {
|
135
|
-
$this->Cleanup->cleanup( $setup['selectors'], $setup['details'] );
|
136
|
-
$this->Organize->organize( $setup['selectors'], $setup['details'] );
|
137
|
-
$this->Combine->combine( $setup['selectors'], $setup['details'] );
|
138
|
-
}
|
139
|
-
|
140
|
-
// Do final maintenace work, remove injected property/values
|
141
|
-
$this->Cleanup->cleanup( $setup['selectors'], $setup['details'] );
|
142
|
-
|
143
|
-
// Run final counters before full cleanup
|
144
|
-
$this->finalCount( $setup['selectors'], $setup['details'] );
|
145
|
-
|
146
|
-
return $setup;
|
147
|
-
}
|
148
|
-
|
149
|
-
/**
|
150
|
-
* Runs final counts on selectors and props
|
151
|
-
*
|
152
|
-
* @param (array) selectors: Selector rules
|
153
|
-
* @param (array) details: Rule sets
|
154
|
-
*/
|
155
|
-
private function finalCount( $selectors, $details ) {
|
156
|
-
// Selectors and props
|
157
|
-
$this->stats['after']['selectors'] = count( $selectors );
|
158
|
-
foreach ( $details as $item ) {
|
159
|
-
$props = preg_split( $this->rsemicolon, $item );
|
160
|
-
|
161
|
-
// Make sure count is true
|
162
|
-
foreach ( $props as $k => $v ) {
|
163
|
-
if ( ! isset( $v ) || $v == '' ) {
|
164
|
-
unset( $props[ $k ] );
|
165
|
-
}
|
166
|
-
}
|
167
|
-
$this->stats['after']['props'] += count( $props );
|
168
|
-
}
|
169
|
-
|
170
|
-
// Final count for stats
|
171
|
-
$this->stats['after']['time'] = microtime( true );
|
172
|
-
}
|
173
|
-
|
174
|
-
/**
|
175
|
-
* Formats the compressed rule sets into a stylesheet
|
176
|
-
*
|
177
|
-
* @param (array) setup: Array containing selectors and rule sets
|
178
|
-
*/
|
179
|
-
private function readability( $setup ) {
|
180
|
-
// Format css to users preference
|
181
|
-
$css = $this->Format->readability( $this->options['readability'], $setup['selectors'], $setup['details'] );
|
182
|
-
|
183
|
-
// Intros
|
184
|
-
foreach ( $setup as $value ) {
|
185
|
-
if ( $value && is_string( $value ) ) {
|
186
|
-
$css = $value . $css;
|
187
|
-
}
|
188
|
-
}
|
189
|
-
|
190
|
-
// Remove escapables
|
191
|
-
$css = $this->Cleanup->removeInjections( $css );
|
192
|
-
|
193
|
-
return $css;
|
194
|
-
}
|
195
|
-
|
196
|
-
/**
|
197
|
-
* Access to private methods for testing
|
198
|
-
*
|
199
|
-
* @param (string) method: Method to be called
|
200
|
-
* @param (array) args: Array of paramters to be passed in
|
201
|
-
*/
|
202
|
-
public function access( $method, $args ) {
|
203
|
-
if ( method_exists( $this, $method ) ) {
|
204
|
-
return call_user_func_array( array( $this, $method ), $args );
|
205
|
-
}
|
206
|
-
else {
|
207
|
-
throw new CSSCompression_Exception( "Unknown method in Compress Class - " . $method );
|
208
|
-
}
|
209
|
-
}
|
210
|
-
};
|
211
|
-
|
212
|
-
?>
|