Add RTL support to Discourse CSS pre-processing using the RTLit gem and configurable via discourse.conf

This commit is contained in:
Zohar Arad 2014-08-08 09:31:31 +03:00
parent c1cbf1b269
commit 557af8b8bd
4 changed files with 15 additions and 1 deletions

View File

@ -154,6 +154,7 @@ gem 'rack-protection' # security
group :assets do group :assets do
gem 'sass-rails', '~> 4.0.2' gem 'sass-rails', '~> 4.0.2'
gem 'uglifier' gem 'uglifier'
gem 'rtlit' # for css rtling
end end
group :test do group :test do

View File

@ -308,6 +308,7 @@ GEM
rspec-core (~> 2.14.0) rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0) rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0) rspec-mocks (~> 2.14.0)
rtlit (0.0.5)
ruby-openid (2.5.0) ruby-openid (2.5.0)
ruby-readability (0.6.1) ruby-readability (0.6.1)
guess_html_encoding (>= 0.0.4) guess_html_encoding (>= 0.0.4)
@ -464,6 +465,7 @@ DEPENDENCIES
rmmseg-cpp rmmseg-cpp
rspec-given rspec-given
rspec-rails rspec-rails
rtlit
ruby-readability ruby-readability
sanitize sanitize
sass sass

View File

@ -97,3 +97,6 @@ serve_static_assets = false
# number of sidekiq workers (launched via unicorn master) # number of sidekiq workers (launched via unicorn master)
sidekiq_workers = 5 sidekiq_workers = 5
# adjust stylesheets to rtl (requires "rtlit" gem)
rtl_css = false

View File

@ -49,7 +49,7 @@ class DiscourseSassCompiler
style: :expanded style: :expanded
} }
::Sass::Engine.new(@scss, { css = ::Sass::Engine.new(@scss, {
syntax: :scss, syntax: :scss,
cache: false, cache: false,
read_cache: false, read_cache: false,
@ -60,6 +60,14 @@ class DiscourseSassCompiler
environment: context.environment environment: context.environment
} }
}.merge(debug_opts)).render }.merge(debug_opts)).render
# Check if CSS needs to be RTLed after compilation
# and run RTLit gem on compiled CSS if true and RTLit gem is available
if GlobalSetting.rtl_css && defined?(RTLit)
RTLit::Converter.to_rtl(css)
else
css
end
end end
end end