mirror of
https://github.com/WatchOutNewsAgency/wona.github.com.git
synced 2026-01-01 01:16:26 +00:00
Finally a nice solution for mapping relative urls
This commit is contained in:
@ -20,15 +20,23 @@ module OctopressFilters
|
||||
end
|
||||
|
||||
# Replaces relative urls with full urls
|
||||
def full_urls(input, url='')
|
||||
url ||= ''
|
||||
def expand_urls(input, url='')
|
||||
url ||= '/'
|
||||
input.gsub /(\s+(href|src)\s*=\s*["|']{1})(\/[^\"'>]+)/ do
|
||||
$1+url+$3
|
||||
end
|
||||
end
|
||||
|
||||
# Returns a url without the http:// for use in as a search modifier eg. 'search terms site:website.com'
|
||||
def search_url(input)
|
||||
# Removes trailing forward slash from a string for easily appending url segments
|
||||
def strip_slash(input)
|
||||
if input =~ /(.+)\/$|^\/$/
|
||||
input = $1
|
||||
end
|
||||
input
|
||||
end
|
||||
|
||||
# Returns a url without the protocol (http://)
|
||||
def shorthand_url(input)
|
||||
input.gsub /(https?:\/\/)(\S+)/ do
|
||||
$2
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user