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,35 @@
1
+ module Sass
2
+ # Sass::SyntaxError encapsulates information about the exception,
3
+ # such as the line of the Sass template it was raised on
4
+ # and the Sass file that was being parsed (if applicable).
5
+ # It also provides a handy way to rescue only exceptions raised
6
+ # because of a faulty template.
7
+ class SyntaxError < Exception
8
+ # The line of the Sass template on which the exception was thrown.
9
+ attr_accessor :sass_line
10
+
11
+ # The name of the file that was being parsed when the exception was raised.
12
+ # This will be nil unless Sass is being used as an ActionView plugin.
13
+ attr_reader :sass_filename
14
+
15
+ # Creates a new SyntaxError.
16
+ # +lineno+ should be the line of the Sass template on which the error occurred.
17
+ def initialize(msg, lineno = nil)
18
+ @message = msg
19
+ @sass_line = lineno
20
+ end
21
+
22
+ # Adds a properly formatted entry to the exception's backtrace.
23
+ # +filename+ should be the file in which the error occurred,
24
+ # if applicable (defaults to "(sass)").
25
+ def add_backtrace_entry(filename) # :nodoc:
26
+ @sass_filename ||= filename
27
+ self.backtrace ||= []
28
+ self.backtrace.unshift "#{@sass_filename || '(sass)'}:#{@sass_line}"
29
+ end
30
+
31
+ def to_s # :nodoc:
32
+ @message
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,165 @@
1
+ require 'sass/engine'
2
+
3
+ module Sass
4
+ # This module contains methods to aid in using Sass
5
+ # as a stylesheet-rendering plugin for various systems.
6
+ # Currently Rails/ActionController and Merb are supported out of the box.
7
+ module Plugin
8
+ class << self
9
+ @@options = {
10
+ :template_location => './public/stylesheets/sass',
11
+ :css_location => './public/stylesheets',
12
+ :always_update => false,
13
+ :always_check => true,
14
+ :full_exception => true
15
+ }
16
+ @@checked_for_updates = false
17
+
18
+ # Whether or not Sass has *ever* checked if the stylesheets need updates
19
+ # (in this Ruby instance).
20
+ def checked_for_updates
21
+ @@checked_for_updates
22
+ end
23
+
24
+ # Gets various options for Sass. See README.rdoc for details.
25
+ #--
26
+ # TODO: *DOCUMENT OPTIONS*
27
+ #++
28
+ def options
29
+ @@options
30
+ end
31
+
32
+ # Sets various options for Sass.
33
+ def options=(value)
34
+ @@options.merge!(value)
35
+ end
36
+
37
+ # Checks each stylesheet in <tt>options[:css_location]</tt>
38
+ # to see if it needs updating,
39
+ # and updates it using the corresponding template
40
+ # from <tt>options[:templates]</tt>
41
+ # if it does.
42
+ def update_stylesheets
43
+ return if options[:never_update]
44
+
45
+ @@checked_for_updates = true
46
+ Dir.glob(File.join(options[:template_location], "**", "*.sass")).entries.each do |file|
47
+
48
+ # Get the relative path to the file with no extension
49
+ name = file.sub(options[:template_location] + "/", "")[0...-5]
50
+
51
+ if !forbid_update?(name) && (options[:always_update] || stylesheet_needs_update?(name))
52
+ css = css_filename(name)
53
+ File.delete(css) if File.exists?(css)
54
+
55
+ filename = template_filename(name)
56
+ l_options = @@options.dup
57
+ l_options[:filename] = filename
58
+ l_options[:load_paths] = load_paths
59
+ engine = Engine.new(File.read(filename), l_options)
60
+ result = begin
61
+ engine.render
62
+ rescue Exception => e
63
+ exception_string(e)
64
+ end
65
+
66
+ # Create any directories that might be necessary
67
+ dirs = [l_options[:css_location]]
68
+ name.split("/")[0...-1].each { |dir| dirs << "#{dirs[-1]}/#{dir}" }
69
+ dirs.each { |dir| Dir.mkdir(dir) unless File.exist?(dir) }
70
+
71
+ # Finally, write the file
72
+ File.open(css, 'w') do |file|
73
+ file.print(result)
74
+ end
75
+ end
76
+ end
77
+ end
78
+
79
+ private
80
+
81
+ def load_paths
82
+ (options[:load_paths] || []) + [options[:template_location]]
83
+ end
84
+
85
+ def exception_string(e)
86
+ if options[:full_exception]
87
+ e_string = "#{e.class}: #{e.message}"
88
+
89
+ if e.is_a? Sass::SyntaxError
90
+ e_string << "\non line #{e.sass_line}"
91
+
92
+ if e.sass_filename
93
+ e_string << " of #{e.sass_filename}"
94
+
95
+ if File.exists?(e.sass_filename)
96
+ e_string << "\n\n"
97
+
98
+ min = [e.sass_line - 5, 0].max
99
+ File.read(e.sass_filename).rstrip.split("\n")[
100
+ min .. e.sass_line + 5
101
+ ].each_with_index do |line, i|
102
+ e_string << "#{min + i + 1}: #{line}\n"
103
+ end
104
+ end
105
+ end
106
+ end
107
+ <<END
108
+ /*
109
+ #{e_string}
110
+
111
+ Backtrace:\n#{e.backtrace.join("\n")}
112
+ */
113
+ body:before {
114
+ white-space: pre;
115
+ font-family: monospace;
116
+ content: "#{e_string.gsub('"', '\"').gsub("\n", '\\A ')}"; }
117
+ END
118
+ # Fix an emacs syntax-highlighting hiccup: '
119
+ else
120
+ "/* Internal stylesheet error */"
121
+ end
122
+ end
123
+
124
+ def template_filename(name)
125
+ "#{options[:template_location]}/#{name}.sass"
126
+ end
127
+
128
+ def css_filename(name)
129
+ "#{options[:css_location]}/#{name}.css"
130
+ end
131
+
132
+ def forbid_update?(name)
133
+ name.sub(/^.*\//, '')[0] == ?_
134
+ end
135
+
136
+ def stylesheet_needs_update?(name)
137
+ if !File.exists?(css_filename(name))
138
+ return true
139
+ else
140
+ css_mtime = File.mtime(css_filename(name))
141
+ File.mtime(template_filename(name)) > css_mtime ||
142
+ dependencies(template_filename(name)).any?(&dependency_updated?(css_mtime))
143
+ end
144
+ end
145
+
146
+ def dependency_updated?(css_mtime)
147
+ lambda do |dep|
148
+ File.mtime(dep) > css_mtime ||
149
+ dependencies(dep).any?(&dependency_updated?(css_mtime))
150
+ end
151
+ end
152
+
153
+ def dependencies(filename)
154
+ File.readlines(filename).grep(/^@import /).map do |line|
155
+ line[8..-1].split(',').map do |inc|
156
+ Sass::Engine.find_file_to_import(inc.strip, load_paths)
157
+ end
158
+ end.flatten.grep(/\.sass$/)
159
+ end
160
+ end
161
+ end
162
+ end
163
+
164
+ require 'sass/plugin/rails' if defined?(ActionController)
165
+ require 'sass/plugin/merb' if defined?(Merb::Plugins)
@@ -0,0 +1,56 @@
1
+ unless defined?(Sass::MERB_LOADED)
2
+ Sass::MERB_LOADED = true
3
+
4
+ version = Merb::VERSION.split('.').map { |n| n.to_i }
5
+ if version[0] <= 0 && version[1] < 5
6
+ root = MERB_ROOT
7
+ env = MERB_ENV
8
+ else
9
+ root = Merb.root
10
+ env = Merb.environment
11
+ end
12
+
13
+ Sass::Plugin.options.merge!(:template_location => root + '/public/stylesheets/sass',
14
+ :css_location => root + '/public/stylesheets',
15
+ :always_check => env != "production",
16
+ :full_exception => env != "production")
17
+ config = Merb::Plugins.config[:sass] || Merb::Plugins.config["sass"] || {}
18
+
19
+ if defined? config.symbolize_keys!
20
+ config.symbolize_keys!
21
+ end
22
+
23
+ Sass::Plugin.options.merge!(config)
24
+
25
+ if version[0] > 0 || version[1] >= 9
26
+
27
+ class Merb::Rack::Application # :nodoc:
28
+ def call_with_sass(env)
29
+ if !Sass::Plugin.checked_for_updates ||
30
+ Sass::Plugin.options[:always_update] || Sass::Plugin.options[:always_check]
31
+ Sass::Plugin.update_stylesheets
32
+ end
33
+
34
+ call_without_sass(env)
35
+ end
36
+ alias_method :call_without_sass, :call
37
+ alias_method :call, :call_with_sass
38
+ end
39
+
40
+ else
41
+
42
+ class MerbHandler # :nodoc:
43
+ def process_with_sass(request, response)
44
+ if !Sass::Plugin.checked_for_updates ||
45
+ Sass::Plugin.options[:always_update] || Sass::Plugin.options[:always_check]
46
+ Sass::Plugin.update_stylesheets
47
+ end
48
+
49
+ process_without_sass(request, response)
50
+ end
51
+ alias_method :process_without_sass, :process
52
+ alias_method :process, :process_with_sass
53
+ end
54
+
55
+ end
56
+ end
@@ -0,0 +1,24 @@
1
+ unless defined?(Sass::RAILS_LOADED)
2
+ Sass::RAILS_LOADED = true
3
+
4
+ Sass::Plugin.options.merge!(:template_location => RAILS_ROOT + '/public/stylesheets/sass',
5
+ :css_location => RAILS_ROOT + '/public/stylesheets',
6
+ :always_check => RAILS_ENV != "production",
7
+ :full_exception => RAILS_ENV != "production")
8
+
9
+ # :stopdoc:
10
+ module ActionController
11
+ class Base
12
+ alias_method :sass_old_process, :process
13
+ def process(*args)
14
+ if !Sass::Plugin.checked_for_updates ||
15
+ Sass::Plugin.options[:always_update] || Sass::Plugin.options[:always_check]
16
+ Sass::Plugin.update_stylesheets
17
+ end
18
+
19
+ sass_old_process(*args)
20
+ end
21
+ end
22
+ end
23
+ # :startdoc:
24
+ end
@@ -0,0 +1,53 @@
1
+ require 'sass/tree/node'
2
+
3
+ module Sass::Tree
4
+ class AttrNode < ValueNode
5
+ attr_accessor :name
6
+
7
+ def initialize(name, value, style)
8
+ @name = name
9
+ super(value, style)
10
+ end
11
+
12
+ def to_s(tabs, parent_name = nil)
13
+ if value[-1] == ?;
14
+ raise Sass::SyntaxError.new("Invalid attribute: #{declaration.dump} (This isn't CSS!).", @line)
15
+ end
16
+ real_name = name
17
+ real_name = "#{parent_name}-#{real_name}" if parent_name
18
+
19
+ if value.empty? && children.empty?
20
+ raise Sass::SyntaxError.new("Invalid attribute: #{declaration.dump}.", @line)
21
+ end
22
+
23
+ join_string = case @style
24
+ when :compact; ' '
25
+ when :compressed; ''
26
+ else "\n"
27
+ end
28
+ spaces = ' ' * (tabs - 1)
29
+ to_return = ''
30
+ if !value.empty?
31
+ to_return << "#{spaces}#{real_name}:#{@style == :compressed ? '' : ' '}#{value};#{join_string}"
32
+ end
33
+
34
+ children.each do |kid|
35
+ to_return << "#{kid.to_s(tabs, real_name)}" << join_string
36
+ end
37
+
38
+ (@style == :compressed && parent_name) ? to_return : to_return[0...-1]
39
+ end
40
+
41
+ private
42
+
43
+ def declaration
44
+ ":#{name} #{value}"
45
+ end
46
+
47
+ def invalid_child?(child)
48
+ if !child.is_a?(AttrNode) && !child.is_a?(CommentNode)
49
+ "Illegal nesting: Only attributes may be nested beneath attributes."
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,20 @@
1
+ require 'sass/tree/node'
2
+
3
+ module Sass::Tree
4
+ class CommentNode < ValueNode
5
+ def initialize(value, style)
6
+ super(value[2..-1].strip, style)
7
+ end
8
+
9
+ def to_s(tabs = 0, parent_name = nil)
10
+ return if @style == :compressed
11
+
12
+ spaces = ' ' * (tabs - 1)
13
+ join_string = @style == :compact ? ' ' : "\n#{spaces} * "
14
+ str = "#{spaces}/* #{value}"
15
+ str << join_string unless children.empty?
16
+ str << "#{children.join join_string} */"
17
+ str
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,46 @@
1
+ require 'sass/tree/node'
2
+ require 'sass/tree/value_node'
3
+
4
+ module Sass::Tree
5
+ class DirectiveNode < ValueNode
6
+ def to_s(tabs)
7
+ if children.empty?
8
+ value + ";"
9
+ else
10
+ result = if @style == :compressed
11
+ "#{value}{"
12
+ else
13
+ "#{' ' * (tabs - 1)}#{value} {" + (@style == :compact ? ' ' : "\n")
14
+ end
15
+ was_attr = false
16
+ first = true
17
+ children.each do |child|
18
+ if @style == :compact
19
+ if child.is_a?(AttrNode)
20
+ result << "#{child.to_s(first || was_attr ? 1 : tabs + 1)} "
21
+ else
22
+ if was_attr
23
+ result[-1] = "\n"
24
+ end
25
+ rendered = child.to_s(tabs + 1)
26
+ rendered.lstrip! if first
27
+ result << rendered
28
+ end
29
+ was_attr = child.is_a?(AttrNode)
30
+ first = false
31
+ elsif @style == :compressed
32
+ result << (was_attr ? ";#{child.to_s(1)}" : child.to_s(1))
33
+ was_attr = child.is_a?(AttrNode)
34
+ else
35
+ result << child.to_s(tabs + 1) + "\n"
36
+ end
37
+ end
38
+ result.rstrip + if @style == :compressed
39
+ "}"
40
+ else
41
+ (@style == :expanded ? "\n" : " ") + "}\n"
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,42 @@
1
+ module Sass
2
+ module Tree
3
+ class Node
4
+ attr_accessor :children
5
+ attr_accessor :line
6
+ attr_accessor :filename
7
+
8
+ def initialize(style)
9
+ @style = style
10
+ @children = []
11
+ end
12
+
13
+ def <<(child)
14
+ if msg = invalid_child?(child)
15
+ raise Sass::SyntaxError.new(msg, child.line)
16
+ end
17
+ @children << child
18
+ end
19
+
20
+ def to_s
21
+ result = String.new
22
+ children.each do |child|
23
+ if child.is_a? AttrNode
24
+ raise SyntaxError.new('Attributes aren\'t allowed at the root of a document.', child.line)
25
+ else
26
+ result << "#{child.to_s(1)}" + (@style == :compressed ? '' : "\n")
27
+ end
28
+ end
29
+ @style == :compressed ? result+"\n" : result[0...-1]
30
+ end
31
+
32
+ private
33
+
34
+ # This method should be overridden by subclasses to return an error message
35
+ # if the given child node is invalid,
36
+ # and false or nil otherwise.
37
+ def invalid_child?(child)
38
+ false
39
+ end
40
+ end
41
+ end
42
+ end