Skip to content
Browse files

Add Article#url to return a shiny nice article URL

git-svn-id: svn://78.47.249.61/ruby-mediawiki/trunk@65 ba9c31aa-a806-0410-9a81-9f13d15ee83b
  • Loading branch information...
1 parent dcda185 commit df71d279910c4ae61f41ef0d96d9212385798c94 neingeist committed
Showing with 17 additions and 0 deletions.
  1. +5 −0 lib/mediawiki.rb
  2. +12 −0 lib/mediawiki/article.rb
View
5 lib/mediawiki.rb
@@ -35,6 +35,11 @@ class Wiki
# This must be readable as it's used by Article and Category
# to fetch themselves.
attr_reader :browser
+
+ ##
+ # The URL-Path to index.php (without index.php) as given
+ # to Wiki#initialize
+ attr_reader :url
##
# Initialize a new Wiki instance.
View
12 lib/mediawiki/article.rb
@@ -51,6 +51,18 @@ def full_name
end
##
+ # Return the URL of the article as configured
+ #
+ # This will return a nice human-readable URL if your MediWiki
+ # is configured that way, unlike Wiki#full_article_url
+ # result:: [String] URL
+ def url
+ uri = @wiki.url.dup
+ uri.path = xhtml.elements['//li[@id="ca-nstab-main"]//a'].attributes['href']
+ uri.to_s
+ end
+
+ ##
# Get the XHTML,
# will invoke Article#xhtml_reload if not already cached
# result:: [REXML::Element] html root element

0 comments on commit df71d27

Please sign in to comment.
Something went wrong with that request. Please try again.