radiant 0.6.6 → 0.6.7

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of radiant might be problematic. Click here for more details.

Files changed (208) hide show
  1. data/CHANGELOG +15 -0
  2. data/CONTRIBUTORS +8 -0
  3. data/app/controllers/admin/page_controller.rb +1 -11
  4. data/app/controllers/admin/welcome_controller.rb +5 -6
  5. data/app/controllers/application.rb +2 -0
  6. data/app/controllers/site_controller.rb +1 -0
  7. data/app/helpers/admin/page_helper.rb +36 -0
  8. data/app/helpers/admin/regions_helper.rb +28 -0
  9. data/app/helpers/admin/user_helper.rb +6 -0
  10. data/app/helpers/application_helper.rb +2 -1
  11. data/app/models/user.rb +7 -8
  12. data/app/views/admin/extension/index.html.haml +28 -0
  13. data/app/views/admin/layout/edit.html.haml +44 -0
  14. data/app/views/admin/layout/index.html.haml +25 -0
  15. data/app/views/admin/layout/remove.html.haml +16 -0
  16. data/app/views/admin/page/_meta_row.html.haml +6 -0
  17. data/app/views/admin/page/_node.html.haml +25 -0
  18. data/app/views/admin/page/_part.html.haml +17 -0
  19. data/app/views/admin/page/_tag_reference.html.haml +3 -0
  20. data/app/views/admin/page/children.html.haml +2 -0
  21. data/app/views/admin/page/edit.html.haml +114 -0
  22. data/app/views/admin/page/index.html.haml +28 -0
  23. data/app/views/admin/page/remove.html.haml +20 -0
  24. data/app/views/admin/snippet/edit.html.haml +36 -0
  25. data/app/views/admin/snippet/index.html.haml +20 -0
  26. data/app/views/admin/snippet/remove.html.haml +19 -0
  27. data/app/views/admin/user/edit.html.haml +80 -0
  28. data/app/views/admin/user/index.html.haml +23 -0
  29. data/app/views/admin/user/preferences.html.haml +28 -0
  30. data/app/views/admin/user/remove.html.haml +18 -0
  31. data/app/views/admin/welcome/login.html.haml +44 -0
  32. data/app/views/layouts/application.html.haml +54 -0
  33. data/app/views/site/not_found.html.haml +3 -0
  34. data/db/migrate/019_add_salt_to_users.rb +11 -0
  35. data/db/schema.rb +2 -1
  36. data/lib/login_system.rb +1 -0
  37. data/lib/radiant.rb +1 -1
  38. data/lib/radiant/admin_ui.rb +65 -0
  39. data/lib/radiant/admin_ui/region_partials.rb +18 -0
  40. data/lib/radiant/admin_ui/region_set.rb +35 -0
  41. data/lib/tasks/extensions.rake +33 -0
  42. data/public/javascripts/admin/admin.js +8 -2
  43. data/public/javascripts/admin/sitemap.js +2 -1
  44. data/public/stylesheets/admin/main.css +4 -0
  45. data/spec/controllers/admin/abstract_model_controller_spec.rb +2 -0
  46. data/spec/controllers/admin/page_controller_spec.rb +3 -28
  47. data/spec/controllers/admin/user_controller_spec.rb +1 -1
  48. data/spec/controllers/admin/welcome_controller_spec.rb +26 -0
  49. data/spec/helpers/admin/page_helper_spec.rb +4 -0
  50. data/spec/helpers/admin/regions_helper_spec.rb +47 -0
  51. data/spec/helpers/admin/user_helper_spec.rb +7 -0
  52. data/spec/helpers/application_helper_spec.rb +7 -3
  53. data/spec/lib/login_system_spec.rb +5 -0
  54. data/spec/lib/radiant/admin_ui/region_partials_spec.rb +35 -0
  55. data/spec/lib/radiant/admin_ui/region_set_spec.rb +61 -0
  56. data/spec/lib/radiant/admin_ui_spec.rb +74 -18
  57. data/spec/models/user_spec.rb +11 -4
  58. data/spec/scenarios/users_scenario.rb +2 -2
  59. data/vendor/plugins/haml/MIT-LICENSE +20 -0
  60. data/vendor/plugins/haml/README.rdoc +319 -0
  61. data/vendor/plugins/haml/Rakefile +158 -0
  62. data/vendor/plugins/haml/TODO +9 -0
  63. data/vendor/plugins/haml/VERSION +1 -0
  64. data/vendor/plugins/haml/bin/css2sass +7 -0
  65. data/vendor/plugins/haml/bin/haml +8 -0
  66. data/vendor/plugins/haml/bin/html2haml +7 -0
  67. data/vendor/plugins/haml/bin/sass +8 -0
  68. data/vendor/plugins/haml/extra/haml-mode.el +328 -0
  69. data/vendor/plugins/haml/extra/sass-mode.el +88 -0
  70. data/vendor/plugins/haml/init.rb +2 -0
  71. data/vendor/plugins/haml/lib/haml.rb +977 -0
  72. data/vendor/plugins/haml/lib/haml/buffer.rb +229 -0
  73. data/vendor/plugins/haml/lib/haml/engine.rb +274 -0
  74. data/vendor/plugins/haml/lib/haml/error.rb +23 -0
  75. data/vendor/plugins/haml/lib/haml/exec.rb +347 -0
  76. data/vendor/plugins/haml/lib/haml/filters.rb +249 -0
  77. data/vendor/plugins/haml/lib/haml/helpers.rb +413 -0
  78. data/vendor/plugins/haml/lib/haml/helpers/action_view_extensions.rb +45 -0
  79. data/vendor/plugins/haml/lib/haml/helpers/action_view_mods.rb +122 -0
  80. data/vendor/plugins/haml/lib/haml/html.rb +188 -0
  81. data/vendor/plugins/haml/lib/haml/precompiler.rb +757 -0
  82. data/vendor/plugins/haml/lib/haml/template.rb +43 -0
  83. data/vendor/plugins/haml/lib/haml/template/patch.rb +58 -0
  84. data/vendor/plugins/haml/lib/haml/template/plugin.rb +72 -0
  85. data/vendor/plugins/haml/lib/sass.rb +833 -0
  86. data/vendor/plugins/haml/lib/sass/constant.rb +245 -0
  87. data/vendor/plugins/haml/lib/sass/constant/color.rb +101 -0
  88. data/vendor/plugins/haml/lib/sass/constant/literal.rb +53 -0
  89. data/vendor/plugins/haml/lib/sass/constant/number.rb +87 -0
  90. data/vendor/plugins/haml/lib/sass/constant/operation.rb +30 -0
  91. data/vendor/plugins/haml/lib/sass/constant/string.rb +22 -0
  92. data/vendor/plugins/haml/lib/sass/css.rb +378 -0
  93. data/vendor/plugins/haml/lib/sass/engine.rb +459 -0
  94. data/vendor/plugins/haml/lib/sass/error.rb +35 -0
  95. data/vendor/plugins/haml/lib/sass/plugin.rb +165 -0
  96. data/vendor/plugins/haml/lib/sass/plugin/merb.rb +56 -0
  97. data/vendor/plugins/haml/lib/sass/plugin/rails.rb +24 -0
  98. data/vendor/plugins/haml/lib/sass/tree/attr_node.rb +53 -0
  99. data/vendor/plugins/haml/lib/sass/tree/comment_node.rb +20 -0
  100. data/vendor/plugins/haml/lib/sass/tree/directive_node.rb +46 -0
  101. data/vendor/plugins/haml/lib/sass/tree/node.rb +42 -0
  102. data/vendor/plugins/haml/lib/sass/tree/rule_node.rb +89 -0
  103. data/vendor/plugins/haml/lib/sass/tree/value_node.rb +16 -0
  104. data/vendor/plugins/haml/test/benchmark.rb +82 -0
  105. data/vendor/plugins/haml/test/haml/engine_test.rb +587 -0
  106. data/vendor/plugins/haml/test/haml/helper_test.rb +187 -0
  107. data/vendor/plugins/haml/test/haml/html2haml_test.rb +60 -0
  108. data/vendor/plugins/haml/test/haml/markaby/standard.mab +52 -0
  109. data/vendor/plugins/haml/test/haml/mocks/article.rb +6 -0
  110. data/vendor/plugins/haml/test/haml/results/content_for_layout.xhtml +16 -0
  111. data/vendor/plugins/haml/test/haml/results/eval_suppressed.xhtml +11 -0
  112. data/vendor/plugins/haml/test/haml/results/filters.xhtml +82 -0
  113. data/vendor/plugins/haml/test/haml/results/helpers.xhtml +94 -0
  114. data/vendor/plugins/haml/test/haml/results/helpful.xhtml +10 -0
  115. data/vendor/plugins/haml/test/haml/results/just_stuff.xhtml +64 -0
  116. data/vendor/plugins/haml/test/haml/results/list.xhtml +12 -0
  117. data/vendor/plugins/haml/test/haml/results/original_engine.xhtml +22 -0
  118. data/vendor/plugins/haml/test/haml/results/partials.xhtml +21 -0
  119. data/vendor/plugins/haml/test/haml/results/silent_script.xhtml +74 -0
  120. data/vendor/plugins/haml/test/haml/results/standard.xhtml +42 -0
  121. data/vendor/plugins/haml/test/haml/results/tag_parsing.xhtml +28 -0
  122. data/vendor/plugins/haml/test/haml/results/very_basic.xhtml +7 -0
  123. data/vendor/plugins/haml/test/haml/results/whitespace_handling.xhtml +94 -0
  124. data/vendor/plugins/haml/test/haml/rhtml/_av_partial_1.rhtml +12 -0
  125. data/vendor/plugins/haml/test/haml/rhtml/_av_partial_2.rhtml +8 -0
  126. data/vendor/plugins/haml/test/haml/rhtml/action_view.rhtml +62 -0
  127. data/vendor/plugins/haml/test/haml/rhtml/standard.rhtml +54 -0
  128. data/vendor/plugins/haml/test/haml/template_test.rb +168 -0
  129. data/vendor/plugins/haml/test/haml/templates/_av_partial_1.haml +9 -0
  130. data/vendor/plugins/haml/test/haml/templates/_av_partial_2.haml +5 -0
  131. data/vendor/plugins/haml/test/haml/templates/_partial.haml +8 -0
  132. data/vendor/plugins/haml/test/haml/templates/_text_area.haml +3 -0
  133. data/vendor/plugins/haml/test/haml/templates/action_view.haml +47 -0
  134. data/vendor/plugins/haml/test/haml/templates/breakage.haml +8 -0
  135. data/vendor/plugins/haml/test/haml/templates/content_for_layout.haml +10 -0
  136. data/vendor/plugins/haml/test/haml/templates/eval_suppressed.haml +11 -0
  137. data/vendor/plugins/haml/test/haml/templates/filters.haml +81 -0
  138. data/vendor/plugins/haml/test/haml/templates/helpers.haml +69 -0
  139. data/vendor/plugins/haml/test/haml/templates/helpful.haml +11 -0
  140. data/vendor/plugins/haml/test/haml/templates/just_stuff.haml +77 -0
  141. data/vendor/plugins/haml/test/haml/templates/list.haml +12 -0
  142. data/vendor/plugins/haml/test/haml/templates/original_engine.haml +17 -0
  143. data/vendor/plugins/haml/test/haml/templates/partialize.haml +1 -0
  144. data/vendor/plugins/haml/test/haml/templates/partials.haml +12 -0
  145. data/vendor/plugins/haml/test/haml/templates/silent_script.haml +40 -0
  146. data/vendor/plugins/haml/test/haml/templates/standard.haml +42 -0
  147. data/vendor/plugins/haml/test/haml/templates/tag_parsing.haml +24 -0
  148. data/vendor/plugins/haml/test/haml/templates/very_basic.haml +4 -0
  149. data/vendor/plugins/haml/test/haml/templates/whitespace_handling.haml +87 -0
  150. data/vendor/plugins/haml/test/haml/test_helper.rb +15 -0
  151. data/vendor/plugins/haml/test/profile.rb +65 -0
  152. data/vendor/plugins/haml/test/sass/engine_test.rb +276 -0
  153. data/vendor/plugins/haml/test/sass/plugin_test.rb +159 -0
  154. data/vendor/plugins/haml/test/sass/results/alt.css +4 -0
  155. data/vendor/plugins/haml/test/sass/results/basic.css +9 -0
  156. data/vendor/plugins/haml/test/sass/results/compact.css +5 -0
  157. data/vendor/plugins/haml/test/sass/results/complex.css +87 -0
  158. data/vendor/plugins/haml/test/sass/results/compressed.css +1 -0
  159. data/vendor/plugins/haml/test/sass/results/constants.css +14 -0
  160. data/vendor/plugins/haml/test/sass/results/expanded.css +19 -0
  161. data/vendor/plugins/haml/test/sass/results/import.css +29 -0
  162. data/vendor/plugins/haml/test/sass/results/mixins.css +95 -0
  163. data/vendor/plugins/haml/test/sass/results/multiline.css +24 -0
  164. data/vendor/plugins/haml/test/sass/results/nested.css +22 -0
  165. data/vendor/plugins/haml/test/sass/results/parent_ref.css +13 -0
  166. data/vendor/plugins/haml/test/sass/results/subdir/nested_subdir/nested_subdir.css +1 -0
  167. data/vendor/plugins/haml/test/sass/results/subdir/subdir.css +1 -0
  168. data/vendor/plugins/haml/test/sass/templates/_partial.sass +2 -0
  169. data/vendor/plugins/haml/test/sass/templates/alt.sass +16 -0
  170. data/vendor/plugins/haml/test/sass/templates/basic.sass +23 -0
  171. data/vendor/plugins/haml/test/sass/templates/bork.sass +2 -0
  172. data/vendor/plugins/haml/test/sass/templates/bork2.sass +2 -0
  173. data/vendor/plugins/haml/test/sass/templates/compact.sass +17 -0
  174. data/vendor/plugins/haml/test/sass/templates/complex.sass +310 -0
  175. data/vendor/plugins/haml/test/sass/templates/compressed.sass +15 -0
  176. data/vendor/plugins/haml/test/sass/templates/constants.sass +97 -0
  177. data/vendor/plugins/haml/test/sass/templates/expanded.sass +17 -0
  178. data/vendor/plugins/haml/test/sass/templates/import.sass +11 -0
  179. data/vendor/plugins/haml/test/sass/templates/importee.sass +14 -0
  180. data/vendor/plugins/haml/test/sass/templates/mixins.sass +76 -0
  181. data/vendor/plugins/haml/test/sass/templates/multiline.sass +20 -0
  182. data/vendor/plugins/haml/test/sass/templates/nested.sass +25 -0
  183. data/vendor/plugins/haml/test/sass/templates/parent_ref.sass +25 -0
  184. data/vendor/plugins/haml/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +3 -0
  185. data/vendor/plugins/haml/test/sass/templates/subdir/subdir.sass +6 -0
  186. metadata +185 -24
  187. data/app/views/admin/extension/index.html.erb +0 -40
  188. data/app/views/admin/layout/edit.html.erb +0 -39
  189. data/app/views/admin/layout/index.html.erb +0 -38
  190. data/app/views/admin/layout/remove.html.erb +0 -17
  191. data/app/views/admin/page/_meta_row.html.erb +0 -4
  192. data/app/views/admin/page/_node.html.erb +0 -28
  193. data/app/views/admin/page/_part.html.erb +0 -13
  194. data/app/views/admin/page/_tag_reference.html.erb +0 -4
  195. data/app/views/admin/page/children.html.erb +0 -4
  196. data/app/views/admin/page/edit.html.erb +0 -140
  197. data/app/views/admin/page/index.html.erb +0 -31
  198. data/app/views/admin/page/remove.html.erb +0 -14
  199. data/app/views/admin/snippet/edit.html.erb +0 -29
  200. data/app/views/admin/snippet/index.html.erb +0 -36
  201. data/app/views/admin/snippet/remove.html.erb +0 -16
  202. data/app/views/admin/user/edit.html.erb +0 -54
  203. data/app/views/admin/user/index.html.erb +0 -43
  204. data/app/views/admin/user/preferences.html.erb +0 -29
  205. data/app/views/admin/user/remove.html.erb +0 -16
  206. data/app/views/admin/welcome/login.html.erb +0 -51
  207. data/app/views/layouts/application.html.erb +0 -83
  208. data/app/views/site/not_found.html.erb +0 -3
