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,751 @@
1
+ <?php
2
+ /**
3
+ * SassScript functions class file.
4
+ *
5
+ * Methods in this module are accessible from the SassScript context.
6
+ * For example, you can write:
7
+ *
8
+ * $colour = hsl(120, 100%, 50%)
9
+ * and it will call SassFunctions::hsl().
10
+ *
11
+ * There are a few things to keep in mind when modifying this module.
12
+ * First of all, the arguments passed are SassLiteral objects.
13
+ * Literal objects are also expected to be returned.
14
+ *
15
+ * Most Literal objects support the SassLiteral->value accessor
16
+ * for getting their values. Colour objects, though, must be accessed using
17
+ * SassColour::rgb().
18
+ *
19
+ * Second, making functions accessible from Sass introduces the temptation
20
+ * to do things like database access within stylesheets.
21
+ * This temptation must be resisted.
22
+ * Keep in mind that Sass stylesheets are only compiled once and then left as
23
+ * static CSS files. Any dynamic CSS should be left in <style> tags in the
24
+ * HTML.
25
+ *
26
+ * @author Chris Yates <chris.l.yates@gmail.com>
27
+ * @copyright Copyright (c) 2010 PBM Web Development
28
+ * @license http://phamlp.googlecode.com/files/license.txt
29
+ * @package PHamlP
30
+ * @subpackage Sass.script
31
+ */
32
+
33
+ /**
34
+ * SassScript functions class.
35
+ * A collection of functions for use in SassSCript.
36
+ * @package PHamlP
37
+ * @subpackage Sass.script
38
+ */
39
+ class SassScriptFunctions {
40
+ const DECREASE = false;
41
+ const INCREASE = true;
42
+
43
+ /*
44
+ * Colour Creation
45
+ */
46
+
47
+ /**
48
+ * Creates a SassColour object from red, green, and blue values.
49
+ * @param SassNumber the red component.
50
+ * A number between 0 and 255 inclusive, or between 0% and 100% inclusive
51
+ * @param SassNumber the green component.
52
+ * A number between 0 and 255 inclusive, or between 0% and 100% inclusive
53
+ * @param SassNumber the blue component.
54
+ * A number between 0 and 255 inclusive, or between 0% and 100% inclusive
55
+ * @return new SassColour SassColour object
56
+ * @throws SassScriptFunctionException if red, green, or blue are out of bounds
57
+ */
58
+ public static function rgb($red, $green, $blue) {
59
+ return self::rgba($red, $green, $blue, new SassNumber(1));
60
+ }
61
+
62
+ /**
63
+ * Creates a SassColour object from red, green, and blue values and alpha
64
+ * channel (opacity).
65
+ * There are two overloads:
66
+ * * rgba(red, green, blue, alpha)
67
+ * @param SassNumber the red component.
68
+ * A number between 0 and 255 inclusive, or between 0% and 100% inclusive
69
+ * @param SassNumber the green component.
70
+ * A number between 0 and 255 inclusive, or between 0% and 100% inclusive
71
+ * @param SassNumber the blue component.
72
+ * A number between 0 and 255 inclusive, or between 0% and 100% inclusive
73
+ * @param SassNumber The alpha channel. A number between 0 and 1.
74
+ *
75
+ * * rgba(colour, alpha)
76
+ * @param SassColour a SassColour object
77
+ * @param SassNumber The alpha channel. A number between 0 and 1.
78
+ *
79
+ * @return new SassColour SassColour object
80
+ * @throws SassScriptFunctionException if any of the red, green, or blue
81
+ * colour components are out of bounds, or or the colour is not a colour, or
82
+ * alpha is out of bounds
83
+ */
84
+ public static function rgba() {
85
+ switch (func_num_args()) {
86
+ case 2:
87
+ $colour = func_get_arg(0);
88
+ $alpha = func_get_arg(1);
89
+ SassLiteral::assertType($colour, 'SassColour');
90
+ SassLiteral::assertType($alpha, 'SassNumber');
91
+ SassLiteral::assertInRange($alpha, 0, 1);
92
+ return $colour->with(array('alpha' => $alpha->value));
93
+ break;
94
+ case 4:
95
+ $rgba = array();
96
+ $components = func_get_args();
97
+ $alpha = array_pop($components);
98
+ foreach($components as $component) {
99
+ SassLiteral::assertType($component, 'SassNumber');
100
+ if ($component->units == '%') {
101
+ SassLiteral::assertInRange($component, 0, 100, '%');
102
+ $rgba[] = $component->value * 2.55;
103
+ }
104
+ else {
105
+ SassLiteral::assertInRange($component, 0, 255);
106
+ $rgba[] = $component->value;
107
+ }
108
+ }
109
+ SassLiteral::assertType($alpha, 'SassNumber');
110
+ SassLiteral::assertInRange($alpha, 0, 1);
111
+ $rgba[] = $alpha->value;
112
+ return new SassColour($rgba);
113
+ break;
114
+ default:
115
+ throw new SassScriptFunctionException('Incorrect argument count for {method}; expected {expected}, received {received}', array('{method}' => __METHOD__, '{expected}' => '2 or 4', '{received}' => func_num_args()), SassScriptParser::$context->node);
116
+ }
117
+ }
118
+
119
+ /**
120
+ * Creates a SassColour object from hue, saturation, and lightness.
121
+ * Uses the algorithm from the
122
+ * {@link http://www.w3.org/TR/css3-colour/#hsl-colour CSS3 spec}.
123
+ * @param float The hue of the colour in degrees.
124
+ * Should be between 0 and 360 inclusive
125
+ * @param mixed The saturation of the colour as a percentage.
126
+ * Must be between '0%' and 100%, inclusive
127
+ * @param mixed The lightness of the colour as a percentage.
128
+ * Must be between 0% and 100%, inclusive
129
+ * @return new SassColour The resulting colour
130
+ * @throws SassScriptFunctionException if saturation or lightness are out of bounds
131
+ */
132
+ public static function hsl($h, $s, $l) {
133
+ return self::hsla($h, $s, $l, new SassNumber(1));
134
+ }
135
+
136
+ /**
137
+ * Creates a SassColour object from hue, saturation, lightness and alpha
138
+ * channel (opacity).
139
+ * @param SassNumber The hue of the colour in degrees.
140
+ * Should be between 0 and 360 inclusive
141
+ * @param SassNumber The saturation of the colour as a percentage.
142
+ * Must be between 0% and 100% inclusive
143
+ * @param SassNumber The lightness of the colour as a percentage.
144
+ * Must be between 0% and 100% inclusive
145
+ * @param float The alpha channel. A number between 0 and 1.
146
+ * @return new SassColour The resulting colour
147
+ * @throws SassScriptFunctionException if saturation, lightness or alpha are
148
+ * out of bounds
149
+ */
150
+ public static function hsla($h, $s, $l, $a) {
151
+ SassLiteral::assertType($h, 'SassNumber');
152
+ SassLiteral::assertType($s, 'SassNumber');
153
+ SassLiteral::assertType($l, 'SassNumber');
154
+ SassLiteral::assertType($a, 'SassNumber');
155
+ SassLiteral::assertInRange($s, 0, 100, '%');
156
+ SassLiteral::assertInRange($l, 0, 100, '%');
157
+ SassLiteral::assertInRange($a, 0, 1);
158
+ return new SassColour(array('hue'=>$h, 'saturation'=>$s, 'lightness'=>$l, 'alpha'=>$a));
159
+ }
160
+
161
+ /*
162
+ * Colour Information
163
+ */
164
+
165
+ /**
166
+ * Returns the red component of a colour.
167
+ * @param SassColour The colour
168
+ * @return new SassNumber The red component of colour
169
+ * @throws SassScriptFunctionException If $colour is not a colour
170
+ */
171
+ public static function red($colour) {
172
+ SassLiteral::assertType($colour, 'SassColour');
173
+ return new SassNumber($colour->red);
174
+ }
175
+
176
+ /**
177
+ * Returns the green component of a colour.
178
+ * @param SassColour The colour
179
+ * @return new SassNumber The green component of colour
180
+ * @throws SassScriptFunctionException If $colour is not a colour
181
+ */
182
+ public static function green($colour) {
183
+ SassLiteral::assertType($colour, 'SassColour');
184
+ return new SassNumber($colour->green);
185
+ }
186
+
187
+ /**
188
+ * Returns the blue component of a colour.
189
+ * @param SassColour The colour
190
+ * @return new SassNumber The blue component of colour
191
+ * @throws SassScriptFunctionException If $colour is not a colour
192
+ */
193
+ public static function blue($colour) {
194
+ SassLiteral::assertType($colour, 'SassColour');
195
+ return new SassNumber($colour->blue);
196
+ }
197
+
198
+ /**
199
+ * Returns the hue component of a colour.
200
+ * @param SassColour The colour
201
+ * @return new SassNumber The hue component of colour
202
+ * @throws SassScriptFunctionException If $colour is not a colour
203
+ */
204
+ public static function hue($colour) {
205
+ SassLiteral::assertType($colour, 'SassColour');
206
+ return new SassNumber($colour->hue);
207
+ }
208
+
209
+ /**
210
+ * Returns the saturation component of a colour.
211
+ * @param SassColour The colour
212
+ * @return new SassNumber The saturation component of colour
213
+ * @throws SassScriptFunctionException If $colour is not a colour
214
+ */
215
+ public static function saturation($colour) {
216
+ SassLiteral::assertType($colour, 'SassColour');
217
+ return new SassNumber($colour->saturation);
218
+ }
219
+
220
+ /**
221
+ * Returns the lightness component of a colour.
222
+ * @param SassColour The colour
223
+ * @return new SassNumber The lightness component of colour
224
+ * @throws SassScriptFunctionException If $colour is not a colour
225
+ */
226
+ public static function lightness($colour) {
227
+ SassLiteral::assertType($colour, 'SassColour');
228
+ return new SassNumber($colour->lightness);
229
+ }
230
+
231
+ /**
232
+ * Returns the alpha component (opacity) of a colour.
233
+ * @param SassColour The colour
234
+ * @return new SassNumber The alpha component (opacity) of colour
235
+ * @throws SassScriptFunctionException If $colour is not a colour
236
+ */
237
+ public static function alpha($colour) {
238
+ SassLiteral::assertType($colour, 'SassColour');
239
+ return new SassNumber($colour->alpha);
240
+ }
241
+
242
+ /**
243
+ * Returns the alpha component (opacity) of a colour.
244
+ * @param SassColour The colour
245
+ * @return new SassNumber The alpha component (opacity) of colour
246
+ * @throws SassScriptFunctionException If $colour is not a colour
247
+ */
248
+ public static function opacity($colour) {
249
+ SassLiteral::assertType($colour, 'SassColour');
250
+ return new SassNumber($colour->alpha);
251
+ }
252
+
253
+ /*
254
+ * Colour Adjustments
255
+ */
256
+
257
+ /**
258
+ * Changes the hue of a colour while retaining the lightness and saturation.
259
+ * @param SassColour The colour to adjust
260
+ * @param SassNumber The amount to adjust the colour by
261
+ * @return new SassColour The adjusted colour
262
+ * @throws SassScriptFunctionException If $colour is not a colour or
263
+ * $degrees is not a number
264
+ */
265
+ public static function adjust_hue($colour, $degrees) {
266
+ SassLiteral::assertType($colour, 'SassColour');
267
+ SassLiteral::assertType($degrees, 'SassNumber');
268
+ return $colour->with(array('hue' => $colour->hue + $degrees->value));
269
+ }
270
+
271
+ /**
272
+ * Makes a colour lighter.
273
+ * @param SassColour The colour to lighten
274
+ * @param SassNumber The amount to lighten the colour by
275
+ * @param SassBoolean Whether the amount is a proportion of the current value
276
+ * (true) or the total range (false).
277
+ * The default is false - the amount is a proportion of the total range.
278
+ * If the colour lightness value is 40% and the amount is 50%,
279
+ * the resulting colour lightness value is 90% if the amount is a proportion
280
+ * of the total range, whereas it is 60% if the amount is a proportion of the
281
+ * current value.
282
+ * @return new SassColour The lightened colour
283
+ * @throws SassScriptFunctionException If $colour is not a colour or
284
+ * $amount is not a number
285
+ * @see lighten_rel
286
+ */
287
+ public static function lighten($colour, $amount, $ofCurrent = false) {
288
+ return self::adjust($colour, $amount, $ofCurrent, 'lightness', self::INCREASE, 0, 100, '%');
289
+ }
290
+
291
+ /**
292
+ * Makes a colour darker.
293
+ * @param SassColour The colour to darken
294
+ * @param SassNumber The amount to darken the colour by
295
+ * @param SassBoolean Whether the amount is a proportion of the current value
296
+ * (true) or the total range (false).
297
+ * The default is false - the amount is a proportion of the total range.
298
+ * If the colour lightness value is 80% and the amount is 50%,
299
+ * the resulting colour lightness value is 30% if the amount is a proportion
300
+ * of the total range, whereas it is 40% if the amount is a proportion of the
301
+ * current value.
302
+ * @return new SassColour The darkened colour
303
+ * @throws SassScriptFunctionException If $colour is not a colour or
304
+ * $amount is not a number
305
+ * @see adjust
306
+ */
307
+ public static function darken($colour, $amount, $ofCurrent = false) {
308
+ return self::adjust($colour, $amount, $ofCurrent, 'lightness', self::DECREASE, 0, 100, '%');
309
+ }
310
+
311
+ /**
312
+ * Makes a colour more saturated.
313
+ * @param SassColour The colour to saturate
314
+ * @param SassNumber The amount to saturate the colour by
315
+ * @param SassBoolean Whether the amount is a proportion of the current value
316
+ * (true) or the total range (false).
317
+ * The default is false - the amount is a proportion of the total range.
318
+ * If the colour saturation value is 40% and the amount is 50%,
319
+ * the resulting colour saturation value is 90% if the amount is a proportion
320
+ * of the total range, whereas it is 60% if the amount is a proportion of the
321
+ * current value.
322
+ * @return new SassColour The saturated colour
323
+ * @throws SassScriptFunctionException If $colour is not a colour or
324
+ * $amount is not a number
325
+ * @see adjust
326
+ */
327
+ public static function saturate($colour, $amount, $ofCurrent = false) {
328
+ return self::adjust($colour, $amount, $ofCurrent, 'saturation', self::INCREASE, 0, 100, '%');
329
+ }
330
+
331
+ /**
332
+ * Makes a colour less saturated.
333
+ * @param SassColour The colour to desaturate
334
+ * @param SassNumber The amount to desaturate the colour by
335
+ * @param SassBoolean Whether the amount is a proportion of the current value
336
+ * (true) or the total range (false).
337
+ * The default is false - the amount is a proportion of the total range.
338
+ * If the colour saturation value is 80% and the amount is 50%,
339
+ * the resulting colour saturation value is 30% if the amount is a proportion
340
+ * of the total range, whereas it is 40% if the amount is a proportion of the
341
+ * current value.
342
+ * @return new SassColour The desaturateed colour
343
+ * @throws SassScriptFunctionException If $colour is not a colour or
344
+ * $amount is not a number
345
+ * @see adjust
346
+ */
347
+ public static function desaturate($colour, $amount, $ofCurrent = false) {
348
+ return self::adjust($colour, $amount, $ofCurrent, 'saturation', self::DECREASE, 0, 100, '%');
349
+ }
350
+
351
+ /**
352
+ * Makes a colour more opaque.
353
+ * @param SassColour The colour to opacify
354
+ * @param SassNumber The amount to opacify the colour by
355
+ * If this is a unitless number between 0 and 1 the adjustment is absolute,
356
+ * if it is a percentage the adjustment is relative.
357
+ * If the colour alpha value is 0.4
358
+ * if the amount is 0.5 the resulting colour alpha value is 0.9,
359
+ * whereas if the amount is 50% the resulting colour alpha value is 0.6.
360
+ * @return new SassColour The opacified colour
361
+ * @throws SassScriptFunctionException If $colour is not a colour or
362
+ * $amount is not a number
363
+ * @see opacify_rel
364
+ */
365
+ public static function opacify($colour, $amount, $ofCurrent = false) {
366
+ $units = self::units($amount);
367
+ return self::adjust($colour, $amount, $ofCurrent, 'alpha', self::INCREASE, 0, ($units === '%' ? 100 : 1), $units);
368
+ }
369
+
370
+ /**
371
+ * Makes a colour more transparent.
372
+ * @param SassColour The colour to transparentize
373
+ * @param SassNumber The amount to transparentize the colour by.
374
+ * If this is a unitless number between 0 and 1 the adjustment is absolute,
375
+ * if it is a percentage the adjustment is relative.
376
+ * If the colour alpha value is 0.8
377
+ * if the amount is 0.5 the resulting colour alpha value is 0.3,
378
+ * whereas if the amount is 50% the resulting colour alpha value is 0.4.
379
+ * @return new SassColour The transparentized colour
380
+ * @throws SassScriptFunctionException If $colour is not a colour or
381
+ * $amount is not a number
382
+ */
383
+ public static function transparentize($colour, $amount, $ofCurrent = false) {
384
+ $units = self::units($amount);
385
+ return self::adjust($colour, $amount, $ofCurrent, 'alpha', self::DECREASE, 0, ($units === '%' ? 100 : 1), $units);
386
+ }
387
+
388
+ /**
389
+ * Makes a colour more opaque.
390
+ * Alias for {@link opacify}.
391
+ * @param SassColour The colour to opacify
392
+ * @param SassNumber The amount to opacify the colour by
393
+ * @param SassBoolean Whether the amount is a proportion of the current value
394
+ * (true) or the total range (false).
395
+ * @return new SassColour The opacified colour
396
+ * @throws SassScriptFunctionException If $colour is not a colour or
397
+ * $amount is not a number
398
+ * @see opacify
399
+ */
400
+ public static function fade_in($colour, $amount, $ofCurrent = false) {
401
+ return self::opacify($colour, $amount, $ofCurrent);
402
+ }
403
+
404
+ /**
405
+ * Makes a colour more transparent.
406
+ * Alias for {@link transparentize}.
407
+ * @param SassColour The colour to transparentize
408
+ * @param SassNumber The amount to transparentize the colour by
409
+ * @param SassBoolean Whether the amount is a proportion of the current value
410
+ * (true) or the total range (false).
411
+ * @return new SassColour The transparentized colour
412
+ * @throws SassScriptFunctionException If $colour is not a colour or
413
+ * $amount is not a number
414
+ * @see transparentize
415
+ */
416
+ public static function fade_out($colour, $amount, $ofCurrent = false) {
417
+ return self::transparentize($colour, $amount, $ofCurrent);
418
+ }
419
+
420
+ /**
421
+ * Returns the complement of a colour.
422
+ * Rotates the hue by 180 degrees.
423
+ * @param SassColour The colour
424
+ * @return new SassColour The comlemented colour
425
+ * @uses adjust_hue()
426
+ */
427
+ public static function complement($colour) {
428
+ return self::adjust_hue($colour, new SassNumber('180deg'));
429
+ }
430
+
431
+ /**
432
+ * Greyscale for non-english speakers.
433
+ * @param SassColour The colour
434
+ * @return new SassColour The greyscale colour
435
+ * @see desaturate
436
+ */
437
+ public static function grayscale($colour) {
438
+ return self::desaturate($colour, new SassNumber(100));
439
+ }
440
+
441
+ /**
442
+ * Converts a colour to greyscale.
443
+ * Reduces the saturation to zero.
444
+ * @param SassColour The colour
445
+ * @return new SassColour The greyscale colour
446
+ * @see desaturate
447
+ */
448
+ public static function greyscale($colour) {
449
+ return self::desaturate($colour, new SassNumber(100));
450
+ }
451
+
452
+ /**
453
+ * Mixes two colours together.
454
+ * Takes the average of each of the RGB components, optionally weighted by the
455
+ * given percentage. The opacity of the colours is also considered when
456
+ * weighting the components.
457
+ * The weight specifies the amount of the first colour that should be included
458
+ * in the returned colour. The default, 50%, means that half the first colour
459
+ * and half the second colour should be used. 25% means that a quarter of the
460
+ * first colour and three quarters of the second colour should be used.
461
+ * For example:
462
+ * mix(#f00, #00f) => #7f007f
463
+ * mix(#f00, #00f, 25%) => #3f00bf
464
+ * mix(rgba(255, 0, 0, 0.5), #00f) => rgba(63, 0, 191, 0.75)
465
+ *
466
+ * @param SassColour The first colour
467
+ * @param SassColour The second colour
468
+ * @param float Percentage of the first colour to use
469
+ * @return new SassColour The mixed colour
470
+ * @throws SassScriptFunctionException If $colour1 or $colour2 is
471
+ * not a colour
472
+ */
473
+ public static function mix($colour1, $colour2, $weight = null) {
474
+ if (is_null($weight)) $weight = new SassNumber('50%');
475
+ SassLiteral::assertType($colour1, 'SassColour');
476
+ SassLiteral::assertType($colour2, 'SassColour');
477
+ SassLiteral::assertType($weight, 'SassNumber');
478
+ SassLiteral::assertInRange($weight, 0, 100, '%');
479
+
480
+ /*
481
+ * This algorithm factors in both the user-provided weight
482
+ * and the difference between the alpha values of the two colours
483
+ * to decide how to perform the weighted average of the two RGB values.
484
+ *
485
+ * It works by first normalizing both parameters to be within [-1, 1],
486
+ * where 1 indicates "only use colour1", -1 indicates "only use colour 0",
487
+ * and all values in between indicated a proportionately weighted average.
488
+ *
489
+ * Once we have the normalized variables w and a,
490
+ * we apply the formula (w + a)/(1 + w*a)
491
+ * to get the combined weight (in [-1, 1]) of colour1.
492
+ * This formula has two especially nice properties:
493
+ *
494
+ * * When either w or a are -1 or 1, the combined weight is also that number
495
+ * (cases where w * a == -1 are undefined, and handled as a special case).
496
+ *
497
+ * * When a is 0, the combined weight is w, and vice versa
498
+ *
499
+ * Finally, the weight of colour1 is renormalized to be within [0, 1]
500
+ * and the weight of colour2 is given by 1 minus the weight of colour1.
501
+ */
502
+
503
+ $p = $weight->value/100;
504
+ $w = $p * 2 - 1;
505
+ $a = $colour1->alpha - $colour2->alpha;
506
+
507
+ $w1 = ((($w * $a == -1) ? $w : ($w + $a)/(1 + $w * $a)) + 1) / 2;
508
+ $w2 = 1 - $w1;
509
+
510
+ $rgb1 = $colour1->rgb();
511
+ $rgb2 = $colour2->rgb();
512
+ $rgba = array();
513
+ foreach ($rgb1 as $key=>$value) {
514
+ $rgba[$key] = $value * $w1 + $rgb2[$key] * $w2;
515
+ } // foreach
516
+ $rgba[] = $colour1->alpha * $p + $colour2->alpha * (1 - $p);
517
+ return new SassColour($rgba);
518
+ }
519
+
520
+ /**
521
+ * Adjusts the colour
522
+ * @param SassColour the colour to adjust
523
+ * @param SassNumber the amount to adust by
524
+ * @param boolean whether the amount is a proportion of the current value or
525
+ * the total range
526
+ * @param string the attribute to adjust
527
+ * @param boolean whether to decrease (false) or increase (true) the value of the attribute
528
+ * @param float minimum value the amount can be
529
+ * @param float maximum value the amount can bemixed
530
+ * @param string amount units
531
+ */
532
+ private static function adjust($colour, $amount, $ofCurrent, $attribute, $op, $min, $max, $units='') {
533
+ SassLiteral::assertType($colour, 'SassColour');
534
+ SassLiteral::assertType($amount, 'SassNumber');
535
+ SassLiteral::assertInRange($amount, $min, $max, $units);
536
+ if (!is_bool($ofCurrent)) {
537
+ SassLiteral::assertType($ofCurrent, 'SassBoolean');
538
+ $ofCurrent = $ofCurrent->value;
539
+ }
540
+
541
+ $amount = $amount->value * (($attribute === 'alpha' && $ofCurrent && $units === '') ? 100 : 1);
542
+
543
+ return $colour->with(array(
544
+ $attribute => self::inRange((
545
+ $ofCurrent ?
546
+ $colour->$attribute * (1 + ($amount * ($op === self::INCREASE ? 1 : -1))/100) :
547
+ $colour->$attribute + ($amount * ($op === self::INCREASE ? 1 : -1))
548
+ ), $min, $max)
549
+ ));
550
+ }
551
+
552
+ /*
553
+ * Number Functions
554
+ */
555
+
556
+ /**
557
+ * Finds the absolute value of a number.
558
+ * For example:
559
+ * abs(10px) => 10px
560
+ * abs(-10px) => 10px
561
+ *
562
+ * @param SassNumber The number to round
563
+ * @return SassNumber The absolute value of the number
564
+ * @throws SassScriptFunctionException If $number is not a number
565
+ */
566
+ public static function abs($number) {
567
+ SassLiteral::assertType($number, 'SassNumber');
568
+ return new SassNumber(abs($number->value).$number->units);
569
+ }
570
+
571
+ /**
572
+ * Rounds a number up to the nearest whole number.
573
+ * For example:
574
+ * ceil(10.4px) => 11px
575
+ * ceil(10.6px) => 11px
576
+ *
577
+ * @param SassNumber The number to round
578
+ * @return new SassNumber The rounded number
579
+ * @throws SassScriptFunctionException If $number is not a number
580
+ */
581
+ public static function ceil($number) {
582
+ SassLiteral::assertType($number, 'SassNumber');
583
+ return new SassNumber(ceil($number->value).$number->units);
584
+ }
585
+
586
+ /**
587
+ * Rounds down to the nearest whole number.
588
+ * For example:
589
+ * floor(10.4px) => 10px
590
+ * floor(10.6px) => 10px
591
+ *
592
+ * @param SassNumber The number to round
593
+ * @return new SassNumber The rounded number
594
+ * @throws SassScriptFunctionException If $value is not a number
595
+ */
596
+ public static function floor($number) {
597
+ SassLiteral::assertType($number, 'SassNumber');
598
+ return new SassNumber(floor($number->value).$number->units);
599
+ }
600
+
601
+ /**
602
+ * Rounds a number to the nearest whole number.
603
+ * For example:
604
+ * round(10.4px) => 10px
605
+ * round(10.6px) => 11px
606
+ *
607
+ * @param SassNumber The number to round
608
+ * @return new SassNumber The rounded number
609
+ * @throws SassScriptFunctionException If $number is not a number
610
+ */
611
+ public static function round($number) {
612
+ SassLiteral::assertType($number, 'SassNumber');
613
+ return new SassNumber(round($number->value).$number->units);
614
+ }
615
+
616
+ /**
617
+ * Returns true if two numbers are similar enough to be added, subtracted,
618
+ * or compared.
619
+ * @param SassNumber The first number to test
620
+ * @param SassNumber The second number to test
621
+ * @return new SassBoolean True if the numbers are similar
622
+ * @throws SassScriptFunctionException If $number1 or $number2 is not
623
+ * a number
624
+ */
625
+ public static function comparable($number1, $number2) {
626
+ SassLiteral::assertType($number1, 'SassNumber');
627
+ SassLiteral::assertType($number2, 'SassNumber');
628
+ return new SassBoolean($number1->isComparableTo($number2));
629
+ }
630
+
631
+ /**
632
+ * Converts a decimal number to a percentage.
633
+ * For example:
634
+ * percentage(100px / 50px) => 200%
635
+ *
636
+ * @param SassNumber The decimal number to convert to a percentage
637
+ * @return new SassNumber The number as a percentage
638
+ * @throws SassScriptFunctionException If $number isn't a unitless number
639
+ */
640
+ public static function percentage($number) {
641
+ if (!$number instanceof SassNumber || $number->hasUnits()) {
642
+ throw new SassScriptFunctionException('{what} must be a {type}', array('{what}'=>'number', '{type}'=>'unitless SassNumber'), SassScriptParser::$context->node);
643
+ }
644
+ $number->value *= 100;
645
+ $number->units = '%';
646
+ return $number;
647
+ }
648
+
649
+ /**
650
+ * Inspects the unit of the number, returning it as a quoted string.
651
+ * Alias for units.
652
+ * @param SassNumber The number to inspect
653
+ * @return new SassString The units of the number
654
+ * @throws SassScriptFunctionException If $number is not a number
655
+ * @see units
656
+ */
657
+ public static function unit($number) {
658
+ return self::units($number);
659
+ }
660
+
661
+ /**
662
+ * Inspects the units of the number, returning it as a quoted string.
663
+ * @param SassNumber The number to inspect
664
+ * @return new SassString The units of the number
665
+ * @throws SassScriptFunctionException If $number is not a number
666
+ */
667
+ public static function units($number) {
668
+ SassLiteral::assertType($number, 'SassNumber');
669
+ return new SassString($number->units);
670
+ }
671
+
672
+ /**
673
+ * Inspects the unit of the number, returning a boolean indicating if it is
674
+ * unitless.
675
+ * @param SassNumber The number to inspect
676
+ * @return new SassBoolean True if the number is unitless, false if it has units.
677
+ * @throws SassScriptFunctionException If $number is not a number
678
+ */
679
+ public static function unitless() {
680
+ SassLiteral::assertType($number, 'SassNumber');
681
+ return new SassBoolean(!$number->hasUnits());
682
+ }
683
+
684
+ /*
685
+ * String Functions
686
+ */
687
+
688
+ /**
689
+ * Add quotes to a string if the string isn't quoted,
690
+ * or returns the same string if it is.
691
+ * @param string String to quote
692
+ * @return new SassString Quoted string
693
+ * @throws SassScriptFunctionException If $string is not a string
694
+ * @see unquote
695
+ */
696
+ public static function quote($string) {
697
+ SassLiteral::assertType($string, 'SassString');
698
+ return new SassString('"'.$string->value.'"');
699
+ }
700
+
701
+ /**
702
+ * Removes quotes from a string if the string is quoted, or returns the same
703
+ * string if it's not.
704
+ * @param string String to unquote
705
+ * @return new SassString Unuoted string
706
+ * @throws SassScriptFunctionException If $string is not a string
707
+ * @see quote
708
+ */
709
+ public static function unquote($string) {
710
+ SassLiteral::assertType($string, 'SassString');
711
+ return new SassString($string->value);
712
+ }
713
+
714
+ /**
715
+ * Returns the variable whose name is the string.
716
+ * @param string String to unquote
717
+ * @return
718
+ * @throws SassScriptFunctionException If $string is not a string
719
+ */
720
+ public static function get_var($string) {
721
+ SassLiteral::assertType($string, 'SassString');
722
+ return new SassString($string->toVar());
723
+ }
724
+
725
+ /*
726
+ * Misc. Functions
727
+ */
728
+
729
+ /**
730
+ * Inspects the type of the argument, returning it as an unquoted string.
731
+ * @param SassLiteral The object to inspect
732
+ * @return new SassString The type of object
733
+ * @throws SassScriptFunctionException If $obj is not an instance of a
734
+ * SassLiteral
735
+ */
736
+ public static function type_of($obj) {
737
+ SassLiteral::assertType($obj, SassLiteral);
738
+ return new SassString($obj->typeOf);
739
+ }
740
+
741
+ /**
742
+ * Ensures the value is within the given range, clipping it if needed.
743
+ * @param float the value to test
744
+ * @param float the minimum value
745
+ * @param float the maximum value
746
+ * @return the value clipped to the range
747
+ */
748
+ private static function inRange($value, $min, $max) {
749
+ return ($value < $min ? $min : ($value > $max ? $max : $value));
750
+ }
751
+ }