Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add Article#talk_url to return the URL to the talk page of an article…

…, also fix up things if we have query string in the URLs

git-svn-id: svn://78.47.249.61/ruby-mediawiki/trunk@66 ba9c31aa-a806-0410-9a81-9f13d15ee83b
  • Loading branch information...
commit 2d593b6cd1caa3d321e994234a65e8beb08df11a 1 parent df71d27
neingeist authored
Showing with 13 additions and 1 deletion.
  1. +13 −1 lib/mediawiki/article.rb
View
14 lib/mediawiki/article.rb
@@ -58,7 +58,19 @@ def full_name
# result:: [String] URL
def url
uri = @wiki.url.dup
- uri.path = xhtml.elements['//li[@id="ca-nstab-main"]//a'].attributes['href']
+ uri.path, uri.query = xhtml.elements['//li[@id="ca-nstab-main"]//a'].attributes['href'].split(/\?/, 2)
+ uri.to_s
+ end
+
+ ##
+ # Return the URL of the talk page of the article
+ #
+ # This will return a nice human-readable URL if your MediWiki
+ # is configured that way.
+ # result:: [String] URL
+ def talk_url
+ uri = @wiki.url.dup
+ uri.path, uri.query = xhtml.elements['//li[@id="ca-talk"]//a'].attributes['href'].split(/\?/, 2)
uri.to_s
end
Please sign in to comment.
Something went wrong with that request. Please try again.