Skip to content
This repository has been archived by the owner on Mar 9, 2024. It is now read-only.

Commit

Permalink
Add Article#url to return a shiny nice article URL
Browse files Browse the repository at this point in the history
git-svn-id: svn://78.47.249.61/ruby-mediawiki/trunk@65 ba9c31aa-a806-0410-9a81-9f13d15ee83b
  • Loading branch information
neingeist committed Nov 20, 2006
1 parent dcda185 commit df71d27
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/mediawiki.rb
Expand Up @@ -35,6 +35,11 @@ class Wiki
# This must be readable as it's used by Article and Category # This must be readable as it's used by Article and Category
# to fetch themselves. # to fetch themselves.
attr_reader :browser 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. # Initialize a new Wiki instance.
Expand Down
12 changes: 12 additions & 0 deletions lib/mediawiki/article.rb
Expand Up @@ -50,6 +50,18 @@ def full_name
@name @name
end 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, # Get the XHTML,
# will invoke Article#xhtml_reload if not already cached # will invoke Article#xhtml_reload if not already cached
Expand Down

0 comments on commit df71d27

Please sign in to comment.