Skip to content

Commit

Permalink
Merge branch 'ros2' into simplify_search
Browse files Browse the repository at this point in the history
  • Loading branch information
tfoote authored Jan 4, 2024
2 parents ca01d46 + 30086f3 commit 7fdc99c
Show file tree
Hide file tree
Showing 10 changed files with 114 additions and 214 deletions.
4 changes: 0 additions & 4 deletions _data/remotes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,3 @@ repositories:
type: git
url: https://github.com/ros/rosdistro.git
version: master
rosforks:
type: git
url: https://github.com/rosindex/rosforks.git
version: master
95 changes: 3 additions & 92 deletions _includes/package_body.html
Original file line number Diff line number Diff line change
Expand Up @@ -433,112 +433,23 @@ <h3 class="panel-title">Plugins</h3>
<div class="tab-pane" id="{{distro}}-questions">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Recent questions tagged <kbd>{{package.name}}</kbd> at <strong><a href="https://answers.ros.org" target="_blank">answers.ros.org</a></strong></h3>
</div>
<h3 class="panel-title">Recent questions tagged <kbd>{{package.name}}</kbd> at <strong><a href="https://robotics.stackexchange.com/" target="_blank">Robotics Stack Exchange</a></strong></h3> </div>
<div id="{{distro}}-question-list" class="panel-body" style="display: none;"></div>
<div id="{{distro}}-no-question-list" class="panel-body" style="display: none;">
<p>No questions yet, you can ask one <a href="https://answers.ros.org/questions/ask/?tags={{package.name}},{{distro}}">here</a>.</p>
<p>No questions yet, you can ask one <a href="https://robotics.stackexchange.com/questions/tagged/{{package.name}}+{{distro}}">here</a>.</p>
</div>
<div id="{{distro}}-get-question-fail" class="panel-body alert alert-warning" style="display: none;">
<p>Failed to get question list, you can ticket an issue <a href="https://github.com/ros2/rosindex/issues/new" target="_blank" class="alert-link">here</a> </p>
<p>Failed to get question list, you can ticket an issue <a href="https://github.com/ros-infrastructure/rosindex/issues/new" target="_blank" class="alert-link">here</a> </p>
</div>
</div>
</div>
</div>

<script type="text/javascript" src="{{ '/js/package_body_tabs.js' | prepend: site.baseurl }}"></script>

