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,465 +0,0 @@
|
|
1
|
-
<?php
|
2
|
-
/**
|
3
|
-
* CSS Compressor [VERSION]
|
4
|
-
* [DATE]
|
5
|
-
* Corey Hart @ http://www.codenothing.com
|
6
|
-
*/
|
7
|
-
|
8
|
-
// Static dependencies, Subclasses loaded ondemand
|
9
|
-
require( dirname(__FILE__) . '/lib/Exception.php' );
|
10
|
-
require( dirname(__FILE__) . '/lib/Control.php' );
|
11
|
-
|
12
|
-
|
13
|
-
Class CSSCompression
|
14
|
-
{
|
15
|
-
/**
|
16
|
-
* CSSCompression Info
|
17
|
-
*
|
18
|
-
* @const (string) VERSION: Release version
|
19
|
-
* @const (string) DATE: Release date
|
20
|
-
*/
|
21
|
-
const VERSION = "[VERSION]";
|
22
|
-
const DATE = "[DATE]";
|
23
|
-
|
24
|
-
/**
|
25
|
-
* WARNING: This should ALWAYS BE FALSE in production
|
26
|
-
* When DEV is true, backdoor access to private methods is opened.
|
27
|
-
* Only used for unit testing and development.
|
28
|
-
*/
|
29
|
-
const DEV = true;
|
30
|
-
|
31
|
-
/**
|
32
|
-
* TOKEN is a special string that gets used as a marker within
|
33
|
-
* the compressor, and is removed before final output. Make sure
|
34
|
-
* this token is unique to your stylsheets.
|
35
|
-
*
|
36
|
-
* NOTE: This string gets used in regular expressions, and escaping
|
37
|
-
* won't help, so don't pick a complicated token.
|
38
|
-
*/
|
39
|
-
const TOKEN = "@____CSSCOMPRESSION_TOKEN____@";
|
40
|
-
|
41
|
-
/**
|
42
|
-
* The default set of options for every instance.
|
43
|
-
*/
|
44
|
-
public static $defaults = array(
|
45
|
-
// Converts long color names to short hex names
|
46
|
-
// (aliceblue -> #f0f8ff)
|
47
|
-
'color-long2hex' => true,
|
48
|
-
|
49
|
-
// Converts rgb colors to hex
|
50
|
-
// (rgb(159,80,98) -> #9F5062, rgb(100%) -> #FFFFFF)
|
51
|
-
'color-rgb2hex' => true,
|
52
|
-
|
53
|
-
// Converts long hex codes to short color names (#f5f5dc -> beige)
|
54
|
-
// Only works on latest browsers, careful when using
|
55
|
-
'color-hex2shortcolor' => false,
|
56
|
-
|
57
|
-
// Converts long hex codes to short hex codes
|
58
|
-
// (#44ff11 -> #4f1)
|
59
|
-
'color-hex2shorthex' => true,
|
60
|
-
|
61
|
-
// Converts hex codes to safe CSS Level 1 color names
|
62
|
-
// (#F00 -> red)
|
63
|
-
'color-hex2safe' => true,
|
64
|
-
|
65
|
-
// Converts font-weight names to numbers
|
66
|
-
// (bold -> 700)
|
67
|
-
'fontweight2num' => true,
|
68
|
-
|
69
|
-
// Removes zero decimals and 0 units
|
70
|
-
// (15.0px -> 15px || 0px -> 0)
|
71
|
-
'format-units' => true,
|
72
|
-
|
73
|
-
// Lowercases html tags from list
|
74
|
-
// (BODY -> body)
|
75
|
-
'lowercase-selectors' => true,
|
76
|
-
|
77
|
-
// Converts id and class attribute selectors, to their short selector counterpart
|
78
|
-
// (div[id=blah][class=moreblah] -> div#blah.moreblah)
|
79
|
-
'attr2selector' => true,
|
80
|
-
|
81
|
-
// Promotes nested id's to the front of the selector
|
82
|
-
// (body>div#elem p -> $elem p)
|
83
|
-
'strict-id' => false,
|
84
|
-
|
85
|
-
// Add space after pseudo selectors, for ie6
|
86
|
-
// (a:first-child{ -> a:first-child {)
|
87
|
-
'pseudo-space' => false,
|
88
|
-
|
89
|
-
// Compresses single defined multi-directional properties
|
90
|
-
// (margin: 15px 25px 15px 25px -> margin:15px 25px)
|
91
|
-
'directional-compress' => true,
|
92
|
-
|
93
|
-
// Combines multiply defined selectors and details
|
94
|
-
// (p{color:blue;} p{font-size:12pt} -> p{color:blue;font-size:12pt;})
|
95
|
-
// (p{color:blue;} a{color:blue;} -> p,a{color:blue;})
|
96
|
-
'organize' => true,
|
97
|
-
|
98
|
-
// Combines color/style/width properties
|
99
|
-
// (border-style:dashed;border-color:black;border-width:4px; -> border:4px dashed black)
|
100
|
-
'csw-combine' => true,
|
101
|
-
|
102
|
-
// Combines cue/pause properties
|
103
|
-
// (cue-before: url(before.au); cue-after: url(after.au) -> cue:url(before.au) url(after.au))
|
104
|
-
'auralcp-combine' => true,
|
105
|
-
|
106
|
-
// Combines margin/padding directionals
|
107
|
-
// (margin-top:10px;margin-right:5px;margin-bottom:4px;margin-left:1px; -> margin:10px 5px 4px 1px;)
|
108
|
-
'mp-combine' => true,
|
109
|
-
|
110
|
-
// Combines border directionals
|
111
|
-
// (border-top|right|bottom|left:1px solid black -> border:1px solid black)
|
112
|
-
'border-combine' => true,
|
113
|
-
|
114
|
-
// Combines font properties
|
115
|
-
// (font-size:12pt; font-family: arial; -> font:12pt arial)
|
116
|
-
'font-combine' => true,
|
117
|
-
|
118
|
-
// Combines background properties
|
119
|
-
// (background-color: black; background-image: url(bgimg.jpeg); -> background:black url(bgimg.jpeg))
|
120
|
-
'background-combine' => true,
|
121
|
-
|
122
|
-
// Combines list-style properties
|
123
|
-
// (list-style-type: round; list-style-position: outside -> list-style:round outside)
|
124
|
-
'list-combine' => true,
|
125
|
-
|
126
|
-
// Combines border-radius properties
|
127
|
-
// {
|
128
|
-
// border-top-left-radius: 10px;
|
129
|
-
// border-top-right-radius: 10px;
|
130
|
-
// border-bottom-right-radius: 10px;
|
131
|
-
// border-bottom-left-radius: 10px;
|
132
|
-
// }
|
133
|
-
// -> { border-radius: 10px; }
|
134
|
-
'border-radius-combine' => true,
|
135
|
-
|
136
|
-
// Removes the last semicolon of a property set
|
137
|
-
// ({margin: 2px; color: blue;} -> {margin: 2px; color: blue})
|
138
|
-
'unnecessary-semicolons' => true,
|
139
|
-
|
140
|
-
// Removes multiple declarations within the same rule set
|
141
|
-
'rm-multi-define' => true,
|
142
|
-
|
143
|
-
// Adds all unknown blocks to the top of the output in a comment strip
|
144
|
-
// Purely for bug reporting, but also useful to know what isn't being handled
|
145
|
-
'add-unknown' => true,
|
146
|
-
|
147
|
-
// Readibility of Compressed Output, Defaults to none
|
148
|
-
'readability' => 0,
|
149
|
-
);
|
150
|
-
|
151
|
-
/**
|
152
|
-
* Modes are predefined sets of configuration for referencing. When creating a mode, all options are set to true,
|
153
|
-
* and the mode array defines which options are to be false
|
154
|
-
*
|
155
|
-
* @mode safe: Safe mode does zero combinations or organizing. It's the best mode if you use a lot of hacks
|
156
|
-
* @mode sane: Sane mode does most combinations(multiple long hand notations to single shorthand),
|
157
|
-
* --- but still keeps most declarations in their place
|
158
|
-
* @mode small: Small mode reorganizes the whole sheet, combines as much as it can, and will break most comment hacks
|
159
|
-
* @mode full: Full mode does everything small does, but also converts hex codes to their short color name alternatives
|
160
|
-
*/
|
161
|
-
private static $modes = array(
|
162
|
-
'safe' => array(
|
163
|
-
'color-hex2shortcolor' => false,
|
164
|
-
'attr2selector' => false,
|
165
|
-
'strict-id' => false,
|
166
|
-
'organize' => false,
|
167
|
-
'csw-combine' => false,
|
168
|
-
'auralcp-combine' => false,
|
169
|
-
'mp-combine' => false,
|
170
|
-
'border-combine' => false,
|
171
|
-
'font-combine' => false,
|
172
|
-
'background-combine' => false,
|
173
|
-
'list-combine' => false,
|
174
|
-
'border-radius-combine' => false,
|
175
|
-
'rm-multi-define' => false,
|
176
|
-
),
|
177
|
-
'sane' => array(
|
178
|
-
'color-hex2shortcolor' => false,
|
179
|
-
'strict-id' => false,
|
180
|
-
'organize' => false,
|
181
|
-
'font-combine' => false,
|
182
|
-
'background-combine' => false,
|
183
|
-
'list-combine' => false,
|
184
|
-
'rm-multi-define' => false,
|
185
|
-
),
|
186
|
-
'small' => array(
|
187
|
-
'color-hex2shortcolor' => false,
|
188
|
-
'pseudo-space' => false,
|
189
|
-
),
|
190
|
-
'full' => array(
|
191
|
-
'pseudo-space' => false,
|
192
|
-
),
|
193
|
-
);
|
194
|
-
|
195
|
-
/**
|
196
|
-
* Readability Constants
|
197
|
-
*
|
198
|
-
* @param (int) READ_MAX: Maximum readability of output
|
199
|
-
* @param (int) READ_MED: Medium readability of output
|
200
|
-
* @param (int) READ_MIN: Minimal readability of output
|
201
|
-
* @param (int) READ_NONE: No readability of output (full compression into single line)
|
202
|
-
*/
|
203
|
-
const READ_MAX = 3;
|
204
|
-
const READ_MED = 2;
|
205
|
-
const READ_MIN = 1;
|
206
|
-
const READ_NONE = 0;
|
207
|
-
|
208
|
-
/**
|
209
|
-
* Static Helpers
|
210
|
-
*
|
211
|
-
* @instance express: Use a separate instance from singleton access
|
212
|
-
* @instance instance: Saved instance of CSSCompression
|
213
|
-
* @param (array) instances: Array of stored instances
|
214
|
-
* @param (array) rjson: Comment removal before json decoding
|
215
|
-
*/
|
216
|
-
private static $express;
|
217
|
-
private static $instance;
|
218
|
-
private static $instances = array();
|
219
|
-
private static $rjson = array(
|
220
|
-
'patterns' => array(
|
221
|
-
"/^(.*?){/s",
|
222
|
-
"/(\t|\s)+\/\/.*/",
|
223
|
-
),
|
224
|
-
'replacements' => array(
|
225
|
-
'{',
|
226
|
-
'',
|
227
|
-
),
|
228
|
-
);
|
229
|
-
|
230
|
-
/**
|
231
|
-
* Controller Instance
|
232
|
-
*/
|
233
|
-
private $Control;
|
234
|
-
|
235
|
-
/**
|
236
|
-
* Builds the subclasses, runs the compression if css passed, and merges options
|
237
|
-
*
|
238
|
-
* @param (string) css: CSS to compress on initialization if needed
|
239
|
-
* @param (array) options: Array of preferences to override the defaults
|
240
|
-
*/
|
241
|
-
public function __construct( $css = NULL, $options = NULL ) {
|
242
|
-
$this->Control = new CSSCompression_Control( $this );
|
243
|
-
|
244
|
-
// Autorun against css passed
|
245
|
-
if ( $css ) {
|
246
|
-
// Allow passing options/mode only
|
247
|
-
if ( is_array( $css ) || array_key_exists( $css, self::$modes ) ) {
|
248
|
-
$this->Control->Option->merge( $css );
|
249
|
-
}
|
250
|
-
else {
|
251
|
-
$this->Control->compress( $css, $options );
|
252
|
-
}
|
253
|
-
}
|
254
|
-
// Merge passed options
|
255
|
-
else if ( $options ) {
|
256
|
-
$this->Control->Option->merge( $options );
|
257
|
-
}
|
258
|
-
}
|
259
|
-
|
260
|
-
/**
|
261
|
-
* (Proxy function) Control access to properties
|
262
|
-
*
|
263
|
-
* - Getting stats/_mode/css returns the current value of that property
|
264
|
-
* - Getting options will return the current full options array
|
265
|
-
* - Getting anything else returns that current value in the options array or NULL
|
266
|
-
*
|
267
|
-
* @param (string) name: Name of property that you want to access
|
268
|
-
*/
|
269
|
-
public function __get( $name ) {
|
270
|
-
return $this->Control->get( $name );
|
271
|
-
}
|
272
|
-
|
273
|
-
/**
|
274
|
-
* (Proxy function) The setter method only allows
|
275
|
-
* access to setting values in the options array
|
276
|
-
*
|
277
|
-
* @param (string) name: Key name of the option you want to set
|
278
|
-
* @param (mixed) value: Value of the option you want to set
|
279
|
-
*/
|
280
|
-
public function __set( $name, $value ) {
|
281
|
-
return $this->Control->set( $name, $value );
|
282
|
-
}
|
283
|
-
|
284
|
-
/**
|
285
|
-
* (Proxy function) Merges a predefined set options
|
286
|
-
*
|
287
|
-
* @param (string) mode: Name of mode to use.
|
288
|
-
*/
|
289
|
-
public function mode( $mode = NULL ) {
|
290
|
-
return $this->Control->Option->merge( $mode );
|
291
|
-
}
|
292
|
-
|
293
|
-
/**
|
294
|
-
* Creates a new mode, or overwrites existing mode
|
295
|
-
*
|
296
|
-
* @param (mixed) mode: Name of the mode, or array of modes
|
297
|
-
* @param (array) config: Configuration of the mode
|
298
|
-
*/
|
299
|
-
public static function modes( $mode = NULL, $config = NULL ) {
|
300
|
-
if ( $mode === NULL ) {
|
301
|
-
return self::$modes;
|
302
|
-
}
|
303
|
-
else if ( is_array( $mode ) ) {
|
304
|
-
return array_merge( self::$modes, $mode );
|
305
|
-
}
|
306
|
-
else if ( $config === NULL ) {
|
307
|
-
return isset( self::$modes[ $mode ] ) ? self::$modes[ $mode ] : NULL;
|
308
|
-
}
|
309
|
-
else {
|
310
|
-
return self::$modes[ $mode ] = $config;
|
311
|
-
}
|
312
|
-
}
|
313
|
-
|
314
|
-
/**
|
315
|
-
* (Proxy function) Maintainable access to the options array
|
316
|
-
*
|
317
|
-
* - Passing no arguments returns the entire options array
|
318
|
-
* - Passing a single name argument returns the value for the option
|
319
|
-
* - Passing an array will merge the options with the array passed, for object like extension
|
320
|
-
* - Passing both a name and value, sets the value to the name key, and returns the value
|
321
|
-
*
|
322
|
-
* @param (mixed) name: The key name of the option
|
323
|
-
* @param (mixed) value: Value to set the option
|
324
|
-
*/
|
325
|
-
public function option( $name = NULL, $value = NULL ) {
|
326
|
-
return $this->Control->Option->option( $name, $value );
|
327
|
-
}
|
328
|
-
|
329
|
-
/**
|
330
|
-
* (Proxy function) Run compression on the sheet passed.
|
331
|
-
*
|
332
|
-
* @param (string) css: Stylesheet to be compressed
|
333
|
-
* @param (mixed) options: Array of options or mode to use.
|
334
|
-
*/
|
335
|
-
public function compress( $css = NULL, $options = NULL ) {
|
336
|
-
return $this->Control->compress( $css, $options );
|
337
|
-
}
|
338
|
-
|
339
|
-
/**
|
340
|
-
* Static access for direct compression
|
341
|
-
*
|
342
|
-
* @param (string) css: Stylesheet to be compressed
|
343
|
-
* @param (mixed) options: Array of options or mode to use.
|
344
|
-
*/
|
345
|
-
public static function express( $css = NULL, $options = NULL ) {
|
346
|
-
if ( ! self::$express ) {
|
347
|
-
self::$express = new CSSCompression();
|
348
|
-
}
|
349
|
-
|
350
|
-
self::$express->reset();
|
351
|
-
return self::$express->compress( $css, $options );
|
352
|
-
}
|
353
|
-
|
354
|
-
/**
|
355
|
-
* (Proxy Function) Cleans out compressor and it's subclasses to defaults
|
356
|
-
*
|
357
|
-
* @params none
|
358
|
-
*/
|
359
|
-
public function reset(){
|
360
|
-
return $this->Control->reset();
|
361
|
-
}
|
362
|
-
|
363
|
-
/**
|
364
|
-
* (Proxy Function) Cleans out class variables for next run
|
365
|
-
*
|
366
|
-
* @params none
|
367
|
-
*/
|
368
|
-
public function flush(){
|
369
|
-
return $this->Control->flush();
|
370
|
-
}
|
371
|
-
|
372
|
-
/**
|
373
|
-
* The Singleton access method (for those that want it)
|
374
|
-
*
|
375
|
-
* @param (string) name: Name of the stored instance
|
376
|
-
*/
|
377
|
-
public static function getInstance( $name = NULL ) {
|
378
|
-
if ( $name !== NULL ) {
|
379
|
-
if ( ! isset( self::$instances[ $name ] ) ) {
|
380
|
-
self::$instances[ $name ] = new self;
|
381
|
-
}
|
382
|
-
|
383
|
-
return self::$instances[ $name ];
|
384
|
-
}
|
385
|
-
else if ( ! self::$instance ) {
|
386
|
-
self::$instance = new self;
|
387
|
-
}
|
388
|
-
|
389
|
-
return self::$instance;
|
390
|
-
}
|
391
|
-
|
392
|
-
/**
|
393
|
-
* Reads JOSN based files, strips comments and converts to array
|
394
|
-
*
|
395
|
-
* @param (string) file: Filename
|
396
|
-
*/
|
397
|
-
public static function getJSON( $file ) {
|
398
|
-
// Assume helper file if full path not given
|
399
|
-
$file = $file[ 0 ] == '/' ? $file : dirname(__FILE__) . '/helpers/' . $file;
|
400
|
-
|
401
|
-
// Strip comments
|
402
|
-
$json = preg_replace( self::$rjson['patterns'], self::$rjson['replacements'], file_get_contents( $file ) );
|
403
|
-
|
404
|
-
// Decode json
|
405
|
-
$json = json_decode( $json, true );
|
406
|
-
|
407
|
-
// Check for errors
|
408
|
-
if ( $json === NULL ) {
|
409
|
-
$e = '';
|
410
|
-
// JSON Errors, taken directly from http://php.net/manual/en/function.json-last-error.php
|
411
|
-
switch( json_last_error() ) {
|
412
|
-
case JSON_ERROR_NONE:
|
413
|
-
$e = 'No error has occurred';
|
414
|
-
break;
|
415
|
-
case JSON_ERROR_DEPTH:
|
416
|
-
$e = 'The maximum stack depth has been exceeded';
|
417
|
-
break;
|
418
|
-
case JSON_ERROR_CTRL_CHAR:
|
419
|
-
$e = 'Control character error, possibly incorrectly encoded';
|
420
|
-
break;
|
421
|
-
case JSON_ERROR_STATE_MISMATCH:
|
422
|
-
$e = 'Invalid or malformed JSON';
|
423
|
-
break;
|
424
|
-
case JSON_ERROR_SYNTAX:
|
425
|
-
$e = 'Syntax error';
|
426
|
-
break;
|
427
|
-
case JSON_ERROR_UTF8:
|
428
|
-
$e = 'Malformed UTF-8 characters, possibly incorrectly encoded';
|
429
|
-
break;
|
430
|
-
default:
|
431
|
-
$e = 'Unknown JSON Error';
|
432
|
-
break;
|
433
|
-
}
|
434
|
-
|
435
|
-
throw new CSSCompression_Exception( "JSON Error in $file: $e" );
|
436
|
-
}
|
437
|
-
|
438
|
-
// Good to go
|
439
|
-
return $json;
|
440
|
-
}
|
441
|
-
|
442
|
-
/**
|
443
|
-
* Backdoor access to subclasses
|
444
|
-
* ONLY FOR DEVELOPMENT/TESTING.
|
445
|
-
*
|
446
|
-
* @param (string) class: Name of the focus class
|
447
|
-
* @param (string) method: Method function to call
|
448
|
-
* @param (array) args: Array of arguments to pass in
|
449
|
-
*/
|
450
|
-
public function access( $class = NULL, $method = NULL, $args = NULL ) {
|
451
|
-
if ( ! self::DEV ) {
|
452
|
-
throw new CSSCompression_Exception( "CSSCompression is not in development mode." );
|
453
|
-
}
|
454
|
-
else if ( $class === NULL || $method === NULL || $args === NULL ) {
|
455
|
-
throw new CSSCompression_Exception( "Invalid Access Call." );
|
456
|
-
}
|
457
|
-
else if ( ! is_array( $args ) ) {
|
458
|
-
throw new CSSCompression_Exception( "Expecting array of arguments." );
|
459
|
-
}
|
460
|
-
|
461
|
-
return $this->Control->access( $class, $method, $args );
|
462
|
-
}
|
463
|
-
};
|
464
|
-
|
465
|
-
?>
|
@@ -1,22 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# CSS Compression [VERSION] Change Log
|
3
|
-
# [DATE]
|
4
|
-
# Corey Hart @ http://www.codenothing.com
|
5
|
-
#
|
6
|
-
|
7
|
-
# Compressor Additions
|
8
|
-
- Configuration Modes
|
9
|
-
- pseduo-space, add space between pseduo selectors and comma/brace for ie6
|
10
|
-
- removing leading 0 of a decimal, 0.633px -> .633px
|
11
|
-
- handling all At Rules (charsets,media,imports,font-family,etc..)
|
12
|
-
- handling ms filter paths
|
13
|
-
- More css hacks support, including box-modal hack
|
14
|
-
- attr2selector, Convert id=blah and class=blah attributes to their selector counterparts
|
15
|
-
- strict-id, removes all selectors up to the last id
|
16
|
-
- add-unknown, adds unknown blocks to top of output in a comment
|
17
|
-
|
18
|
-
# Codebase Changes
|
19
|
-
- Converted to subclass architecture, more modular.
|
20
|
-
- Using JSON based sandbox specs for focused unit tests.
|
21
|
-
- Helper conversion definitions(long2hex, hex2short) are now in JSON based files.
|
22
|
-
- Added benchmark/regression testing
|
@@ -1,101 +0,0 @@
|
|
1
|
-
<?php
|
2
|
-
/**
|
3
|
-
* CSS Compressor [VERSION]
|
4
|
-
* [DATE]
|
5
|
-
* Corey Hart @ http://www.codenothing.com
|
6
|
-
*/
|
7
|
-
require( dirname(__FILE__) . '/CSSCompression.php' );
|
8
|
-
|
9
|
-
|
10
|
-
Class Cli
|
11
|
-
{
|
12
|
-
/**
|
13
|
-
* Cli Patterns
|
14
|
-
*
|
15
|
-
* @param (CSSCompression instance) instance: CSSCompression instance
|
16
|
-
* @param (array) args: Array of command line arguments
|
17
|
-
* @param (array) options: Array of options read from cli arguments
|
18
|
-
* @param (string) mode: Compression mode
|
19
|
-
* @param (string) cwd: Current working directory
|
20
|
-
* @param (string) content: CSS Sheets read
|
21
|
-
* @param (regex) rcss: Matches css file name extension
|
22
|
-
* @param (regex) roption: Matches the longhand options
|
23
|
-
* @param (regex) rsingle: Matches shorthand options
|
24
|
-
* @param (regex) rprefix: Matches absolute paths
|
25
|
-
*/
|
26
|
-
private $instance;
|
27
|
-
private $args = array();
|
28
|
-
private $options = array();
|
29
|
-
private $mode = 'safe';
|
30
|
-
private $cwd = '';
|
31
|
-
private $content = '';
|
32
|
-
private $rcss = "/\.css$/";
|
33
|
-
private $roption = "/^--/i";
|
34
|
-
private $rsingle = "/^-/";
|
35
|
-
private $rprefix = "/^(\/|\~\/)/";
|
36
|
-
|
37
|
-
/**
|
38
|
-
* Run the compression across files passed to cli
|
39
|
-
*
|
40
|
-
* @param (array) args: Array of argument passed over the command line
|
41
|
-
*/
|
42
|
-
public function __construct( $args = array() ) {
|
43
|
-
$this->args = $args;
|
44
|
-
$this->cwd = getcwd() . '/';
|
45
|
-
|
46
|
-
$this->read();
|
47
|
-
$this->render();
|
48
|
-
}
|
49
|
-
|
50
|
-
/**
|
51
|
-
* Reads the cli arguments and puts them in their place
|
52
|
-
*
|
53
|
-
* @params none
|
54
|
-
*/
|
55
|
-
public function read(){
|
56
|
-
while ( count( $this->args ) ) {
|
57
|
-
$arg = array_shift( $this->args );
|
58
|
-
|
59
|
-
if ( preg_match( $this->rcss, $arg ) ) {
|
60
|
-
$path = preg_match( $this->rprefix, $arg ) ? $arg : $this->cwd . $arg;
|
61
|
-
$this->content .= file_get_contents( $path );
|
62
|
-
}
|
63
|
-
else if ( substr( $arg, 0, 2 ) == '--' ) {
|
64
|
-
$parts = explode( '=', $arg, 2 );
|
65
|
-
$name = substr( $parts[ 0 ], 2 );
|
66
|
-
$value = isset( $parts[ 1 ] ) ? $parts[ 1 ] : true;
|
67
|
-
|
68
|
-
if ( $name == 'mode' ) {
|
69
|
-
$this->mode = $value;
|
70
|
-
}
|
71
|
-
else {
|
72
|
-
$this->options[ $name ] = $value === 'false' ? false : $value;
|
73
|
-
}
|
74
|
-
}
|
75
|
-
}
|
76
|
-
}
|
77
|
-
|
78
|
-
/**
|
79
|
-
* Outputs the compression of the content read
|
80
|
-
*
|
81
|
-
* @params none
|
82
|
-
*/
|
83
|
-
public function render(){
|
84
|
-
$this->instance = new CSSCompression();
|
85
|
-
|
86
|
-
if ( $this->mode ) {
|
87
|
-
$this->instance->mode( $this->mode );
|
88
|
-
}
|
89
|
-
|
90
|
-
if ( $this->options ) {
|
91
|
-
$this->instance->option( $this->options );
|
92
|
-
}
|
93
|
-
|
94
|
-
echo $this->instance->compress( $this->content );
|
95
|
-
}
|
96
|
-
};
|
97
|
-
|
98
|
-
// Auto-initialize the cli script
|
99
|
-
new Cli( $_SERVER['argv'] );
|
100
|
-
|
101
|
-
?>
|
@@ -1,39 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* CSS Compressor [VERSION]
|
3
|
-
* [DATE]
|
4
|
-
* Corey Hart @ http://www.codenothing.com
|
5
|
-
*/
|
6
|
-
{
|
7
|
-
"#f0ffff":"azure",
|
8
|
-
"#f5f5dc":"beige",
|
9
|
-
"#ffe4c4":"bisque",
|
10
|
-
"#a52a2a":"brown",
|
11
|
-
"#ff7f50":"coral",
|
12
|
-
"#ffd700":"gold",
|
13
|
-
"#808080":"gray",
|
14
|
-
"#008000":"green",
|
15
|
-
"#4b0082":"indigo",
|
16
|
-
"#fffff0":"ivory",
|
17
|
-
"#f0e68c":"khaki",
|
18
|
-
"#faf0e6":"linen",
|
19
|
-
"#800000":"maroon",
|
20
|
-
"#000080":"navy",
|
21
|
-
"#808000":"olive",
|
22
|
-
"#ffa500":"orange",
|
23
|
-
"#da70d6":"orchid",
|
24
|
-
"#cd853f":"peru",
|
25
|
-
"#ffc0cb":"pink",
|
26
|
-
"#dda0dd":"plum",
|
27
|
-
"#800080":"purple",
|
28
|
-
"#ff0000":"red",
|
29
|
-
"#fa8072":"salmon",
|
30
|
-
"#a0522d":"sienna",
|
31
|
-
"#c0c0c0":"silver",
|
32
|
-
"#fffafa":"snow",
|
33
|
-
"#d2b48c":"tan",
|
34
|
-
"#008080":"teal",
|
35
|
-
"#ff6347":"tomato",
|
36
|
-
"#ee82ee":"violet",
|
37
|
-
"#f5deb3":"wheat",
|
38
|
-
"#f00":"red"
|
39
|
-
}
|
@@ -1,16 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* CSS Compressor [VERSION]
|
3
|
-
* [DATE]
|
4
|
-
* Corey Hart @ http://www.codenothing.com
|
5
|
-
*/
|
6
|
-
{
|
7
|
-
"#808080":"gray",
|
8
|
-
"#008000":"green",
|
9
|
-
"#800000":"maroon",
|
10
|
-
"#000080":"navy",
|
11
|
-
"#808000":"olive",
|
12
|
-
"#ff0000":"red",
|
13
|
-
"#c0c0c0":"silver",
|
14
|
-
"#008080":"teal",
|
15
|
-
"#f00":"red"
|
16
|
-
}
|