From ffeca41ef41f1276d85aa683a00f7e3da8817ad4 Mon Sep 17 00:00:00 2001 From: Maikel Date: Wed, 10 Jul 2019 10:24:25 +1000 Subject: [PATCH] Revert "Fix JS render-blocking in Darkswarm" --- app/views/checkout/_form.html.haml | 9 +++-- app/views/checkout/edit.html.haml | 5 ++- app/views/enterprises/shop.html.haml | 3 +- app/views/groups/index.html.haml | 3 +- app/views/groups/show.html.haml | 3 +- app/views/layouts/darkswarm.html.haml | 36 +++++++++---------- app/views/layouts/registration.html.haml | 18 +++++----- app/views/map/index.html.haml | 3 +- app/views/producers/index.html.haml | 3 +- app/views/registration/index.html.haml | 7 ++-- .../shopping_shared/_order_cycles.html.haml | 4 +-- app/views/shops/index.html.haml | 3 +- app/views/spree/orders/edit.html.haml | 3 +- app/views/spree/orders/show.html.haml | 3 +- app/views/spree/users/show.html.haml | 4 +-- 15 files changed, 45 insertions(+), 62 deletions(-) diff --git a/app/views/checkout/_form.html.haml b/app/views/checkout/_form.html.haml index 901fe64a00..0fdfe267b8 100644 --- a/app/views/checkout/_form.html.haml +++ b/app/views/checkout/_form.html.haml @@ -1,14 +1,13 @@ -- content_for :injection_data do - = inject_available_shipping_methods - = inject_available_payment_methods - = inject_saved_credit_cards - = f_form_for current_order, html: {name: "checkout", id: "checkout_form", novalidate: true, "ng-submit" => "purchase($event, checkout)"} do |f| + = inject_available_shipping_methods + = inject_available_payment_methods + = inject_saved_credit_cards + = render "checkout/details", f: f = render "checkout/billing", f: f = render "checkout/shipping", f: f diff --git a/app/views/checkout/edit.html.haml b/app/views/checkout/edit.html.haml index 1c5765243b..ab5253538b 100644 --- a/app/views/checkout/edit.html.haml +++ b/app/views/checkout/edit.html.haml @@ -1,9 +1,8 @@ - content_for(:title) do = t :checkout_title -- content_for :injection_data do - = inject_enterprise_and_relatives - = inject_available_countries += inject_enterprise_and_relatives += inject_available_countries .darkswarm.footer-pad - content_for :order_cycle_form do diff --git a/app/views/enterprises/shop.html.haml b/app/views/enterprises/shop.html.haml index 96df8b89ff..108ad893e9 100644 --- a/app/views/enterprises/shop.html.haml +++ b/app/views/enterprises/shop.html.haml @@ -5,8 +5,7 @@ - content_for(:image) do = current_distributor.logo.url -- content_for :injection_data do - = inject_enterprise_shopfront(@enterprise) += inject_enterprise_shopfront(@enterprise) %shop.darkswarm - if @shopfront_layout == 'embedded' diff --git a/app/views/groups/index.html.haml b/app/views/groups/index.html.haml index 1994d30fee..dabfd70b6c 100644 --- a/app/views/groups/index.html.haml +++ b/app/views/groups/index.html.haml @@ -1,8 +1,7 @@ - content_for(:title) do = t :groups_title -- content_for :injection_data do - = inject_groups += inject_groups #groups.pad-top.footer-pad{"ng-controller" => "GroupsCtrl"} .row diff --git a/app/views/groups/show.html.haml b/app/views/groups/show.html.haml index 76a83fd734..48ba7df8b2 100644 --- a/app/views/groups/show.html.haml +++ b/app/views/groups/show.html.haml @@ -5,8 +5,7 @@ - content_for(:image) do = @group.logo.url -- content_for :injection_data do - = inject_group_enterprises += inject_group_enterprises #group-page.row.pad-top.footer-pad{"ng-controller" => "GroupPageCtrl"} .small-12.columns.pad-top diff --git a/app/views/layouts/darkswarm.html.haml b/app/views/layouts/darkswarm.html.haml index 3a352950d9..5daa4d1d45 100644 --- a/app/views/layouts/darkswarm.html.haml +++ b/app/views/layouts/darkswarm.html.haml @@ -15,7 +15,16 @@ %link{href: "https://fonts.googleapis.com/css?family=Roboto:400,300italic,400italic,300,700,700italic|Oswald:300,400,700", rel: "stylesheet", type: "text/css"} %link{href: "/OFN-v2.woff?eslsji", rel: "preload", as: "font", crossorigin: "anonymous"} + = yield :scripts + %script{:src => "https://js.stripe.com/v3/", :type => "text/javascript"} + %script{src: "//maps.googleapis.com/maps/api/js?libraries=places,geometry#{ ENV['GOOGLE_MAPS_API_KEY'] ? '&key=' + ENV['GOOGLE_MAPS_API_KEY'] : ''} "} = stylesheet_link_tag "darkswarm/all" + = javascript_include_tag "darkswarm/all" + = javascript_include_tag "web/all" + + = render "layouts/i18n_script" + = render "layouts/bugherd_script" + = render "layouts/matomo_tag" = csrf_meta_tags %body{class: body_classes, ng: {app: "Darkswarm"}} @@ -25,6 +34,14 @@ = render "layouts/shopfront_script" if @shopfront_layout + = inject_current_hub + = inject_json "user", "current_user" + = inject_json "railsFlash", "flash" + = inject_taxons + = inject_properties + = inject_current_order + = inject_currency_config + .off-canvas-wrap{offcanvas: true} .inner-wrap = render "shared/menu/menu" unless @hide_menu @@ -34,23 +51,4 @@ #footer %loading - - %script{:src => "https://js.stripe.com/v3/", :type => "text/javascript"} - %script{src: "//maps.googleapis.com/maps/api/js?libraries=places,geometry#{ ENV['GOOGLE_MAPS_API_KEY'] ? '&key=' + ENV['GOOGLE_MAPS_API_KEY'] : ''} "} - = javascript_include_tag "darkswarm/all" - = javascript_include_tag "web/all" - = render "layouts/i18n_script" - = yield :scripts - - = inject_current_hub - = inject_json "user", "current_user" - = inject_json "railsFlash", "flash" - = inject_taxons - = inject_properties - = inject_current_order - = inject_currency_config - = yield :injection_data - - = render "layouts/bugherd_script" - = render "layouts/matomo_tag" = render 'spree/shared/google_analytics' diff --git a/app/views/layouts/registration.html.haml b/app/views/layouts/registration.html.haml index 0221b1ce3a..ba4078147c 100644 --- a/app/views/layouts/registration.html.haml +++ b/app/views/layouts/registration.html.haml @@ -10,7 +10,13 @@ = favicon_link_tag "/favicon-staging.ico" %link{href: "https://fonts.googleapis.com/css?family=Roboto:400,300italic,400italic,300,700,700italic|Oswald:300,400,700", rel: "stylesheet", type: "text/css"} + = yield :scripts + %script{src: "//maps.googleapis.com/maps/api/js?libraries=places"} = stylesheet_link_tag "darkswarm/all" + = javascript_include_tag "darkswarm/all" + + = render "layouts/i18n_script" + = render "layouts/bugherd_script" = csrf_meta_tags %body.off-canvas{"ng-app" => "Darkswarm", style: 'background-image: url("/assets/tile-wide.png")' } @@ -18,6 +24,8 @@ = render partial: "shared/ie_warning" = javascript_include_tag "iehack" + = inject_json "user", "current_user" + .off-canvas-wrap{offcanvas: true} .inner-wrap @@ -26,13 +34,3 @@ #footer %loading - - %script{src: "//maps.googleapis.com/maps/api/js?libraries=places"} - = javascript_include_tag "darkswarm/all" - = yield :scripts - - = inject_json "user", "current_user" - = yield :injection_data - - = render "layouts/i18n_script" - = render "layouts/bugherd_script" diff --git a/app/views/map/index.html.haml b/app/views/map/index.html.haml index 48e05d2d0a..b66df8429f 100644 --- a/app/views/map/index.html.haml +++ b/app/views/map/index.html.haml @@ -1,8 +1,7 @@ - content_for(:title) do = t :label_map -- content_for :injection_data do - = inject_enterprise_shopfront_list += inject_enterprise_shopfront_list .map-container{"fill-vertical" => true} %map{"ng-controller" => "MapCtrl"} diff --git a/app/views/producers/index.html.haml b/app/views/producers/index.html.haml index c192c12dc3..c6b62b2725 100644 --- a/app/views/producers/index.html.haml +++ b/app/views/producers/index.html.haml @@ -1,8 +1,7 @@ - content_for(:title) do = t :producers_title -- content_for :injection_data do - = inject_enterprises(@enterprises) += inject_enterprises(@enterprises) .producers{"ng-controller" => "EnterprisesCtrl", "ng-cloak" => true} .row diff --git a/app/views/registration/index.html.haml b/app/views/registration/index.html.haml index 5c2e63f0e4..fbfb0c175c 100644 --- a/app/views/registration/index.html.haml +++ b/app/views/registration/index.html.haml @@ -1,10 +1,9 @@ - content_for(:title) do = t :register_title -- content_for :injection_data do - = inject_spree_api_key - = inject_available_countries - = inject_enterprise_attributes += inject_spree_api_key += inject_available_countries += inject_enterprise_attributes - steps = %w{about contact details finished images introduction} - steps += %w{logo promo social steps type} diff --git a/app/views/shopping_shared/_order_cycles.html.haml b/app/views/shopping_shared/_order_cycles.html.haml index 7a8fe772f9..99483d9a19 100644 --- a/app/views/shopping_shared/_order_cycles.html.haml +++ b/app/views/shopping_shared/_order_cycles.html.haml @@ -1,9 +1,7 @@ -- content_for :scripts do +%ordercycle{"ng-controller" => "OrderCycleCtrl"} :javascript angular.module('Darkswarm').value('orderCycleData', #{render "json/order_cycle"}) -%ordercycle{"ng-controller" => "OrderCycleCtrl"} - - if @order_cycles and @order_cycles.empty? %h4 %i.ofn-i_012-warning diff --git a/app/views/shops/index.html.haml b/app/views/shops/index.html.haml index d436b85e5e..f38a1c6797 100644 --- a/app/views/shops/index.html.haml +++ b/app/views/shops/index.html.haml @@ -1,8 +1,7 @@ - content_for(:title) do = t :shops_title -- content_for :injection_data do - = inject_enterprises(@enterprises) += inject_enterprises(@enterprises) #panes #shops.pane diff --git a/app/views/spree/orders/edit.html.haml b/app/views/spree/orders/edit.html.haml index c05e644fac..31574b37d3 100644 --- a/app/views/spree/orders/edit.html.haml +++ b/app/views/spree/orders/edit.html.haml @@ -1,8 +1,7 @@ - content_for(:title) do = t :orders_edit_title -- content_for :injection_data do - = inject_enterprise_and_relatives += inject_enterprise_and_relatives .darkswarm - content_for :order_cycle_form do diff --git a/app/views/spree/orders/show.html.haml b/app/views/spree/orders/show.html.haml index 5abbc1c2ed..24d058db49 100644 --- a/app/views/spree/orders/show.html.haml +++ b/app/views/spree/orders/show.html.haml @@ -1,8 +1,7 @@ - content_for(:title) do = t :orders_show_title -- content_for :injection_data do - = inject_enterprise_and_relatives if current_distributor.present? += inject_enterprise_and_relatives if current_distributor.present? .darkswarm = render "shopping_shared/details" if current_distributor.present? diff --git a/app/views/spree/users/show.html.haml b/app/views/spree/users/show.html.haml index 9b18322f86..23de4fd744 100644 --- a/app/views/spree/users/show.html.haml +++ b/app/views/spree/users/show.html.haml @@ -1,12 +1,12 @@ -- content_for :injection_data do +.darkswarm = inject_orders = inject_shops = inject_saved_credit_cards + - if Stripe.publishable_key :javascript angular.module('Darkswarm').value("stripeObject", Stripe("#{Stripe.publishable_key}")) -.darkswarm .row.pad-top .small-12.columns.pad-top %h2