class API::URL
Public Class Methods
encode_uri_component(s)
click to toggle source
# File lib/quintype/api/url.rb, line 35 def encode_uri_component(s) URI.escape(s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")) if s end
search(term)
click to toggle source
# File lib/quintype/api/url.rb, line 24 def search (term) "/search?q=" + term end
section(section_name)
click to toggle source
# File lib/quintype/api/url.rb, line 20 def section (section_name) "/section/" + make_slug(section_name) end
story(story)
click to toggle source
# File lib/quintype/api/url.rb, line 4 def story (story) "/" + story['slug'] end
story_amp(root, story)
click to toggle source
# File lib/quintype/api/url.rb, line 12 def story_amp(root, story) root + 'amp/' + story['slug'].split('/').last end
story_canonical(root, story)
click to toggle source
# File lib/quintype/api/url.rb, line 8 def story_canonical(root, story) story['canonical_url'] || (root + story['slug']) end
topic(tag_name)
click to toggle source
# File lib/quintype/api/url.rb, line 16 def topic (tag_name) "/topic/" + encode_uri_component(tag_name) end
Private Class Methods
make_slug(s)
click to toggle source
# File lib/quintype/api/url.rb, line 41 def make_slug(s) s.gsub(/[^\w -]/, "").gsub(/\s+/, "-").downcase if s end