Class: API::URL
- Inherits:
-
Object
- Object
- API::URL
- Defined in:
- lib/quintype/api/url.rb
Class Method Summary collapse
- .author(args) ⇒ Object
- .encode_uri_component(s) ⇒ Object
- .search(term) ⇒ Object
- .section(section_name) ⇒ Object
- .story(story) ⇒ Object
- .story_amp(root, story) ⇒ Object
- .story_canonical(root, story) ⇒ Object
- .topic(tag_name) ⇒ Object
Class Method Details
.author(args) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/quintype/api/url.rb', line 28 def (args) id = args['id'] slug = args['slug'] "/author/#{id}/#{slug}" end |
.encode_uri_component(s) ⇒ Object
35 36 37 |
# 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) ⇒ Object
24 25 26 |
# File 'lib/quintype/api/url.rb', line 24 def search (term) "/search?q=" + term end |
.section(section_name) ⇒ Object
20 21 22 |
# File 'lib/quintype/api/url.rb', line 20 def section (section_name) "/section/" + make_slug(section_name) end |
.story(story) ⇒ Object
4 5 6 |
# File 'lib/quintype/api/url.rb', line 4 def story (story) "/" + story['slug'] end |
.story_amp(root, story) ⇒ Object
12 13 14 |
# File 'lib/quintype/api/url.rb', line 12 def story_amp(root, story) root + 'amp/' + story['slug'].split('/').last end |
.story_canonical(root, story) ⇒ Object
8 9 10 |
# File 'lib/quintype/api/url.rb', line 8 def story_canonical(root, story) story['canonical_url'] || (root + story['slug']) end |
.topic(tag_name) ⇒ Object
16 17 18 |
# File 'lib/quintype/api/url.rb', line 16 def topic (tag_name) "/topic/" + encode_uri_component(tag_name) end |