html5-starter 0.1.3b

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.
Files changed (87) hide show
  1. data/LICENSE +3 -0
  2. data/README.md +135 -0
  3. data/VERSION +1 -0
  4. data/lib/app/helpers/html5_boilerplate_helper.rb +47 -0
  5. data/lib/html5-boilerplate.rb +6 -0
  6. data/stylesheets/_html5-boilerplate.scss +15 -0
  7. data/stylesheets/html5-boilerplate/_fonts.scss +36 -0
  8. data/stylesheets/html5-boilerplate/_handheld.scss +8 -0
  9. data/stylesheets/html5-boilerplate/_helpers.scss +25 -0
  10. data/stylesheets/html5-boilerplate/_print.scss +20 -0
  11. data/stylesheets/html5-boilerplate/_reset.scss +50 -0
  12. data/stylesheets/html5-boilerplate/_styles.scss +100 -0
  13. data/templates/project/_flashes.html.haml +4 -0
  14. data/templates/project/_footer.html.haml +2 -0
  15. data/templates/project/_head.html.haml +32 -0
  16. data/templates/project/_header.html.haml +1 -0
  17. data/templates/project/_javascripts.html.haml +38 -0
  18. data/templates/project/_stylesheets.html.haml +8 -0
  19. data/templates/project/application.html.haml +15 -0
  20. data/templates/project/files/404.html +22 -0
  21. data/templates/project/files/apple-touch-icon.png +0 -0
  22. data/templates/project/files/build/build.xml +636 -0
  23. data/templates/project/files/build/buildinfo.properties +5 -0
  24. data/templates/project/files/build/config/build.properties +3 -0
  25. data/templates/project/files/build/config/default.properties +79 -0
  26. data/templates/project/files/build/config/project.properties +49 -0
  27. data/templates/project/files/build/createproject.sh +73 -0
  28. data/templates/project/files/build/tools/ant-contrib-1.0b3.jar +0 -0
  29. data/templates/project/files/build/tools/css-compressor/CSSCompression.php +465 -0
  30. data/templates/project/files/build/tools/css-compressor/changelog.txt +22 -0
  31. data/templates/project/files/build/tools/css-compressor/cli.php +101 -0
  32. data/templates/project/files/build/tools/css-compressor/helpers/hex2short-colors.json +39 -0
  33. data/templates/project/files/build/tools/css-compressor/helpers/hex2short-safe.json +16 -0
  34. data/templates/project/files/build/tools/css-compressor/helpers/long2hex-colors.json +127 -0
  35. data/templates/project/files/build/tools/css-compressor/lib/Cleanup.php +218 -0
  36. data/templates/project/files/build/tools/css-compressor/lib/Color.php +199 -0
  37. data/templates/project/files/build/tools/css-compressor/lib/Combine.php +191 -0
  38. data/templates/project/files/build/tools/css-compressor/lib/Combine/Aural.php +109 -0
  39. data/templates/project/files/build/tools/css-compressor/lib/Combine/Background.php +107 -0
  40. data/templates/project/files/build/tools/css-compressor/lib/Combine/Border.php +98 -0
  41. data/templates/project/files/build/tools/css-compressor/lib/Combine/BorderOutline.php +109 -0
  42. data/templates/project/files/build/tools/css-compressor/lib/Combine/BorderRadius.php +262 -0
  43. data/templates/project/files/build/tools/css-compressor/lib/Combine/Font.php +125 -0
  44. data/templates/project/files/build/tools/css-compressor/lib/Combine/List.php +104 -0
  45. data/templates/project/files/build/tools/css-compressor/lib/Combine/MarginPadding.php +190 -0
  46. data/templates/project/files/build/tools/css-compressor/lib/Compress.php +212 -0
  47. data/templates/project/files/build/tools/css-compressor/lib/Control.php +236 -0
  48. data/templates/project/files/build/tools/css-compressor/lib/Exception.php +32 -0
  49. data/templates/project/files/build/tools/css-compressor/lib/Format.php +187 -0
  50. data/templates/project/files/build/tools/css-compressor/lib/Individuals.php +307 -0
  51. data/templates/project/files/build/tools/css-compressor/lib/Numeric.php +103 -0
  52. data/templates/project/files/build/tools/css-compressor/lib/Option.php +133 -0
  53. data/templates/project/files/build/tools/css-compressor/lib/Organize.php +149 -0
  54. data/templates/project/files/build/tools/css-compressor/lib/Selectors.php +245 -0
  55. data/templates/project/files/build/tools/css-compressor/lib/Setup.php +292 -0
  56. data/templates/project/files/build/tools/css-compressor/lib/Trim.php +213 -0
  57. data/templates/project/files/build/tools/css-compressor/license.txt +21 -0
  58. data/templates/project/files/build/tools/htmlcompressor-0.9.8.jar +0 -0
  59. data/templates/project/files/build/tools/jpegtran.exe +0 -0
  60. data/templates/project/files/build/tools/optipng-0.6.4-exe/LICENSE.txt +21 -0
  61. data/templates/project/files/build/tools/optipng-0.6.4-exe/optipng.exe +0 -0
  62. data/templates/project/files/build/tools/yuicompressor-2.4.2.jar +0 -0
  63. data/templates/project/files/crossdomain.xml +25 -0
  64. data/templates/project/files/favicon.ico +0 -0
  65. data/templates/project/files/gitignore.txt +32 -0
  66. data/templates/project/files/gitignore_placeholder.txt +2 -0
  67. data/templates/project/files/google.yml +22 -0
  68. data/templates/project/files/htaccess +415 -0
  69. data/templates/project/files/humans.txt +43 -0
  70. data/templates/project/files/lighttpd.conf +149 -0
  71. data/templates/project/files/mime.types +80 -0
  72. data/templates/project/files/nginx.conf +108 -0
  73. data/templates/project/files/robots.txt +5 -0
  74. data/templates/project/files/web.config +207 -0
  75. data/templates/project/handheld.scss +8 -0
  76. data/templates/project/index.html +81 -0
  77. data/templates/project/javascripts/libs/dd_belatedpng.js +13 -0
  78. data/templates/project/javascripts/libs/jquery-1.4.4.js +7179 -0
  79. data/templates/project/javascripts/libs/jquery-1.4.4.min.js +167 -0
  80. data/templates/project/javascripts/libs/modernizr-1.6.min.js +30 -0
  81. data/templates/project/javascripts/plugins.js +13 -0
  82. data/templates/project/javascripts/rails.js +156 -0
  83. data/templates/project/javascripts/script.js +26 -0
  84. data/templates/project/manifest.rb +101 -0
  85. data/templates/project/partials/_base.scss +23 -0
  86. data/templates/project/style.scss +70 -0
  87. metadata +171 -0
