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.
- data/CHANGELOG +15 -0
- data/CONTRIBUTORS +8 -0
- data/app/controllers/admin/page_controller.rb +1 -11
- data/app/controllers/admin/welcome_controller.rb +5 -6
- data/app/controllers/application.rb +2 -0
- data/app/controllers/site_controller.rb +1 -0
- data/app/helpers/admin/page_helper.rb +36 -0
- data/app/helpers/admin/regions_helper.rb +28 -0
- data/app/helpers/admin/user_helper.rb +6 -0
- data/app/helpers/application_helper.rb +2 -1
- data/app/models/user.rb +7 -8
- data/app/views/admin/extension/index.html.haml +28 -0
- data/app/views/admin/layout/edit.html.haml +44 -0
- data/app/views/admin/layout/index.html.haml +25 -0
- data/app/views/admin/layout/remove.html.haml +16 -0
- data/app/views/admin/page/_meta_row.html.haml +6 -0
- data/app/views/admin/page/_node.html.haml +25 -0
- data/app/views/admin/page/_part.html.haml +17 -0
- data/app/views/admin/page/_tag_reference.html.haml +3 -0
- data/app/views/admin/page/children.html.haml +2 -0
- data/app/views/admin/page/edit.html.haml +114 -0
- data/app/views/admin/page/index.html.haml +28 -0
- data/app/views/admin/page/remove.html.haml +20 -0
- data/app/views/admin/snippet/edit.html.haml +36 -0
- data/app/views/admin/snippet/index.html.haml +20 -0
- data/app/views/admin/snippet/remove.html.haml +19 -0
- data/app/views/admin/user/edit.html.haml +80 -0
- data/app/views/admin/user/index.html.haml +23 -0
- data/app/views/admin/user/preferences.html.haml +28 -0
- data/app/views/admin/user/remove.html.haml +18 -0
- data/app/views/admin/welcome/login.html.haml +44 -0
- data/app/views/layouts/application.html.haml +54 -0
- data/app/views/site/not_found.html.haml +3 -0
- data/db/migrate/019_add_salt_to_users.rb +11 -0
- data/db/schema.rb +2 -1
- data/lib/login_system.rb +1 -0
- data/lib/radiant.rb +1 -1
- data/lib/radiant/admin_ui.rb +65 -0
- data/lib/radiant/admin_ui/region_partials.rb +18 -0
- data/lib/radiant/admin_ui/region_set.rb +35 -0
- data/lib/tasks/extensions.rake +33 -0
- data/public/javascripts/admin/admin.js +8 -2
- data/public/javascripts/admin/sitemap.js +2 -1
- data/public/stylesheets/admin/main.css +4 -0
- data/spec/controllers/admin/abstract_model_controller_spec.rb +2 -0
- data/spec/controllers/admin/page_controller_spec.rb +3 -28
- data/spec/controllers/admin/user_controller_spec.rb +1 -1
- data/spec/controllers/admin/welcome_controller_spec.rb +26 -0
- data/spec/helpers/admin/page_helper_spec.rb +4 -0
- data/spec/helpers/admin/regions_helper_spec.rb +47 -0
- data/spec/helpers/admin/user_helper_spec.rb +7 -0
- data/spec/helpers/application_helper_spec.rb +7 -3
- data/spec/lib/login_system_spec.rb +5 -0
- data/spec/lib/radiant/admin_ui/region_partials_spec.rb +35 -0
- data/spec/lib/radiant/admin_ui/region_set_spec.rb +61 -0
- data/spec/lib/radiant/admin_ui_spec.rb +74 -18
- data/spec/models/user_spec.rb +11 -4
- data/spec/scenarios/users_scenario.rb +2 -2
- data/vendor/plugins/haml/MIT-LICENSE +20 -0
- data/vendor/plugins/haml/README.rdoc +319 -0
- data/vendor/plugins/haml/Rakefile +158 -0
- data/vendor/plugins/haml/TODO +9 -0
- data/vendor/plugins/haml/VERSION +1 -0
- data/vendor/plugins/haml/bin/css2sass +7 -0
- data/vendor/plugins/haml/bin/haml +8 -0
- data/vendor/plugins/haml/bin/html2haml +7 -0
- data/vendor/plugins/haml/bin/sass +8 -0
- data/vendor/plugins/haml/extra/haml-mode.el +328 -0
- data/vendor/plugins/haml/extra/sass-mode.el +88 -0
- data/vendor/plugins/haml/init.rb +2 -0
- data/vendor/plugins/haml/lib/haml.rb +977 -0
- data/vendor/plugins/haml/lib/haml/buffer.rb +229 -0
- data/vendor/plugins/haml/lib/haml/engine.rb +274 -0
- data/vendor/plugins/haml/lib/haml/error.rb +23 -0
- data/vendor/plugins/haml/lib/haml/exec.rb +347 -0
- data/vendor/plugins/haml/lib/haml/filters.rb +249 -0
- data/vendor/plugins/haml/lib/haml/helpers.rb +413 -0
- data/vendor/plugins/haml/lib/haml/helpers/action_view_extensions.rb +45 -0
- data/vendor/plugins/haml/lib/haml/helpers/action_view_mods.rb +122 -0
- data/vendor/plugins/haml/lib/haml/html.rb +188 -0
- data/vendor/plugins/haml/lib/haml/precompiler.rb +757 -0
- data/vendor/plugins/haml/lib/haml/template.rb +43 -0
- data/vendor/plugins/haml/lib/haml/template/patch.rb +58 -0
- data/vendor/plugins/haml/lib/haml/template/plugin.rb +72 -0
- data/vendor/plugins/haml/lib/sass.rb +833 -0
- data/vendor/plugins/haml/lib/sass/constant.rb +245 -0
- data/vendor/plugins/haml/lib/sass/constant/color.rb +101 -0
- data/vendor/plugins/haml/lib/sass/constant/literal.rb +53 -0
- data/vendor/plugins/haml/lib/sass/constant/number.rb +87 -0
- data/vendor/plugins/haml/lib/sass/constant/operation.rb +30 -0
- data/vendor/plugins/haml/lib/sass/constant/string.rb +22 -0
- data/vendor/plugins/haml/lib/sass/css.rb +378 -0
- data/vendor/plugins/haml/lib/sass/engine.rb +459 -0
- data/vendor/plugins/haml/lib/sass/error.rb +35 -0
- data/vendor/plugins/haml/lib/sass/plugin.rb +165 -0
- data/vendor/plugins/haml/lib/sass/plugin/merb.rb +56 -0
- data/vendor/plugins/haml/lib/sass/plugin/rails.rb +24 -0
- data/vendor/plugins/haml/lib/sass/tree/attr_node.rb +53 -0
- data/vendor/plugins/haml/lib/sass/tree/comment_node.rb +20 -0
- data/vendor/plugins/haml/lib/sass/tree/directive_node.rb +46 -0
- data/vendor/plugins/haml/lib/sass/tree/node.rb +42 -0
- data/vendor/plugins/haml/lib/sass/tree/rule_node.rb +89 -0
- data/vendor/plugins/haml/lib/sass/tree/value_node.rb +16 -0
- data/vendor/plugins/haml/test/benchmark.rb +82 -0
- data/vendor/plugins/haml/test/haml/engine_test.rb +587 -0
- data/vendor/plugins/haml/test/haml/helper_test.rb +187 -0
- data/vendor/plugins/haml/test/haml/html2haml_test.rb +60 -0
- data/vendor/plugins/haml/test/haml/markaby/standard.mab +52 -0
- data/vendor/plugins/haml/test/haml/mocks/article.rb +6 -0
- data/vendor/plugins/haml/test/haml/results/content_for_layout.xhtml +16 -0
- data/vendor/plugins/haml/test/haml/results/eval_suppressed.xhtml +11 -0
- data/vendor/plugins/haml/test/haml/results/filters.xhtml +82 -0
- data/vendor/plugins/haml/test/haml/results/helpers.xhtml +94 -0
- data/vendor/plugins/haml/test/haml/results/helpful.xhtml +10 -0
- data/vendor/plugins/haml/test/haml/results/just_stuff.xhtml +64 -0
- data/vendor/plugins/haml/test/haml/results/list.xhtml +12 -0
- data/vendor/plugins/haml/test/haml/results/original_engine.xhtml +22 -0
- data/vendor/plugins/haml/test/haml/results/partials.xhtml +21 -0
- data/vendor/plugins/haml/test/haml/results/silent_script.xhtml +74 -0
- data/vendor/plugins/haml/test/haml/results/standard.xhtml +42 -0
- data/vendor/plugins/haml/test/haml/results/tag_parsing.xhtml +28 -0
- data/vendor/plugins/haml/test/haml/results/very_basic.xhtml +7 -0
- data/vendor/plugins/haml/test/haml/results/whitespace_handling.xhtml +94 -0
- data/vendor/plugins/haml/test/haml/rhtml/_av_partial_1.rhtml +12 -0
- data/vendor/plugins/haml/test/haml/rhtml/_av_partial_2.rhtml +8 -0
- data/vendor/plugins/haml/test/haml/rhtml/action_view.rhtml +62 -0
- data/vendor/plugins/haml/test/haml/rhtml/standard.rhtml +54 -0
- data/vendor/plugins/haml/test/haml/template_test.rb +168 -0
- data/vendor/plugins/haml/test/haml/templates/_av_partial_1.haml +9 -0
- data/vendor/plugins/haml/test/haml/templates/_av_partial_2.haml +5 -0
- data/vendor/plugins/haml/test/haml/templates/_partial.haml +8 -0
- data/vendor/plugins/haml/test/haml/templates/_text_area.haml +3 -0
- data/vendor/plugins/haml/test/haml/templates/action_view.haml +47 -0
- data/vendor/plugins/haml/test/haml/templates/breakage.haml +8 -0
- data/vendor/plugins/haml/test/haml/templates/content_for_layout.haml +10 -0
- data/vendor/plugins/haml/test/haml/templates/eval_suppressed.haml +11 -0
- data/vendor/plugins/haml/test/haml/templates/filters.haml +81 -0
- data/vendor/plugins/haml/test/haml/templates/helpers.haml +69 -0
- data/vendor/plugins/haml/test/haml/templates/helpful.haml +11 -0
- data/vendor/plugins/haml/test/haml/templates/just_stuff.haml +77 -0
- data/vendor/plugins/haml/test/haml/templates/list.haml +12 -0
- data/vendor/plugins/haml/test/haml/templates/original_engine.haml +17 -0
- data/vendor/plugins/haml/test/haml/templates/partialize.haml +1 -0
- data/vendor/plugins/haml/test/haml/templates/partials.haml +12 -0
- data/vendor/plugins/haml/test/haml/templates/silent_script.haml +40 -0
- data/vendor/plugins/haml/test/haml/templates/standard.haml +42 -0
- data/vendor/plugins/haml/test/haml/templates/tag_parsing.haml +24 -0
- data/vendor/plugins/haml/test/haml/templates/very_basic.haml +4 -0
- data/vendor/plugins/haml/test/haml/templates/whitespace_handling.haml +87 -0
- data/vendor/plugins/haml/test/haml/test_helper.rb +15 -0
- data/vendor/plugins/haml/test/profile.rb +65 -0
- data/vendor/plugins/haml/test/sass/engine_test.rb +276 -0
- data/vendor/plugins/haml/test/sass/plugin_test.rb +159 -0
- data/vendor/plugins/haml/test/sass/results/alt.css +4 -0
- data/vendor/plugins/haml/test/sass/results/basic.css +9 -0
- data/vendor/plugins/haml/test/sass/results/compact.css +5 -0
- data/vendor/plugins/haml/test/sass/results/complex.css +87 -0
- data/vendor/plugins/haml/test/sass/results/compressed.css +1 -0
- data/vendor/plugins/haml/test/sass/results/constants.css +14 -0
- data/vendor/plugins/haml/test/sass/results/expanded.css +19 -0
- data/vendor/plugins/haml/test/sass/results/import.css +29 -0
- data/vendor/plugins/haml/test/sass/results/mixins.css +95 -0
- data/vendor/plugins/haml/test/sass/results/multiline.css +24 -0
- data/vendor/plugins/haml/test/sass/results/nested.css +22 -0
- data/vendor/plugins/haml/test/sass/results/parent_ref.css +13 -0
- data/vendor/plugins/haml/test/sass/results/subdir/nested_subdir/nested_subdir.css +1 -0
- data/vendor/plugins/haml/test/sass/results/subdir/subdir.css +1 -0
- data/vendor/plugins/haml/test/sass/templates/_partial.sass +2 -0
- data/vendor/plugins/haml/test/sass/templates/alt.sass +16 -0
- data/vendor/plugins/haml/test/sass/templates/basic.sass +23 -0
- data/vendor/plugins/haml/test/sass/templates/bork.sass +2 -0
- data/vendor/plugins/haml/test/sass/templates/bork2.sass +2 -0
- data/vendor/plugins/haml/test/sass/templates/compact.sass +17 -0
- data/vendor/plugins/haml/test/sass/templates/complex.sass +310 -0
- data/vendor/plugins/haml/test/sass/templates/compressed.sass +15 -0
- data/vendor/plugins/haml/test/sass/templates/constants.sass +97 -0
- data/vendor/plugins/haml/test/sass/templates/expanded.sass +17 -0
- data/vendor/plugins/haml/test/sass/templates/import.sass +11 -0
- data/vendor/plugins/haml/test/sass/templates/importee.sass +14 -0
- data/vendor/plugins/haml/test/sass/templates/mixins.sass +76 -0
- data/vendor/plugins/haml/test/sass/templates/multiline.sass +20 -0
- data/vendor/plugins/haml/test/sass/templates/nested.sass +25 -0
- data/vendor/plugins/haml/test/sass/templates/parent_ref.sass +25 -0
- data/vendor/plugins/haml/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +3 -0
- data/vendor/plugins/haml/test/sass/templates/subdir/subdir.sass +6 -0
- metadata +185 -24
- data/app/views/admin/extension/index.html.erb +0 -40
- data/app/views/admin/layout/edit.html.erb +0 -39
- data/app/views/admin/layout/index.html.erb +0 -38
- data/app/views/admin/layout/remove.html.erb +0 -17
- data/app/views/admin/page/_meta_row.html.erb +0 -4
- data/app/views/admin/page/_node.html.erb +0 -28
- data/app/views/admin/page/_part.html.erb +0 -13
- data/app/views/admin/page/_tag_reference.html.erb +0 -4
- data/app/views/admin/page/children.html.erb +0 -4
- data/app/views/admin/page/edit.html.erb +0 -140
- data/app/views/admin/page/index.html.erb +0 -31
- data/app/views/admin/page/remove.html.erb +0 -14
- data/app/views/admin/snippet/edit.html.erb +0 -29
- data/app/views/admin/snippet/index.html.erb +0 -36
- data/app/views/admin/snippet/remove.html.erb +0 -16
- data/app/views/admin/user/edit.html.erb +0 -54
- data/app/views/admin/user/index.html.erb +0 -43
- data/app/views/admin/user/preferences.html.erb +0 -29
- data/app/views/admin/user/remove.html.erb +0 -16
- data/app/views/admin/welcome/login.html.erb +0 -51
- data/app/views/layouts/application.html.erb +0 -83
- 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
|