diff --git a/Gemfile b/Gemfile index 6d7f176eb4e..51234139fa0 100644 --- a/Gemfile +++ b/Gemfile @@ -154,6 +154,7 @@ gem 'rack-protection' # security group :assets do gem 'sass-rails', '~> 4.0.2' gem 'uglifier' + gem 'rtlit' # for css rtling end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index e7d2f509e5a..aa8e92501c7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -308,6 +308,7 @@ GEM rspec-core (~> 2.14.0) rspec-expectations (~> 2.14.0) rspec-mocks (~> 2.14.0) + rtlit (0.0.5) ruby-openid (2.5.0) ruby-readability (0.6.1) guess_html_encoding (>= 0.0.4) @@ -464,6 +465,7 @@ DEPENDENCIES rmmseg-cpp rspec-given rspec-rails + rtlit ruby-readability sanitize sass diff --git a/config/discourse_defaults.conf b/config/discourse_defaults.conf index 3678c838f39..1299a36ad25 100644 --- a/config/discourse_defaults.conf +++ b/config/discourse_defaults.conf @@ -97,3 +97,6 @@ serve_static_assets = false # number of sidekiq workers (launched via unicorn master) sidekiq_workers = 5 + +# adjust stylesheets to rtl (requires "rtlit" gem) +rtl_css = false \ No newline at end of file diff --git a/lib/sass/discourse_sass_compiler.rb b/lib/sass/discourse_sass_compiler.rb index 41568ff1766..a5c4db3cd91 100644 --- a/lib/sass/discourse_sass_compiler.rb +++ b/lib/sass/discourse_sass_compiler.rb @@ -49,7 +49,7 @@ class DiscourseSassCompiler style: :expanded } - ::Sass::Engine.new(@scss, { + css = ::Sass::Engine.new(@scss, { syntax: :scss, cache: false, read_cache: false, @@ -60,6 +60,14 @@ class DiscourseSassCompiler environment: context.environment } }.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