aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorMax Magorsch <max@magorsch.de>2019-10-18 21:13:39 +0200
committerMax Magorsch <max@magorsch.de>2019-10-18 21:16:54 +0200
commit0ba27a0f95fa49ecdc11b7599da66eb98d20ea4f (patch)
treeb97f9509c3f430bc824e9f614d66e81b7598c75a /app
parentAdd atom feeds for package search results (diff)
downloadpackages-5-0ba27a0f95fa49ecdc11b7599da66eb98d20ea4f.tar.gz
packages-5-0ba27a0f95fa49ecdc11b7599da66eb98d20ea4f.tar.bz2
packages-5-0ba27a0f95fa49ecdc11b7599da66eb98d20ea4f.zip
Change the documentation link to the wiki page
So far the documentation link for each package points to a full-text search in the wiki. Now the documentation link points to the respective wiki page in case the page exists. Only in case, the page doesn't exist the link points to the full-text search. Additionally, if the page doesn't exist the link is labelled as 'Search for Documentation'. In case the page exists, it is still labelled 'Documentation'. Closes: https://bugs.gentoo.org/611262 Signed-off-by: Max Magorsch <max@magorsch.de>
Diffstat (limited to 'app')
-rw-r--r--app/helpers/packages_helper.rb8
-rw-r--r--app/views/packages/_resources.html.erb4
2 files changed, 10 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>