From 0256e68399674e832204ba0d66626e994ef1cf3a Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Tue, 31 May 2016 18:07:44 -0600 Subject: [PATCH 1/5] Remove d3 except for on pages where it's necessary. --- app/assets/javascripts/application.js.coffee | 9 +++++++-- app/assets/javascripts/stat_graph/application.js.coffee | 7 +++++++ .../javascripts/{ => stat_graph}/stat_graph.js.coffee | 0 .../{ => stat_graph}/stat_graph_contributors.js.coffee | 1 - .../stat_graph_contributors_graph.js.coffee | 2 -- .../stat_graph_contributors_util.js.coffee | 0 app/helpers/javascript_helper.rb | 7 +++++++ app/views/layouts/_head.html.haml | 3 +++ app/views/projects/graphs/_head.html.haml | 1 + config/application.rb | 1 + 10 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 app/assets/javascripts/stat_graph/application.js.coffee rename app/assets/javascripts/{ => stat_graph}/stat_graph.js.coffee (100%) rename app/assets/javascripts/{ => stat_graph}/stat_graph_contributors.js.coffee (98%) rename app/assets/javascripts/{ => stat_graph}/stat_graph_contributors_graph.js.coffee (99%) rename app/assets/javascripts/{ => stat_graph}/stat_graph_contributors_util.js.coffee (100%) create mode 100644 app/helpers/javascript_helper.rb diff --git a/app/assets/javascripts/application.js.coffee b/app/assets/javascripts/application.js.coffee index 7c547ac843b..18c1aa0d4e2 100644 --- a/app/assets/javascripts/application.js.coffee +++ b/app/assets/javascripts/application.js.coffee @@ -18,7 +18,6 @@ #= require jquery.atwho #= require jquery.scrollTo #= require jquery.turbolinks -#= require d3 #= require turbolinks #= require autosave #= require bootstrap/affix @@ -51,7 +50,13 @@ #= require shortcuts_network #= require jquery.nicescroll #= require date.format -#= require_tree . +#= require_directory ./behaviors +#= require_directory ./blob +#= require_directory ./ci +#= require_directory ./commit +#= require_directory ./extensions +#= require_directory ./lib +#= require_directory . #= require fuzzaldrin-plus #= require cropper diff --git a/app/assets/javascripts/stat_graph/application.js.coffee b/app/assets/javascripts/stat_graph/application.js.coffee new file mode 100644 index 00000000000..e0f681acf0b --- /dev/null +++ b/app/assets/javascripts/stat_graph/application.js.coffee @@ -0,0 +1,7 @@ +# This is a manifest file that'll be compiled into including all the files listed below. +# Add new JavaScript/Coffee code in separate files in this directory and they'll automatically +# be included in the compiled file accessible from http://example.com/assets/application.js +# It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +# the compiled file. +# +#= require_tree . diff --git a/app/assets/javascripts/stat_graph.js.coffee b/app/assets/javascripts/stat_graph/stat_graph.js.coffee similarity index 100% rename from app/assets/javascripts/stat_graph.js.coffee rename to app/assets/javascripts/stat_graph/stat_graph.js.coffee diff --git a/app/assets/javascripts/stat_graph_contributors.js.coffee b/app/assets/javascripts/stat_graph/stat_graph_contributors.js.coffee similarity index 98% rename from app/assets/javascripts/stat_graph_contributors.js.coffee rename to app/assets/javascripts/stat_graph/stat_graph_contributors.js.coffee index 3be14cb43dd..1d9fae7cf79 100644 --- a/app/assets/javascripts/stat_graph_contributors.js.coffee +++ b/app/assets/javascripts/stat_graph/stat_graph_contributors.js.coffee @@ -1,5 +1,4 @@ #= require d3 -#= require stat_graph_contributors_util class @ContributorsStatGraph init: (log) -> diff --git a/app/assets/javascripts/stat_graph_contributors_graph.js.coffee b/app/assets/javascripts/stat_graph/stat_graph_contributors_graph.js.coffee similarity index 99% rename from app/assets/javascripts/stat_graph_contributors_graph.js.coffee rename to app/assets/javascripts/stat_graph/stat_graph_contributors_graph.js.coffee index b7a0e073766..584d281a510 100644 --- a/app/assets/javascripts/stat_graph_contributors_graph.js.coffee +++ b/app/assets/javascripts/stat_graph/stat_graph_contributors_graph.js.coffee @@ -1,6 +1,4 @@ #= require d3 -#= require jquery -#= require underscore class @ContributorsGraph MARGIN: diff --git a/app/assets/javascripts/stat_graph_contributors_util.js.coffee b/app/assets/javascripts/stat_graph/stat_graph_contributors_util.js.coffee similarity index 100% rename from app/assets/javascripts/stat_graph_contributors_util.js.coffee rename to app/assets/javascripts/stat_graph/stat_graph_contributors_util.js.coffee diff --git a/app/helpers/javascript_helper.rb b/app/helpers/javascript_helper.rb new file mode 100644 index 00000000000..95b12db842a --- /dev/null +++ b/app/helpers/javascript_helper.rb @@ -0,0 +1,7 @@ +module JavascriptHelper + def page_specific_javascripts(js = nil) + @page_specific_javascripts = js unless js.nil? + + @page_specific_javascripts + end + end diff --git a/app/views/layouts/_head.html.haml b/app/views/layouts/_head.html.haml index 79cdbac1f37..b30fb0a5da9 100644 --- a/app/views/layouts/_head.html.haml +++ b/app/views/layouts/_head.html.haml @@ -30,6 +30,9 @@ = javascript_include_tag "application" + - if page_specific_javascripts + = javascript_include_tag page_specific_javascripts, {"data-turbolinks-track" => true} + = csrf_meta_tags = include_gon diff --git a/app/views/projects/graphs/_head.html.haml b/app/views/projects/graphs/_head.html.haml index 79a56647c53..49b101a26a1 100644 --- a/app/views/projects/graphs/_head.html.haml +++ b/app/views/projects/graphs/_head.html.haml @@ -1,3 +1,4 @@ +- page_specific_javascripts asset_path("stat_graph/application.js") %ul.nav-links = nav_link(action: :show) do = link_to 'Contributors', namespace_project_graph_path diff --git a/config/application.rb b/config/application.rb index de2bb08c978..c37542e8851 100644 --- a/config/application.rb +++ b/config/application.rb @@ -81,6 +81,7 @@ module Gitlab config.assets.precompile << "print.css" config.assets.precompile << "notify.css" config.assets.precompile << "mailers/*.css" + config.assets.precompile << "stat_graph/application.js" # Version of your assets, change this if you want to expire all your assets config.assets.version = '1.0' From 026b7abc5afc33847f9dcf8bdfc29167da4e9c02 Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Tue, 31 May 2016 18:25:33 -0600 Subject: [PATCH 2/5] Attempt to fix the user page. --- .../{stat_graph => graphs}/application.js.coffee | 0 .../{stat_graph => graphs}/stat_graph.js.coffee | 0 .../stat_graph_contributors.js.coffee | 0 .../stat_graph_contributors_graph.js.coffee | 0 .../stat_graph_contributors_util.js.coffee | 0 app/assets/javascripts/users/application.js.coffee | 8 ++++++++ app/assets/javascripts/{ => users}/calendar.js.coffee | 0 app/views/projects/graphs/_head.html.haml | 2 +- app/views/users/show.html.haml | 1 + config/application.rb | 3 ++- 10 files changed, 12 insertions(+), 2 deletions(-) rename app/assets/javascripts/{stat_graph => graphs}/application.js.coffee (100%) rename app/assets/javascripts/{stat_graph => graphs}/stat_graph.js.coffee (100%) rename app/assets/javascripts/{stat_graph => graphs}/stat_graph_contributors.js.coffee (100%) rename app/assets/javascripts/{stat_graph => graphs}/stat_graph_contributors_graph.js.coffee (100%) rename app/assets/javascripts/{stat_graph => graphs}/stat_graph_contributors_util.js.coffee (100%) create mode 100644 app/assets/javascripts/users/application.js.coffee rename app/assets/javascripts/{ => users}/calendar.js.coffee (100%) diff --git a/app/assets/javascripts/stat_graph/application.js.coffee b/app/assets/javascripts/graphs/application.js.coffee similarity index 100% rename from app/assets/javascripts/stat_graph/application.js.coffee rename to app/assets/javascripts/graphs/application.js.coffee diff --git a/app/assets/javascripts/stat_graph/stat_graph.js.coffee b/app/assets/javascripts/graphs/stat_graph.js.coffee similarity index 100% rename from app/assets/javascripts/stat_graph/stat_graph.js.coffee rename to app/assets/javascripts/graphs/stat_graph.js.coffee diff --git a/app/assets/javascripts/stat_graph/stat_graph_contributors.js.coffee b/app/assets/javascripts/graphs/stat_graph_contributors.js.coffee similarity index 100% rename from app/assets/javascripts/stat_graph/stat_graph_contributors.js.coffee rename to app/assets/javascripts/graphs/stat_graph_contributors.js.coffee diff --git a/app/assets/javascripts/stat_graph/stat_graph_contributors_graph.js.coffee b/app/assets/javascripts/graphs/stat_graph_contributors_graph.js.coffee similarity index 100% rename from app/assets/javascripts/stat_graph/stat_graph_contributors_graph.js.coffee rename to app/assets/javascripts/graphs/stat_graph_contributors_graph.js.coffee diff --git a/app/assets/javascripts/stat_graph/stat_graph_contributors_util.js.coffee b/app/assets/javascripts/graphs/stat_graph_contributors_util.js.coffee similarity index 100% rename from app/assets/javascripts/stat_graph/stat_graph_contributors_util.js.coffee rename to app/assets/javascripts/graphs/stat_graph_contributors_util.js.coffee diff --git a/app/assets/javascripts/users/application.js.coffee b/app/assets/javascripts/users/application.js.coffee new file mode 100644 index 00000000000..647ffbf5f45 --- /dev/null +++ b/app/assets/javascripts/users/application.js.coffee @@ -0,0 +1,8 @@ +# This is a manifest file that'll be compiled into including all the files listed below. +# Add new JavaScript/Coffee code in separate files in this directory and they'll automatically +# be included in the compiled file accessible from http://example.com/assets/application.js +# It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +# the compiled file. +# +#= require d3 +#= require_tree . diff --git a/app/assets/javascripts/calendar.js.coffee b/app/assets/javascripts/users/calendar.js.coffee similarity index 100% rename from app/assets/javascripts/calendar.js.coffee rename to app/assets/javascripts/users/calendar.js.coffee diff --git a/app/views/projects/graphs/_head.html.haml b/app/views/projects/graphs/_head.html.haml index 49b101a26a1..8becaea246f 100644 --- a/app/views/projects/graphs/_head.html.haml +++ b/app/views/projects/graphs/_head.html.haml @@ -1,4 +1,4 @@ -- page_specific_javascripts asset_path("stat_graph/application.js") +- page_specific_javascripts asset_path("graphs/application.js") %ul.nav-links = nav_link(action: :show) do = link_to 'Contributors', namespace_project_graph_path diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index 0c513308308..8268380dafc 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -1,5 +1,6 @@ - page_title @user.name - page_description @user.bio +- page_specific_javascripts asset_path("users/application.js") - header_title @user.name, user_path(@user) - @no_container = true diff --git a/config/application.rb b/config/application.rb index c37542e8851..49d4d3ba555 100644 --- a/config/application.rb +++ b/config/application.rb @@ -81,7 +81,8 @@ module Gitlab config.assets.precompile << "print.css" config.assets.precompile << "notify.css" config.assets.precompile << "mailers/*.css" - config.assets.precompile << "stat_graph/application.js" + config.assets.precompile << "graphs/application.js" + config.assets.precompile << "users/application.js" # Version of your assets, change this if you want to expire all your assets config.assets.version = '1.0' From 3eb683b651fab11b2315e12feb57e6384f2c285e Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Tue, 31 May 2016 18:34:30 -0600 Subject: [PATCH 3/5] Fix indentation --- app/helpers/javascript_helper.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/helpers/javascript_helper.rb b/app/helpers/javascript_helper.rb index 95b12db842a..91dd91718dc 100644 --- a/app/helpers/javascript_helper.rb +++ b/app/helpers/javascript_helper.rb @@ -1,7 +1,7 @@ module JavascriptHelper - def page_specific_javascripts(js = nil) - @page_specific_javascripts = js unless js.nil? - - @page_specific_javascripts - end - end + def page_specific_javascripts(js = nil) + @page_specific_javascripts = js unless js.nil? + + @page_specific_javascripts + end +end From 81f46054483bfb7284d5d1d85ac1204542854923 Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Tue, 31 May 2016 18:44:42 -0600 Subject: [PATCH 4/5] Fix teaspoon --- spec/javascripts/stat_graph_contributors_graph_spec.js | 2 +- spec/javascripts/stat_graph_contributors_util_spec.js | 2 +- spec/javascripts/stat_graph_spec.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/javascripts/stat_graph_contributors_graph_spec.js b/spec/javascripts/stat_graph_contributors_graph_spec.js index 78d39f1b428..82ee1954a59 100644 --- a/spec/javascripts/stat_graph_contributors_graph_spec.js +++ b/spec/javascripts/stat_graph_contributors_graph_spec.js @@ -1,4 +1,4 @@ -//= require stat_graph_contributors_graph +//= require graphs/stat_graph_contributors_graph describe("ContributorsGraph", function () { describe("#set_x_domain", function () { diff --git a/spec/javascripts/stat_graph_contributors_util_spec.js b/spec/javascripts/stat_graph_contributors_util_spec.js index dbafe782b77..5b992447473 100644 --- a/spec/javascripts/stat_graph_contributors_util_spec.js +++ b/spec/javascripts/stat_graph_contributors_util_spec.js @@ -1,4 +1,4 @@ -//= require stat_graph_contributors_util +//= require graphs/stat_graph_contributors_util describe("ContributorsStatGraphUtil", function () { diff --git a/spec/javascripts/stat_graph_spec.js b/spec/javascripts/stat_graph_spec.js index 4c652910cd6..4b05d401a42 100644 --- a/spec/javascripts/stat_graph_spec.js +++ b/spec/javascripts/stat_graph_spec.js @@ -1,4 +1,4 @@ -//= require stat_graph +//= require graphs/stat_graph describe("StatGraph", function () { From 586d1a9b241268a92840e7e6ba5034e399657d01 Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Wed, 1 Jun 2016 19:48:01 -0600 Subject: [PATCH 5/5] Move JS graph specs to match assets tree. --- .../{ => graphs}/stat_graph_contributors_graph_spec.js | 0 .../javascripts/{ => graphs}/stat_graph_contributors_util_spec.js | 0 spec/javascripts/{ => graphs}/stat_graph_spec.js | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename spec/javascripts/{ => graphs}/stat_graph_contributors_graph_spec.js (100%) rename spec/javascripts/{ => graphs}/stat_graph_contributors_util_spec.js (100%) rename spec/javascripts/{ => graphs}/stat_graph_spec.js (100%) diff --git a/spec/javascripts/stat_graph_contributors_graph_spec.js b/spec/javascripts/graphs/stat_graph_contributors_graph_spec.js similarity index 100% rename from spec/javascripts/stat_graph_contributors_graph_spec.js rename to spec/javascripts/graphs/stat_graph_contributors_graph_spec.js diff --git a/spec/javascripts/stat_graph_contributors_util_spec.js b/spec/javascripts/graphs/stat_graph_contributors_util_spec.js similarity index 100% rename from spec/javascripts/stat_graph_contributors_util_spec.js rename to spec/javascripts/graphs/stat_graph_contributors_util_spec.js diff --git a/spec/javascripts/stat_graph_spec.js b/spec/javascripts/graphs/stat_graph_spec.js similarity index 100% rename from spec/javascripts/stat_graph_spec.js rename to spec/javascripts/graphs/stat_graph_spec.js