Unified · Split
| @@ -4,6 +4,7 @@ Bundler.require :app · 3 unmodified lines | |||
| 4 | class App < Sinatra::Application | 4 | class App < Sinatra::Application |
| 5 | Bundler.require environment | 5 | Bundler.require environment |
| 6 | require 'sinatra/cookies' | 6 | require 'sinatra/cookies' |
| 7 | require 'tilt/erubis' | ||
| 7 | 8 | ||
| 8 | Rack::Mime::MIME_TYPES['.webapp'] = 'application/x-web-app-manifest+json' | 9 | Rack::Mime::MIME_TYPES['.webapp'] = 'application/x-web-app-manifest+json' |
| 9 | 10 | ||
| @@ -94,15 +95,17 @@ class App < Sinatra::Application · 84 unmodified lines | |||
| 94 | @browser ||= Browser.new ua: request.user_agent | 95 | @browser ||= Browser.new ua: request.user_agent |
| 95 | end | 96 | end |
| 96 | 97 | ||
| 98 | UNSUPPORTED_IE_VERSIONS = %w(6 7 8 9).freeze | ||
| 99 | |||
| 97 | def unsupported_browser? | 100 | def unsupported_browser? |
| 98 | browser.ie? && %w(6 7 8 9).include?(browser.version) | 101 | browser.ie? && UNSUPPORTED_IE_VERSIONS.include?(browser.version) |
| 99 | end | 102 | end |
| 100 | 103 | ||
| 101 | def docs | 104 | def docs |
| 102 | @docs ||= begin | 105 | @docs ||= begin |
| 103 | cookie = cookies[:docs] | 106 | cookie = cookies[:docs] |
| 104 | 107 | ||
| 105 | docs = if cookie.nil? || cookie.empty? | 108 | if cookie.nil? || cookie.empty? |
| 106 | settings.default_docs | 109 | settings.default_docs |
| 107 | else | 110 | else |
| 108 | cookie.split('/') | 111 | cookie.split('/') |
| @@ -111,11 +114,10 @@ class App < Sinatra::Application · 2 unmodified lines | |||
| 111 | end | 114 | end |
| 112 | 115 | ||
| 113 | def doc_index_urls | 116 | def doc_index_urls |
| 114 | docs.inject [] do |result, slug| | 117 | docs.each_with_object [] do |slug, result| |
| 115 | if doc = settings.docs[slug] | 118 | if doc = settings.docs[slug] |
| 116 | result << File.join('', settings.docs_prefix, doc['index_path']) + "?#{doc['mtime']}" | 119 | result << File.join('', settings.docs_prefix, doc['index_path']) + "?#{doc['mtime']}" |
| 117 | end | 120 | end |
| 118 | result | ||
| 119 | end | 121 | end |
| 120 | end | 122 | end |
| 121 | 123 | ||