Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to Robotics Stack Exchange #334

Merged
merged 3 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ <h2>More resources</h2>
<a href="https://discourse.ros.org/">ROS Discourse</a>
</p>
<p>
<a href="https://answers.ros.org/questions/">ROS Answers</a>
<a href="https://robotics.stackexchange.com/">Robotics Stack Exchange</a>
</p>
<p>
<a href="https://www.ros.org/">ros.org</a>
Expand Down