module BusinessCatalyst

Constants

CATALOG_CHAR_BLACKLIST

The following characters cause an error message if they appear in a catalog name.

MORE_STRICT_BLACKLIST
VERSION

Public Class Methods

reset_global_urls!() click to toggle source
# File lib/business_catalyst.rb, line 36
def self.reset_global_urls!
  BusinessCatalyst::CSV::SEOFriendlyUrlTransformer.reset_global_urls!
end
sanitize_catalog_name(name) click to toggle source

Strip all characters out of a catalog name that will cause an error. Replaces them with “ ” and then squishes all whitespace to single space to preserve word structure.

# File lib/business_catalyst.rb, line 18
def self.sanitize_catalog_name(name)
  return name if name.nil?
  sanitized = name.strip
  sanitized.gsub!(CATALOG_CHAR_BLACKLIST, " ")
  sanitized.gsub!(/\s+/, " ")
  sanitized
end
seo_friendly_url(name) click to toggle source

A guess as to how business catalyst converts names to URL's, based on this blog entry: www.businesscatalyst.com/bc-blog/seo-friendly-urls-for-products-and-catalogs

Downcases, converts invalid characters and whitespace to '-', and finally removes multiple consecutive dashes and leading and trailing dashes. Does NOT append numbers to ensure uniqueness, you must do this yourself after conversion.

# File lib/business_catalyst.rb, line 32
def self.seo_friendly_url(name)
  name.strip.downcase.gsub(/[^a-z0-9\-]/, "-").gsub(/-{2,}/, "-").gsub(/\A-+|-+\Z/, "")
end