@@ -0,0 +1,11 @@
1
+ %div[@article]
2
+ %h1= @article.title
3
+ %div= @article.body
4
+ #id[@article] id
5
+ .class[@article] class
6
+ #id.class[@article] id class
7
+ %div{:class => "article full"}[@article]= "boo"
8
+ %div{'class' => "article full"}[@article]= "moo"
9
+ %div.articleFull[@article]= "foo"
10
+ %span[@not_a_real_variable_and_will_be_nil]
11
+ Boo
@@ -0,0 +1,77 @@
1
+ !!! XML
2
+ !!! XML ISO-8859-1
3
+ !!! XML UtF-8 Foo bar
4
+ !!!
5
+ !!! 1.1
6
+ !!! 1.1 Strict
7
+ !!! Strict foo bar
8
+ !!! FRAMESET
9
+ %strong{:apos => "Foo's bar!"} Boo!
10
+ == Embedded? false!
11
+ == Embedded? #{true}!
12
+ - embedded = true
13
+ == Embedded? #{embedded}!
14
+ == Embedded? #{"twice! #{true}"}!
15
+ == Embedded? #{"one"} af"t"er #{"another"}!
16
+ %p== Embedded? false!
17
+ %p== Embedded? #{true}!
18
+ - embedded = true
19
+ %p== Embedded? #{embedded}!
20
+ %p== Embedded? #{"twice! #{true}"}!
21
+ %p== Embedded? #{"one"} af"t"er #{"another"}!
22
+ .render= render :inline => "%em= 'wow!'", :type => :haml
23
+ = "stuff followed by whitespace"
24
+
25
+ - if true
26
+
27
+ %strong block with whitespace
28
+ %p
29
+ \Escape
30
+ \- character
31
+ \%p foo
32
+ \yee\ha
33
+ / Short comment
34
+ /
35
+ This is a block comment
36
+ cool, huh?
37
+ %strong there can even be sub-tags!
38
+ = "Or script!"
39
+ -# Haml comment
40
+ -#
41
+ Nested Haml comment
42
+ - raise 'dead'
43
+ %p{ :class => "" } class attribute should appear!
44
+ %p{ :gorbachev => nil } this attribute shouldn't appear
45
+ /[if lte IE6] conditional comment!
46
+ /[if gte IE7]
47
+ %p Block conditional comment
48
+ %div
49
+ %h1 Cool, eh?
50
+ /[if gte IE5.2]
51
+ Woah a period.
52
+ = "test" |
53
+ "test" |
54
+ -# Hard tabs shouldn't throw errors.
55
+
56
+ - case :foo
57
+ - when :bar
58
+ %br Blah
59
+ - when :foo
60
+ %br
61
+ - case :foo
62
+ - when :bar
63
+ %meta{ :foo => 'blah'}
64
+ - when :foo
65
+ %meta{ :foo => 'bar'}
66
+ %img
67
+ %hr
68
+ %link
69
+ %script Inline content
70
+ %br
71
+ Nested content
72
+ %p.foo{:class => true ? 'bar' : 'baz'}[@article] Blah
73
+ %p.foo{:class => false ? 'bar' : ''}[@article] Blah
74
+ %p.qux{:class => 'quux'}[@article] Blump
75
+ == #{"Woah inner quotes"}
76
+ %p.dynamic_quote{:quotes => "single '", :dyn => 1 + 2}
77
+ %p.dynamic_self_closing{:dyn => 1 + 2}/
@@ -0,0 +1,12 @@
1
+ ! Not a Doctype !
2
+ %ul
3
+ %li a
4
+ %li b
5
+ %li c
6
+ %li d
7
+ %li e
8
+ %li f
9
+ %li g
10
+ %li h
11
+ %li i
12
+
@@ -0,0 +1,17 @@
1
+ !!!
2
+ %html
3
+ %head
4
+ %title Stop. haml time
5
+ #content
6
+ %h1 This is a title!
7
+ %p Lorem ipsum dolor sit amet, consectetur adipisicing elit
8
+ %p{:class => 'foo'} Cigarettes!
9
+ %h2 Man alive!
10
+ %ul.things
11
+ %li Slippers
12
+ %li Shoes
13
+ %li Bathrobe
14
+ %li Coffee
15
+ %pre
16
+ This is some text that's in a pre block!
17
+ Let's see what happens when it's rendered! What about now, since we're on a new line?
@@ -0,0 +1 @@
1
+ = render :file => "#{name}.haml"
@@ -0,0 +1,12 @@
1
+ - @foo = 'value one'
2
+ %p
3
+ @foo =
4
+ = @foo
5
+ - @foo = 'value two'
6
+ %p
7
+ @foo =
8
+ = @foo
9
+ = render :file => "_partial.haml"
10
+ %p
11
+ @foo =
12
+ = @foo
@@ -0,0 +1,40 @@
1
+ %div
2
+ %h1 I can count!
3
+ - (1..20).each do |i|
4
+ = i
5
+ %h1 I know my ABCs!
6
+ %ul
7
+ - ('a'..'z').each do |i|
8
+ %li= i
9
+ %h1 I can catch errors!
10
+ - begin
11
+ - String.silly
12
+ - rescue NameError => e
13
+ = "Oh no! \"#{e}\" happened!"
14
+ %p
15
+ "false" is:
16
+ - if false
17
+ = "true"
18
+ - else
19
+ = "false"
20
+ - if true
21
+ - 5.times do |i|
22
+ - if i % 2 == 1
23
+ Odd!
24
+ - else
25
+ Even!
26
+ - else
27
+ = "This can't happen!"
28
+ - 13 |
29
+ .foo
30
+ %strong foobar
31
+ - 5.times |
32
+ do |
33
+ |a| |
34
+ %strong= a
35
+ .test
36
+ - "foo |
37
+ bar |
38
+ baz" |
39
+
40
+ %p boom
@@ -0,0 +1,42 @@
1
+ !!!
2
+ %html{html_attrs}
3
+ %head
4
+ %title Hampton Catlin Is Totally Awesome
5
+ %meta{"http-equiv" => "Content-Type", :content => "text/html; charset=utf-8"}
6
+ %body
7
+ / You're In my house now!
8
+ .header
9
+ Yes, ladies and gentileman. He is just that egotistical.
10
+ Fantastic! This should be multi-line output
11
+ The question is if this would translate! Ahah!
12
+ = 1 + 9 + 8 + 2 #numbers should work and this should be ignored
13
+ #body= " Quotes should be loved! Just like people!"
14
+ - 120.times do |number|
15
+ - number
16
+ Wow.|
17
+ %p
18
+ = "Holy cow " + |
19
+ "multiline " + |
20
+ "tags! " + |
21
+ "A pipe (|) even!" |
22
+ = [1, 2, 3].collect { |n| "PipesIgnored|" }
23
+ = [1, 2, 3].collect { |n| |
24
+ n.to_s |
25
+ }.join("|") |
26
+ %div.silent
27
+ - foo = String.new
28
+ - foo << "this"
29
+ - foo << " shouldn't"
30
+ - foo << " evaluate"
31
+ = foo + " but now it should!"
32
+ -# Woah crap a comment!
33
+
34
+ -# That was a line that shouldn't close everything.
35
+ %ul.really.cool
36
+ - ('a'..'f').each do |a|
37
+ %li= a
38
+ #combo.of_divs_with_underscore= @should_eval = "with this text"
39
+ = [ 104, 101, 108, 108, 111 ].map do |byte|
40
+ - byte.chr
41
+ .footer
42
+ %strong.shout= "This is a really long ruby quote. It should be loved and wrapped because its more than 50 characters. This value may change in the future and this test may look stupid. \nSo, I'm just making it *really* long. God, I hope this works"
@@ -0,0 +1,24 @@
1
+ %div.tags
2
+ %foo 1
3
+ %FOO 2
4
+ %fooBAR 3
5
+ %fooBar 4
6
+ %foo_bar 5
7
+ %foo-bar 6
8
+ %foo:bar 7
9
+ %foo.bar 8
10
+ %fooBAr_baz:boom_bar 9
11
+ %foo13 10
12
+ %foo2u 11
13
+ %div.classes
14
+ %p.foo.bar#baz#boom
15
+ .fooBar a
16
+ .foo-bar b
17
+ .foo_bar c
18
+ .FOOBAR d
19
+ .foo16 e
20
+ .123 f
21
+ .foo2u g
22
+ %div.broken
23
+ %foo<{ :a => :b }
24
+ .foo>{ :c => :d }
@@ -0,0 +1,4 @@
1
+ !!!
2
+ %html
3
+ %head
4
+ %body
@@ -0,0 +1,87 @@
1
+ #whitespace_test
2
+ = render :file => "_text_area.haml", :locals => { :value => "Oneline" }
3
+ = render :file => "_text_area.haml", :locals => { :value => "Two\nlines" }
4
+ ~ render :file => "_text_area.haml", :locals => { :value => "Oneline" }
5
+ ~ render :file => "_text_area.haml", :locals => { :value => "Two\nlines" }
6
+ #flattened~ render :file => "_text_area.haml", :locals => { :value => "Two\nlines" }
7
+ .hithere
8
+ ~ "Foo bar"
9
+ ~ "<pre>foo bar</pre>"
10
+ ~ "<pre>foo\nbar</pre>"
11
+ %p~ "<pre>foo\nbar</pre>"
12
+ %p~ "foo\nbar"
13
+ .foo
14
+ ~ 13
15
+ ~ ['a', 'b', 'c'].map do |a|
16
+ - "<textarea>\n#{a}\n</textarea>"
17
+ #whitespace_test
18
+ = render :file => "_text_area.haml", :locals => { :value => "Oneline" }
19
+ = render :file => "_text_area.haml", :locals => { :value => "Two\nlines" }
20
+ = find_and_preserve render(:file => "_text_area.haml", :locals => { :value => "Oneline" })
21
+ = find_and_preserve render(:file => "_text_area.haml", :locals => { :value => "Two\nlines" })
22
+ #flattened= find_and_preserve render(:file => "_text_area.haml", :locals => { :value => "Two\nlines" })
23
+ .hithere
24
+ = find_and_preserve("Foo bar")
25
+ = find_and_preserve("<pre>foo bar</pre>")
26
+ = find_and_preserve("<pre>foo\nbar</pre>")
27
+ %p= find_and_preserve("<pre>foo\nbar</pre>")
28
+ %p= find_and_preserve("foo\nbar")
29
+ %pre
30
+ :preserve
31
+ ___
32
+ ,o88888
33
+ ,o8888888'
34
+ ,:o:o:oooo. ,8O88Pd8888"
35
+ ,.::.::o:ooooOoOoO. ,oO8O8Pd888'"
36
+ ,.:.::o:ooOoOoOO8O8OOo.8OOPd8O8O"
37
+ , ..:.::o:ooOoOOOO8OOOOo.FdO8O8"
38
+ , ..:.::o:ooOoOO8O888O8O,COCOO"
39
+ , . ..:.::o:ooOoOOOO8OOOOCOCO"
40
+ . ..:.::o:ooOoOoOO8O8OCCCC"o
41
+ . ..:.::o:ooooOoCoCCC"o:o
42
+ . ..:.::o:o:,cooooCo"oo:o:
43
+ ` . . ..:.:cocoooo"'o:o:::'
44
+ .` . ..::ccccoc"'o:o:o:::'
45
+ :.:. ,c:cccc"':.:.:.:.:.'
46
+ ..:.:"'`::::c:"'..:.:.:.:.:.' http://www.chris.com/ASCII/
47
+ ...:.'.:.::::"' . . . . .'
48
+ .. . ....:."' ` . . . ''
49
+ . . . ...."'
50
+ .. . ."' -hrr-
51
+ .
52
+
53
+
54
+ It's a planet!
55
+ %strong This shouldn't be bold!
56
+ %strong This should!
57
+ %textarea
58
+ :preserve
59
+ ___ ___ ___ ___
60
+ /\__\ /\ \ /\__\ /\__\
61
+ /:/ / /::\ \ /::| | /:/ /
62
+ /:/__/ /:/\:\ \ /:|:| | /:/ /
63
+ /::\ \ ___ /::\~\:\ \ /:/|:|__|__ /:/ /
64
+ /:/\:\ /\__\ /:/\:\ \:\__\ /:/ |::::\__\ /:/__/
65
+ \/__\:\/:/ / \/__\:\/:/ / \/__/~~/:/ / \:\ \
66
+ \::/ / \::/ / /:/ / \:\ \
67
+ /:/ / /:/ / /:/ / \:\ \
68
+ /:/ / /:/ / /:/ / \:\__\
69
+ \/__/ \/__/ \/__/ \/__/
70
+
71
+ Many
72
+ thanks
73
+ to
74
+ http://www.network-science.de/ascii/
75
+ %strong indeed!
76
+ .foo
77
+ = find_and_preserve(13)
78
+ %pre
79
+ :preserve
80
+ __ ______ __ ______
81
+ .----.| |--.|__ |.----.| |--..--------.| __ |
82
+ | __|| ||__ || __|| < | || __ |
83
+ |____||__|__||______||____||__|__||__|__|__||______|
84
+ %pre
85
+ :preserve
86
+ foo
87
+ bar
@@ -0,0 +1,15 @@
1
+ # allows testing with edge Rails by creating a test/rails symlink
2
+ linked_rails = File.dirname(__FILE__) + '/../rails'
3
+
4
+ if File.exists? linked_rails
5
+ puts "[ using linked Rails ]"
6
+ $:.unshift linked_rails + '/activesupport/lib'
7
+ $:.unshift linked_rails + '/actionpack/lib'
8
+ else
9
+ require 'rubygems'
10
+ end
11
+ require 'action_controller'
12
+ require 'action_view'
13
+
14
+ require 'test/unit'
15
+ require File.dirname(__FILE__) + '/../../lib/haml'
@@ -0,0 +1,65 @@
1
+ require 'rubygems'
2
+ require 'active_support'
3
+ require 'action_controller'
4
+ require 'action_view'
5
+
6
+ require File.dirname(__FILE__) + '/../lib/haml'
7
+ require 'haml/template'
8
+
9
+ require 'profiler'
10
+ require 'stringio'
11
+
12
+ module Haml
13
+ # Used by both Haml::Profiler and Sass::Profiler.
14
+ # Encapsulates profiling behavior.
15
+ module AbstractProfiler
16
+ def self.profile(times, &block)
17
+ # Runs the profiler, collects information
18
+ Profiler__::start_profile
19
+ times.times &block
20
+ Profiler__::stop_profile
21
+
22
+ # Outputs information to a StringIO, returns result
23
+ io = StringIO.new
24
+ Profiler__::print_profile(io)
25
+ io.pos = 0
26
+ result = io.read
27
+ io.close
28
+ result
29
+ end
30
+ end
31
+
32
+ # A profiler for Haml, mostly for development use. This simply implements
33
+ # the Ruby profiler for profiling haml code.
34
+ class Profiler
35
+
36
+ # Creates a new profiler that looks for templates in the base
37
+ # directory.
38
+ def initialize(base = File.join(File.dirname(__FILE__), 'haml', 'templates'))
39
+ unless base.class == ActionView::Base
40
+ @base = ActionView::Base.new(base)
41
+ else
42
+ @base = base
43
+ end
44
+ end
45
+
46
+ # Profiles haml on the given template with the given number of runs.
47
+ # The template name shouldn't have a file extension; this will
48
+ # automatically look for a haml template.
49
+ #
50
+ # Returns the results of the profiling as a string.
51
+ def profile(runs = 100, template_name = 'standard')
52
+ AbstractProfiler.profile(runs) { @base.render template_name }
53
+ end
54
+ end
55
+ end
56
+
57
+ module Sass
58
+ class Profiler
59
+ def profile(runs = 100, template_name = 'complex')
60
+ Haml::AbstractProfiler.profile(runs) do
61
+ Sass::Engine.new("#{File.dirname(__FILE__)}/sass/templates/#{template_name}.sass").render
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,276 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'test/unit'
4
+ require File.dirname(__FILE__) + '/../../lib/sass'
5
+ require 'sass/engine'
6
+
7
+ class SassEngineTest < Test::Unit::TestCase
8
+ # A map of erroneous Sass documents to the error messages they should produce.
9
+ # The error messages may be arrays;
10
+ # if so, the second element should be the line number that should be reported for the error.
11
+ # If this isn't provided, the tests will assume the line number should be the last line of the document.
12
+ EXCEPTION_MAP = {
13
+ "!a = 1 + " => 'Constant arithmetic error: "1 +".',
14
+ "!a = 1 + 2 +" => 'Constant arithmetic error: "1 + 2 +".',
15
+ "!a = \"b" => 'Unterminated string: "\\"b".',
16
+ "!a = #aaa - a" => 'Undefined operation: "#aaaaaa minus a".',
17
+ "!a = #aaa / a" => 'Undefined operation: "#aaaaaa div a".',
18
+ "!a = #aaa * a" => 'Undefined operation: "#aaaaaa times a".',
19
+ "!a = #aaa % a" => 'Undefined operation: "#aaaaaa mod a".',
20
+ "!a = 1 - a" => 'Undefined operation: "1 minus a".',
21
+ "!a = 1 * a" => 'Undefined operation: "1 times a".',
22
+ "!a = 1 / a" => 'Undefined operation: "1 div a".',
23
+ "!a = 1 % a" => 'Undefined operation: "1 mod a".',
24
+ ":" => 'Invalid attribute: ":".',
25
+ ": a" => 'Invalid attribute: ": a".',
26
+ ":= a" => 'Invalid attribute: ":= a".',
27
+ "a\n :b" => 'Invalid attribute: ":b ".',
28
+ "a\n :b: c" => 'Invalid attribute: ":b: c".',
29
+ "a\n :b:c d" => 'Invalid attribute: ":b:c d".',
30
+ "a\n :b=c d" => 'Invalid attribute: ":b=c d".',
31
+ "a\n :b c;" => 'Invalid attribute: ":b c;" (This isn\'t CSS!).',
32
+ "a\n b : c" => 'Invalid attribute: "b : c".',
33
+ "a\n b=c: d" => 'Invalid attribute: "b=c: d".',
34
+ ":a" => 'Attributes aren\'t allowed at the root of a document.',
35
+ "!" => 'Invalid constant: "!".',
36
+ "!a" => 'Invalid constant: "!a".',
37
+ "! a" => 'Invalid constant: "! a".',
38
+ "!a b" => 'Invalid constant: "!a b".',
39
+ "a\n\t:b c" => <<END.strip,
40
+ A tab character was used for indentation. Sass must be indented using two spaces.
41
+ Are you sure you have soft tabs enabled in your editor?
42
+ END
43
+ "a\n :b c" => "1 space was used for indentation. Sass must be indented using two spaces.",
44
+ "a\n :b c" => "4 spaces were used for indentation. Sass must be indented using two spaces.",
45
+ "a\n :b c\n !d = 3" => "Constants may only be declared at the root of a document.",
46
+ "!a = 1b + 2c" => "Incompatible units: b and c.",
47
+ "& a\n :b c" => "Base-level rules cannot contain the parent-selector-referencing character '&'.",
48
+ "a\n :b\n c" => "Illegal nesting: Only attributes may be nested beneath attributes.",
49
+ "a,\n :b c" => "Rules can\'t end in commas.",
50
+ "a," => "Rules can\'t end in commas.",
51
+ "a,\n!b = c" => "Rules can\'t end in commas.",
52
+ "!a = b\n :c d\n" => "Illegal nesting: Nothing may be nested beneath constants.",
53
+ "@import foo.sass" => "File to import not found or unreadable: foo.sass.",
54
+ "@import templates/basic\n foo" => "Illegal nesting: Nothing may be nested beneath import directives.",
55
+ "foo\n @import templates/basic" => "Import directives may only be used at the root of a document.",
56
+ "!foo = bar baz !" => "Unterminated constant.",
57
+ "!foo = !(foo)" => "Invalid constant.",
58
+ "=foo\n :color red\n.bar\n +bang" => "Undefined mixin 'bang'.",
59
+ ".bar\n =foo\n :color red\n" => "Mixins may only be defined at the root of a document.",
60
+ "=foo\n :color red\n.bar\n +foo\n :color red" => "Illegal nesting: Nothing may be nested beneath mixin directives.",
61
+
62
+ # Regression tests
63
+ "a\n b:\n c\n d" => ["Illegal nesting: Only attributes may be nested beneath attributes.", 3]
64
+ }
65
+
66
+ def test_basic_render
67
+ renders_correctly "basic", { :style => :compact }
68
+ end
69
+
70
+ def test_multiple_calls_to_render
71
+ sass = Sass::Engine.new("a\n b: c")
72
+ assert_equal sass.render, sass.render
73
+ end
74
+
75
+ def test_alternate_styles
76
+ renders_correctly "expanded", { :style => :expanded }
77
+ renders_correctly "compact", { :style => :compact }
78
+ renders_correctly "nested", { :style => :nested }
79
+ renders_correctly "compressed", { :style => :compressed }
80
+ end
81
+
82
+ def test_exceptions
83
+ EXCEPTION_MAP.each do |key, value|
84
+ begin
85
+ Sass::Engine.new(key).render
86
+ rescue Sass::SyntaxError => err
87
+ value = [value] unless value.is_a?(Array)
88
+
89
+ assert_equal(value.first, err.message, "Line: #{key}")
90
+ assert_equal(value[1] || key.split("\n").length, err.sass_line, "Line: #{key}")
91
+ assert_match(/\(sass\):[0-9]+/, err.backtrace[0], "Line: #{key}")
92
+ else
93
+ assert(false, "Exception not raised for\n#{key}")
94
+ end
95
+ end
96
+ end
97
+
98
+ def test_exception_line
99
+ to_render = "rule\n :attr val\n// comment!\n\n :broken\n"
100
+ begin
101
+ Sass::Engine.new(to_render).render
102
+ rescue Sass::SyntaxError => err
103
+ assert_equal(5, err.sass_line)
104
+ else
105
+ assert(false, "Exception not raised for '#{to_render}'!")
106
+ end
107
+ end
108
+
109
+ def test_imported_exception
110
+ [1, 2].each do |i|
111
+ i = nil if i == 1
112
+ begin
113
+ Sass::Engine.new("@import bork#{i}", :load_paths => [File.dirname(__FILE__) + '/templates/']).render
114
+ rescue Sass::SyntaxError => err
115
+ assert_equal(2, err.sass_line)
116
+ assert_match(/bork#{i}\.sass$/, err.sass_filename)
117
+ else
118
+ assert(false, "Exception not raised for imported template: bork#{i}")
119
+ end
120
+ end
121
+ end
122
+
123
+ def test_css_import
124
+ assert_equal("@import url(./fonts.css) screen;", render("@import url(./fonts.css) screen"))
125
+ assert_equal("@import \"./fonts.css\" screen;", render("@import \"./fonts.css\" screen"))
126
+ end
127
+
128
+ def test_sass_import
129
+ renders_correctly "import", { :style => :compact, :load_paths => [File.dirname(__FILE__) + "/templates"] }
130
+ end
131
+
132
+ def test_default_function
133
+ assert_equal("foo {\n bar: url(foo.png); }\n",
134
+ render("foo\n bar = url(foo.png)\n"));
135
+ end
136
+
137
+ def test_basic_multiline_selector
138
+ assert_equal("#foo #bar,\n#baz #boom {\n foo: bar; }\n",
139
+ render("#foo #bar,\n#baz #boom\n :foo bar"))
140
+ assert_equal("#foo #bar,\n#foo #baz {\n foo: bar; }\n",
141
+ render("#foo\n #bar,\n #baz\n :foo bar"))
142
+ assert_equal("#foo,\n#bar {\n foo: bar; }\n #foo #baz,\n #bar #baz {\n foo: bar; }\n",
143
+ render("#foo,\n#bar\n :foo bar\n #baz\n :foo bar"))
144
+ assert_equal("#foo #bar, #baz #boom { foo: bar; }\n",
145
+ render("#foo #bar,\n#baz #boom\n :foo bar", :style => :compact))
146
+
147
+ assert_equal("#foo #bar,#baz #boom{foo:bar}\n",
148
+ render("#foo #bar,\n#baz #boom\n :foo bar", :style => :compressed))
149
+ end
150
+
151
+ def test_complex_multiline_selector
152
+ renders_correctly "multiline"
153
+ end
154
+
155
+ def test_colon_only
156
+ begin
157
+ render("a\n b: c", :attribute_syntax => :normal)
158
+ rescue Sass::SyntaxError => e
159
+ assert_equal("Illegal attribute syntax: can't use alternate syntax when :attribute_syntax => :normal is set.",
160
+ e.message)
161
+ else
162
+ assert(false, "SyntaxError not raised for :attribute_syntax => :normal")
163
+ end
164
+
165
+ begin
166
+ render("a\n :b c", :attribute_syntax => :alternate)
167
+ rescue Sass::SyntaxError => e
168
+ assert_equal("Illegal attribute syntax: can't use normal syntax when :attribute_syntax => :alternate is set.",
169
+ e.message)
170
+ else
171
+ assert(false, "SyntaxError not raised for :attribute_syntax => :alternate")
172
+ end
173
+ end
174
+
175
+ def test_directive
176
+ assert_equal("@a b;", render("@a b"))
177
+
178
+ assert_equal("@a {\n b: c; }\n", render("@a\n :b c"))
179
+ assert_equal("@a { b: c; }\n", render("@a\n :b c", :style => :compact))
180
+ assert_equal("@a {\n b: c;\n}\n", render("@a\n :b c", :style => :expanded))
181
+ assert_equal("@a{b:c}\n", render("@a\n :b c", :style => :compressed))
182
+
183
+ assert_equal("@a {\n b: c;\n d: e; }\n",
184
+ render("@a\n :b c\n :d e"))
185
+ assert_equal("@a { b: c; d: e; }\n",
186
+ render("@a\n :b c\n :d e", :style => :compact))
187
+ assert_equal("@a {\n b: c;\n d: e;\n}\n",
188
+ render("@a\n :b c\n :d e", :style => :expanded))
189
+ assert_equal("@a{b:c;d:e}\n",
190
+ render("@a\n :b c\n :d e", :style => :compressed))
191
+
192
+ assert_equal("@a {\n #b {\n c: d; } }\n",
193
+ render("@a\n #b\n :c d"))
194
+ assert_equal("@a { #b { c: d; } }\n",
195
+ render("@a\n #b\n :c d", :style => :compact))
196
+ assert_equal("@a {\n #b {\n c: d;\n }\n}\n",
197
+ render("@a\n #b\n :c d", :style => :expanded))
198
+ assert_equal("@a{#b{c:d}}\n",
199
+ render("@a\n #b\n :c d", :style => :compressed))
200
+
201
+ assert_equal("@a {\n #b {\n a: b; }\n #b #c {\n d: e; } }\n",
202
+ render("@a\n #b\n :a b\n #c\n :d e"))
203
+ assert_equal("@a { #b { a: b; }\n #b #c { d: e; } }\n",
204
+ render("@a\n #b\n :a b\n #c\n :d e", :style => :compact))
205
+ assert_equal("@a {\n #b {\n a: b;\n }\n #b #c {\n d: e;\n }\n}\n",
206
+ render("@a\n #b\n :a b\n #c\n :d e", :style => :expanded))
207
+ assert_equal("@a{#b{a:b}#b #c{d:e}}\n",
208
+ render("@a\n #b\n :a b\n #c\n :d e", :style => :compressed))
209
+
210
+ assert_equal("@a {\n #foo,\n #bar {\n b: c; } }\n",
211
+ render("@a\n #foo, \n #bar\n :b c"))
212
+ assert_equal("@a { #foo, #bar { b: c; } }\n",
213
+ render("@a\n #foo, \n #bar\n :b c", :style => :compact))
214
+ assert_equal("@a {\n #foo,\n #bar {\n b: c;\n }\n}\n",
215
+ render("@a\n #foo, \n #bar\n :b c", :style => :expanded))
216
+ assert_equal("@a{#foo,#bar{b:c}}\n",
217
+ render("@a\n #foo, \n #bar\n :b c", :style => :compressed))
218
+
219
+ to_render = <<END
220
+ @a
221
+ :b c
222
+ #d
223
+ :e f
224
+ :g h
225
+ END
226
+ rendered = <<END
227
+ @a { b: c;
228
+ #d { e: f; }
229
+ g: h; }
230
+ END
231
+ assert_equal(rendered, render(to_render, :style => :compact))
232
+
233
+ assert_equal("@a{b:c;#d{e:f}g:h}\n", render(to_render, :style => :compressed))
234
+ end
235
+
236
+ def test_empty_first_line
237
+ assert_equal("#a {\n b: c; }\n", render("#a\n\n b: c"))
238
+ end
239
+
240
+ def test_escaped_rule
241
+ assert_equal(":focus {\n a: b; }\n", render("\\:focus\n a: b"))
242
+ assert_equal("a {\n b: c; }\n a :focus {\n d: e; }\n", render("\\a\n b: c\n \\:focus\n d: e"))
243
+ end
244
+
245
+ def test_cr_newline
246
+ assert_equal("foo {\n a: b;\n c: d;\n e: f; }\n", render("foo\r a: b\r\n c: d\n\r e: f"))
247
+ end
248
+
249
+ def test_or_eq
250
+ assert_equal("foo {\n a: b; }\n", render("!foo = b\n!foo ||= c\nfoo\n a = !foo"))
251
+ assert_equal("foo {\n a: b; }\n", render("!foo ||= b\nfoo\n a = !foo"))
252
+ end
253
+
254
+ def test_mixins
255
+ renders_correctly "mixins", { :style => :expanded }
256
+ end
257
+
258
+ private
259
+
260
+ def render(sass, options = {})
261
+ Sass::Engine.new(sass, options).render
262
+ end
263
+
264
+ def renders_correctly(name, options={})
265
+ sass_file = load_file(name, "sass")
266
+ css_file = load_file(name, "css")
267
+ css_result = Sass::Engine.new(sass_file, options).render
268
+ assert_equal css_file, css_result
269
+ end
270
+
271
+ def load_file(name, type = "sass")
272
+ @result = ''
273
+ File.new(File.dirname(__FILE__) + "/#{type == 'sass' ? 'templates' : 'results'}/#{name}.#{type}").each_line { |l| @result += l }
274
+ @result
275
+ end
276
+ end