Sha256: 38572f5727d130b51c4207f35389ba3f894714cc3ce0300209a7a7a78d9c836f

Contents?: true

Size: 796 Bytes

Versions: 31

Compression:

Stored size: 796 Bytes

Contents

class VanityUrlPage < Page

  def clean_target_url
    (self.target_url.match('http://') || self.target_url.match('https://')) ? self.target_url : VanityUrlPage.clean_path(self.target_url)
  end

  class << self

    def find_vanity_url_by_path(path, live = true)
      vanity_url_page = Page.current_site.homepage.children.find_by_slug('vanity-urls')
      vanity_pages = vanity_url_page.children.where("vanity_url like '%#{path}%'")
      vanity_pages.each do |vanity_page|
        return vanity_page if clean_comparison_path(path).downcase == clean_comparison_path(vanity_page.vanity_url).downcase
      end
      nil
    end

    def clean_comparison_path(path)
      "#{clean_path(path)}/"
    end

    def clean_path(path)
      "/#{path.to_s.strip}".gsub(%r{//+}, '/')
    end

  end

end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
trusty-festivity-extension-2.6.3 app/models/vanity_url_page.rb
trusty-festivity-extension-2.6.2 app/models/vanity_url_page.rb
trusty-festivity-extension-2.6.1 app/models/vanity_url_page.rb
trusty-festivity-extension-2.6 app/models/vanity_url_page.rb
trusty-festivity-extension-2.5.19 app/models/vanity_url_page.rb
trusty-festivity-extension-2.5.18 app/models/vanity_url_page.rb
trusty-festivity-extension-2.5.17 app/models/vanity_url_page.rb
trusty-festivity-extension-2.5.16 app/models/vanity_url_page.rb
trusty-festivity-extension-2.5.15 app/models/vanity_url_page.rb
trusty-festivity-extension-2.5.14 app/models/vanity_url_page.rb
trusty-festivity-extension-2.5.13 app/models/vanity_url_page.rb
trusty-festivity-extension-2.5.12 app/models/vanity_url_page.rb
trusty-festivity-extension-2.5.11 app/models/vanity_url_page.rb
trusty-festivity-extension-2.5.10 app/models/vanity_url_page.rb
trusty-festivity-extension-2.5.9 app/models/vanity_url_page.rb
trusty-festivity-extension-2.5.8 app/models/vanity_url_page.rb
trusty-festivity-extension-2.5.7 app/models/vanity_url_page.rb
trusty-festivity-extension-2.5.6 app/models/vanity_url_page.rb
trusty-festivity-extension-2.5.5 app/models/vanity_url_page.rb
trusty-festivity-extension-2.5.4 app/models/vanity_url_page.rb