<script id="{{distro}}-question-list-template" type="text/html">
<p>
Browse <a href="https://answers.ros.org/questions/scope:all/sort:activity-desc/tags:{{package.name}}/page:1/">recent questions</a>
or see the <a href="https://answers.ros.org/questions/scope:all/sort:votes-desc/tags:{{package.name}}/page:1/">higest voted ones</a>.
</p>
{% raw %}
<div class="list-group">
{{#questions}}
<div class="list-group-item mb-1">
<a href="{{link}}">
<h4 class="w-75 float-left">{{title}}</h4>
<small class="w-25">{{updated}}</small>
</a>
<hr>
<div class="question-description question-description-collapsed" id="question-description-{{id}}" title="{{link}}">
{{&description}}
</div>
<a class="question-description-toggle" id="question-description-{{id}}-toggle">Show more</a>
<a class="question-link" target="_blank" href="{{link}}">View on answers.ros.org</a>
</div>
{{/questions}}
</div>
{% endraw %}
</script>

<script type="text/javascript" src="{{ '/js/jquery.jfeed.pack.js' | prepend: site.baseurl }}"></script>
<link rel="stylesheet" type="text/css" href="{{ '/css/prettify.css' | prepend: site.baseurl }}"/>
<script type="text/javascript" src="{{ '/js/prettify.js' | prepend: site.baseurl }}"></script>
<script type="text/javascript" src="{{ '/js/mustache.js' | prepend: site.baseurl }}"></script>
<script type="text/javascript" src="{{ '/js/showdown.min.js' | prepend: site.baseurl }}"></script>
<script src={{ "/js/contribution_suggestions.js" | prepend: site.baseurl }}></script>
<script type="text/javascript">
jQuery.browser = {};
(function () {
jQuery.browser.msie = false;
jQuery.browser.version = 0;
if (navigator.userAgent.match(/MSIE ([0-9]+)\./)) {
jQuery.browser.msie = true;
jQuery.browser.version = RegExp.$1;
}
})();
jQuery(function() {
jQuery.getFeed({
url: "https://answers.ros.org/feeds/rss/?tags={{package.name}}",
success: function(feed) {
if (feed.items.length > 0) {
var converter = new showdown.Converter();
var questions = feed.items.slice(0, 10).map(function(question) {
question.description = converter.makeHtml(question.description);
question.id = Math.round(Math.random() * 99999.0);
return question;
});
var template = jQuery("#{{distro}}-question-list-template").text();
Mustache.parse(template);
var rendered = Mustache.render(template, {questions: questions});
jQuery("#{{distro}}-question-list").html(rendered);
jQuery("#{{distro}}-question-list pre").addClass("prettyprint");
jQuery("#{{distro}}-question-list img").each(function() {
if (jQuery(this).attr("src").startsWith("/upfiles")) {
jQuery(this).attr("src", "https://answers.ros.org" + jQuery(this).attr("src"));
}
});
jQuery("#{{distro}}-question-list .question-description").each(function() {
jQuery(this).click( function() {
if (jQuery(this).hasClass("question-description-collapsed")) {
window.open(jQuery(this).attr("title"));
}
})
});
jQuery("#{{distro}}-question-list .question-description-toggle").each(function() {
jQuery(this).click( function() {
if (jQuery(this).prev().hasClass("question-description-collapsed")) {
jQuery(this).html("Show less");
} else {
jQuery(this).html("Show more");
}
jQuery(this).prev().toggleClass( "question-description-collapsed", 1000 );
})
});
jQuery("#{{distro}}-question-list").show();
PR.prettyPrint();
} else {
jQuery("#{{distro}}-no-question-list").show();
}
jQuery("#{{distro}}-questions-count").text(feed.items.length);
},
error: function(res, err) {
console.error("Failed to get feed:", err)
jQuery("#{{distro}}-get-question-fail").show();
}
});
// Update the count on the links to the contribution suggestions
updateContributionSuggestionsCountOnPackage('{{package.repo.uri}}');
});
Expand Down
102 changes: 102 additions & 0 deletions _includes/package_qna_updater.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{% comment %} Template for Q&A content {% endcomment %}
<script id="question-list-template" type="text/html">
<p>
Browse <a href="https://robotics.stackexchange.com/questions/tagged/{{package.name}}?tab=Newest">recent questions</a>
or see the <a href="https://robotics.stackexchange.com/questions/tagged/{{package.name}}?tab=Votes">higest voted ones</a>.
</p>
{% raw %}
<div class="list-group">
{{#questions}}
<div class="list-group-item mb-1">
<a href="{{link}}">
<h4 class="w-75 float-left">{{title}}</h4>
<small class="w-25">{{updated}}</small>
</a>
<hr>
<div class="question-description question-description-collapsed" id="question-description-{{id}}" title="{{link}}">
{{&description}}
</div>
<a class="question-description-toggle" id="question-description-{{id}}-toggle">Show more</a>
<a class="question-link" target="_blank" href="{{link}}">View on Robotics Stack Exchange</a>
</div>
{{/questions}}
</div>
{% endraw %}
</script>

<script type="text/javascript" src="{{ '/js/jquery.jfeed.pack.js' | prepend: site.baseurl }}"></script>
<link rel="stylesheet" type="text/css" href="{{ '/css/prettify.css' | prepend: site.baseurl }}"/>
<script type="text/javascript" src="{{ '/js/prettify.js' | prepend: site.baseurl }}"></script>
<script type="text/javascript" src="{{ '/js/mustache.js' | prepend: site.baseurl }}"></script>
<script type="text/javascript" src="{{ '/js/showdown.min.js' | prepend: site.baseurl }}"></script>
<script src={{ "/js/contribution_suggestions.js" | prepend: site.baseurl }}></script>
<script type="text/javascript">
jQuery.browser = {};
(function () {
jQuery.browser.msie = false;
jQuery.browser.version = 0;
if (navigator.userAgent.match(/MSIE ([0-9]+)\./)) {
jQuery.browser.msie = true;
jQuery.browser.version = RegExp.$1;
}
})();
jQuery(function() {
jQuery.getFeed({
url: "https://robotics.stackexchange.com/feeds/tag/{{package.name}}",
success: function(feed) {
{% for distro in page.all_distros %}
if (feed.items.length > 0) {
var converter = new showdown.Converter();
var questions = feed.items.slice(0, 10).map(function(question) {
question.description = converter.makeHtml(question.description);
question.id = Math.round(Math.random() * 99999.0);
return question;
});
var template = jQuery("#question-list-template").text();
Mustache.parse(template);
var rendered = Mustache.render(template, {questions: questions});
jQuery("#{{distro}}-question-list").html(rendered);
jQuery("#{{distro}}-question-list pre").addClass("prettyprint");
// TODO(tfoote) Resolve images
// jQuery("#{{distro}}-question-list img").each(function() {
// if (jQuery(this).attr("src").startsWith("/upfiles")) {
// jQuery(this).attr("src", "https://answers.ros.org" + jQuery(this).attr("src"));
// }
// });
jQuery("#{{distro}}-question-list .question-description").each(function() {
jQuery(this).click( function() {
if (jQuery(this).hasClass("question-description-collapsed")) {
window.open(jQuery(this).attr("title"));
}
})
});
jQuery("#{{distro}}-question-list .question-description-toggle").each(function() {
jQuery(this).click( function() {
if (jQuery(this).prev().hasClass("question-description-collapsed")) {
jQuery(this).html("Show less");
} else {
jQuery(this).html("Show more");
}
jQuery(this).prev().toggleClass( "question-description-collapsed", 1000 );
})
});
jQuery("#{{distro}}-question-list").show();
PR.prettyPrint();
} else {python
jQuery("#{{distro}}-no-question-list").show();
}
jQuery("#{{distro}}-questions-count").text(feed.items.length);
{% endfor %}
},
error: function(res, err) {
// TODO(tfoote) resolve 404 errors which are what R.SE gives for non-extant tags, which in this context are just empty lists.
{% for distro in page.all_distros %}
console.error("Failed to get feed for {{distro}}:", err)
jQuery("#{{distro}}-get-question-fail").show();
{% endfor %}
}

});

});
</script>
2 changes: 2 additions & 0 deletions _layouts/package.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
</div>
{% endfor %}

{% include package_qna_updater.html %}

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

{% include package_qna_updater.html %}

<script type="text/javascript">
$(document).ready(function() {
setupDistroSwitch("{{ page.default_distro }}");
Expand Down
14 changes: 3 additions & 11 deletions _layouts/repo_instances.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,9 @@ <h3><img style="width: 50px; margin-right: 5px;" src="{{ '/assets/repo.png' | pr
</div>
<div class="row">
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title">Instances
<!--
<span class="pull-right">
<a
href="https://github.com/rosindex/rosforks/edit/source/repos/{{ page.repo_instances.name }}.md">
<button type="button" class="btn btn-xs btn-success">
<span class="glyphicon glyphicon-plus"></span> Submit New Instance
</button>
</a>
</span> -->
</h3></div>
<div class="panel-heading">
<h3 class="panel-title">Instances</h3>
</div>
<div class="table-responsive">
<table class="table table-condensed">
<thead>
Expand Down
100 changes: 0 additions & 100 deletions _plugins/rosindex_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1256,106 +1256,6 @@ def generate(site)
end
end

# add additional repo instances to the main dict
Dir.glob(File.join(site.config['repos_path'],'*.yaml')) do |repo_filename|

# limit repos if requested
#if site.config['max_repos'] > 0 and @all_repos.length > site.config['max_repos'] then break end

# read in the repo data
repo_name = File.basename(repo_filename, File.extname(repo_filename)).to_s
repo_data = YAML.load_file(repo_filename)

puts " - Adding repositories for " << repo_name

# add all the instances
repo_data['instances'].each do |instance|

# create a new repo structure for this remote
repo = Repo.new(
repo_name,
instance['type'],
instance['uri'],
instance['purpose'],
@checkout_path)

uri = repo.uri

dputs " -- Added repo for " << repo.name << " instance: " << repo.id << " from uri " << repo.uri.to_s

# add distro versions for instance
$all_distros.each do |distro|

# get the explicit version identifier for this distro
explicit_version = if instance.key?('distros') and instance['distros'].key?(distro) and instance['distros'][distro].key?('version') then instance['distros'][distro]['version'] else nil end

# add the specific version from this instance
repo.snapshots[distro].version = explicit_version
repo.snapshots[distro].released = false
end

# store this repo in the unique index
@all_repos[repo.id] = repo

# store this repo in the name index
@repo_names[repo.name].instances[repo.id] = repo
if instance['default'] or @repo_names[repo.name].default.nil?
@repo_names[repo.name].default = repo
end
end
end

# add attic repos
attic_filename = site.config['attic_file']
attic_data = {}
# read in the repo data
if File.exists?(attic_filename)
attic_data = YAML.load_file(attic_filename)
end

attic_data.each do |repo_name, instances|
puts " - Adding repositories for " << repo_name

# add all the instances
instances.each do |id, instance|

# create a new repo structure for this remote
repo = Repo.new(
repo_name,
instance['type'],
instance['uri'],
'attic mirror',
@checkout_path)

repo.attic = true

uri = repo.uri

dputs " -- Added attic repo for " << repo.name << " instance: " << repo.id << " from uri " << repo.uri.to_s

# add distro versions for instance
$all_distros.each do |distro|

# get the explicit version identifier for this distro
explicit_version = if instance.fetch('distros',{})[distro] then instance['distros'][distro] else nil end

# add the specific version from this instance
repo.snapshots[distro].version = explicit_version
repo.snapshots[distro].released = false
end

# store this repo in the unique index
# note this will overwrite the mirrored repo
@all_repos[repo.id] = repo

# store this repo in the name index
@repo_names[repo.name].instances[repo.id] = repo
if instance['default'] or @repo_names[repo.name].default.nil?
@repo_names[repo.name].default = repo
end
end
end

puts "Found " << @all_repos.length.to_s << " repositories corresponding to " << @repo_names.length.to_s << " repo identifiers."
end

Expand Down
5 changes: 1 addition & 4 deletions _ruby_libs/rosindex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def initialize(version, distro, released, documented)

class Repo < Liquid::Drop
# This represents a remote repository
attr_accessor :name, :id, :uri, :accessible, :errors, :purpose, :snapshots, :tags, :type, :status, :local_path, :local_name, :release_manifests, :attic
attr_accessor :name, :id, :uri, :accessible, :errors, :purpose, :snapshots, :tags, :type, :status, :local_path, :local_name, :release_manifests
def initialize(name, type, uri, purpose, checkout_path, id = nil)
# non-unique identifier for this repo
@name = name
Expand Down Expand Up @@ -87,9 +87,6 @@ def initialize(name, type, uri, purpose, checkout_path, id = nil)
# release manifests
# hash distro -> manifest xml data
@release_manifests = {}

# whether this repo is in the attic
@attic = false
end
end

Expand Down
Loading

0 comments on commit 7fdc99c

Please sign in to comment.