Ref #25.
Unified · Split
| @@ -32,6 +32,7 @@ class App < Sinatra::Application · 31 unmodified lines | |||
| 32 | Hash[JSON.parse(File.read(docs_manifest_path)).map! { |doc| | 32 | Hash[JSON.parse(File.read(docs_manifest_path)).map! { |doc| |
| 33 | doc['full_name'] = doc['name'].dup | 33 | doc['full_name'] = doc['name'].dup |
| 34 | doc['full_name'] << " #{doc['version']}" if doc['version'] | 34 | doc['full_name'] << " #{doc['version']}" if doc['version'] |
| 35 | doc['slug_without_version'] = doc['slug'].split('~').first | ||
| 35 | [doc['slug'], doc] | 36 | [doc['slug'], doc] |
| 36 | }] | 37 | }] |
| 37 | } | 38 | } |
| @@ -123,9 +124,8 @@ class App < Sinatra::Application · 85 unmodified lines | |||
| 123 | 124 | ||
| 124 | def find_doc(slug) | 125 | def find_doc(slug) |
| 125 | settings.docs[slug] || begin | 126 | settings.docs[slug] || begin |
| 126 | slug = "#{slug}~" | 127 | settings.docs.each do |_, doc| |
| 127 | settings.docs.each do |_slug, _doc| | 128 | return doc if doc['slug_without_version'] == slug |
| 128 | return _doc if _slug.start_with?(slug) | ||
| 129 | end | 129 | end |
| 130 | nil | 130 | nil |
| 131 | end | 131 | end |
| @@ -147,7 +147,7 @@ class App < Sinatra::Application · 15 unmodified lines | |||
| 147 | end | 147 | end |
| 148 | 148 | ||
| 149 | def doc_index_page? | 149 | def doc_index_page? |
| 150 | @doc && request.path == "/#{@doc['slug']}/" | 150 | @doc && (request.path == "/#{@doc['slug']}/" || request.path == "/#{@doc['slug_without_version']}/") |
| 151 | end | 151 | end |
| 152 | 152 | ||
| 153 | def query_string_for_redirection | 153 | def query_string_for_redirection |