class Textigniter::Plugins::Slug
Public Instance Methods
parse(h)
click to toggle source
# File lib/textigniter/plugins/slug.rb, line 3 def parse(h) # get the value value = h['slug'] # split the value by / values = value.split(/\//) # get the filename filename = values.last # values pop values.pop # check for date in slug valid = Date.parse(filename[0..9]) rescue false # slug does contain date if valid != false slug = "#{values.join('/')}/#{filename.gsub(filename[0..9] + "-", '')}" # slug does not contain date else slug = value end # check for path name slug = "#{$owd}/#{slug}" unless slug.include? $twd # check for index slug = slug.sub('index', '') # replace twd with owd slug = slug.sub("#{$twd}/content", "#{$owd}") # return parsed slug return slug end