Merge pull request #2633 from zohararad/master
Add RTL support to Discourse CSS Theme
This commit is contained in:
commit
31cc6ea633
1
Gemfile
1
Gemfile
|
@ -154,6 +154,7 @@ gem 'rack-protection' # security
|
|||
group :assets do
|
||||
gem 'sass-rails', '~> 4.0.2'
|
||||
gem 'uglifier'
|
||||
gem 'rtlit', require: false # for css rtling
|
||||
end
|
||||
|
||||
group :test do
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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,17 @@ 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
|
||||
css_output = css
|
||||
if GlobalSetting.rtl_css
|
||||
begin
|
||||
require 'rtlit'
|
||||
css_output = RTLit::Converter.to_rtl(css) if defined?(RTLit)
|
||||
rescue; end
|
||||
end
|
||||
css_output
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue