radiant 0.6.7 → 0.6.8
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 +35 -3
- data/CONTRIBUTORS +11 -1
- data/README +5 -3
- data/app/controllers/admin/welcome_controller.rb +7 -0
- data/app/migrate/020_add_session_info_to_users.rb +11 -0
- data/app/models/page.rb +22 -9
- data/app/models/standard_tags.rb +133 -10
- data/app/models/user.rb +9 -1
- data/app/views/admin/page/edit.html.haml +5 -4
- data/app/views/admin/welcome/login.html.haml +42 -24
- data/app/views/layouts/application.html.haml +1 -1
- data/config/environment.rb +4 -2
- data/db/migrate/020_add_session_info_to_users.rb +11 -0
- data/db/migrate/021_remove_session_expire_from_users.rb +9 -0
- data/db/schema.rb +3 -2
- data/lib/generators/instance/instance_generator.rb +2 -1
- data/lib/generators/instance/templates/instance_environment.rb +5 -3
- data/lib/login_system.rb +13 -0
- data/lib/radiant.rb +1 -1
- data/lib/radiant/admin_ui.rb +21 -21
- data/lib/radiant/extension/script.rb +251 -0
- data/lib/radiant/extension_loader.rb +22 -20
- data/lib/radiant/initializer.rb +1 -1
- data/lib/radiant/setup.rb +2 -0
- data/lib/tasks/framework.rake +39 -29
- data/public/500.html +1 -1
- data/public/javascripts/admin/admin.js +11 -9
- data/script/extension +5 -0
- data/spec/controllers/admin/user_controller_spec.rb +1 -1
- data/spec/controllers/admin/welcome_controller_spec.rb +31 -5
- data/spec/controllers/site_controller_spec.rb +15 -2
- data/spec/lib/login_system_spec.rb +106 -60
- data/spec/lib/radiant/extension/script_spec.rb +349 -0
- data/spec/lib/radiant/extension_loader_spec.rb +3 -0
- data/spec/models/page_spec.rb +62 -2
- data/spec/models/standard_tags_spec.rb +150 -3
- data/spec/models/user_spec.rb +28 -0
- data/spec/scenarios/file_not_found_scenario.rb +5 -0
- data/spec/scenarios/pages_scenario.rb +6 -0
- data/spec/scenarios/snippets_scenario.rb +4 -0
- data/test/fixtures/users.yml +11 -6
- data/vendor/plugins/haml/FAQ +138 -0
- data/vendor/plugins/haml/REVISION +1 -0
- data/vendor/plugins/haml/Rakefile +54 -62
- data/vendor/plugins/haml/VERSION +1 -1
- data/vendor/plugins/haml/init.rb +6 -1
- data/vendor/plugins/haml/lib/haml.rb +72 -12
- data/vendor/plugins/haml/lib/haml/buffer.rb +47 -40
- data/vendor/plugins/haml/lib/haml/engine.rb +20 -30
- data/vendor/plugins/haml/lib/haml/error.rb +4 -5
- data/vendor/plugins/haml/lib/haml/exec.rb +4 -2
- data/vendor/plugins/haml/lib/haml/filters.rb +30 -15
- data/vendor/plugins/haml/lib/haml/helpers.rb +47 -28
- data/vendor/plugins/haml/lib/haml/helpers/action_view_mods.rb +74 -25
- data/vendor/plugins/haml/lib/haml/precompiler.rb +92 -51
- data/vendor/plugins/haml/lib/haml/template.rb +11 -3
- data/vendor/plugins/haml/lib/haml/template/patch.rb +1 -1
- data/vendor/plugins/haml/lib/sass.rb +26 -3
- data/vendor/plugins/haml/lib/sass/constant.rb +26 -57
- data/vendor/plugins/haml/lib/sass/constant/literal.rb +1 -0
- data/vendor/plugins/haml/lib/sass/constant/nil.rb +9 -0
- data/vendor/plugins/haml/lib/sass/css.rb +17 -2
- data/vendor/plugins/haml/lib/sass/engine.rb +11 -5
- data/vendor/plugins/haml/test/haml/engine_test.rb +57 -39
- data/vendor/plugins/haml/test/haml/helper_test.rb +20 -4
- data/vendor/plugins/haml/test/haml/html2haml_test.rb +1 -3
- data/vendor/plugins/haml/test/haml/results/content_for_layout.xhtml +1 -2
- data/vendor/plugins/haml/test/haml/results/eval_suppressed.xhtml +2 -4
- data/vendor/plugins/haml/test/haml/results/filters.xhtml +12 -8
- data/vendor/plugins/haml/test/haml/results/helpers.xhtml +2 -5
- data/vendor/plugins/haml/test/haml/results/just_stuff.xhtml +1 -3
- data/vendor/plugins/haml/test/haml/results/nuke_inner_whitespace.xhtml +40 -0
- data/vendor/plugins/haml/test/haml/results/nuke_outer_whitespace.xhtml +148 -0
- data/vendor/plugins/haml/test/haml/results/original_engine.xhtml +2 -4
- data/vendor/plugins/haml/test/haml/results/tag_parsing.xhtml +1 -6
- data/vendor/plugins/haml/test/haml/results/very_basic.xhtml +2 -4
- data/vendor/plugins/haml/test/haml/results/whitespace_handling.xhtml +13 -21
- data/vendor/plugins/haml/test/haml/template_test.rb +31 -48
- data/vendor/plugins/haml/test/haml/templates/filters.haml +13 -0
- data/vendor/plugins/haml/test/haml/templates/helpers.haml +1 -1
- data/vendor/plugins/haml/test/haml/templates/just_stuff.haml +0 -1
- data/vendor/plugins/haml/test/haml/templates/nuke_inner_whitespace.haml +32 -0
- data/vendor/plugins/haml/test/haml/templates/nuke_outer_whitespace.haml +144 -0
- data/vendor/plugins/haml/test/haml/templates/partials.haml +1 -1
- data/vendor/plugins/haml/test/haml/templates/tag_parsing.haml +0 -3
- data/vendor/plugins/haml/test/haml/templates/whitespace_handling.haml +10 -10
- data/vendor/plugins/haml/test/sass/engine_test.rb +11 -5
- data/vendor/plugins/haml/test/sass/plugin_test.rb +2 -6
- data/vendor/plugins/haml/test/sass/results/constants.css +2 -0
- data/vendor/plugins/haml/test/sass/templates/constants.sass +3 -0
- data/vendor/plugins/haml/test/{haml/test_helper.rb → test_helper.rb} +4 -3
- metadata +21 -11
- data/vendor/plugins/haml/TODO +0 -9
- data/vendor/plugins/haml/extra/haml-mode.el +0 -328
- data/vendor/plugins/haml/extra/sass-mode.el +0 -88
- data/vendor/plugins/haml/test/profile.rb +0 -65
data/vendor/plugins/haml/TODO
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
Testing:
|
2
|
-
Test html2haml and css2sass
|
3
|
-
|
4
|
-
Features:
|
5
|
-
Sass should throw generic errors for undefined constants, not syntax errors
|
6
|
-
Sass::Plugin should log errors
|
7
|
-
There should be a way to make Haml tags not insert whitespace
|
8
|
-
"%li, %a"?
|
9
|
-
Sass::Engine load_paths option should be set by executable
|
@@ -1,328 +0,0 @@
|
|
1
|
-
;;; haml-mode.el -- Major mode for editing Haml files
|
2
|
-
;;; Written by Nathan Weizenbaum
|
3
|
-
|
4
|
-
;;; Because Haml's indentation schema is similar
|
5
|
-
;;; to that of YAML and Python, many indentation-related
|
6
|
-
;;; functions are similar to those in yaml-mode and python-mode.
|
7
|
-
|
8
|
-
;;; To install, save this somewhere and add the following to your .emacs file:
|
9
|
-
;;;
|
10
|
-
;;; (add-to-list 'load-path "/path/to/haml-mode.el")
|
11
|
-
;;; (require 'haml-mode nil 't)
|
12
|
-
;;; (add-to-list 'auto-mode-alist '("\\.sass$" . sass-mode))
|
13
|
-
;;;
|
14
|
-
|
15
|
-
;;; Code:
|
16
|
-
|
17
|
-
(eval-when-compile (require 'cl))
|
18
|
-
|
19
|
-
;; User definable variables
|
20
|
-
|
21
|
-
(defgroup haml nil
|
22
|
-
"Support for the Haml template language."
|
23
|
-
:group 'languages
|
24
|
-
:prefix "haml-")
|
25
|
-
|
26
|
-
(defcustom haml-mode-hook nil
|
27
|
-
"Hook run when entering Haml mode."
|
28
|
-
:type 'hook
|
29
|
-
:group 'haml)
|
30
|
-
|
31
|
-
(defcustom haml-indent-offset 2
|
32
|
-
"Amount of offset per level of indentation."
|
33
|
-
:type 'integer
|
34
|
-
:group 'haml)
|
35
|
-
|
36
|
-
(defcustom haml-backspace-backdents-nesting t
|
37
|
-
"Non-nil to have `haml-electric-backspace' re-indent all code
|
38
|
-
nested beneath the backspaced line be re-indented along with the
|
39
|
-
line itself."
|
40
|
-
:type 'boolean
|
41
|
-
:group 'haml)
|
42
|
-
|
43
|
-
(defface haml-tab-face
|
44
|
-
'((((class color)) (:background "hotpink"))
|
45
|
-
(t (:reverse-video t)))
|
46
|
-
"Face to use for highlighting tabs in Haml files."
|
47
|
-
:group 'faces
|
48
|
-
:group 'haml)
|
49
|
-
|
50
|
-
(defvar haml-indent-function 'haml-indent-p
|
51
|
-
"This function should look at the current line and return true
|
52
|
-
if the next line could be nested within this line.")
|
53
|
-
|
54
|
-
(defvar haml-block-openers
|
55
|
-
`("^ *\\([%\\.#][^ \t]*\\)\\(\\[.*\\]\\)?\\({.*}\\)?\\(\\[.*\\]\\)?[ \t]*$"
|
56
|
-
"^ *[-=].*do[ \t]*\\(|.*|[ \t]*\\)?$"
|
57
|
-
,(concat "^ *-[ \t]*"
|
58
|
-
(regexp-opt '("else" "elsif" "rescue" "ensure" "when")))
|
59
|
-
"^ */\\(\\[.*\\]\\)?[ \t]*$"
|
60
|
-
"^ *-#"
|
61
|
-
"^ *:")
|
62
|
-
"A list of regexps that match lines of Haml that could have
|
63
|
-
text nested beneath them.")
|
64
|
-
|
65
|
-
;; Font lock
|
66
|
-
|
67
|
-
(defconst haml-font-lock-keywords
|
68
|
-
'(("^ *\\(\t\\)" 1 'haml-tab-face)
|
69
|
-
("^!!!.*" 0 font-lock-constant-face)
|
70
|
-
("\\('[^']*'\\)" 1 font-lock-string-face append)
|
71
|
-
("\\(\"[^\"]*\"\\)" 1 font-lock-string-face append)
|
72
|
-
("&?:\\w+" 0 font-lock-constant-face append)
|
73
|
-
("@[a-z0-9_]+" 0 font-lock-variable-name-face append)
|
74
|
-
("| *$" 0 font-lock-string-face)
|
75
|
-
("^[ \t]*\\(/.*\\)$" 1 font-lock-comment-face append)
|
76
|
-
("^ *\\(#[a-z0-9_]+\/?\\)" 1 font-lock-keyword-face)
|
77
|
-
("^ *\\(\\.[a-z0-9_]+\/?\\)" 1 font-lock-type-face)
|
78
|
-
("^ *\\(%[a-z0-9_]+\/?\\)" 1 font-lock-function-name-face)
|
79
|
-
("^ *\\(#[a-z0-9_]+\/?\\)" (1 font-lock-keyword-face)
|
80
|
-
("\\.[a-z0-9_]+" nil nil (0 font-lock-type-face)))
|
81
|
-
("^ *\\(\\.[a-z0-9_]+\/?\\)" (1 font-lock-type-face)
|
82
|
-
("\\.[a-z0-9_]+" nil nil (0 font-lock-type-face)))
|
83
|
-
("^ *\\(\\.[a-z0-9_]+\/?\\)" (1 font-lock-type-face)
|
84
|
-
("\\#[a-z0-9_]+" nil nil (0 font-lock-keyword-face)))
|
85
|
-
("^ *\\(%[a-z0-9_]+\/?\\)" (1 font-lock-function-name-face)
|
86
|
-
("\\.[a-z0-9_]+" nil nil (0 font-lock-type-face)))
|
87
|
-
("^ *\\(%[a-z0-9_]+\/?\\)" (1 font-lock-function-name-face)
|
88
|
-
("\\#[a-z0-9_]+" nil nil (0 font-lock-keyword-face)))
|
89
|
-
("^ *\\([~=-] .*\\)" 1 font-lock-preprocessor-face prepend)
|
90
|
-
("^ *[\\.#%a-z0-9_]+\\([~=-] .*\\)" 1 font-lock-preprocessor-face prepend)
|
91
|
-
("^ *[\\.#%a-z0-9_]+\\({[^}]+}\\)" 1 font-lock-preprocessor-face prepend)
|
92
|
-
("^ *[\\.#%a-z0-9_]+\\(\\[[^]]+\\]\\)" 1 font-lock-preprocessor-face prepend)))
|
93
|
-
|
94
|
-
;; Mode setup
|
95
|
-
|
96
|
-
(defvar haml-mode-syntax-table
|
97
|
-
(let ((table (make-syntax-table)))
|
98
|
-
(modify-syntax-entry ?: "." table)
|
99
|
-
(modify-syntax-entry ?_ "w" table)
|
100
|
-
table)
|
101
|
-
"Syntax table in use in haml-mode buffers.")
|
102
|
-
|
103
|
-
(defvar haml-mode-map
|
104
|
-
(let ((map (make-sparse-keymap)))
|
105
|
-
(define-key map [backspace] 'haml-electric-backspace)
|
106
|
-
(define-key map "\C-?" 'haml-electric-backspace)
|
107
|
-
(define-key map "\C-\M-f" 'haml-forward-sexp)
|
108
|
-
(define-key map "\C-\M-b" 'haml-backward-sexp)
|
109
|
-
(define-key map "\C-\M-u" 'haml-up-list)
|
110
|
-
(define-key map "\C-\M-d" 'haml-down-list)
|
111
|
-
(define-key map "\C-C\C-k" 'haml-kill-line-and-indent)
|
112
|
-
map))
|
113
|
-
|
114
|
-
(define-derived-mode haml-mode fundamental-mode "Haml"
|
115
|
-
"Major mode for editing Haml files.
|
116
|
-
|
117
|
-
\\{haml-mode-map}"
|
118
|
-
(set-syntax-table haml-mode-syntax-table)
|
119
|
-
(set (make-local-variable 'indent-line-function) 'haml-indent-line)
|
120
|
-
(set (make-local-variable 'indent-region-function) 'haml-indent-region)
|
121
|
-
(set (make-local-variable 'forward-sexp-function) 'haml-forward-sexp)
|
122
|
-
(setq font-lock-defaults '((haml-font-lock-keywords) nil t)))
|
123
|
-
|
124
|
-
;; Navigation
|
125
|
-
|
126
|
-
(defun haml-forward-through-whitespace (&optional backward)
|
127
|
-
"Move the point forward at least one line, until it reaches
|
128
|
-
either the end of the buffer or a line with no whitespace.
|
129
|
-
|
130
|
-
If `backward' is non-nil, move the point backward instead."
|
131
|
-
(let ((arg (if backward -1 1))
|
132
|
-
(endp (if backward 'bobp 'eobp)))
|
133
|
-
(loop do (forward-line arg)
|
134
|
-
while (and (not (funcall endp))
|
135
|
-
(looking-at "^[ \t]*$")))))
|
136
|
-
|
137
|
-
(defun haml-at-indent-p ()
|
138
|
-
"Returns whether or not the point is at the first
|
139
|
-
non-whitespace character in a line or whitespace preceding that
|
140
|
-
character."
|
141
|
-
(let ((opoint (point)))
|
142
|
-
(save-excursion
|
143
|
-
(back-to-indentation)
|
144
|
-
(>= (point) opoint))))
|
145
|
-
|
146
|
-
(defun haml-forward-sexp (&optional arg)
|
147
|
-
"Move forward across one nested expression.
|
148
|
-
With `arg', do it that many times. Negative arg -N means move
|
149
|
-
backward across N balanced expressions.
|
150
|
-
|
151
|
-
A sexp in Haml is defined as a line of Haml code as well as any
|
152
|
-
lines nested beneath it."
|
153
|
-
(interactive "p")
|
154
|
-
(or arg (setq arg 1))
|
155
|
-
(if (and (< arg 0) (not (haml-at-indent-p)))
|
156
|
-
(back-to-indentation)
|
157
|
-
(while (/= arg 0)
|
158
|
-
(let ((indent (current-indentation)))
|
159
|
-
(loop do (haml-forward-through-whitespace (< arg 0))
|
160
|
-
while (and (not (eobp))
|
161
|
-
(not (bobp))
|
162
|
-
(> (current-indentation) indent)))
|
163
|
-
(back-to-indentation)
|
164
|
-
(setq arg (+ arg (if (> arg 0) -1 1)))))))
|
165
|
-
|
166
|
-
(defun haml-backward-sexp (&optional arg)
|
167
|
-
"Move backward across one nested expression.
|
168
|
-
With ARG, do it that many times. Negative arg -N means move
|
169
|
-
forward across N balanced expressions.
|
170
|
-
|
171
|
-
A sexp in Haml is defined as a line of Haml code as well as any
|
172
|
-
lines nested beneath it."
|
173
|
-
(interactive "p")
|
174
|
-
(haml-forward-sexp (if arg (- arg) -1)))
|
175
|
-
|
176
|
-
(defun haml-up-list (&optional arg)
|
177
|
-
"Move out of one level of nesting.
|
178
|
-
With ARG, do this that many times."
|
179
|
-
(interactive "p")
|
180
|
-
(or arg (setq arg 1))
|
181
|
-
(while (> arg 0)
|
182
|
-
(let ((indent (current-indentation)))
|
183
|
-
(loop do (haml-forward-through-whitespace t)
|
184
|
-
while (and (not (bobp))
|
185
|
-
(>= (current-indentation) indent)))
|
186
|
-
(setq arg (- arg 1))))
|
187
|
-
(back-to-indentation))
|
188
|
-
|
189
|
-
(defun haml-down-list (&optional arg)
|
190
|
-
"Move down one level of nesting.
|
191
|
-
With ARG, do this that many times."
|
192
|
-
(interactive "p")
|
193
|
-
(or arg (setq arg 1))
|
194
|
-
(while (> arg 0)
|
195
|
-
(let ((indent (current-indentation)))
|
196
|
-
(haml-forward-through-whitespace)
|
197
|
-
(when (<= (current-indentation) indent)
|
198
|
-
(haml-forward-through-whitespace t)
|
199
|
-
(back-to-indentation)
|
200
|
-
(error "Nothing is nested beneath this line"))
|
201
|
-
(setq arg (- arg 1))))
|
202
|
-
(back-to-indentation))
|
203
|
-
|
204
|
-
(defun haml-mark-sexp-but-not-next-line ()
|
205
|
-
"Marks the next Haml sexp, but puts the mark at the end of the
|
206
|
-
last line of the sexp rather than the first non-whitespace
|
207
|
-
character of the next line."
|
208
|
-
(mark-sexp)
|
209
|
-
(set-mark
|
210
|
-
(save-excursion
|
211
|
-
(goto-char (mark))
|
212
|
-
(forward-line -1)
|
213
|
-
(end-of-line)
|
214
|
-
(point))))
|
215
|
-
|
216
|
-
;; Indentation and electric keys
|
217
|
-
|
218
|
-
(defun haml-indent-p ()
|
219
|
-
"Returns true if the current line can have lines nested beneath it."
|
220
|
-
(loop for opener in haml-block-openers
|
221
|
-
if (looking-at opener) return t
|
222
|
-
return nil))
|
223
|
-
|
224
|
-
(defun haml-compute-indentation ()
|
225
|
-
"Calculate the maximum sensible indentation for the current line."
|
226
|
-
(save-excursion
|
227
|
-
(beginning-of-line)
|
228
|
-
(if (bobp) 0
|
229
|
-
(haml-forward-through-whitespace t)
|
230
|
-
(+ (current-indentation)
|
231
|
-
(if (funcall haml-indent-function) haml-indent-offset
|
232
|
-
0)))))
|
233
|
-
|
234
|
-
(defun haml-indent-region (start end)
|
235
|
-
"Indent each nonblank line in the region.
|
236
|
-
This is done by indenting the first line based on
|
237
|
-
`haml-compute-indentation' and preserving the relative
|
238
|
-
indentation of the rest of the region.
|
239
|
-
|
240
|
-
If this command is used multiple times in a row, it will cycle
|
241
|
-
between possible indentations."
|
242
|
-
(save-excursion
|
243
|
-
(goto-char end)
|
244
|
-
(setq end (point-marker))
|
245
|
-
(goto-char start)
|
246
|
-
(let (this-line-column current-column
|
247
|
-
(next-line-column
|
248
|
-
(if (and (equal last-command this-command) (/= (current-indentation) 0))
|
249
|
-
(* (/ (- (current-indentation) 1) haml-indent-offset) haml-indent-offset)
|
250
|
-
(haml-compute-indentation))))
|
251
|
-
(while (< (point) end)
|
252
|
-
(setq this-line-column next-line-column
|
253
|
-
current-column (current-indentation))
|
254
|
-
;; Delete whitespace chars at beginning of line
|
255
|
-
(delete-horizontal-space)
|
256
|
-
(unless (eolp)
|
257
|
-
(setq next-line-column (save-excursion
|
258
|
-
(loop do (forward-line 1)
|
259
|
-
while (and (not (eobp)) (looking-at "^[ \t]*$")))
|
260
|
-
(+ this-line-column
|
261
|
-
(- (current-indentation) current-column))))
|
262
|
-
;; Don't indent an empty line
|
263
|
-
(unless (eolp) (indent-to this-line-column)))
|
264
|
-
(forward-line 1)))
|
265
|
-
(move-marker end nil)))
|
266
|
-
|
267
|
-
(defun haml-indent-line ()
|
268
|
-
"Indent the current line.
|
269
|
-
The first time this command is used, the line will be indented to the
|
270
|
-
maximum sensible indentation. Each immediately subsequent usage will
|
271
|
-
back-dent the line by `haml-indent-offset' spaces. On reaching column
|
272
|
-
0, it will cycle back to the maximum sensible indentation."
|
273
|
-
(interactive "*")
|
274
|
-
(let ((ci (current-indentation))
|
275
|
-
(cc (current-column))
|
276
|
-
(need (haml-compute-indentation)))
|
277
|
-
(save-excursion
|
278
|
-
(beginning-of-line)
|
279
|
-
(delete-horizontal-space)
|
280
|
-
(if (and (equal last-command this-command) (/= ci 0))
|
281
|
-
(indent-to (* (/ (- ci 1) haml-indent-offset) haml-indent-offset))
|
282
|
-
(indent-to need)))
|
283
|
-
(if (< (current-column) (current-indentation))
|
284
|
-
(forward-to-indentation 0))))
|
285
|
-
|
286
|
-
(defun haml-reindent-region-by (n)
|
287
|
-
"Add N spaces to the beginning of each line in the region.
|
288
|
-
If N is negative, will remove the spaces instead. Assumes all
|
289
|
-
lines in the region have indentation >= that of the first line."
|
290
|
-
(let ((ci (current-indentation)))
|
291
|
-
(save-excursion
|
292
|
-
(replace-regexp (concat "^" (make-string ci ? ))
|
293
|
-
(make-string (max 0 (+ ci n)) ? )
|
294
|
-
nil (point) (mark)))))
|
295
|
-
|
296
|
-
(defun haml-electric-backspace (arg)
|
297
|
-
"Delete characters or back-dent the current line.
|
298
|
-
If invoked following only whitespace on a line, will back-dent
|
299
|
-
the line and all nested lines to the immediately previous
|
300
|
-
multiple of `haml-indent-offset' spaces.
|
301
|
-
|
302
|
-
Set `haml-backspace-backdents-nesting' to nil to just back-dent
|
303
|
-
the current line."
|
304
|
-
(interactive "*p")
|
305
|
-
(if (or (/= (current-indentation) (current-column))
|
306
|
-
(bolp)
|
307
|
-
(looking-at "^[ \t]+$"))
|
308
|
-
(backward-delete-char arg)
|
309
|
-
(let ((ci (current-column)))
|
310
|
-
(beginning-of-line)
|
311
|
-
(if haml-backspace-backdents-nesting
|
312
|
-
(haml-mark-sexp-but-not-next-line)
|
313
|
-
(set-mark (save-excursion (end-of-line) (point))))
|
314
|
-
(haml-reindent-region-by (* (- arg) haml-indent-offset))
|
315
|
-
(back-to-indentation)
|
316
|
-
(pop-mark))))
|
317
|
-
|
318
|
-
(defun haml-kill-line-and-indent ()
|
319
|
-
"Kill the current line, and re-indent all lines nested beneath it."
|
320
|
-
(interactive)
|
321
|
-
(beginning-of-line)
|
322
|
-
(haml-mark-sexp-but-not-next-line)
|
323
|
-
(kill-line 1)
|
324
|
-
(haml-reindent-region-by (* -1 haml-indent-offset)))
|
325
|
-
|
326
|
-
;; Setup/Activation
|
327
|
-
|
328
|
-
(provide 'haml-mode)
|
@@ -1,88 +0,0 @@
|
|
1
|
-
;;; sass-mode.el -- Major mode for editing Sass files
|
2
|
-
;;; Written by Nathan Weizenbaum
|
3
|
-
|
4
|
-
;;; Because Sass's indentation schema is similar
|
5
|
-
;;; to that of YAML and Python, many indentation-related
|
6
|
-
;;; functions are similar to those in yaml-mode and python-mode.
|
7
|
-
|
8
|
-
;;; To install, save this somewhere and add the following to your .emacs file:
|
9
|
-
;;;
|
10
|
-
;;; (add-to-list 'load-path "/path/to/sass-mode.el")
|
11
|
-
;;; (require 'sass-mode nil 't)
|
12
|
-
;;; (add-to-list 'auto-mode-alist '("\\.sass$" . sass-mode))
|
13
|
-
;;;
|
14
|
-
|
15
|
-
;;; Code:
|
16
|
-
|
17
|
-
(require 'haml-mode)
|
18
|
-
|
19
|
-
;; User definable variables
|
20
|
-
|
21
|
-
(defgroup sass nil
|
22
|
-
"Support for the Sass template language."
|
23
|
-
:group 'languages
|
24
|
-
:prefix "sass-")
|
25
|
-
|
26
|
-
(defcustom sass-mode-hook nil
|
27
|
-
"Hook run when entering Sass mode."
|
28
|
-
:type 'hook
|
29
|
-
:group 'sass)
|
30
|
-
|
31
|
-
(defcustom sass-indent-offset 2
|
32
|
-
"Amount of offset per level of indentation."
|
33
|
-
:type 'integer
|
34
|
-
:group 'sass)
|
35
|
-
|
36
|
-
(defvar sass-non-block-openers
|
37
|
-
'("^ *:[^ \t]+[ \t]+[^ \t]"
|
38
|
-
"^ *[^ \t:]+[ \t]*[=:][ \t]*[^ \t]")
|
39
|
-
"A list of regexps that match lines of Sass that couldn't have
|
40
|
-
text nested beneath them.")
|
41
|
-
|
42
|
-
;; Font lock
|
43
|
-
|
44
|
-
(defconst sass-font-lock-keywords
|
45
|
-
'(("^ *\\(\t\\)" 1 'haml-tab-face)
|
46
|
-
("^@.*" 0 font-lock-constant-face)
|
47
|
-
("\\(\'[^']*'\\)" 1 font-lock-string-face append)
|
48
|
-
("\\(\"[^\"]*\"\\)" 1 font-lock-string-face append)
|
49
|
-
("\\(#[0-9a-fA-F]\\{3\\}\\{1,2\\}\\>\\)" 1 font-lock-string-face append)
|
50
|
-
("\\(:[A-Za-z-]+\\|[A-Za-z-]+:\\)" 0 font-lock-constant-face append)
|
51
|
-
("![a-z0-9_-]+" 0 font-lock-variable-name-face append)
|
52
|
-
("^ *\\(/[/*].*\\)$" 1 font-lock-comment-face append)
|
53
|
-
("\\(?:^\\|,\\) *\\(#[a-z0-9_-]+\/?\\)" 1 font-lock-keyword-face)
|
54
|
-
("\\(?:^\\|,\\) *\\(\\.[a-z0-9_-]+\/?\\)" 1 font-lock-type-face)
|
55
|
-
("\\(?:^\\|,\\) *\\(&\\|[a-z0-9_]+\/?\\)" 1 font-lock-function-name-face)
|
56
|
-
("\\([=]\\)" 0 font-lock-preprocessor-face prepend)
|
57
|
-
("\\(?:^\\|,\\) *\\(#[a-z0-9_]+\/?\\)" (1 font-lock-keyword-face)
|
58
|
-
("\\.[a-z0-9_-]+" nil nil (0 font-lock-type-face)))
|
59
|
-
("\\(?:^\\|,\\) *\\(\\.[a-z0-9_]+\/?\\)" (1 font-lock-type-face)
|
60
|
-
("\\.[a-z0-9_-]+" nil nil (0 font-lock-type-face)))
|
61
|
-
("\\(?:^\\|,\\) *\\(\\.[a-z0-9_]+\/?\\)" (1 font-lock-type-face)
|
62
|
-
("\\#[a-z0-9_-]+" nil nil (0 font-lock-keyword-face)))
|
63
|
-
("\\(?:^\\|,\\) *\\(&\\|[a-z0-9_]+\/?\\)" (1 font-lock-function-name-face)
|
64
|
-
("\\.[a-z0-9_-]+" nil nil (0 font-lock-type-face)))
|
65
|
-
("\\(?:^\\|,\\) *\\(&\\|[a-z0-9_]+\/?\\)" (1 font-lock-function-name-face)
|
66
|
-
("\\#[a-z0-9_-]+" nil nil (0 font-lock-keyword-face)))))
|
67
|
-
|
68
|
-
;; Constants
|
69
|
-
|
70
|
-
;; Mode setup
|
71
|
-
|
72
|
-
(define-derived-mode sass-mode haml-mode "Sass"
|
73
|
-
"Major mode for editing Sass files."
|
74
|
-
(set (make-local-variable 'haml-indent-function) 'sass-indent-p)
|
75
|
-
(set (make-local-variable 'haml-indent-offset) sass-indent-offset)
|
76
|
-
(setq font-lock-defaults '(sass-font-lock-keywords nil t)))
|
77
|
-
|
78
|
-
;; Indentation
|
79
|
-
|
80
|
-
(defun sass-indent-p ()
|
81
|
-
"Returns true if the current line can have lines nested beneath it."
|
82
|
-
(loop for opener in sass-non-block-openers
|
83
|
-
unless (looking-at opener) return t
|
84
|
-
return nil))
|
85
|
-
|
86
|
-
;; Setup/Activation
|
87
|
-
|
88
|
-
(provide 'sass-mode)
|
@@ -1,65 +0,0 @@
|
|
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
|