Skip to content

Commit

Permalink
Merge pull request #115 from ros-infrastructure/hidmic/use-newest-ava…
Browse files Browse the repository at this point in the history
…ilable-distro

Uses the newest available distro on first package or repo page load
  • Loading branch information
hidmic authored Nov 12, 2018
2 parents 00aa31f + 4ebe13f commit 494c477
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 34 deletions.
5 changes: 5 additions & 0 deletions _layouts/deps.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,8 @@
</div>

<script src="/js/distro_switch.js"></script>
<script type="text/javascript">
$(document).ready(function() {
setupDistroSwitch("{{ site.distros[0] }}");
});
</script>
6 changes: 5 additions & 1 deletion _layouts/package.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,8 @@
</div>
{% endfor %}


<script type="text/javascript">
$(document).ready(function() {
setupDistroSwitch("{{ page.default_distro }}");
});
</script>
5 changes: 5 additions & 0 deletions _layouts/package_instance.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,8 @@
</div>
{% endfor %}

<script type="text/javascript">
$(document).ready(function() {
setupDistroSwitch("{{ page.default_distro }}");
});
</script>
5 changes: 5 additions & 0 deletions _layouts/packages.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,8 @@
</div>
</div>

<script type="text/javascript">
$(document).ready(function() {
setupDistroSwitch("{{ site.distros[0] }}");
});
</script>
5 changes: 5 additions & 0 deletions _layouts/repo_instance.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,8 @@
</div>
{% endfor %}

<script type="text/javascript">
$(document).ready(function() {
setupDistroSwitch("{{ page.default_distro }}");
});
</script>
18 changes: 10 additions & 8 deletions _layouts/repo_instance_distro.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,15 @@
<script src="{{ '/js/repo_switch.js' | prepend: site.baseurl }}"></script>

<script>
$(document).ready(function(){
$('#content-tabs a').click(
function (e) {
//e.preventDefault();
$(this).tab('show');
console.log(this)
});
});
$(document).ready(function() {
setupDistroSwitch("{{ site.distros[0] }}");
$('#content-tabs a').click(
function (e) {
//e.preventDefault();
$(this).tab('show');
console.log(this)
}
);
});
</script>

19 changes: 10 additions & 9 deletions _layouts/repo_variant_distro.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,14 @@
<script src="{{ '/js/repo_switch.js' | prepend: site.baseurl }}"></script>

<script>
$(document).ready(function(){
$('#content-tabs a').click(
function (e) {
//e.preventDefault();
$(this).tab('show');
console.log(this)
});
});
$(document).ready(function() {
setupDistroSwitch("{{ site.distros[0] }}");
$('#content-tabs a').click(
function (e) {
//e.preventDefault();
$(this).tab('show');
console.log(this)
}
);
});
</script>

6 changes: 5 additions & 1 deletion _layouts/repos.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,8 @@
</div>
</div>


<script type="text/javascript">
$(document).ready(function() {
setupDistroSwitch("{{ site.distros[0] }}");
});
</script>
5 changes: 5 additions & 0 deletions _layouts/system_deps.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,8 @@
</div>
</div>

<script type="text/javascript">
$(document).ready(function() {
setupDistroSwitch("{{ site.distros[0] }}");
});
</script>
8 changes: 4 additions & 4 deletions _plugins/pre_configuration.rb
Original file line number Diff line number Diff line change
@@ -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
22 changes: 18 additions & 4 deletions _ruby_libs/pages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
10 changes: 3 additions & 7 deletions js/distro_switch.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
---

$(document).ready(function(){
function setupDistroSwitch(default_distro) {
$('#distro-switch label').click(function (e) {
console.log(e.target)
// get the distro and set the cookie
Expand Down Expand Up @@ -57,12 +54,11 @@ $(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");
});

}

0 comments on commit 494c477

Please sign in to comment.