From 02cd9820682ff0cb65cb0845aa1670546ac22106 Mon Sep 17 00:00:00 2001 From: Michel Hidalgo Date: Tue, 6 Nov 2018 19:04:33 -0300 Subject: [PATCH 1/2] Uses the newest available distro on first package or repo page load. --- _layouts/deps.html | 5 +++++ _layouts/package.html | 6 +++++- _layouts/package_instance.html | 5 +++++ _layouts/packages.html | 5 +++++ _layouts/repo_instance.html | 5 +++++ _layouts/repo_instance_distro.html | 18 ++++++++++-------- _layouts/repo_variant_distro.html | 19 ++++++++++--------- _layouts/repos.html | 6 +++++- _layouts/system_deps.html | 5 +++++ _plugins/pre_configuration.rb | 8 ++++---- _ruby_libs/pages.rb | 22 ++++++++++++++++++---- js/distro_switch.js | 8 +++----- 12 files changed, 80 insertions(+), 32 deletions(-) diff --git a/_layouts/deps.html b/_layouts/deps.html index 8c4128d8..a1bdc41b 100644 --- a/_layouts/deps.html +++ b/_layouts/deps.html @@ -120,3 +120,8 @@ + diff --git a/_layouts/package.html b/_layouts/package.html index 871c4fc3..08d54328 100644 --- a/_layouts/package.html +++ b/_layouts/package.html @@ -51,4 +51,8 @@ {% endfor %} - + diff --git a/_layouts/package_instance.html b/_layouts/package_instance.html index 426b6558..09943aa9 100644 --- a/_layouts/package_instance.html +++ b/_layouts/package_instance.html @@ -54,3 +54,8 @@ {% endfor %} + diff --git a/_layouts/packages.html b/_layouts/packages.html index a8e5274c..ed2ed8cc 100644 --- a/_layouts/packages.html +++ b/_layouts/packages.html @@ -138,3 +138,8 @@ + diff --git a/_layouts/repo_instance.html b/_layouts/repo_instance.html index f1783a87..96a4d221 100644 --- a/_layouts/repo_instance.html +++ b/_layouts/repo_instance.html @@ -94,3 +94,8 @@ {% endfor %} + diff --git a/_layouts/repo_instance_distro.html b/_layouts/repo_instance_distro.html index c760dba1..b91af1c3 100644 --- a/_layouts/repo_instance_distro.html +++ b/_layouts/repo_instance_distro.html @@ -85,13 +85,15 @@ diff --git a/_layouts/repo_variant_distro.html b/_layouts/repo_variant_distro.html index 93b8a8a3..d2008313 100644 --- a/_layouts/repo_variant_distro.html +++ b/_layouts/repo_variant_distro.html @@ -84,13 +84,14 @@ - diff --git a/_layouts/repos.html b/_layouts/repos.html index 0df7f083..5ec8459e 100644 --- a/_layouts/repos.html +++ b/_layouts/repos.html @@ -135,4 +135,8 @@ - + diff --git a/_layouts/system_deps.html b/_layouts/system_deps.html index f6d3cb07..4cda1711 100644 --- a/_layouts/system_deps.html +++ b/_layouts/system_deps.html @@ -109,3 +109,8 @@ + diff --git a/_plugins/pre_configuration.rb b/_plugins/pre_configuration.rb index e0bcb5ea..3f1df118 100644 --- a/_plugins/pre_configuration.rb +++ b/_plugins/pre_configuration.rb @@ -1,6 +1,6 @@ Jekyll::Hooks.register :site, :after_init do |site| - site.config['distros'] = site.config['ros_distros'] + - site.config['ros2_distros'] - site.config['old_distros'] = site.config['old_ros_distros'] + - site.config['old_ros2_distros'] + site.config['distros'] = site.config['ros2_distros'] + + site.config['ros_distros'] + site.config['old_distros'] = site.config['old_ros2_distros'] + + site.config['old_ros_distros'] end diff --git a/_ruby_libs/pages.rb b/_ruby_libs/pages.rb index e45be699..480930db 100644 --- a/_ruby_libs/pages.rb +++ b/_ruby_libs/pages.rb @@ -75,9 +75,14 @@ def initialize(site, instances, repo, default) self.data['instance_index_url'] = File.join('repos', repo.name) self.data['default_instance_id'] = instances.default.id - self.data['available_distros'], self.data['available_older_distros'], self.data['n_available_older_distros'] = get_available_distros(site, repo.snapshots) - + self.data['available_distros'], + self.data['available_older_distros'], + self.data['n_available_older_distros'] = get_available_distros(site, repo.snapshots) self.data['all_distros'] = site.config['distros'] + site.config['old_distros'] + + self.data['default_distro'] = self.data['available_distros'].keys.first or + self.data['available_older_distros'].keys.first or + self.data['all_distros'].first end end @@ -208,9 +213,14 @@ def initialize(site, package_instances) self.data['instance_index_url'] = File.join('packages',package_instances.name) self.data['instance_base_url'] = @dir - self.data['available_distros'], self.data['available_older_distros'], self.data['n_available_older_distros'] = get_available_distros(site, package_instances.snapshots) - + self.data['available_distros'], + self.data['available_older_distros'], + self.data['n_available_older_distros'] = get_available_distros(site, package_instances.snapshots) self.data['all_distros'] = site.config['distros'] + site.config['old_distros'] + + self.data['default_distro'] = self.data['available_distros'].keys.first or + self.data['available_older_distros'].keys.first or + self.data['all_distros'].first end end @@ -258,6 +268,10 @@ def initialize(site, package_instances, instance, package_name) self.data['n_available_older_distros'] = self.data['available_older_distros'].values.count(true) self.data['all_distros'] = site.config['distros'] + site.config['old_distros'] + + self.data['default_distro'] = self.data['available_distros'].keys.first or + self.data['available_older_distros'].keys.first or + self.data['all_distros'].first end end diff --git a/js/distro_switch.js b/js/distro_switch.js index 9d35355a..214805d5 100644 --- a/js/distro_switch.js +++ b/js/distro_switch.js @@ -1,7 +1,5 @@ ---- ---- -$(document).ready(function(){ +function setupDistroSwitch(default_distro) { $('#distro-switch label').click(function (e) { console.log(e.target) // get the distro and set the cookie @@ -57,12 +55,12 @@ $(document).ready(function(){ } if(typeof distro == 'undefined') { - distro = "{{site.distros[0]}}"; + distro = default_distro; } $('.distro').not('.distro-'+distro).hide(0); $('.distro-'+distro).show(0); $('#'+distro+'-option').addClass('active'); $('#'+distro+'-button').trigger("click"); -}); +} From 4ebe13f41e932a531f9534c74016ed34823ef11d Mon Sep 17 00:00:00 2001 From: Michel Hidalgo Date: Mon, 12 Nov 2018 12:02:02 -0300 Subject: [PATCH 2/2] Addresses peer review comments. --- js/distro_switch.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/js/distro_switch.js b/js/distro_switch.js index 214805d5..ecb6043f 100644 --- a/js/distro_switch.js +++ b/js/distro_switch.js @@ -1,5 +1,4 @@ - -function setupDistroSwitch(default_distro) { +function setupDistroSwitch(default_distro) { $('#distro-switch label').click(function (e) { console.log(e.target) // get the distro and set the cookie @@ -55,7 +54,7 @@ function setupDistroSwitch(default_distro) { } if(typeof distro == 'undefined') { - distro = default_distro; + distro = default_distro; } $('.distro').not('.distro-'+distro).hide(0); @@ -63,4 +62,3 @@ function setupDistroSwitch(default_distro) { $('#'+distro+'-option').addClass('active'); $('#'+distro+'-button').trigger("click"); } -