Unified · Split
| @@ -27,7 +27,8 @@ · 26 unmodified lines | |||
| 27 | @document = new app.views.Document | 27 | @document = new app.views.Document |
| 28 | @mobile = new app.views.Mobile if @isMobile() | 28 | @mobile = new app.views.Mobile if @isMobile() |
| 29 | 29 | ||
| 30 | if @DOC | 30 | if document.body.hasAttribute('data-doc') |
| 31 | @DOC = JSON.parse(document.body.getAttribute('data-doc')) | ||
| 31 | @bootOne() | 32 | @bootOne() |
| 32 | else if @DOCS | 33 | else if @DOCS |
| 33 | @bootAll() | 34 | @bootAll() |
| @@ -185,13 +185,13 @@ class AppTest < MiniTest::Spec · 184 unmodified lines | |||
| 185 | it "works when the doc exists" do | 185 | it "works when the doc exists" do |
| 186 | get '/html~4-foo-bar_42/' | 186 | get '/html~4-foo-bar_42/' |
| 187 | assert last_response.ok? | 187 | assert last_response.ok? |
| 188 | assert_includes last_response.body, 'app.DOC = {"name":"HTML","slug":"html~4"' | 188 | assert_includes last_response.body, 'data-doc="{"name":"HTML","slug":"html~4"' |
| 189 | end | 189 | end |
| 190 | 190 | ||
| 191 | it "works when the doc has no version in the path and a version exists" do | 191 | it "works when the doc has no version in the path and a version exists" do |
| 192 | get '/html-foo-bar_42/' | 192 | get '/html-foo-bar_42/' |
| 193 | assert last_response.ok? | 193 | assert last_response.ok? |
| 194 | assert_includes last_response.body, 'app.DOC = {"name":"HTML","slug":"html~5"' | 194 | assert_includes last_response.body, 'data-doc="{"name":"HTML","slug":"html~5"' |
| 195 | end | 195 | end |
| 196 | 196 | ||
| 197 | it "returns 404 when the type is blank" do | 197 | it "returns 404 when the type is blank" do |
| @@ -13,9 +13,8 @@ · 12 unmodified lines | |||
| 13 | <link rel="stylesheet" href="<%= main_stylesheet_path %>" data-alt="<%= alternate_stylesheet_path %>"> | 13 | <link rel="stylesheet" href="<%= main_stylesheet_path %>" data-alt="<%= alternate_stylesheet_path %>"> |
| 14 | <%= javascript_tag 'application', asset_host: false %><% unless App.production? %> | 14 | <%= javascript_tag 'application', asset_host: false %><% unless App.production? %> |
| 15 | <%= javascript_tag 'debug' %><% end %> | 15 | <%= javascript_tag 'debug' %><% end %> |
| 16 | <script>app.DOC = <%= @doc.to_json %>;</script> | ||
| 17 | </head> | 16 | </head> |
| 18 | <body class="_booting _noscript"> | 17 | <body class="_booting _noscript" data-doc="<%= CGI::escape_html @doc.to_json %>"> |
| 19 | <noscript class="_fail">DevDocs requires JavaScript to run.</noscript> | 18 | <noscript class="_fail">DevDocs requires JavaScript to run.</noscript> |
| 20 | <%= erb :app %></body> | 19 | <%= erb :app %></body> |
| 21 | </html> | 20 | </html> |