@@ -0,0 +1,5 @@
1
+ #Build Information File - DO NOT CHANGE
2
+ #Mon, 20 Dec 2010 22:15:18 +0700
3
+
4
+ build.number=0028
5
+ build.date=20.12.2010 22\:15
@@ -0,0 +1,3 @@
1
+ # build.properties file defines overrides for default.properties
2
+ # Explaination: This file should be created by each user as and when he or she needs to override particular values.
3
+ # Consequently, it should not be placed under version control.
@@ -0,0 +1,79 @@
1
+ #
2
+ # Default Build Settings
3
+ # you can override these settings on a project basis in a project.properties file
4
+ # so probably best not to touch these as they could be overwritten in later versions!
5
+ #
6
+
7
+
8
+ #
9
+ # Directory Paths
10
+ #
11
+ dir.publish = publish
12
+ dir.build = build
13
+ dir.build.tools = ${dir.build}/tools
14
+ dir.test = test
15
+ dir.demo = demo
16
+ dir.js = assets/js
17
+ dir.js.main = ${dir.js}
18
+ # scripts in the lib direcotry will only be minified, not concatenated together
19
+ dir.js.libs = ${dir.js}/libs
20
+ dir.js.mylibs = ${dir.js}/mylibs
21
+ dir.css = assets/css
22
+ dir.images = assets/img
23
+
24
+
25
+ #
26
+ # HTML, PHP, etc files to clean and update script/css references
27
+ #
28
+ file.pages.default.include = index.html, 404.html
29
+
30
+ # You will need to include the property file.pages.include in your project.properties file
31
+ # and add any extra pages you want to be updated by the scripts in a comma separated list
32
+
33
+
34
+ # the server configuration you're going with. If you don't use apache,
35
+ # get a different one here: github.com/paulirish/html5-boilerplate-server-configs
36
+
37
+ file.serverconfig = .htaccess
38
+
39
+ #
40
+ # Files not to be copied over by the script to the publish directory
41
+ #
42
+ file.default.exclude = .gitignore, .project, .settings, README.markdown, README.md, **/.git/**, **/.svn/**, **/${dir.build}/**, **/${dir.test}/**, **/${dir.demo}/**
43
+
44
+ # Declare the file.exclude property in your project.properties file if you want to exclude files / folders you have added
45
+ # Note: you cannot decalre an empty file.exclude property
46
+
47
+
48
+ #
49
+ # Default Stylesheet
50
+ #
51
+ file.default.stylesheets = style.css
52
+
53
+ #
54
+ # Script Optimisation
55
+ #
56
+ # If set, concat libraries with main scripts file, producing single script file
57
+ build.concat.scripts = true
58
+ # If set, delete minified but unconcatted files.
59
+ build.delete.unoptimized = true
60
+
61
+
62
+ #
63
+ # Image Optimisation
64
+ #
65
+ images.strip.metadata = false
66
+ # Seting this to true will strip the metadata from all jpeg files.
67
+ # YOU SHOULD ONLY DO THIS IF YOU OWN THE COPYRIGHT TO ALL THE IMAGES IN THE BUILD
68
+
69
+
70
+ # Build Info
71
+ build.version.info = buildinfo.properties
72
+ build.scripts.dir = ${dir.build}/build-scripts
73
+
74
+ # Tools
75
+ tool.yuicompressor = yuicompressor-2.4.2.jar
76
+ tool.htmlcompressor = htmlcompressor-0.9.8.jar
77
+ tool.csscompressor = css-compressor/cli.php
78
+
79
+
@@ -0,0 +1,49 @@
1
+ # project.properties file defines overrides for default.properties
2
+ # Explanation: This file should be created by each user as and when he or she needs to override particular values.
3
+ # Consequently, it should not be placed under version control.
4
+
5
+
6
+ # Stylesheets
7
+ #
8
+ # Note: Stylesheets will be concatonated in the order they are listed in the file.stylesheets property (i.e. the last
9
+ # file listed will be at the end of the concatenated file), so it probably makes sense to have the main style.css file
10
+ # as the first entry
11
+ # Example:
12
+ # file.stylesheets = style.css, lightbox.css, plugin.css
13
+ #
14
+ file.stylesheets =
15
+
16
+
17
+ # Web Pages
18
+ #
19
+ # These are the pages (files) that will be served to users (.html, .php, .asp, etc). Files in this property will
20
+ # be minified / optimised and have any stylesheet or javascript references updated to the minified examples
21
+ #
22
+ # The paths need to be relative
23
+ #
24
+ # Files can be added in a comma separated form
25
+ file.pages =
26
+
27
+
28
+
29
+ # Excluded files and dirs
30
+ #
31
+ # Add any files or directories you add to the project and do not want to be copied to the publish directory as a
32
+ # comma separated list
33
+ # These files are ignored in addition to the default ones specified in default.properties.
34
+ file.exclude =
35
+
36
+
37
+
38
+
39
+ # Directory Structure
40
+ #
41
+ # Override any directory paths specific to this project
42
+ #
43
+ # dir.publish
44
+ # dir.js
45
+ # dir.js.libs
46
+ # dir.js.mylibs
47
+ # dir.css
48
+ # dir.images
49
+
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env bash
2
+
3
+ #Generate a new project from your HTML5 Boilerplate repo clone
4
+ #Created 2010-10-13, Rick Waldron
5
+
6
+
7
+ ##first run
8
+ # $ cd html5-boilerplate/build
9
+ # $ sudo chmod a+x createproject.sh && ./createproject.sh
10
+
11
+ ##usage
12
+ # $ cd html5-boilerplate/build
13
+ # $ ./createproject.sh
14
+
15
+ echo "To create a new html5-boilerplate project, enter a new directory name:"
16
+
17
+ read name
18
+
19
+ cd ..
20
+
21
+ webroot=$PWD
22
+
23
+ SRC=$webroot"/html5-boilerplate"
24
+ DST=$webroot"/../"$name
25
+
26
+ if [ -d "$DST" ]
27
+ then
28
+ echo "$DST exists"
29
+ else
30
+ #create new project
31
+ mkdir $name
32
+
33
+ #sucess message
34
+ echo "Created Directory: $DST"
35
+
36
+ cd $SRC
37
+
38
+ #copy to new project directory
39
+ #http://en.wikipedia.org/wiki/Cpio#Copy
40
+ #http://cybertiggyr.com/cpio-howto/
41
+ #http://www.cyberciti.biz/faq/how-do-i-use-cpio-command-under-linux/
42
+ find . -depth -print0 | cpio -0pdmv $DST
43
+
44
+
45
+ #sucess message
46
+ echo "Created Project: $DST"
47
+
48
+ # delete that temporary folder
49
+ rm -r $name
50
+
51
+ #move into new project
52
+ cd $DST
53
+
54
+ #in Bourne Again Shell, the cpio was copying
55
+ #the whole dir into the new project, along with the contents
56
+ if [ -d "$DST/html5-boilerplate" ]
57
+ then
58
+ rm -r html5-boilerplate
59
+ fi
60
+
61
+ if [ -e "$DST/createproject.sh" ]
62
+ then
63
+ rm -r createproject.sh
64
+ fi
65
+
66
+ if [ -e "$DST/.git" ]
67
+ then
68
+ rm -rf .git
69
+ fi
70
+
71
+
72
+ fi
73
+
@@ -0,0 +1,465 @@
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
+ ?>