aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorBrandon Mathis <brandon@imathis.com>2011-07-21 23:50:32 -0400
committerBrandon Mathis <brandon@imathis.com>2011-07-22 00:00:18 -0400
commit39d56bc98834b09fc6939fd27bde8848efbb251d (patch)
tree404e6d12464884a763949215bb66081c74cf56c9 /plugins
parent44e1351fc71eaef7aefdc168dc9bc15b20d4bda4 (diff)
downloadmy_new_personal_website-39d56bc98834b09fc6939fd27bde8848efbb251d.tar.xz
my_new_personal_website-39d56bc98834b09fc6939fd27bde8848efbb251d.zip
Finally a nice solution for mapping relative urls
Diffstat (limited to 'plugins')
-rw-r--r--plugins/category_generator.rb2
-rw-r--r--plugins/custom_filters.rb16
2 files changed, 13 insertions, 5 deletions
diff --git a/plugins/category_generator.rb b/plugins/category_generator.rb
index c2e9a46e..e636781e 100644
--- a/plugins/category_generator.rb
+++ b/plugins/category_generator.rb
@@ -130,7 +130,7 @@ module Jekyll
#
def category_links(categories)
dir = @context.registers[:site].config['category_dir']
- root_url = @context.registers[:site].config['root']
+ root_url = @context.registers[:site].config['root'].sub(/\/$/, '')
categories = categories.sort!.map do |item|
"<a class='category' href='#{root_url}/#{dir}/#{item.gsub(/_|\W/, '-')}/'>#{item}</a>"
end
diff --git a/plugins/custom_filters.rb b/plugins/custom_filters.rb
index 0a7604f7..5b49363b 100644
--- a/plugins/custom_filters.rb
+++ b/plugins/custom_filters.rb
@@ -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