aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/helpers/packages_helper.rb8
-rw-r--r--app/views/packages/_resources.html.erb4
-rw-r--r--config/locales/en.yml1
3 files changed, 11 insertions, 2 deletions
diff --git a/app/helpers/packages_helper.rb b/app/helpers/packages_helper.rb
index 8a4205f..3ddde56 100644
--- a/app/helpers/packages_helper.rb
+++ b/app/helpers/packages_helper.rb
@@ -1,3 +1,5 @@
+require 'open-uri'
+
# Helpers for displaying package models
module PackagesHelper
def restrict_label(version)
@@ -90,4 +92,10 @@ module PackagesHelper
nil
end
+
+ def documentation_label(package)
+ doc = Nokogiri::XML(open("https://wiki.gentoo.org/api.php?action=query&titles=" + package + "&format=xml"))
+ doc.xpath("//api/query/pages/page")[0].attr('missing').nil? ? (t :res_docs) : (t :res_search_docs)
+ end
+
end
diff --git a/app/views/packages/_resources.html.erb b/app/views/packages/_resources.html.erb
index 40a2547..34c8486 100644
--- a/app/views/packages/_resources.html.erb
+++ b/app/views/packages/_resources.html.erb
@@ -7,9 +7,9 @@
<span class="fa fa-fw fa-bug"></span>
<%= t :res_bugs %>
</a>
- <a href="https://wiki.gentoo.org/index.php?title=Special%3ASearch&fulltext=Search&search=<%= u package.name %>" class="list-group-item" target="_blank">
+ <a href="https://wiki.gentoo.org/wiki/Special:Search/<%= u package.name %>" class="list-group-item" target="_blank">
<span class="fa fa-fw fa-book"></span>
- <%= t :res_docs %>
+ <%= documentation_label(package.name) %>
</a>
<a href="https://forums.gentoo.org/search.php?search_terms=all&show_results=topics&search_keywords=<%= u package.name %>&mode=results" class="list-group-item" target="_blank">
<span class="fa fa-fw fa-comments-o"></span>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index c00801b..a2061cc 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -59,6 +59,7 @@ en:
view_git_changelog: "View Git Changelog"
res_bugs: "Related bugs"
res_docs: "Documentation"
+ res_search_docs: "Search for Documentation"
res_forums: "Forums posts"
res_repo: "Git repository browser"
res_log: "Git log"