-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rules
94 lines (83 loc) · 2.69 KB
/
Rules
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env ruby
# A few helpful tips about the Rules file:
#
# * The string given to #compile and #route are matching patterns for
# identifiers--not for paths. Therefore, you can't match on extension.
#
# * The order of rules is important: for each item, only the first matching
# rule is applied.
#
# * Item identifiers start and end with a slash (e.g. "/about/" for the file
# "content/about.html"). To select all children, grandchildren, ... of an
# item, use the pattern "/about/*/"; "/about/*" will also select the parent,
# because "*" matches zero or more characters.
require 'compass'
require 'coffee_script'
Compass.add_project_configuration('compass.rb')
I18n.available_locales.each do |locale|
compile "*", :rep => :"locale_#{locale}" do
extensions = item[:extension].split('.').reverse
if item.binary? || extensions.size == 1
# don't filter binary items or ones with only a single extension
else
I18n.locale = locale
extensions.each do |extension|
case extension
when 'coffee'
filter :coffee
when 'erb'
filter :erb
when 'sass'
filter :sass, Compass.sass_engine_options.merge(:syntax => :sass)
when 'scss'
filter :sass, Compass.sass_engine_options.merge(:syntax => :scss)
when 'haml'
filter :haml, {:escape_attrs => false}
filter :erb
layout 'default'
when 'layout'
layout 'default'
end
end
end
end
end
I18n.available_locales.each do |locale|
route '*', :rep => :"locale_#{locale}" do
I18n.locale = locale
skip_locale_path = false
if item.binary?
# Write item with /foo/ to /foo.ext
item.identifier.chop + '.' + item[:extension]
elsif item.identifier.chop.split('/').last !~ /^_/
extensions = item[:extension].split('.').reverse
path = item.identifier.chop
extensions.each do |extension|
case extension
when 'nolocale'
skip_locale_path = true
when 'locale'
path << "-#{locale}"
when 'html', 'php'
path = "/#{locale}#{path}" if I18n.default_locale != locale && !skip_locale_path
path = "#{path}/index"
break
when 'css'
path.sub!('stylesheets', 'css')
end
end
unless skip_locale_path
path = path.split('/').map do |path_element|
txt = I18n.translate("page_#{path_element.gsub('-', '_')}")
if txt =~ /translation missing/ || path_element == 'index'
path_element
else
txt
end
end.join('/')
end
"#{path}.#{extensions.last}"
end
end
end
layout '*', :haml, :format => :html5