html5-starter 0.1.3b

Sign up to get free protection for your applications and to get access to all the features.
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,107 @@
1
+ <?php
2
+ /**
3
+ * CSS Compressor [VERSION]
4
+ * [DATE]
5
+ * Corey Hart @ http://www.codenothing.com
6
+ */
7
+
8
+ Class CSSCompression_Combine_Background
9
+ {
10
+ /**
11
+ * Combine Patterns
12
+ *
13
+ * @class Control: Compression Controller
14
+ * @class Combine: Combine Controller
15
+ * @param (regex) rbackground: Background matching
16
+ * @param (array) groupings: List of background combinations
17
+ */
18
+ private $Control;
19
+ private $Combine;
20
+ private $rbackground = "/(^|(?<!\\\);)background-(color|image|repeat|attachment|position):(.*?)((?<!\\\);|$)/";
21
+ private $groupings = array(
22
+ // With color
23
+ array( 'color', 'image', 'repeat', 'attachment', 'position' ),
24
+ array( 'color', 'image', 'attachment', 'position' ),
25
+ array( 'color', 'image', 'repeat', 'position' ),
26
+ array( 'color', 'image', 'repeat', 'attachment' ),
27
+ array( 'color', 'image', 'repeat' ),
28
+ array( 'color', 'image', 'attachment' ),
29
+ array( 'color', 'image', 'position' ),
30
+ array( 'color', 'image' ),
31
+ // Without Color
32
+ array( 'image', 'attachment', 'position' ),
33
+ array( 'image', 'repeat', 'position' ),
34
+ array( 'image', 'repeat', 'attachment' ),
35
+ array( 'image', 'repeat' ),
36
+ array( 'image', 'attachment' ),
37
+ array( 'image', 'position' ),
38
+ // Just Color/Image
39
+ array( 'image' ),
40
+ array( 'color' ),
41
+ );
42
+
43
+ /**
44
+ * Stash a reference to the controller & combiner
45
+ *
46
+ * @param (class) control: CSSCompression Controller
47
+ * @param (class) combine: CSSCompression Combiner
48
+ */
49
+ public function __construct( CSSCompression_Control $control, CSSCompression_Combine $combine ) {
50
+ $this->Control = $control;
51
+ $this->Combine = $combine;
52
+ }
53
+
54
+ /**
55
+ * Combines multiple background props into single definition
56
+ *
57
+ * @param (string) val: Rule Set
58
+ */
59
+ public function combine( $val ) {
60
+ $storage = array();
61
+
62
+ // Find all possible occurences and build the replacement
63
+ $pos = 0;
64
+ while ( preg_match( $this->rbackground, $val, $match, PREG_OFFSET_CAPTURE, $pos ) ) {
65
+ $storage[ $match[ 2 ][ 0 ] ] = $match[ 3 ][ 0 ];
66
+ $pos = $match[ 0 ][ 1 ] + strlen( $match[ 0 ][ 0 ] ) - 1;
67
+ }
68
+
69
+ // Run background checks and get replacement str
70
+ foreach ( $this->groupings as $props ) {
71
+ if ( $replace = $this->Combine->searchDefinitions( 'background', $storage, $props ) ) {
72
+ break;
73
+ }
74
+ }
75
+
76
+ // If replacement string found, run it on all declarations
77
+ if ( $replace ) {
78
+ $pos = 0;
79
+ while ( preg_match( $this->rbackground, $val, $match, PREG_OFFSET_CAPTURE, $pos ) ) {
80
+ $colon = strlen( $match[ 1 ][ 0 ] );
81
+ $val = substr_replace( $val, $replace, $match[ 0 ][ 1 ] + $colon, strlen( $match[ 0 ][ 0 ] ) - $colon );
82
+ $pos = $match[ 0 ][ 1 ] + strlen( $replace ) - $colon - 1;
83
+ $replace = '';
84
+ }
85
+ }
86
+
87
+ // Return converted val
88
+ return $val;
89
+ }
90
+
91
+ /**
92
+ * Access to private methods for testing
93
+ *
94
+ * @param (string) method: Method to be called
95
+ * @param (array) args: Array of paramters to be passed in
96
+ */
97
+ public function access( $method, $args ) {
98
+ if ( method_exists( $this, $method ) ) {
99
+ return call_user_func_array( array( $this, $method ), $args );
100
+ }
101
+ else {
102
+ throw new CSSCompression_Exception( "Unknown method in Background Class - " . $method );
103
+ }
104
+ }
105
+ };
106
+
107
+ ?>
@@ -0,0 +1,98 @@
1
+ <?php
2
+ /**
3
+ * CSS Compressor [VERSION]
4
+ * [DATE]
5
+ * Corey Hart @ http://www.codenothing.com
6
+ */
7
+
8
+ Class CSSCompression_Combine_Border
9
+ {
10
+ /**
11
+ * Combine Patterns
12
+ *
13
+ * @class Control: Compression Controller
14
+ * @class Combine: Combine Controller
15
+ * @param (regex) rborder: Border matching
16
+ */
17
+ private $Control;
18
+ private $Combine;
19
+ private $rborder = "/(^|(?<!\\\);)border-(top|right|bottom|left):(.*?)((?<!\\\);|$)/";
20
+
21
+ /**
22
+ * Stash a reference to the controller & combiner
23
+ *
24
+ * @param (class) control: CSSCompression Controller
25
+ * @param (class) combine: CSSCompression Combiner
26
+ */
27
+ public function __construct( CSSCompression_Control $control, CSSCompression_Combine $combine ) {
28
+ $this->Control = $control;
29
+ $this->Combine = $combine;
30
+ }
31
+
32
+ /**
33
+ * Combines multiple border properties into single definition
34
+ *
35
+ * @param (string) val: Rule Set
36
+ */
37
+ public function combine( $val ) {
38
+ if ( ( $replace = $this->replace( $val ) ) === false ) {
39
+ return $val;
40
+ }
41
+
42
+ // Rebuild the rule set with the combinations found
43
+ $pos = 0;
44
+ while ( preg_match( $this->rborder, $val, $match, PREG_OFFSET_CAPTURE, $pos ) ) {
45
+ $colon = strlen( $match[ 1 ][ 0 ] );
46
+ $val = substr_replace( $val, $replace, $match[ 0 ][ 1 ] + $colon, strlen( $match[ 0 ][ 0 ] ) - $colon );
47
+ $pos = $match[ 0 ][ 1 ] + strlen( $replace ) - $colon - 1;
48
+ $replace = '';
49
+ }
50
+
51
+ // Return converted val
52
+ return $val;
53
+ }
54
+
55
+ /**
56
+ * Builds a replacement string
57
+ *
58
+ * @param (string) val: Rule Set
59
+ */
60
+ private function replace( $val ) {
61
+ $storage = array();
62
+
63
+ // Find all possible occurences and build the replacement
64
+ $pos = 0;
65
+ while ( preg_match( $this->rborder, $val, $match, PREG_OFFSET_CAPTURE, $pos ) ) {
66
+ // Override double written properties
67
+ $storage[ $match[ 2 ][ 0 ] ] = $match[ 3 ][ 0 ];
68
+ $pos = $match[ 0 ][ 1 ] + strlen( $match[ 0 ][ 0 ] ) - 1;
69
+ }
70
+
71
+ // All 4 have to be defined
72
+ if ( count( $storage ) == 4 &&
73
+ $storage['top'] == $storage['bottom'] &&
74
+ $storage['left'] == $storage['right'] &&
75
+ $storage['top'] == $storage['right'] ) {
76
+ return "border:" . $storage['top'] . ';';
77
+ }
78
+
79
+ return false;
80
+ }
81
+
82
+ /**
83
+ * Access to private methods for testing
84
+ *
85
+ * @param (string) method: Method to be called
86
+ * @param (array) args: Array of paramters to be passed in
87
+ */
88
+ public function access( $method, $args ) {
89
+ if ( method_exists( $this, $method ) ) {
90
+ return call_user_func_array( array( $this, $method ), $args );
91
+ }
92
+ else {
93
+ throw new CSSCompression_Exception( "Unknown method in Border Class - " . $method );
94
+ }
95
+ }
96
+ };
97
+
98
+ ?>
@@ -0,0 +1,109 @@
1
+ <?php
2
+ /**
3
+ * CSS Compressor [VERSION]
4
+ * [DATE]
5
+ * Corey Hart @ http://www.codenothing.com
6
+ */
7
+
8
+ Class CSSCompression_Combine_BorderOutline
9
+ {
10
+ /**
11
+ * Combine Patterns
12
+ *
13
+ * @class Control: Compression Controller
14
+ * @class Combine: Combine Controller
15
+ * @param (regex) rcsw: Border/Outline matching
16
+ */
17
+ private $Control;
18
+ private $Combine;
19
+ private $rcsw = "/(^|(?<!\\\);)(border|border-top|border-bottom|border-left|border-right|outline)-(color|style|width):(.*?)((?<!\\\);|$)/";
20
+
21
+ /**
22
+ * Stash a reference to the controller & combiner
23
+ *
24
+ * @param (class) control: CSSCompression Controller
25
+ * @param (class) combine: CSSCompression Combiner
26
+ */
27
+ public function __construct( CSSCompression_Control $control, CSSCompression_Combine $combine ) {
28
+ $this->Control = $control;
29
+ $this->Combine = $combine;
30
+ }
31
+
32
+ /**
33
+ * Combines color/style/width of border/outline properties
34
+ *
35
+ * @param (string) val: Rule Set
36
+ */
37
+ public function combine( $val ) {
38
+ $storage = $this->storage( $val );
39
+ $pos = 0;
40
+
41
+ // Now rebuild the string replacing all instances
42
+ while ( preg_match( $this->rcsw, $val, $match, PREG_OFFSET_CAPTURE, $pos ) ) {
43
+ $prop = $match[ 2 ][ 0 ];
44
+ if ( isset( $storage[ $prop ] ) ) {
45
+ $colon = strlen( $match[ 1 ][ 0 ] );
46
+ $val = substr_replace( $val, $storage[ $prop ], $match[ 0 ][ 1 ] + $colon, strlen( $match[ 0 ][ 0 ] ) - $colon );
47
+ $pos = $match[ 0 ][ 1 ] + strlen( $storage[ $prop ] ) - $colon - 1;
48
+ $storage[ $prop ] = '';
49
+ }
50
+ else {
51
+ $pos = $match[ 0 ][ 1 ] + strlen( $match[ 0 ][ 0 ] ) - 1;
52
+ }
53
+ }
54
+
55
+ // Return converted val
56
+ return $val;
57
+ }
58
+
59
+ /**
60
+ * Builds a storage object for iteration
61
+ *
62
+ * @param (string) val: Rule Set
63
+ */
64
+ private function storage( $val ) {
65
+ $storage = array();
66
+ $pos = 0;
67
+
68
+ // Find all possible occurences and build the replacement
69
+ while ( preg_match( $this->rcsw, $val, $match, PREG_OFFSET_CAPTURE, $pos ) ) {
70
+ if ( ! isset( $storage[ $match[ 2 ][ 0 ] ] ) ) {
71
+ $storage[ $match[ 2 ][ 0 ] ] = array( $match[ 3 ][ 0 ] => $match[ 4 ][ 0 ] );
72
+ }
73
+
74
+ // Override double written properties
75
+ $storage[ $match[ 2 ][ 0 ] ][ $match[ 3 ][ 0 ] ] = $match[ 4 ][ 0 ];
76
+ $pos = $match[ 0 ][ 1 ] + strlen( $match[ 0 ][ 0 ] ) - 1;
77
+ }
78
+
79
+ // Go through each tag for possible combination
80
+ foreach ( $storage as $tag => $arr ) {
81
+ // All three have to be defined
82
+ if ( count( $arr ) == 3 && ! $this->Combine->checkUncombinables( $arr ) ) {
83
+ $storage[ $tag ] = "$tag:" . $arr['width'] . ' ' . $arr['style'] . ' ' . $arr['color'] . ';';
84
+ }
85
+ else {
86
+ unset( $storage[ $tag ] );
87
+ }
88
+ }
89
+
90
+ return $storage;
91
+ }
92
+
93
+ /**
94
+ * Access to private methods for testing
95
+ *
96
+ * @param (string) method: Method to be called
97
+ * @param (array) args: Array of paramters to be passed in
98
+ */
99
+ public function access( $method, $args ) {
100
+ if ( method_exists( $this, $method ) ) {
101
+ return call_user_func_array( array( $this, $method ), $args );
102
+ }
103
+ else {
104
+ throw new CSSCompression_Exception( "Unknown method in BorderOutline Class - " . $method );
105
+ }
106
+ }
107
+ };
108
+
109
+ ?>
@@ -0,0 +1,262 @@
1
+ <?php
2
+ /**
3
+ * CSS Compressor [VERSION]
4
+ * [DATE]
5
+ * Corey Hart @ http://www.codenothing.com
6
+ */
7
+
8
+ Class CSSCompression_Combine_BorderRadius
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) rslash: Checks for unescaped slash character
17
+ * @param (array) borderRadius: Various border radii components
18
+ */
19
+ private $Control;
20
+ private $Combine;
21
+ private $rspace = "/(?<!\\\)\s/";
22
+ private $rslash = "/(?<!\\\)\//";
23
+ private $borderRadius = array(
24
+ 'css3' => array(
25
+ 'mod' => '',
26
+ 'base' => "/(^|(?<!\\\);)border-radius:(.*?)((?<!\\\);|$)/",
27
+ 'full' => "/(^|(?<!\\\);)border-(top|bottom)-(left|right)-radius:(.*?)((?<!\\\);|$)/",
28
+ ),
29
+ 'moz' => array(
30
+ 'mod' => '-moz-',
31
+ 'base' => "/(^|(?<!\\\);)-moz-border-radius:(.*?)((?<!\\\);|$)/",
32
+ 'full' => "/(^|(?<!\\\);)-moz-border-radius-(top|bottom)(left|right):(.*?)((?<!\\\);|$)/"
33
+ ),
34
+ 'webkit' => array(
35
+ 'mod' => '-webkit-',
36
+ 'base' => "/(^|(?<!\\\);)-webkit-border-radius:(.*?)((?<!\\\);|$)/",
37
+ 'full' => "/(^|(?<!\\\);)-webkit-border-(top|bottom)-(left|right)-radius:(.*?)((?<!\\\);|$)/"
38
+ ),
39
+ );
40
+
41
+ /**
42
+ * Stash a reference to the controller & combiner
43
+ *
44
+ * @param (class) control: CSSCompression Controller
45
+ * @param (class) combine: CSSCompression Combiner
46
+ */
47
+ public function __construct( CSSCompression_Control $control, CSSCompression_Combine $combine ) {
48
+ $this->Control = $control;
49
+ $this->Combine = $combine;
50
+ }
51
+
52
+
53
+ /**
54
+ * Main handler to combine border-radii into a single rule
55
+ *
56
+ * @param (string) val: Rule Set
57
+ */
58
+ public function combine( $val ) {
59
+ foreach ( $this->borderRadius as $regex ) {
60
+ $val = $this->fix( $val, $regex );
61
+ }
62
+
63
+ return $val;
64
+ }
65
+
66
+ /**
67
+ * Does the actual combining
68
+ *
69
+ * @param (string) val: Rule Set
70
+ */
71
+ private function fix( $val, $regex ) {
72
+ $val = $this->base( $val, $regex );
73
+ $replace = $regex['mod'];
74
+
75
+ // Storage builder
76
+ if ( ( $storage = $this->storage( $val, $regex ) ) === false ) {
77
+ return $val;
78
+ }
79
+
80
+ // Setup horizontal/vertical radii
81
+ foreach ( $storage as $dir => &$config ) {
82
+ // Verticals are optional
83
+ if ( $dir == 'vertical' && ! $config['keep'] ) {
84
+ break;
85
+ }
86
+ // All 4 are the same
87
+ else if ( $config['top-left'] == $config['top-right'] &&
88
+ $config['top-right'] == $config['bottom-right'] &&
89
+ $config['bottom-right'] == $config['bottom-left'] ) {
90
+ $config['replace'] .= $config['top-left'];
91
+ }
92
+ // Opposites are the same
93
+ else if ( $config['top-left'] == $config['bottom-right'] && $config['top-right'] == $config['bottom-left'] ) {
94
+ $config['replace'] .= $config['top-left'] . ' ' . $config['top-right'];
95
+ }
96
+ // 3-point directional
97
+ else if ( $config['top-right'] == $config['bottom-left'] ) {
98
+ $config['replace'] .= $config['top-left'] . ' ' . $config['top-right'] . ' ' . $config['bottom-right'];
99
+ }
100
+ // none are the same, but can still use shorthand notation
101
+ else {
102
+ $config['replace'] .= $config['top-left'] . ' ' . $config['top-right'] . ' '
103
+ . $config['bottom-right'] . ' ' . $config['bottom-left'];
104
+ }
105
+ }
106
+
107
+ // Now rebuild the string replacing all instances of margin/padding if shorthand exists
108
+ $pos = 0;
109
+ $replace = $regex['mod'] . "border-radius:" . $storage['horizontal']['replace'] . $storage['vertical']['replace'] . ';';
110
+ while ( preg_match( $regex['full'], $val, $match, PREG_OFFSET_CAPTURE, $pos ) ) {
111
+ $colon = strlen( $match[ 1 ][ 0 ] );
112
+ $val = substr_replace( $val, $replace, $match[ 0 ][ 1 ] + $colon, strlen( $match[ 0 ][ 0 ] ) - $colon );
113
+ $pos = $match[ 0 ][ 1 ] + strlen( $replace ) - $colon - 1;
114
+ $replace = '';
115
+ }
116
+
117
+ // Return converted val
118
+ return $val;
119
+ }
120
+
121
+ /**
122
+ * Expands short handed border radius props for combination
123
+ *
124
+ * @param (string) val: Rule Set
125
+ */
126
+ private function base( $val, $regex ) {
127
+ $pos = 0;
128
+ while ( preg_match( $regex['base'], $val, $match, PREG_OFFSET_CAPTURE, $pos ) ) {
129
+ $replace = '';
130
+ $parts = preg_split( $this->rslash, trim( $match[ 2 ][ 0 ] ), 2 );
131
+ $positions = array(
132
+ 'top-left' => 0,
133
+ 'top-right' => 0,
134
+ 'bottom-right' => 0,
135
+ 'bottom-left' => 0,
136
+ );
137
+ $base = array(
138
+ 'horizontal' => array(
139
+ 'parts' => preg_split( $this->rspace, trim( $parts[ 0 ] ) ),
140
+ 'pos' => $positions,
141
+ ),
142
+ 'vertical' => array(
143
+ 'parts' => isset( $parts[ 1 ] ) ? preg_split( $this->rspace, trim( $parts[ 1 ] ) ) : '',
144
+ 'pos' => $positions,
145
+ ),
146
+ );
147
+
148
+ foreach ( $base as &$config ) {
149
+ // Skip uncombinables
150
+ if ( $this->Combine->checkUncombinables( $config['parts'] ) ) {
151
+ $pos = $match[ 0 ][ 1 ] + strlen( $match[ 0 ][ 0 ] ) - 1;
152
+ continue 2;
153
+ }
154
+ // Might not have verticals
155
+ else if ( $config['parts'] === '' ) {
156
+ continue;
157
+ }
158
+
159
+ // Each position needs a value
160
+ switch ( count( $config['parts'] ) ) {
161
+ case 1:
162
+ $config['pos']['top-left'] = $config['pos']['top-right'] = $config['parts'][ 0 ];
163
+ $config['pos']['bottom-left'] = $config['pos']['bottom-right'] = $config['parts'][ 0 ];
164
+ break;
165
+ case 2:
166
+ $config['pos']['top-left'] = $config['pos']['bottom-right'] = $config['parts'][ 0 ];
167
+ $config['pos']['bottom-left'] = $config['pos']['top-right'] = $config['parts'][ 1 ];
168
+ break;
169
+ case 3:
170
+ $config['pos']['top-left'] = $config['parts'][ 0 ];
171
+ $config['pos']['bottom-left'] = $config['pos']['top-right'] = $config['parts'][ 1 ];
172
+ $config['pos']['bottom-right'] = $config['parts'][ 2 ];
173
+ break;
174
+ case 4:
175
+ $config['pos']['top-left'] = $config['parts'][ 0 ];
176
+ $config['pos']['top-right'] = $config['parts'][ 1 ];
177
+ $config['pos']['bottom-right'] = $config['parts'][ 2 ];
178
+ $config['pos']['bottom-left'] = $config['parts'][ 3 ];
179
+ break;
180
+ default:
181
+ continue 2;
182
+ }
183
+
184
+ }
185
+
186
+ // Build the replacement
187
+ foreach ( $positions as $p => $v ) {
188
+ if ( $regex['mod'] == '-moz-' ) {
189
+ $replace .= "-moz-border-radius-" . preg_replace( "/-/", '', $p ) . ":"
190
+ . $base['horizontal']['pos'][ $p ]
191
+ . ( $base['vertical']['parts'] === '' ? '' : ' ' . $base['vertical']['pos'][ $p ] )
192
+ . ';';
193
+ }
194
+ else {
195
+ $replace .= $regex['mod'] . "border-$p-radius:"
196
+ . $base['horizontal']['pos'][ $p ]
197
+ . ( $base['vertical']['parts'] === '' ? '' : ' ' . $base['vertical']['pos'][ $p ] )
198
+ . ';';
199
+ }
200
+ }
201
+ $pos += strlen( $replace );
202
+ $val = substr_replace( $val, $replace, $match[ 0 ][ 1 ], strlen( $match[ 0 ][ 0 ] ) );
203
+ }
204
+
205
+ return $val;
206
+ }
207
+
208
+ /**
209
+ * Builds the storage object for border radius props
210
+ *
211
+ * @param (string) val: Rule Set
212
+ * @param (array) regex: Current border radius type checking props
213
+ */
214
+ private function storage( $val, $regex ) {
215
+ $storage = array(
216
+ 'horizontal' => array( 'replace' => '' ),
217
+ 'vertical' => array( 'replace' => '', 'keep' => false ),
218
+ );
219
+
220
+ // Find all possible occurences of this border-radius type and mark their directional value
221
+ $pos = 0;
222
+ while ( preg_match( $regex['full'], $val, $match, PREG_OFFSET_CAPTURE, $pos ) ) {
223
+ $pos = $match[ 0 ][ 1 ] + strlen( $match[ 0 ][ 0 ] ) - 1;
224
+ $parts = preg_split( $this->rspace, $match[ 4 ][ 0 ], 2 );
225
+ $storage['horizontal'][ $match[ 2 ][ 0 ] . '-' . $match[ 3 ][ 0 ] ] = trim( $parts[ 0 ] );
226
+ if ( isset( $parts[ 1 ] ) ) {
227
+ $storage['vertical'][ $match[ 2 ][ 0 ] . '-' . $match[ 3 ][ 0 ] ] = trim( $parts[ 1 ] );
228
+ $storage['vertical']['keep'] = true;
229
+ $storage['vertical']['replace'] = '/';
230
+ }
231
+ else {
232
+ $storage['vertical'][ $match[ 2 ][ 0 ] . '-' . $match[ 3 ][ 0 ] ] = '0';
233
+ }
234
+ }
235
+
236
+ // Only combine if all 4 definitions are found (5 including replace)
237
+ if ( count( $storage['horizontal'] ) != 5 ||
238
+ $this->Combine->checkUncombinables( $storage['horizontal'] ) ||
239
+ $this->Combine->checkUncombinables( $storage['vertical'] ) ) {
240
+ return false;
241
+ }
242
+
243
+ return $storage;
244
+ }
245
+
246
+ /**
247
+ * Access to private methods for testing
248
+ *
249
+ * @param (string) method: Method to be called
250
+ * @param (array) args: Array of paramters to be passed in
251
+ */
252
+ public function access( $method, $args ) {
253
+ if ( method_exists( $this, $method ) ) {
254
+ return call_user_func_array( array( $this, $method ), $args );
255
+ }
256
+ else {
257
+ throw new CSSCompression_Exception( "Unknown method in BorderRadius Class - " . $method );
258
+ }
259
+ }
260
+ };
261
+
262
+ ?>