From 6fc7371079c31ab39fdc58ae63ad6a54ee43adbf Mon Sep 17 00:00:00 2001 From: Simon Cossar Date: Tue, 14 Apr 2015 18:43:49 -0700 Subject: [PATCH 1/7] Add memory to VM --- Vagrantfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Vagrantfile b/Vagrantfile index 54955eaa0..eb822356d 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -17,7 +17,7 @@ Vagrant.configure("2") do |config| config.vm.provider :virtualbox do |v| # This setting gives the VM 1024MB of RAM instead of the default 384. - v.customize ["modifyvm", :id, "--memory", [ENV['DISCOURSE_VM_MEM'].to_i, 1024].max] + v.customize ["modifyvm", :id, "--memory", [ENV['DISCOURSE_VM_MEM'].to_i, 2048].max] # Who has a single core cpu these days anyways? cpu_count = 2 From 0ed67e919c02aa3834f31fa9d61efff4bcae87d2 Mon Sep 17 00:00:00 2001 From: Simon Cossar Date: Tue, 14 Apr 2015 18:53:02 -0700 Subject: [PATCH 2/7] Add r2 gem for rtl stylesheet conversion --- Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile b/Gemfile index 71286aeaa..9b3e98478 100644 --- a/Gemfile +++ b/Gemfile @@ -147,6 +147,7 @@ gem 'omniauth-google-oauth2' gem 'oj' gem 'pg' gem 'pry-rails', require: false +gem 'r2', '~> 0.2.5', require: false gem 'rake' From e52ab2ecf1b267d8a6196abea5abcc9afe895c5f Mon Sep 17 00:00:00 2001 From: Simon Cossar Date: Tue, 14 Apr 2015 19:02:52 -0700 Subject: [PATCH 3/7] Update rtl conditional check in DiscourseSassCompiler --- lib/sass/discourse_sass_compiler.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/sass/discourse_sass_compiler.rb b/lib/sass/discourse_sass_compiler.rb index ebb799ecc..bde2f84db 100644 --- a/lib/sass/discourse_sass_compiler.rb +++ b/lib/sass/discourse_sass_compiler.rb @@ -64,12 +64,12 @@ class DiscourseSassCompiler }.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 + # and run R2 gem on compiled CSS if true and R2 gem is available css_output = css - if GlobalSetting.rtl_css + if !SiteSetting.allow_user_locale && SiteSetting.default_locale.in?(%w(he ar fa_IR)) begin - require 'rtlit' - css_output = RTLit::Converter.to_rtl(css) if defined?(RTLit) + require 'r2' + css_output = R2.r2(css) if defined?(R2) rescue; end end css_output From 9b7f98edc5221fa5d4d86cb446cd39366cbcd632 Mon Sep 17 00:00:00 2001 From: Simon Cossar Date: Tue, 14 Apr 2015 19:07:23 -0700 Subject: [PATCH 4/7] Add to html element - this needs to be explicit so it can be reversed by r2 --- app/assets/stylesheets/common/foundation/base.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/stylesheets/common/foundation/base.scss b/app/assets/stylesheets/common/foundation/base.scss index f8e044ade..bec9a6395 100644 --- a/app/assets/stylesheets/common/foundation/base.scss +++ b/app/assets/stylesheets/common/foundation/base.scss @@ -12,6 +12,7 @@ html { line-height: $base-line-height; background-color: $secondary; overflow-y: scroll; + direction: ltr; } // Links From 4b8ad7637c3ca7d1a65c20a398c2791c21719b93 Mon Sep 17 00:00:00 2001 From: Simon Cossar Date: Tue, 14 Apr 2015 19:19:11 -0700 Subject: [PATCH 5/7] Remove old styles from rtl.scss. Add new styles to fix some positioning. --- Gemfile.lock | 2 + app/assets/stylesheets/common/base/rtl.scss | 418 ++------------------ 2 files changed, 33 insertions(+), 387 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index fca49b6c9..00545971e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -295,6 +295,7 @@ GEM rack (>= 1.1, < 2.0) qunit-rails (0.0.7) railties + r2 (0.2.5) rack (1.5.2) rack-mini-profiler (0.9.3) rack (>= 1.1.3) @@ -511,6 +512,7 @@ DEPENDENCIES pry-rails puma qunit-rails + r2 (~> 0.2.5) rack-mini-profiler rack-protection rails diff --git a/app/assets/stylesheets/common/base/rtl.scss b/app/assets/stylesheets/common/base/rtl.scss index 86c0dd653..9a6dfeb7e 100644 --- a/app/assets/stylesheets/common/base/rtl.scss +++ b/app/assets/stylesheets/common/base/rtl.scss @@ -1,389 +1,33 @@ -.rtl { - - #main { - direction: rtl; - } - - .btn .fa { - margin-left: 7px; - margin-right: 0; - } - - #topic-footer-buttons .btn { - margin-bottom: 5px; - margin-left: 10px; - margin-right: 0; - } - - .caret { - display: inline-block; - width: 0px; - height: 0px; - vertical-align: middle; - border-top: 4px solid #333; - border-right: 4px solid transparent; - border-left: 4px solid transparent; - content: ""; - margin-right: 5px; - margin-left: 0; - } - - #topic-title h1 a.edit-topic { - font-size: .9em; - position: absolute; - margin-right: 8px; - margin-left: 0; - } - - nav.post-controls .create i { - margin-left: 5px; - margin-right: 0; - } - - .btn.no-text .fa { - margin-left: 0px; - line-height: 10px; - } - - #show-topic-admin { - padding: 5px 8px; - margin-top: 5px; - left: 20px; - } - - #topic-title .star { - font-size: 1.429em; - margin-top: 6px; - margin-left: 6px; - } - - a.star { - display: inline-block; - float: right; - } - - .topic-meta-data-inside { - margin-top: -22px; - float: left; - font-size: 0.857em; - } - .post-info a { - color: #B3B3B3; - padding-left: 5px; - } - - - .topic-meta-data { - float: right; - position: relative; - } - - - .span14 { - width: 70%; - padding-right: 1%; - } - .topic-body { - border-top: 1px solid #E6E6E6; - float: right; - position: relative; - padding: 10px 0px 15px; - } - - a.reply-new { - position: absolute; - color: #8C8C8C; - margin-top: -2px; - left: 0; - } - - .reply-new i { - font-size: 0.857em; - margin-left: 5px; - background: none repeat scroll 0% 0% #FFF; - border: 1px solid #E6E6E6; - padding: 2px 4px; - border-radius: 20px; - transition: all 0.15s linear 0s; - } - - .gutter .post-links { - list-style-type: none; - padding-right: 19px; - position: relative; - margin-right: 5px; - line-height: 18px; - } - - - .dropdown-menu a > div { - margin-right: 26px; - } - - .dropdown-menu .icon { - margin-top: 3px; - float: right; - font-size: 1.286em; - } - - .topic-list th, .topic-list td { - padding: 12px 5px; - line-height: 1.25; - text-align: right; - vertical-align: middle; - } - - .topic-admin-menu { - background-color: #FFF; - width: 205px; - padding: 10px; - border: 1px solid #E6E6E6; - position: fixed; - top: 70px; - z-index: 1000; - left: 10px; - } - - .btn-admin { - text-align: right; - } - - #share-link .link { - margin-right: 2px; - float: left; - font-size: 1.429em; - } - - #share-link .social-link { - margin-right: 2px; - margin-left: 8px; - float: right; - font-size: 1.571em; - } - - body .radio input[type="radio"], body .checkbox input[type="checkbox"] { - float: right; - margin-right: -18px; - } - - body .radio, body .checkbox { - min-height: 18px; - padding-right: 18px; - } - - .modal-header .close { - float: left; - font-size: 1.429em; - margin: 10px 10px 0px; - text-decoration: none; - color: #B3B3B3; - cursor: pointer; - } - - #reply-control .wmd-controls .textarea-wrapper { - padding-left: 5px; - float: right; - } - - #reply-control .wmd-controls .preview-wrapper { - padding-right: 5px; - float: left; - } - - #reply-control #wmd-button-bar { - top: 0px; - position: absolute; - border-bottom: 1px solid #E6E6E6; - background-color: #FFF; - z-index: 100; - right: 0; - } - - #reply-control .toggle-preview { - right: auto; - left: 5px; - text-decoration: underline; - } - - #reply-control a.cancel { - text-decoration: underline; - padding-right: 7px; - } - - #reply-control .toggler { - display: block; - width: 13px; - height: 13px; - left: 13px; - position: absolute; - font-size: 1.071em; - color: #333; - text-decoration: none; - right: auto; - } - - .d-header .title { - display: table; - float: right; - height: 40px; - } - - .d-header .panel { - float: left; - position: relative; - } - - .d-header .icons > li { - float: right; - } - - .d-header .icons { - float: right; - text-align: center; - margin: 0px 0px 0px 5px; - list-style: none outside none; - transition: all linear 0.15s; - } - - .nav-pills > li { - float: right; - margin-left: 5px; - } - - #navigation-bar .has-icon span:before { - margin-left: 4px; - font: 1.071em/0.9 "FontAwesome"; - } - - .list-controls .btn { - float: left; - margin-right: 8px; - margin-bottom: 10px; - font-size: 1.143em; - font-weight: normal; - } - - ol.category-breadcrumb { - display: block; - float: right; - list-style: none outside none; - margin: 0px 0px 0px 10px; - padding: 0px; - } - - .list-controls .nav { - float: right; - margin-bottom: 18px; - } - - .d-dropdown { - display: none; - width: 320px; - position: absolute; - top: 100%; - left: 0px; - z-index: 1100; - border: 1px solid #E6E6E6; - background-color: #FFF; - box-shadow: 0px 2px 2px rgba(51, 51, 51, 0.4); - right: auto; - } - - .category-dropdown-menu a.badge-category { - font-size: 0.929em; - font-weight: bold; - padding: 4px 0px; - float: none; - line-height: 19px; - text-transform: none; - width: 100%; - min-width: 102px; - text-align: center; - margin-left: 20px; - margin-bottom: 7px; - margin-right: 0px; - } - - .composer-popup a.close { - float: left; - color: #333; - opacity: 0.5; - font-size: 1.071em; - } - - #topic-progress { - position: relative; - right: 345px; - border: medium none; - background-color: #E6E6E6; - color: #8C8C8C; - width: 145px; - height: 34px; - left: auto; - } - - .topic-map .map li { - float: right; - padding: 7px 11px; - } - - .topic-map .buttons { - float: left; - } - - nav.post-controls button.like, nav.post-controls button.edit, nav.post-controls button.flag, nav.post-controls button.delete, nav.post-controls button.share, nav.post-controls button.bookmark, nav.post-controls button.create { - float: left; - } - - button.create { - float: left; - } - - .topic-list .star { - width: 20px; - padding-left: 0px; - } - - .topic-list th:first-of-type, .topic-list td:first-of-type { - padding-right: 10px; - } - - button.create { - float: right; - } - - .extra-info-wrapper { - float: right; - width: 78%; - max-width: 800px; - } - - body .form-horizontal .controls { - margin-right: 160px; - } - - body .form-horizontal .control-label { - float: right; - width: 140px; - padding-top: 5px; - text-align: right; - font-weight: bold; - } - - .cooked { - margin-top: 40px; - } - - .logo-small { - margin-right: 0px; - } - - .d-dropdown .category { - float: right; - } - - .topic-list .pull-left { - float: right; - } +// Right to left styles. +// *** These styles are all going to be flipped by the r2 gem *** +// There may be a 'do not flip' flag that can be used, but I haven't found it. +// Keep the topic admin menu on the page +.rtl .topic-admin-menu { + right: 0 !important; +} + +// This is used to flip the .fa-caret-right icon +@mixin rotate( $degrees ) { + -webkit-transform: rotate(#{$degrees}deg); + -moz-transform: rotate(#{$degrees}deg); + -ms-transform: rotate(#{$degrees}deg); + -o-transform: rotate(#{$degrees}deg); + transform: rotate(#{$degrees}deg); + + filter: progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand', M11=#{cos($degrees)}, M12=-#{sin($degrees)}, M21=#{sin($degrees)}, M22=#{cos($degrees)}); + -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand', M11=#{cos($degrees)}, M12=-#{sin($degrees)}, M21=#{sin($degrees)}, M22=#{cos($degrees)})"; + zoom: 1; +} + +// Get the right caret to point left +.rtl .fa-caret-right { + @include rotate(180); +} + +// Changes the triangle arrow direction in .nav-stacked .active +// The 'left' and 'right' in these selectors is not being flipped by r2. +.rtl .nav-stacked .active > a::after { + border-left-color: transparent !important; + border-right-color: $secondary !important; } From 51ebc56f89f08054c0b7bb46f1597273aefc1b18 Mon Sep 17 00:00:00 2001 From: Simon Cossar Date: Tue, 14 Apr 2015 19:50:55 -0700 Subject: [PATCH 6/7] Move 'if defined?' conditional to before 'require' statement for r2 gem --- lib/sass/discourse_sass_compiler.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/sass/discourse_sass_compiler.rb b/lib/sass/discourse_sass_compiler.rb index bde2f84db..bccb3c239 100644 --- a/lib/sass/discourse_sass_compiler.rb +++ b/lib/sass/discourse_sass_compiler.rb @@ -66,11 +66,13 @@ class DiscourseSassCompiler # Check if CSS needs to be RTLed after compilation # and run R2 gem on compiled CSS if true and R2 gem is available css_output = css - if !SiteSetting.allow_user_locale && SiteSetting.default_locale.in?(%w(he ar fa_IR)) - begin - require 'r2' - css_output = R2.r2(css) if defined?(R2) - rescue; end + if defined?(R2) + if !SiteSetting.allow_user_locale && SiteSetting.default_locale.in?(%w(he ar fa_IR)) + begin + require 'r2' + css_output = R2.r2(css) + rescue; end + end end css_output end From b0a3401186f8e5d024c7cb3f9d008d145af3cb40 Mon Sep 17 00:00:00 2001 From: Simon Cossar Date: Tue, 14 Apr 2015 20:14:04 -0700 Subject: [PATCH 7/7] Fix if defined? conditional for R2 --- lib/sass/discourse_sass_compiler.rb | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/sass/discourse_sass_compiler.rb b/lib/sass/discourse_sass_compiler.rb index bccb3c239..bde2f84db 100644 --- a/lib/sass/discourse_sass_compiler.rb +++ b/lib/sass/discourse_sass_compiler.rb @@ -66,13 +66,11 @@ class DiscourseSassCompiler # Check if CSS needs to be RTLed after compilation # and run R2 gem on compiled CSS if true and R2 gem is available css_output = css - if defined?(R2) - if !SiteSetting.allow_user_locale && SiteSetting.default_locale.in?(%w(he ar fa_IR)) - begin - require 'r2' - css_output = R2.r2(css) - rescue; end - end + if !SiteSetting.allow_user_locale && SiteSetting.default_locale.in?(%w(he ar fa_IR)) + begin + require 'r2' + css_output = R2.r2(css) if defined?(R2) + rescue; end end css_output end