frontsau 0.0.1

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 (280) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +16 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE +21 -0
  5. data/README.md +30 -0
  6. data/Rakefile +2 -0
  7. data/bin/frontsau +15 -0
  8. data/bin/frontsau-phaml-compiler +35 -0
  9. data/example/.frontsau +12 -0
  10. data/example/assets/head.jpg +0 -0
  11. data/example/assets/script.js +4 -0
  12. data/example/assets/style.css +6 -0
  13. data/example/css/includes.sass +2 -0
  14. data/example/css/style.sass +6 -0
  15. data/example/image/head.jpg +0 -0
  16. data/example/index.html +0 -0
  17. data/example/js/script.coffee +1 -0
  18. data/frontsau.gemspec +41 -0
  19. data/lib/Phamlp/Phamlp.php +72 -0
  20. data/lib/Phamlp/PhamlpException.php +31 -0
  21. data/lib/Phamlp/haml/HamlException.php +29 -0
  22. data/lib/Phamlp/haml/HamlHelpers.php +199 -0
  23. data/lib/Phamlp/haml/HamlParser.php +1250 -0
  24. data/lib/Phamlp/haml/filters/HamlBaseFilter.php +30 -0
  25. data/lib/Phamlp/haml/filters/HamlCdataFilter.php +29 -0
  26. data/lib/Phamlp/haml/filters/HamlCssFilter.php +30 -0
  27. data/lib/Phamlp/haml/filters/HamlEscapedFilter.php +32 -0
  28. data/lib/Phamlp/haml/filters/HamlJavascriptFilter.php +31 -0
  29. data/lib/Phamlp/haml/filters/HamlPhpFilter.php +27 -0
  30. data/lib/Phamlp/haml/filters/HamlPlainFilter.php +28 -0
  31. data/lib/Phamlp/haml/filters/HamlPreserveFilter.php +29 -0
  32. data/lib/Phamlp/haml/filters/HamlSassFilter.php +37 -0
  33. data/lib/Phamlp/haml/filters/HamlScssFilter.php +37 -0
  34. data/lib/Phamlp/haml/filters/_HamlMarkdownFilter.php +50 -0
  35. data/lib/Phamlp/haml/filters/_HamlTextileFilter.php +50 -0
  36. data/lib/Phamlp/haml/messages/_i18n.php +32 -0
  37. data/lib/Phamlp/haml/messages/de.php +32 -0
  38. data/lib/Phamlp/haml/messages/fr.php +32 -0
  39. data/lib/Phamlp/haml/renderers/HamlCompactRenderer.php +32 -0
  40. data/lib/Phamlp/haml/renderers/HamlCompressedRenderer.php +48 -0
  41. data/lib/Phamlp/haml/renderers/HamlExpandedRenderer.php +58 -0
  42. data/lib/Phamlp/haml/renderers/HamlNestedRenderer.php +77 -0
  43. data/lib/Phamlp/haml/renderers/HamlRenderer.php +137 -0
  44. data/lib/Phamlp/haml/tree/HamlCodeBlockNode.php +58 -0
  45. data/lib/Phamlp/haml/tree/HamlCommentNode.php +41 -0
  46. data/lib/Phamlp/haml/tree/HamlDoctypeNode.php +27 -0
  47. data/lib/Phamlp/haml/tree/HamlElementNode.php +52 -0
  48. data/lib/Phamlp/haml/tree/HamlFilterNode.php +50 -0
  49. data/lib/Phamlp/haml/tree/HamlHelperNode.php +73 -0
  50. data/lib/Phamlp/haml/tree/HamlNode.php +253 -0
  51. data/lib/Phamlp/haml/tree/HamlNodeExceptions.php +19 -0
  52. data/lib/Phamlp/haml/tree/HamlRootNode.php +58 -0
  53. data/lib/Phamlp/sass/SassException.php +29 -0
  54. data/lib/Phamlp/sass/SassFile.php +164 -0
  55. data/lib/Phamlp/sass/SassParser.php +848 -0
  56. data/lib/Phamlp/sass/extensions/compass/config.php +65 -0
  57. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/stylesheets/_blueprint.scss +47 -0
  58. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/stylesheets/blueprint/_buttons.scss +101 -0
  59. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/stylesheets/blueprint/_colors.scss +32 -0
  60. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/stylesheets/blueprint/_debug.scss +11 -0
  61. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/stylesheets/blueprint/_fancy-type.scss +86 -0
  62. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/stylesheets/blueprint/_form.scss +68 -0
  63. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/stylesheets/blueprint/_grid.scss +249 -0
  64. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/stylesheets/blueprint/_ie.scss +109 -0
  65. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/stylesheets/blueprint/_interaction.scss +57 -0
  66. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/stylesheets/blueprint/_link-icons.scss +37 -0
  67. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/stylesheets/blueprint/_liquid.scss +147 -0
  68. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/stylesheets/blueprint/_print.scss +93 -0
  69. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/stylesheets/blueprint/_reset.scss +3 -0
  70. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/stylesheets/blueprint/_rtl.scss +133 -0
  71. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/stylesheets/blueprint/_scaffolding.scss +54 -0
  72. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/stylesheets/blueprint/_typography.scss +104 -0
  73. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/stylesheets/blueprint/_utilities.scss +37 -0
  74. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/stylesheets/blueprint/reset/_utilities.scss +58 -0
  75. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/basic/grid.png +0 -0
  76. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/basic/ie.sass +4 -0
  77. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/basic/manifest.rb +30 -0
  78. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/basic/partials/_base.sass +10 -0
  79. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/basic/print.sass +4 -0
  80. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/basic/screen.sass +12 -0
  81. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/buttons/buttons/cross.png +0 -0
  82. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/buttons/buttons/key.png +0 -0
  83. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/buttons/buttons/tick.png +0 -0
  84. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/buttons/buttons.sass +49 -0
  85. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/buttons/manifest.rb +17 -0
  86. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/link_icons/link_icons/doc.png +0 -0
  87. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/link_icons/link_icons/email.png +0 -0
  88. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/link_icons/link_icons/external.png +0 -0
  89. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/link_icons/link_icons/feed.png +0 -0
  90. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/link_icons/link_icons/im.png +0 -0
  91. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/link_icons/link_icons/pdf.png +0 -0
  92. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/link_icons/link_icons/visited.png +0 -0
  93. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/link_icons/link_icons/xls.png +0 -0
  94. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/link_icons/link_icons.sass +13 -0
  95. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/link_icons/manifest.rb +23 -0
  96. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/project/grid.png +0 -0
  97. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/project/ie.sass +16 -0
  98. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/project/manifest.rb +30 -0
  99. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/project/partials/_base.sass +11 -0
  100. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/project/print.sass +8 -0
  101. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/project/screen.sass +45 -0
  102. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/semantic/grid.png +0 -0
  103. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/semantic/ie.sass +16 -0
  104. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/semantic/manifest.rb +33 -0
  105. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/semantic/partials/_base.sass +10 -0
  106. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/semantic/partials/_form.sass +6 -0
  107. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/semantic/partials/_page.sass +18 -0
  108. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/semantic/partials/_two_col.sass +38 -0
  109. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/semantic/print.sass +5 -0
  110. data/lib/Phamlp/sass/extensions/compass/frameworks/blueprint/templates/semantic/screen.sass +14 -0
  111. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/_compass.scss +2 -0
  112. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/_css3.scss +15 -0
  113. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/_layout.scss +1 -0
  114. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/_reset.scss +3 -0
  115. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/_utilities.scss +6 -0
  116. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/css3/_background-clip.scss +43 -0
  117. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/css3/_background-origin.scss +42 -0
  118. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/css3/_background-size.scss +14 -0
  119. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/css3/_border-radius.scss +135 -0
  120. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/css3/_box-shadow.scss +50 -0
  121. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/css3/_box-sizing.scss +13 -0
  122. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/css3/_box.scss +112 -0
  123. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/css3/_columns.scss +55 -0
  124. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/css3/_font-face.scss +33 -0
  125. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/css3/_gradient.scss +82 -0
  126. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/css3/_inline-block.scss +12 -0
  127. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/css3/_opacity.scss +27 -0
  128. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/css3/_shared.scss +47 -0
  129. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/css3/_text-shadow.scss +25 -0
  130. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/css3/_transform.scss +85 -0
  131. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/css3/_transition.scss +85 -0
  132. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/layout/_sticky-footer.scss +23 -0
  133. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/reset/_utilities.scss +133 -0
  134. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/_general.scss +6 -0
  135. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/_links.scss +3 -0
  136. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/_lists.scss +4 -0
  137. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/_print.scss +17 -0
  138. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/_sprites.scss +1 -0
  139. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/_tables.scss +3 -0
  140. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/_text.scss +3 -0
  141. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/general/_clearfix.scss +31 -0
  142. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/general/_float.scss +15 -0
  143. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/general/_hacks.scss +35 -0
  144. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/general/_min.scss +16 -0
  145. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/general/_reset.scss +2 -0
  146. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/general/_tabs.scss +1 -0
  147. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/general/_tag-cloud.scss +18 -0
  148. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/links/_hover-link.scss +5 -0
  149. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/links/_link-colors.scss +28 -0
  150. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/links/_unstyled-link.scss +7 -0
  151. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/lists/_bullets.scss +34 -0
  152. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/lists/_horizontal-list.scss +52 -0
  153. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/lists/_inline-block-list.scss +47 -0
  154. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/lists/_inline-list.scss +29 -0
  155. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/sprites/_sprite-img.scss +56 -0
  156. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/tables/_alternating-rows-and-columns.scss +20 -0
  157. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/tables/_borders.scss +27 -0
  158. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/tables/_scaffolding.scss +9 -0
  159. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/text/_ellipsis.scss +25 -0
  160. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/text/_nowrap.scss +2 -0
  161. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/stylesheets/compass/utilities/text/_replacement.scss +34 -0
  162. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/templates/ellipsis/ellipsis.sass +9 -0
  163. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/templates/ellipsis/manifest.rb +27 -0
  164. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/templates/ellipsis/xml/ellipsis.xml +14 -0
  165. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/templates/extension/manifest.rb +20 -0
  166. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/templates/extension/stylesheets/main.sass +1 -0
  167. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/templates/extension/templates/project/manifest.rb +2 -0
  168. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/templates/extension/templates/project/screen.sass +2 -0
  169. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/templates/project/USAGE.markdown +32 -0
  170. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/templates/project/ie.sass +6 -0
  171. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/templates/project/manifest.rb +4 -0
  172. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/templates/project/print.sass +6 -0
  173. data/lib/Phamlp/sass/extensions/compass/frameworks/compass/templates/project/screen.sass +7 -0
  174. data/lib/Phamlp/sass/extensions/compass/functions/colourStops.php +268 -0
  175. data/lib/Phamlp/sass/extensions/compass/functions/constants.php +44 -0
  176. data/lib/Phamlp/sass/extensions/compass/functions/fontFiles.php +30 -0
  177. data/lib/Phamlp/sass/extensions/compass/functions/imageSize.php +39 -0
  178. data/lib/Phamlp/sass/extensions/compass/functions/inlineData.php +84 -0
  179. data/lib/Phamlp/sass/extensions/compass/functions/lists.php +47 -0
  180. data/lib/Phamlp/sass/extensions/compass/functions/selectors.php +128 -0
  181. data/lib/Phamlp/sass/extensions/compass/functions/urls.php +143 -0
  182. data/lib/Phamlp/sass/extensions/compass/stylesheets/_compass.scss +2 -0
  183. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/_css3.scss +15 -0
  184. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/_layout.scss +1 -0
  185. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/_reset.scss +3 -0
  186. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/_utilities.scss +6 -0
  187. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/css3/_background-clip.scss +43 -0
  188. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/css3/_background-origin.scss +42 -0
  189. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/css3/_background-size.scss +14 -0
  190. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/css3/_border-radius.scss +135 -0
  191. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/css3/_box-shadow.scss +50 -0
  192. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/css3/_box-sizing.scss +13 -0
  193. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/css3/_box.scss +112 -0
  194. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/css3/_columns.scss +55 -0
  195. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/css3/_font-face.scss +33 -0
  196. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/css3/_gradient.scss +96 -0
  197. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/css3/_inline-block.scss +12 -0
  198. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/css3/_opacity.scss +27 -0
  199. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/css3/_shared.scss +47 -0
  200. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/css3/_text-shadow.scss +25 -0
  201. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/css3/_transform.scss +85 -0
  202. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/css3/_transition.scss +85 -0
  203. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/layout/_sticky-footer.scss +23 -0
  204. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/reset/_utilities.scss +133 -0
  205. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/_general.scss +6 -0
  206. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/_links.scss +3 -0
  207. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/_lists.scss +4 -0
  208. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/_print.scss +17 -0
  209. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/_sprites.scss +1 -0
  210. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/_tables.scss +3 -0
  211. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/_text.scss +3 -0
  212. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/general/_clearfix.scss +31 -0
  213. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/general/_float.scss +15 -0
  214. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/general/_hacks.scss +35 -0
  215. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/general/_min.scss +16 -0
  216. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/general/_reset.scss +2 -0
  217. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/general/_tabs.scss +1 -0
  218. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/general/_tag-cloud.scss +18 -0
  219. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/links/_hover-link.scss +5 -0
  220. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/links/_link-colors.scss +28 -0
  221. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/links/_unstyled-link.scss +7 -0
  222. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/lists/_bullets.scss +34 -0
  223. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/lists/_horizontal-list.scss +52 -0
  224. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/lists/_inline-block-list.scss +47 -0
  225. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/lists/_inline-list.scss +29 -0
  226. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/sprites/_sprite-img.scss +56 -0
  227. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/tables/_alternating-rows-and-columns.scss +20 -0
  228. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/tables/_borders.scss +27 -0
  229. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/tables/_scaffolding.scss +9 -0
  230. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/text/_ellipsis.scss +25 -0
  231. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/text/_nowrap.scss +2 -0
  232. data/lib/Phamlp/sass/extensions/compass/stylesheets/compass/utilities/text/_replacement.scss +34 -0
  233. data/lib/Phamlp/sass/messages/_i18n.php +122 -0
  234. data/lib/Phamlp/sass/messages/de.php +70 -0
  235. data/lib/Phamlp/sass/messages/fr.php +70 -0
  236. data/lib/Phamlp/sass/renderers/SassCompactRenderer.php +130 -0
  237. data/lib/Phamlp/sass/renderers/SassCompressedRenderer.php +102 -0
  238. data/lib/Phamlp/sass/renderers/SassExpandedRenderer.php +62 -0
  239. data/lib/Phamlp/sass/renderers/SassNestedRenderer.php +61 -0
  240. data/lib/Phamlp/sass/renderers/SassRenderer.php +51 -0
  241. data/lib/Phamlp/sass/script/SassScriptFunction.php +169 -0
  242. data/lib/Phamlp/sass/script/SassScriptFunctions.php +751 -0
  243. data/lib/Phamlp/sass/script/SassScriptLexer.php +114 -0
  244. data/lib/Phamlp/sass/script/SassScriptOperation.php +151 -0
  245. data/lib/Phamlp/sass/script/SassScriptParser.php +192 -0
  246. data/lib/Phamlp/sass/script/SassScriptParserExceptions.php +40 -0
  247. data/lib/Phamlp/sass/script/SassScriptVariable.php +57 -0
  248. data/lib/Phamlp/sass/script/literals/SassBoolean.php +67 -0
  249. data/lib/Phamlp/sass/script/literals/SassColour.php +886 -0
  250. data/lib/Phamlp/sass/script/literals/SassLiteral.php +359 -0
  251. data/lib/Phamlp/sass/script/literals/SassLiteralExceptions.php +47 -0
  252. data/lib/Phamlp/sass/script/literals/SassNumber.php +503 -0
  253. data/lib/Phamlp/sass/script/literals/SassString.php +106 -0
  254. data/lib/Phamlp/sass/tree/SassCommentNode.php +64 -0
  255. data/lib/Phamlp/sass/tree/SassContext.php +120 -0
  256. data/lib/Phamlp/sass/tree/SassDebugNode.php +84 -0
  257. data/lib/Phamlp/sass/tree/SassDirectiveNode.php +76 -0
  258. data/lib/Phamlp/sass/tree/SassElseNode.php +28 -0
  259. data/lib/Phamlp/sass/tree/SassExtendNode.php +47 -0
  260. data/lib/Phamlp/sass/tree/SassForNode.php +99 -0
  261. data/lib/Phamlp/sass/tree/SassIfNode.php +95 -0
  262. data/lib/Phamlp/sass/tree/SassImportNode.php +69 -0
  263. data/lib/Phamlp/sass/tree/SassMixinDefinitionNode.php +88 -0
  264. data/lib/Phamlp/sass/tree/SassMixinNode.php +91 -0
  265. data/lib/Phamlp/sass/tree/SassNode.php +342 -0
  266. data/lib/Phamlp/sass/tree/SassNodeExceptions.php +117 -0
  267. data/lib/Phamlp/sass/tree/SassPropertyNode.php +239 -0
  268. data/lib/Phamlp/sass/tree/SassRootNode.php +100 -0
  269. data/lib/Phamlp/sass/tree/SassRuleNode.php +337 -0
  270. data/lib/Phamlp/sass/tree/SassVariableNode.php +90 -0
  271. data/lib/Phamlp/sass/tree/SassWhileNode.php +64 -0
  272. data/lib/frontsau/assets/rack.rb +12 -0
  273. data/lib/frontsau/assets/sprockets.rb +59 -0
  274. data/lib/frontsau/assets/static_assets_compiler.rb +50 -0
  275. data/lib/frontsau/assets/url_rewriter.rb +22 -0
  276. data/lib/frontsau/assets/watcher.rb +60 -0
  277. data/lib/frontsau/thor_app.rb +118 -0
  278. data/lib/frontsau/version.rb +3 -0
  279. data/lib/frontsau.rb +64 -0
  280. metadata +578 -0
@@ -0,0 +1,886 @@
1
+ <?php
2
+ /* SVN FILE: $Id: SassColour.php 118 2010-09-21 09:45:11Z chris.l.yates@gmail.com $ */
3
+ /**
4
+ * SassColour class file.
5
+ * @author Chris Yates <chris.l.yates@gmail.com>
6
+ * @copyright Copyright (c) 2010 PBM Web Development
7
+ * @license http://phamlp.googlecode.com/files/license.txt
8
+ * @package PHamlP
9
+ * @subpackage Sass.script.literals
10
+ */
11
+
12
+ require_once('SassLiteral.php');
13
+
14
+ /**
15
+ * SassColour class.
16
+ * A SassScript object representing a CSS colour.
17
+ *
18
+ * A colour may be represented internally as RGBA, HSLA, or both. It is
19
+ * originally represented as whatever its input is; if it’s created with RGB
20
+ * values, it’s represented as RGBA, and if it’s created with HSL values, it’s
21
+ * represented as HSLA. Once a property is accessed that requires the other
22
+ * representation – for example, SassColour::red for an HSL color – that
23
+ * component is calculated and cached.
24
+ *
25
+ * The alpha channel of a color is independent of its RGB or HSL representation.
26
+ * It’s always stored, as 1 if nothing else is specified. If only the alpha
27
+ * channel is modified using SassColour::with(), the cached RGB and HSL values
28
+ * are retained.
29
+ *
30
+ * Colour operations are all piecewise, e.g. when adding two colours each
31
+ * component is added independantly; Rr = R1 + R2, Gr = G1 + G2, Br = B1 + B2.
32
+ *
33
+ * Colours are returned as a named colour if possible or #rrggbb.
34
+ *
35
+ * @package PHamlP
36
+ * @subpackage Sass.script.literals
37
+ */
38
+ class SassColour extends SassLiteral {
39
+ /**@#+
40
+ * Regexes for matching and extracting colours
41
+ */
42
+ const MATCH = '/^((#([\da-f]{6}|[\da-f]{3}))|transparent|{CSS_COLOURS})/';
43
+ const EXTRACT_3 = '/#([\da-f])([\da-f])([\da-f])/';
44
+ const EXTRACT_6 = '/#([\da-f]{2})([\da-f]{2})([\da-f]{2})/';
45
+ const TRANSPARENT = 'transparent';
46
+ /**@#-*/
47
+
48
+ /**@#-*/
49
+ static private $svgColours = array(
50
+ 'aliceblue' => '#f0f8ff',
51
+ 'antiquewhite' => '#faebd7',
52
+ 'aqua' => '#00ffff',
53
+ 'aquamarine' => '#7fffd4',
54
+ 'azure' => '#f0ffff',
55
+ 'beige' => '#f5f5dc',
56
+ 'bisque' => '#ffe4c4',
57
+ 'black' => '#000000',
58
+ 'blanchedalmond' => '#ffebcd',
59
+ 'blue' => '#0000ff',
60
+ 'blueviolet' => '#8a2be2',
61
+ 'brown' => '#a52a2a',
62
+ 'burlywood' => '#deb887',
63
+ 'cadetblue' => '#5f9ea0',
64
+ 'chartreuse' => '#7fff00',
65
+ 'chocolate' => '#d2691e',
66
+ 'coral' => '#ff7f50',
67
+ 'cornflowerblue' => '#6495ed',
68
+ 'cornsilk' => '#fff8dc',
69
+ 'crimson' => '#dc143c',
70
+ 'cyan' => '#00ffff',
71
+ 'darkblue' => '#00008b',
72
+ 'darkcyan' => '#008b8b',
73
+ 'darkgoldenrod' => '#b8860b',
74
+ 'darkgray' => '#a9a9a9',
75
+ 'darkgreen' => '#006400',
76
+ 'darkgrey' => '#a9a9a9',
77
+ 'darkkhaki' => '#bdb76b',
78
+ 'darkmagenta' => '#8b008b',
79
+ 'darkolivegreen' => '#556b2f',
80
+ 'darkorange' => '#ff8c00',
81
+ 'darkorchid' => '#9932cc',
82
+ 'darkred' => '#8b0000',
83
+ 'darksalmon' => '#e9967a',
84
+ 'darkseagreen' => '#8fbc8f',
85
+ 'darkslateblue' => '#483d8b',
86
+ 'darkslategray' => '#2f4f4f',
87
+ 'darkslategrey' => '#2f4f4f',
88
+ 'darkturquoise' => '#00ced1',
89
+ 'darkviolet' => '#9400d3',
90
+ 'deeppink' => '#ff1493',
91
+ 'deepskyblue' => '#00bfff',
92
+ 'dimgray' => '#696969',
93
+ 'dimgrey' => '#696969',
94
+ 'dodgerblue' => '#1e90ff',
95
+ 'firebrick' => '#b22222',
96
+ 'floralwhite' => '#fffaf0',
97
+ 'forestgreen' => '#228b22',
98
+ 'fuchsia' => '#ff00ff',
99
+ 'gainsboro' => '#dcdcdc',
100
+ 'ghostwhite' => '#f8f8ff',
101
+ 'gold' => '#ffd700',
102
+ 'goldenrod' => '#daa520',
103
+ 'gray' => '#808080',
104
+ 'green' => '#008000',
105
+ 'greenyellow' => '#adff2f',
106
+ 'grey' => '#808080',
107
+ 'honeydew' => '#f0fff0',
108
+ 'hotpink' => '#ff69b4',
109
+ 'indianred' => '#cd5c5c',
110
+ 'indigo' => '#4b0082',
111
+ 'ivory' => '#fffff0',
112
+ 'khaki' => '#f0e68c',
113
+ 'lavender' => '#e6e6fa',
114
+ 'lavenderblush' => '#fff0f5',
115
+ 'lawngreen' => '#7cfc00',
116
+ 'lemonchiffon' => '#fffacd',
117
+ 'lightblue' => '#add8e6',
118
+ 'lightcoral' => '#f08080',
119
+ 'lightcyan' => '#e0ffff',
120
+ 'lightgoldenrodyellow' => '#fafad2',
121
+ 'lightgray' => '#d3d3d3',
122
+ 'lightgreen' => '#90ee90',
123
+ 'lightgrey' => '#d3d3d3',
124
+ 'lightpink' => '#ffb6c1',
125
+ 'lightsalmon' => '#ffa07a',
126
+ 'lightseagreen' => '#20b2aa',
127
+ 'lightskyblue' => '#87cefa',
128
+ 'lightslategray' => '#778899',
129
+ 'lightslategrey' => '#778899',
130
+ 'lightsteelblue' => '#b0c4de',
131
+ 'lightyellow' => '#ffffe0',
132
+ 'lime' => '#00ff00',
133
+ 'limegreen' => '#32cd32',
134
+ 'linen' => '#faf0e6',
135
+ 'magenta' => '#ff00ff',
136
+ 'maroon' => '#800000',
137
+ 'mediumaquamarine' => '#66cdaa',
138
+ 'mediumblue' => '#0000cd',
139
+ 'mediumorchid' => '#ba55d3',
140
+ 'mediumpurple' => '#9370db',
141
+ 'mediumseagreen' => '#3cb371',
142
+ 'mediumslateblue' => '#7b68ee',
143
+ 'mediumspringgreen' => '#00fa9a',
144
+ 'mediumturquoise' => '#48d1cc',
145
+ 'mediumvioletred' => '#c71585',
146
+ 'midnightblue' => '#191970',
147
+ 'mintcream' => '#f5fffa',
148
+ 'mistyrose' => '#ffe4e1',
149
+ 'moccasin' => '#ffe4b5',
150
+ 'navajowhite' => '#ffdead',
151
+ 'navy' => '#000080',
152
+ 'oldlace' => '#fdf5e6',
153
+ 'olive' => '#808000',
154
+ 'olivedrab' => '#6b8e23',
155
+ 'orange' => '#ffa500',
156
+ 'orangered' => '#ff4500',
157
+ 'orchid' => '#da70d6',
158
+ 'palegoldenrod' => '#eee8aa',
159
+ 'palegreen' => '#98fb98',
160
+ 'paleturquoise' => '#afeeee',
161
+ 'palevioletred' => '#db7093',
162
+ 'papayawhip' => '#ffefd5',
163
+ 'peachpuff' => '#ffdab9',
164
+ 'peru' => '#cd853f',
165
+ 'pink' => '#ffc0cb',
166
+ 'plum' => '#dda0dd',
167
+ 'powderblue' => '#b0e0e6',
168
+ 'purple' => '#800080',
169
+ 'red' => '#ff0000',
170
+ 'rosybrown' => '#bc8f8f',
171
+ 'royalblue' => '#4169e1',
172
+ 'saddlebrown' => '#8b4513',
173
+ 'salmon' => '#fa8072',
174
+ 'sandybrown' => '#f4a460',
175
+ 'seagreen' => '#2e8b57',
176
+ 'seashell' => '#fff5ee',
177
+ 'sienna' => '#a0522d',
178
+ 'silver' => '#c0c0c0',
179
+ 'skyblue' => '#87ceeb',
180
+ 'slateblue' => '#6a5acd',
181
+ 'slategray' => '#708090',
182
+ 'slategrey' => '#708090',
183
+ 'snow' => '#fffafa',
184
+ 'springgreen' => '#00ff7f',
185
+ 'steelblue' => '#4682b4',
186
+ 'tan' => '#d2b48c',
187
+ 'teal' => '#008080',
188
+ 'thistle' => '#d8bfd8',
189
+ 'tomato' => '#ff6347',
190
+ 'turquoise' => '#40e0d0',
191
+ 'violet' => '#ee82ee',
192
+ 'wheat' => '#f5deb3',
193
+ 'white' => '#ffffff',
194
+ 'whitesmoke' => '#f5f5f5',
195
+ 'yellow' => '#ffff00',
196
+ 'yellowgreen' => '#9acd32'
197
+ );
198
+
199
+ /**
200
+ * @var array reverse array (value => name) of named SVG1.0 colours
201
+ */
202
+ static private $_svgColours;
203
+
204
+ /**
205
+ * @var array reverse array (value => name) of named HTML4 colours
206
+ */
207
+ static private $_html4Colours = array(
208
+ '#000000' => 'black',
209
+ '#000080' => 'navy',
210
+ '#0000ff' => 'blue',
211
+ '#008000' => 'green',
212
+ '#008080' => 'teal',
213
+ '#00ff00' => 'lime',
214
+ '#00ffff' => 'aqua',
215
+ '#800000' => 'maroon',
216
+ '#800080' => 'purple',
217
+ '#808000' => 'olive',
218
+ '#808080' => 'gray',
219
+ '#c0c0c0' => 'silver',
220
+ '#ff0000' => 'red',
221
+ '#ff00ff' => 'fuchsia',
222
+ '#ffff00' => 'yellow',
223
+ '#ffffff' => 'white',
224
+ );
225
+
226
+ static private $regex;
227
+
228
+ /**@#+
229
+ * RGB colour components
230
+ */
231
+ /**
232
+ * @var array RGB colour components. Used to check for RGB attributes.
233
+ */
234
+ static private $rgb = array('red', 'green', 'blue');
235
+ /**
236
+ * @var integer red component. 0 - 255
237
+ */
238
+ private $red;
239
+ /**
240
+ * @var integer green component. 0 - 255
241
+ */
242
+ private $green;
243
+ /**
244
+ * @var integer blue component. 0 - 255
245
+ */
246
+ private $blue;
247
+ /**@#-*/
248
+ /**@#+
249
+ * HSL colour components
250
+ */
251
+ /**
252
+ * @var array HSL colour components. Used to check for HSL attributes.
253
+ */
254
+ static private $hsl = array('hue', 'saturation', 'lightness');
255
+ /**
256
+ * @var float hue component. 0 - 360
257
+ */
258
+ private $hue;
259
+ /**
260
+ * @var float saturation component. 0 - 100
261
+ */
262
+ private $saturation;
263
+ /**
264
+ * @var float lightness component. 0 - 100
265
+ */
266
+ private $lightness;
267
+ /**@#-*/
268
+ /**
269
+ * @var float alpha component. 0 - 1
270
+ */
271
+ private $alpha = 1;
272
+
273
+ /**
274
+ * Constructs an RGB or HSL color object, optionally with an alpha channel.
275
+ * RGB values must be between 0 and 255. Saturation and lightness values must
276
+ * be between 0 and 100. The alpha value must be between 0 and 1.
277
+ * The colour can be specified as:
278
+ * + a string that is an SVG colour or of the form #rgb or #rrggbb
279
+ * + an array with either 'red', 'green', and 'blue' keys, and optionally
280
+ * an alpha key.
281
+ * + an array with 'hue', 'saturation', and 'lightness' keys, and optionally
282
+ * an alpha key.
283
+ * + an array of red, green, and blue values, and optionally an alpha value.
284
+ * @param mixed the colour
285
+ * @return SassColour
286
+ */
287
+ public function __construct($colour) {
288
+ if (is_string($colour)) {
289
+ $colour = strtolower($colour);
290
+ if ($colour === self::TRANSPARENT) {
291
+ $this->red = 0;
292
+ $this->green = 0;
293
+ $this->blue = 0;
294
+ $this->alpha = 0;
295
+ }
296
+ else {
297
+ if (array_key_exists($colour, self::$svgColours)) {
298
+ $colour = self::$svgColours[$colour];
299
+ }
300
+ if (strlen($colour) == 4) {
301
+ preg_match(self::EXTRACT_3, $colour, $matches);
302
+ for ($i = 1; $i < 4; $i++) {
303
+ $matches[$i] = str_repeat($matches[$i], 2);
304
+ }
305
+ }
306
+ else {
307
+ preg_match(self::EXTRACT_6, $colour, $matches);
308
+ }
309
+
310
+ if (empty($matches)) {
311
+ throw new SassColourException('Invalid {what}', array('{what}'=>'SassColour string'), SassScriptParser::$context->node);
312
+ }
313
+ $this->red = intval($matches[1], 16);
314
+ $this->green = intval($matches[2], 16);
315
+ $this->blue = intval($matches[3], 16);
316
+ $this->alpha = 1;
317
+ }
318
+ }
319
+ elseif (is_array($colour)) {
320
+ $scheme = $this->assertValid($colour);
321
+ if ($scheme == 'rgb') {
322
+ $this->red = $colour['red'];
323
+ $this->green = $colour['green'];
324
+ $this->blue = $colour['blue'];
325
+ $this->alpha = (isset($colour['alpha']) ? $colour['alpha'] : 1);
326
+ }
327
+ elseif ($scheme == 'hsl') {
328
+ $this->hue = $colour['hue'];
329
+ $this->saturation = $colour['saturation'];
330
+ $this->lightness = $colour['lightness'];
331
+ $this->alpha = (isset($colour['alpha']) ? $colour['alpha'] : 1);
332
+ }
333
+ else {
334
+ $this->red = $colour[0];
335
+ $this->green = $colour[1];
336
+ $this->blue = $colour[2];
337
+ $this->alpha = (isset($colour[3]) ? $colour[3] : 1);
338
+ }
339
+ }
340
+ else {
341
+ throw new SassColourException('{what} must be a {type}', array('{what}'=>'Colour', '{type}'=>'array'), SassScriptParser::$context->node);
342
+ }
343
+ }
344
+
345
+ /**
346
+ * Colour addition
347
+ * @param mixed SassColour|SassNumber value to add
348
+ * @return sassColour the colour result
349
+ */
350
+ public function op_plus($other) {
351
+ if ($other instanceof SassNumber) {
352
+ if (!$other->isUnitless()) {
353
+ throw new SassColourException('{what} must be a {type}', array('{what}'=>Phamlp::t('sass', 'Number'), '{type}'=>Phamlp::t('sass', 'unitless number')), SassScriptParser::$context->node);
354
+ }
355
+ $this->red = $this->getRed() + $other->value;
356
+ $this->green = $this->getGreen() + $other->value;
357
+ $this->blue = $this->getBlue() + $other->value;
358
+ }
359
+ elseif (!$other instanceof SassColour) {
360
+ throw new SassColourException('{what} must be a {type}', array('{what}'=>'Argument', '{type}'=>'SassColour or SassNumber'), SassScriptParser::$context->node);
361
+ }
362
+ else {
363
+ $this->red = $this->getRed() + $other->getRed();
364
+ $this->green = $this->getGreen() + $other->getGreen();
365
+ $this->blue = $this->getBlue() + $other->getBlue();
366
+ }
367
+ return $this;
368
+ }
369
+
370
+ /**
371
+ * Colour subraction
372
+ * @param mixed value (SassColour or SassNumber) to subtract
373
+ * @return sassColour the colour result
374
+ */
375
+ public function op_minus($other) {
376
+ if ($other instanceof SassNumber) {
377
+ if (!$other->isUnitless()) {
378
+ throw new SassColourException('{what} must be a {type}', array('{what}'=>Phamlp::t('sass', 'Number'), '{type}'=>Phamlp::t('sass', 'unitless number')), SassScriptParser::$context->node);
379
+ }
380
+ $this->red = $this->getRed() - $other->value;
381
+ $this->green = $this->getGreen() - $other->value;
382
+ $this->blue = $this->getBlue() - $other->value;
383
+ }
384
+ elseif (!$other instanceof SassColour) {
385
+ throw new SassColourException('{what} must be a {type}', array('{what}'=>'Argument', '{type}'=>'SassColour or SassNumber'), SassScriptParser::$context->node);
386
+ }
387
+ else {
388
+ $this->red = $this->getRed() - $other->getRed();
389
+ $this->green = $this->getGreen() - $other->getGreen();
390
+ $this->blue = $this->getBlue() - $other->getBlue();
391
+ }
392
+ return $this;
393
+ }
394
+
395
+ /**
396
+ * Colour multiplication
397
+ * @param mixed SassColour|SassNumber value to multiply by
398
+ * @return sassColour the colour result
399
+ */
400
+ public function op_times($other) {
401
+ if ($other instanceof SassNumber) {
402
+ if (!$other->isUnitless()) {
403
+ throw new SassColourException('{what} must be a {type}', array('{what}'=>Phamlp::t('sass', 'Number'), '{type}'=>Phamlp::t('sass', 'unitless number')), SassScriptParser::$context->node);
404
+ }
405
+ $this->red = $this->getRed() * $other->value;
406
+ $this->green = $this->getGreen() * $other->value;
407
+ $this->blue = $this->getBlue() * $other->value;
408
+ }
409
+ elseif (!$other instanceof SassColour) {
410
+ throw new SassColourException('{what} must be a {type}', array('{what}'=>'Argument', '{type}'=>'SassColour or SassNumber'), SassScriptParser::$context->node);
411
+ }
412
+ else {
413
+ $this->red = $this->getRed() * $other->getRed();
414
+ $this->green = $this->getGreen() * $other->getGreen();
415
+ $this->blue = $this->getBlue() * $other->getBlue();
416
+ }
417
+ return $this;
418
+ }
419
+
420
+ /**
421
+ * Colour division
422
+ * @param mixed value (SassColour or SassNumber) to divide by
423
+ * @return sassColour the colour result
424
+ */
425
+ public function op_div($other) {
426
+ if ($other instanceof SassNumber) {
427
+ if (!$other->isUnitless()) {
428
+ throw new SassColourException('{what} must be a {type}', array('{what}'=>Phamlp::t('sass', 'Number'), '{type}'=>Phamlp::t('sass', 'unitless number')), SassScriptParser::$context->node);
429
+ }
430
+ $this->red = $this->getRed() / $other->value;
431
+ $this->green = $this->getGreen() / $other->value;
432
+ $this->blue = $this->getBlue() / $other->value;
433
+ }
434
+ elseif (!$other instanceof SassColour) {
435
+ throw new SassColourException('{what} must be a {type}', array('{what}'=>'Argument', '{type}'=>'SassColour or SassNumber'), SassScriptParser::$context->node);
436
+ }
437
+ else {
438
+ $this->red = $this->getRed() / $other->getRed();
439
+ $this->green = $this->getGreen() / $other->getGreen();
440
+ $this->blue = $this->getBlue() / $other->getBlue();
441
+ }
442
+ return $this;
443
+ }
444
+
445
+ /**
446
+ * Colour modulus
447
+ * @param mixed value (SassColour or SassNumber) to divide by
448
+ * @return sassColour the colour result
449
+ */
450
+ public function op_modulo($other) {
451
+ if ($other instanceof SassNumber) {
452
+ if (!$other->isUnitless()) {
453
+ throw new SassColourException('{what} must be a {type}', array('{what}'=>Phamlp::t('sass', 'Number'), '{type}'=>Phamlp::t('sass', 'unitless number')), SassScriptParser::$context->node);
454
+ }
455
+ $this->red = $this->getRed() % $other->value;
456
+ $this->green = $this->getGreen() % $other->value;
457
+ $this->blue = $this->getBlue() % $other->value;
458
+ }
459
+ elseif (!$other instanceof SassColour) {
460
+ throw new SassColourException('{what} must be a {type}', array('{what}'=>'Argument', '{type}'=>'SassColour or SassNumber'), SassScriptParser::$context->node);
461
+ }
462
+ else {
463
+ $this->red = $this->getRed() % $other->getRed();
464
+ $this->green = $this->getGreen() % $other->getGreen();
465
+ $this->blue = $this->getBlue() % $other->getBlue();
466
+ }
467
+ return $this;
468
+ }
469
+
470
+ /**
471
+ * Colour bitwise AND
472
+ * @param mixed value (SassColour or SassNumber) to bitwise AND with
473
+ * @return sassColour the colour result
474
+ */
475
+ public function op_bw_and($other) {
476
+ if ($other instanceof SassNumber) {
477
+ if (!$other->isUnitless()) {
478
+ throw new SassColourException('{what} must be a {type}', array('{what}'=>Phamlp::t('sass', 'Number'), '{type}'=>Phamlp::t('sass', 'unitless number')), SassScriptParser::$context->node);
479
+ }
480
+ $this->red = $this->getRed() & $other->value;
481
+ $this->green = $this->getGreen() & $other->value;
482
+ $this->blue = $this->getBlue() & $other->value;
483
+ }
484
+ elseif (!$other instanceof SassColour) {
485
+ throw new SassColourException('{what} must be a {type}', array('{what}'=>'Argument', '{type}'=>'SassColour or SassNumber'), SassScriptParser::$context->node);
486
+ }
487
+ else {
488
+ $this->red = $this->getRed() & $other->getRed();
489
+ $this->green = $this->getGreen() & $other->getGreen();
490
+ $this->blue = $this->getBlue() & $other->getBlue();
491
+ }
492
+ return $this;
493
+ }
494
+
495
+ /**
496
+ * Colour bitwise OR
497
+ * @param mixed value (SassColour or SassNumber) to bitwise OR with
498
+ * @return sassColour the colour result
499
+ */
500
+ public function op_bw_or($other) {
501
+ if ($other instanceof SassNumber) {
502
+ if (!$other->isUnitless()) {
503
+ throw new SassColourException('{what} must be a {type}', array('{what}'=>Phamlp::t('sass', 'Number'), '{type}'=>Phamlp::t('sass', 'unitless number')), SassScriptParser::$context->node);
504
+ }
505
+ $this->red = $this->getRed() | $other->value;
506
+ $this->green = $this->getGreen() | $other->value;
507
+ $this->blue = $this->getBlue() | $other->value;
508
+ }
509
+ elseif (!$other instanceof SassColour) {
510
+ throw new SassColourException('{what} must be a {type}', array('{what}'=>'Argument', '{type}'=>'SassColour or SassNumber'), SassScriptParser::$context->node);
511
+ }
512
+ else {
513
+ $this->red = $this->getRed() | $other->getRed();
514
+ $this->green = $this->getGreen() | $other->getGreen();
515
+ $this->blue = $this->getBlue() | $other->getBlue();
516
+ }
517
+ return $this;
518
+ }
519
+
520
+ /**
521
+ * Colour bitwise XOR
522
+ * @param mixed value (SassColour or SassNumber) to bitwise XOR with
523
+ * @return sassColour the colour result
524
+ */
525
+ public function op_bw_xor($other) {
526
+ if ($other instanceof SassNumber) {
527
+ if (!$other->isUnitless()) {
528
+ throw new SassColourException('{what} must be a {type}', array('{what}'=>Phamlp::t('sass', 'Number'), '{type}'=>Phamlp::t('sass', 'unitless number')), SassScriptParser::$context->node);
529
+ }
530
+ $this->red = $this->getRed() ^ $other->value;
531
+ $this->green = $this->getGreen() ^ $other->value;
532
+ $this->blue = $this->getBlue() ^ $other->value;
533
+ }
534
+ elseif (!$other instanceof SassColour) {
535
+ throw new SassColourException('{what} must be a {type}', array('{what}'=>'Argument', '{type}'=>'SassColour or SassNumber'), SassScriptParser::$context->node);
536
+ }
537
+ else {
538
+ $this->red = $this->getRed() ^ $other->getRed();
539
+ $this->green = $this->getGreen() ^ $other->getGreen();
540
+ $this->blue = $this->getBlue() ^ $other->getBlue();
541
+ }
542
+ return $this;
543
+ }
544
+
545
+ /**
546
+ * Colour bitwise NOT
547
+ * @return sassColour the colour result
548
+ */
549
+ public function op_not() {
550
+ $this->red = ~$this->getRed();
551
+ $this->green = ~$this->getGreen();
552
+ $this->blue = ~$this->getBlue();
553
+ return $this;
554
+ }
555
+
556
+ /**
557
+ * Colour bitwise Shift Left
558
+ * @param sassNumber amount to shift left by
559
+ * @return sassColour the colour result
560
+ */
561
+ public function op_shiftl($other) {
562
+ if (!$other instanceof SassNumber ||!$other->isUnitless()) {
563
+ throw new SassColourException('{what} must be a {type}', array('{what}'=>Phamlp::t('sass', 'Number'), '{type}'=>Phamlp::t('sass', 'unitless number')), SassScriptParser::$context->node);
564
+ }
565
+ $this->red = $this->getRed() << $other->value;
566
+ $this->green = $this->getGreen() << $other->value;
567
+ $this->blue = $this->getBlue() << $other->value;
568
+ return $this;
569
+ }
570
+
571
+ /**
572
+ * Colour bitwise Shift Right
573
+ * @param sassNumber amount to shift right by
574
+ * @return sassColour the colour result
575
+ */
576
+ public function op_shiftr($other) {
577
+ if (!$other instanceof SassNumber || !$other->isUnitless()) {
578
+ throw new SassColourException('{what} must be a {type}', array('{what}'=>Phamlp::t('sass', 'Number'), '{type}'=>Phamlp::t('sass', 'unitless number')), SassScriptParser::$context->node);
579
+ }
580
+ $this->red = $this->getRed() >> $other->value;
581
+ $this->green = $this->getGreen() >> $other->value;
582
+ $this->blue = $this->getBlue() >> $other->value;
583
+ return $this;
584
+ }
585
+
586
+ /**
587
+ * Returns a copy of this colour with one or more channels changed.
588
+ * RGB or HSL attributes may be changed, but not both at once.
589
+ * @param array attributes to change
590
+ */
591
+ public function with($attributes) {
592
+ if ($this->assertValid($attributes, false) === 'hsl') {
593
+ $colour = array_merge(array(
594
+ 'hue' => $this->getHue(),
595
+ 'saturation' => $this->getSaturation(),
596
+ 'lightness' => $this->getLightness(),
597
+ 'alpha' => $this->alpha
598
+ ), $attributes);
599
+ }
600
+ else {
601
+ $colour = array_merge(array(
602
+ 'red' => $this->getRed(),
603
+ 'green' => $this->getGreen(),
604
+ 'blue' => $this->getBlue(),
605
+ 'alpha' => $this->alpha
606
+ ), $attributes);
607
+ }
608
+ return new SassColour($colour);
609
+ }
610
+
611
+ /**
612
+ * Returns the alpha component (opacity) of this colour.
613
+ * @return float the alpha component (opacity) of this colour.
614
+ */
615
+ public function getAlpha() {
616
+ return $this->alpha;
617
+ }
618
+
619
+ /**
620
+ * Returns the hue of this colour.
621
+ * @return float the hue of this colour.
622
+ */
623
+ public function getHue() {
624
+ if (is_null($this->hue)) {
625
+ $this->rgb2hsl();
626
+ }
627
+ return $this->hue;
628
+ }
629
+
630
+ /**
631
+ * Returns the saturation of this colour.
632
+ * @return float the saturation of this colour.
633
+ */
634
+ public function getSaturation() {
635
+ if (is_null($this->saturation)) {
636
+ $this->rgb2hsl();
637
+ }
638
+ return $this->saturation;
639
+ }
640
+
641
+ /**
642
+ * Returns the lightness of this colour.
643
+ * @return float the lightness of this colour.
644
+ */
645
+ public function getLightness() {
646
+ if (is_null($this->lightness)) {
647
+ $this->rgb2hsl();
648
+ }
649
+ return $this->lightness;
650
+ }
651
+
652
+ /**
653
+ * Returns the blue component of this colour.
654
+ * @return integer the blue component of this colour.
655
+ */
656
+ public function getBlue() {
657
+ if (is_null($this->blue)) {
658
+ $this->hsl2rgb();
659
+ }
660
+ $component = round(abs($this->blue));
661
+ return ($component > 255 ? $component % 255 : $component);
662
+ }
663
+
664
+ /**
665
+ * Returns the green component of this colour.
666
+ * @return integer the green component of this colour.
667
+ */
668
+ public function getGreen() {
669
+ if (is_null($this->green)) {
670
+ $this->hsl2rgb();
671
+ }
672
+ $component = round(abs($this->green));
673
+ return ($component > 255 ? $component % 255 : $component);
674
+ }
675
+
676
+ /**
677
+ * Returns the red component of this colour.
678
+ * @return integer the red component of this colour.
679
+ */
680
+ public function getRed() {
681
+ if (is_null($this->red)) {
682
+ $this->hsl2rgb();
683
+ }
684
+ $component = round(abs($this->red));
685
+ return ($component > 255 ? $component % 255 : $component);
686
+ }
687
+
688
+ /**
689
+ * Returns an array with the RGB components of this colour.
690
+ * @return array the RGB components of this colour
691
+ */
692
+ public function getRgb() {
693
+ return array($this->red, $this->green, $this->blue);
694
+ }
695
+
696
+ /**
697
+ * Returns an array with the RGB and alpha components of this colour.
698
+ * @return array the RGB and alpha components of this colour
699
+ */
700
+ public function getRgba() {
701
+ return array($this->getRed(), $this->getGreen(), $this->getBlue(), $this->alpha);
702
+ }
703
+
704
+ /**
705
+ * Returns an array with the HSL components of this colour.
706
+ * @return array the HSL components of this colour
707
+ */
708
+ public function getHsl() {
709
+ return array($this->getHue(), $this->getSaturation(), $this->getLightness());
710
+ }
711
+
712
+ /**
713
+ * Returns an array with the HSL and alpha components of this colour.
714
+ * @return array the HSL and alpha components of this colour
715
+ */
716
+ public function getHsla() {
717
+ return array($this->getHue(), $this->getSaturation(), $this->getLightness(), $this->alpha);
718
+ }
719
+
720
+ /**
721
+ * Returns the value of this colour.
722
+ * @return array the colour
723
+ * @deprecated
724
+ */
725
+ public function getValue() {
726
+ return $this->rgb;
727
+ }
728
+
729
+ /**
730
+ * Returns whether this colour object is translucent; that is, whether the alpha channel is non-1.
731
+ * @return boolean true if this colour is translucent, false if not
732
+ */
733
+ public function isTranslucent() {
734
+ return $this->alpha < 1;
735
+ }
736
+
737
+ /**
738
+ * Converts the colour to a string.
739
+ * @param boolean whether to use CSS3 SVG1.0 colour names
740
+ * @return string the colour as a named colour, rgba(r,g,g,a) or #rrggbb
741
+ */
742
+ public function toString($css3 = false) {
743
+ $rgba = $this->rgba;
744
+
745
+ if ($rgba[3] == 0) {
746
+ return 'transparent';
747
+ }
748
+ elseif ($rgba[3] < 1) {
749
+ return sprintf('rgba(%d,%d,%d,%1.2f)', $rgba[0], $rgba[1], $rgba[2], $rgba[3]);
750
+ }
751
+ else {
752
+ $colour = sprintf('#%02x%02x%02x', $rgba[0], $rgba[1], $rgba[2]);
753
+ }
754
+ if ($css3) {
755
+
756
+ if (empty(self::$_svgColours)) {
757
+ self::$_svgColours = array_flip(self::$svgColours);
758
+ }
759
+ return (array_key_exists($colour, self::$svgColours) ?
760
+ self::$_svgColours[$colour] : $colour);
761
+ }
762
+ else {
763
+ return (array_key_exists($colour, self::$_html4Colours) ?
764
+ self::$_html4Colours[$colour] : $colour);
765
+ }
766
+ }
767
+
768
+ /**
769
+ * Converts from HSL to RGB colourspace
770
+ * Algorithm from the CSS3 spec: {@link http://www.w3.org/TR/css3-color/#hsl-color}
771
+ * @uses hue2rgb()
772
+ */
773
+ private function hsl2rgb() {
774
+ $h = ($this->hue % 360)/360;
775
+ $s = $this->saturation/100;
776
+ $l = $this->lightness/100;
777
+
778
+ $m1 = ($l <= 0.5 ? $l * ($s + 1) : $l + $s - $l * $s);
779
+ $m2 = $l * 2 - $m1;
780
+
781
+ $this->red = $this->hue2rgb($m1, $m2, $h + 1/3);
782
+ $this->green = $this->hue2rgb($m1, $m2, $h);
783
+ $this->blue = $this->hue2rgb($m1, $m2, $h - 1/3);
784
+ }
785
+
786
+ /**
787
+ * Converts from hue to RGB colourspace
788
+ */
789
+ private function hue2rgb($m1, $m2, $h) {
790
+ $h += ($h < 0 ? 1 : ($h > 1 ? -1 : 0));
791
+
792
+ if ($h * 6 < 1) {
793
+ $c = $m2 + ($m1 - $m2) * $h * 6;
794
+ }
795
+ elseif ($h * 2 < 1) {
796
+ $c = $m1;
797
+ }
798
+ elseif ($h * 3 < 2) {
799
+ $c = $m2 + ($m1 - $m2) * (2/3 - $h) * 6;
800
+ }
801
+ else {
802
+ $c = $m2;
803
+ }
804
+ return $c * 255;
805
+ }
806
+
807
+ /**
808
+ * Converts from RGB to HSL colourspace
809
+ * Algorithm adapted from {@link http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_RGB_to_HSL_or_HSV}
810
+ */
811
+ private function rgb2hsl() {
812
+ $rgb = array($this->red/255, $this->green/255, $this->blue/255);
813
+ $max = max($rgb);
814
+ $min = min($rgb);
815
+ $c = $max - $min;
816
+
817
+ // Lightness
818
+ $l = ($max + $min)/2;
819
+ $this->lightness = $l * 100;
820
+
821
+ // Saturation
822
+ $this->saturation = ($c ? ($l <= 0.5 ? $c/(2 * $l) : $c/(2 - 2 * $l)) : 0 ) * 100;
823
+
824
+ // Hue
825
+ switch($max) {
826
+ case $min:
827
+ $h = 0;
828
+ break;
829
+ case $rgb[0]:
830
+ $h = (($rgb[1] - $rgb[2])/$c) % 6;
831
+ break;
832
+ case $rgb[1]:
833
+ $h = (($rgb[2] - $rgb[0])/$c) + 2;
834
+ break;
835
+ case $rgb[2]:
836
+ $h = (($rgb[0] - $rgb[1])/$c) + 4;
837
+ break;
838
+ }
839
+ $this->hue = $h * 60;
840
+ }
841
+
842
+ /**
843
+ * Asserts that the colour space is valid.
844
+ * Returns the name of the colour space: 'rgb' if red, green, or blue keys given;
845
+ * 'hsl' if hue, saturation or lightness keys given; null if a non-associative array
846
+ * @param array the colour to test
847
+ * @param boolean whether all colour space keys must be given
848
+ * @return string name of the colour space
849
+ * @throws SassColourException if mixed colour space keys given or not all
850
+ * keys for a colour space are required but not given (contructor)
851
+ */
852
+ private function assertValid($colour, $all = true) {
853
+ if (array_key_exists('red', $colour) || array_key_exists('green', $colour) || array_key_exists('blue', $colour)) {
854
+ if (array_key_exists('hue', $colour) || array_key_exists('saturation', $colour) || array_key_exists('lightness', $colour)) {
855
+ throw new SassColourException('SassColour can not have HSL and RGB keys specified', array(), SassScriptParser::$context->node);
856
+ }
857
+ if ($all && (!array_key_exists('red', $colour) || !array_key_exists('green', $colour) || !array_key_exists('blue', $colour))) {
858
+ throw new SassColourException('SassColour must have all {colourSpace} keys specified', array('{colourSpace}'=>'RGB'), SassScriptParser::$context->node);
859
+ }
860
+ return 'rgb';
861
+ }
862
+ elseif (array_key_exists('hue', $colour) || array_key_exists('saturation', $colour) || array_key_exists('lightness', $colour)) {
863
+ if ($all && (!array_key_exists('hue', $colour) || !array_key_exists('saturation', $colour) || !array_key_exists('lightness', $colour))) {
864
+ throw new SassColourException('SassColour must have all {colourSpace} keys specified', array('{colourSpace}'=>'HSL'), SassScriptParser::$context->node);
865
+ }
866
+ return 'hsl';
867
+ }
868
+ elseif ($all && sizeof($colour) < 3) {
869
+ throw new SassColourException('SassColour array must have at least 3 elements', array(), SassScriptParser::$context->node);
870
+ }
871
+ }
872
+
873
+ /**
874
+ * Returns a value indicating if a token of this type can be matched at
875
+ * the start of the subject string.
876
+ * @param string the subject string
877
+ * @return mixed match at the start of the string or false if no match
878
+ */
879
+ static public function isa($subject) {
880
+ if (empty(self::$regex)) {
881
+ self::$regex = str_replace('{CSS_COLOURS}', join('|', array_reverse(array_keys(self::$svgColours))), self::MATCH);
882
+ }
883
+ return (preg_match(self::$regex, strtolower($subject), $matches) ?
884
+ $matches[0] : false);
885
+ }
886
+ }