浏览代码

Ask all HTTP users to switch to HTTPS

Thibaut Courouble 7 年之前
父节点
当前提交
a379b6299d

+ 11 - 0
assets/javascripts/templates/pages/root_tmpl.coffee.erb

@@ -72,3 +72,14 @@ app.templates.androidWarning = """
     <p>To install DevDocs on your phone, visit <a href="https://devdocs.io" target="_blank" rel="noopener">devdocs.io</a> in Chrome and select "Add to home screen" in the menu.
     <p>To install DevDocs on your phone, visit <a href="https://devdocs.io" target="_blank" rel="noopener">devdocs.io</a> in Chrome and select "Add to home screen" in the menu.
   </div>
   </div>
 """
 """
+
+app.templates.httpWarning = """
+  <div class="_intro"><div class="_intro-message">
+    <h2 class="_intro-title">Hi there!</h2>
+    <p>DevDocs is migrating to HTTPS.
+    <p>Please update your bookmarks to point to <a href="https://devdocs.io">https://devdocs.io</a>.
+    <p>When using the HTTPS version, your preferences will carry over automatically, but your offline data will be reset. Simply re-download documentation in the <a href="https://devdocs.io/offline">Offline area</a>, and you'll be all set to use DevDocs securely offline.
+    <p>Sorry for the inconvenience. This migration is needed because browsers are removing support for certain DOM APIs that power DevDocs's offline mode over non-secure origins.
+    <p>Thanks for using DevDocs, and happy coding!
+  </div></div>
+"""

+ 14 - 3
assets/javascripts/views/content/root_page.coffee

@@ -9,10 +9,21 @@ class app.views.RootPage extends app.View
 
 
   render: ->
   render: ->
     @empty()
     @empty()
-    if app.isAndroidWebview()
-      @append @tmpl('androidWarning')
+
+    tmpl = if app.isAndroidWebview()
+      'androidWarning'
+    else if @isHidden()
+      'splash'
+    else if app.isMobile()
+      'mobileIntro'
     else
     else
-      @append @tmpl if @isHidden() then 'splash' else if app.isMobile() then 'mobileIntro' else 'intro'
+      'intro'
+
+    # temporary
+    if location.host is 'devdocs.io' and location.protocol is 'http:'
+      tmpl = 'httpWarning'
+
+    @append @tmpl(tmpl)
     return
     return
 
 
   hideIntro: ->
   hideIntro: ->