From 80f576bb8aaab83ca78a21f20c03cb4b4fb18f11 Mon Sep 17 00:00:00 2001 From: connorshea Date: Mon, 11 Apr 2016 15:27:07 -0600 Subject: Replace Haml with Hamlit. Hamlit is a library that's faster than Haml while implementing most of its features: https://github.com/k0kubun/hamlit Not sure if this breaks anything, but as far as I can tell most things work the same. No obvious regressions that I've been able to find. --- Gemfile | 3 ++- Gemfile.lock | 18 +++++------------- app/helpers/application_helper.rb | 2 +- config/initializers/haml.rb | 7 ------- config/initializers/hamlit.rb | 15 +++++++++++++++ 5 files changed, 23 insertions(+), 22 deletions(-) delete mode 100644 config/initializers/haml.rb create mode 100644 config/initializers/hamlit.rb diff --git a/Gemfile b/Gemfile index 092ea9d69b0..ae6b917b620 100644 --- a/Gemfile +++ b/Gemfile @@ -76,7 +76,7 @@ gem 'rack-cors', '~> 0.4.0', require: 'rack/cors' gem "kaminari", "~> 0.17.0" # HAML -gem "haml-rails", '~> 0.9.0' +gem "hamlit" # Files attachments gem "carrierwave", '~> 0.10.0' @@ -344,5 +344,6 @@ gem 'oauth2', '~> 1.0.0' # Soft deletion gem "paranoia", "~> 2.0" + # Health check gem 'health_check', '~> 1.5.1' diff --git a/Gemfile.lock b/Gemfile.lock index ba16e4bf337..02c7b75aba3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -320,14 +320,10 @@ GEM grape-entity (0.4.8) activesupport multi_json (>= 1.3.2) - haml (4.0.7) + hamlit (2.5.0) + temple (~> 0.7.6) + thor tilt - haml-rails (0.9.0) - actionpack (>= 4.0.1) - activesupport (>= 4.0.1) - haml (>= 4.0.6, < 5.0) - html2haml (>= 1.0.1) - railties (>= 4.0.1) hashie (3.4.3) health_check (1.5.1) rails (>= 2.3.0) @@ -337,11 +333,6 @@ GEM html-pipeline (1.11.0) activesupport (>= 2) nokogiri (~> 1.4) - html2haml (2.0.0) - erubis (~> 2.7.0) - haml (~> 4.0.0) - nokogiri (~> 1.6.0) - ruby_parser (~> 3.5) htmlentities (4.3.4) http_parser.rb (0.5.3) httparty (0.13.7) @@ -733,6 +724,7 @@ GEM railties (>= 3.2.5, < 6) teaspoon-jasmine (2.2.0) teaspoon (>= 1.0.0) + temple (0.7.7) term-ansicolor (1.3.2) tins (~> 1.0) test_after_commit (0.4.2) @@ -882,7 +874,7 @@ DEPENDENCIES gon (~> 6.0.1) grape (~> 0.13.0) grape-entity (~> 0.4.2) - haml-rails (~> 0.9.0) + hamlit health_check (~> 1.5.1) hipchat (~> 1.5.0) html-pipeline (~> 1.11.0) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 41859841834..62d13a4b4f3 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -197,7 +197,7 @@ module ApplicationHelper def render_markup(file_name, file_content) if gitlab_markdown?(file_name) - Haml::Helpers.preserve(markdown(file_content)) + Hamlit::RailsHelpers.preserve(markdown(file_content)) elsif asciidoc?(file_name) asciidoc(file_content) elsif plain?(file_name) diff --git a/config/initializers/haml.rb b/config/initializers/haml.rb deleted file mode 100644 index 1516476815a..00000000000 --- a/config/initializers/haml.rb +++ /dev/null @@ -1,7 +0,0 @@ -Haml::Template.options[:ugly] = true - -# Remove the `:coffee` and `:coffeescript` filters -# -# See https://git.io/vztMu and http://stackoverflow.com/a/17571242/223897 -Haml::Filters.remove_filter('coffee') -Haml::Filters.remove_filter('coffeescript') diff --git a/config/initializers/hamlit.rb b/config/initializers/hamlit.rb new file mode 100644 index 00000000000..259d562e586 --- /dev/null +++ b/config/initializers/hamlit.rb @@ -0,0 +1,15 @@ +module Hamlit + class TemplateHandler + def call(template) + Engine.new( + generator: Temple::Generators::RailsOutputBuffer, + attr_quote: '"', + ).call(template.source) + end + end +end + +ActionView::Template.register_template_handler( + :haml, + Hamlit::TemplateHandler.new, +) -- cgit v1.2.1 From 8867c5c4b7c3386ae7ad96f8c1faa17d6823393f Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Fri, 17 Jun 2016 23:16:53 -0600 Subject: Remove Haml helpers from the visibility level spec. --- spec/helpers/visibility_level_helper_spec.rb | 5 ----- 1 file changed, 5 deletions(-) diff --git a/spec/helpers/visibility_level_helper_spec.rb b/spec/helpers/visibility_level_helper_spec.rb index ff98249570d..5e7594170c5 100644 --- a/spec/helpers/visibility_level_helper_spec.rb +++ b/spec/helpers/visibility_level_helper_spec.rb @@ -1,11 +1,6 @@ require 'spec_helper' describe VisibilityLevelHelper do - include Haml::Helpers - - before :all do - init_haml_helpers - end let(:project) { build(:project) } let(:group) { build(:group) } -- cgit v1.2.1 From 02f0cb690f2e6da65e1a818cd37b1fe9b037f8f3 Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Wed, 22 Jun 2016 16:18:39 -0600 Subject: Add changelog entry. --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 7179cd13e11..e5be7e6711f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ Please view this file on the master branch, on stable branches it's out of date. v 8.10.0 (unreleased) + - Replace HAML with Hamlit to make view rendering faster. !3666 - Wrap code blocks on Activies and Todos page. !4783 (winniehell) - Fix MR-auto-close text added to description. !4836 -- cgit v1.2.1 From 262f902d9afd4c7ec13124141312726d68f5ca79 Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Thu, 23 Jun 2016 09:21:35 -0600 Subject: Restrict hamlit version, remove coffeescript filters. --- CHANGELOG | 2 +- Gemfile | 3 +-- Gemfile.lock | 2 +- config/initializers/hamlit.rb | 3 +++ doc/development/gotchas.md | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index e5be7e6711f..4fd0146b917 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,7 +1,7 @@ Please view this file on the master branch, on stable branches it's out of date. v 8.10.0 (unreleased) - - Replace HAML with Hamlit to make view rendering faster. !3666 + - Replace Haml with Hamlit to make view rendering faster. !3666 - Wrap code blocks on Activies and Todos page. !4783 (winniehell) - Fix MR-auto-close text added to description. !4836 diff --git a/Gemfile b/Gemfile index ae6b917b620..bae00090fda 100644 --- a/Gemfile +++ b/Gemfile @@ -76,7 +76,7 @@ gem 'rack-cors', '~> 0.4.0', require: 'rack/cors' gem "kaminari", "~> 0.17.0" # HAML -gem "hamlit" +gem 'hamlit', '~> 2.5' # Files attachments gem "carrierwave", '~> 0.10.0' @@ -344,6 +344,5 @@ gem 'oauth2', '~> 1.0.0' # Soft deletion gem "paranoia", "~> 2.0" - # Health check gem 'health_check', '~> 1.5.1' diff --git a/Gemfile.lock b/Gemfile.lock index 02c7b75aba3..98a20d4e715 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -874,7 +874,7 @@ DEPENDENCIES gon (~> 6.0.1) grape (~> 0.13.0) grape-entity (~> 0.4.2) - hamlit + hamlit (~> 2.5) health_check (~> 1.5.1) hipchat (~> 1.5.0) html-pipeline (~> 1.11.0) diff --git a/config/initializers/hamlit.rb b/config/initializers/hamlit.rb index 259d562e586..7b545d8c06c 100644 --- a/config/initializers/hamlit.rb +++ b/config/initializers/hamlit.rb @@ -13,3 +13,6 @@ ActionView::Template.register_template_handler( :haml, Hamlit::TemplateHandler.new, ) + +Hamlit::Filters.remove_filter('coffee') +Hamlit::Filters.remove_filter('coffeescript') diff --git a/doc/development/gotchas.md b/doc/development/gotchas.md index 21078c8d6f9..9d7fe7440d2 100644 --- a/doc/development/gotchas.md +++ b/doc/development/gotchas.md @@ -46,7 +46,7 @@ Rubocop](https://gitlab.com/gitlab-org/gitlab-ce/blob/8-4-stable/.rubocop.yml#L9 Using the inline `:coffee` or `:coffeescript` Haml filters comes with a performance overhead. -_**Note:** We've [removed these two filters](https://gitlab.com/gitlab-org/gitlab-ce/blob/8-5-stable/config/initializers/haml.rb) +_**Note:** We've [removed these two filters](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/config/initializers/hamlit.rb) in an initializer._ ### Further reading -- cgit v1.2.1