diff --git a/.editorconfig b/.editorconfig
index 73db316c..03c17bf8 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -6,3 +6,6 @@ indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
+
+[*.md]
+trim_trailing_whitespace = false
diff --git a/CONTRIBUTING.md b/.github/CONTRIBUTING.md
similarity index 76%
rename from CONTRIBUTING.md
rename to .github/CONTRIBUTING.md
index bdb36d55..d2317ab5 100644
--- a/CONTRIBUTING.md
+++ b/.github/CONTRIBUTING.md
@@ -24,20 +24,18 @@ Want to contribute? Great. Please review the following guidelines carefully and
## Requesting new features
1. Search for similar feature requests; someone may have already requested it.
-2. Make sure your feature fits DevDocs's [vision](https://github.com/freeCodeCamp/devdocs/blob/master/README.md#vision).
+2. Make sure your feature fits DevDocs's [vision](../README.md#vision).
3. Provide a clear and detailed explanation of the feature and why it's important to add it.
-For general feedback and ideas, please use the [mailing list](https://groups.google.com/d/forum/devdocs).
-
## Requesting new documentations
-Please don't open issues to request new documentations.
+Please don't open issues to request new documentations.
Use the [Trello board](https://trello.com/b/6BmTulfx/devdocs-documentation) where everyone can vote.
## Contributing code and features
1. Search for existing issues; someone may already be working on a similar feature.
-2. Before embarking on any significant pull request, please open an issue describing the changes you intend to make. Otherwise you risk spending a lot of time working on something I may not want to merge. This also tells other contributors that you're working on the feature.
+2. Before embarking on any significant pull request, please open an issue describing the changes you intend to make. Otherwise you risk spending a lot of time working on something we may not want to merge. This also tells other contributors that you're working on the feature.
3. Follow the [coding conventions](#coding-conventions).
4. If you're modifying the Ruby code, include tests and ensure they pass.
5. Try to keep your pull request small and simple.
@@ -46,7 +44,7 @@ Use the [Trello board](https://trello.com/b/6BmTulfx/devdocs-documentation) wher
## Contributing new documentations
-See the [wiki](https://github.com/freeCodeCamp/devdocs/wiki) to learn how to add new documentations.
+See the [`docs` folder](https://github.com/freeCodeCamp/devdocs/tree/master/docs) to learn how to add new documentations.
**Important:** the documentation's license must permit alteration, redistribution and commercial use, and the documented software must be released under an open source license. Feel free to get in touch if you're not sure if a documentation meets those requirements.
@@ -65,13 +63,6 @@ Please don't submit a pull request updating the version number of a documentatio
To ask that an existing documentation be updated, please use the [Trello board](https://trello.com/c/2B0hmW7M/52-request-updates-here).
-## Other contributions
-
-Besides new docs and features, here are other ways you can contribute:
-
-* **Improve our copy.** English isn't my first language so if you notice grammatical or usage errors, feel free to submit a pull request — it'll be much appreciated.
-* **Participate in the issue tracker.** Your opinion matters — feel free to add comments to existing issues. You're also welcome to participate to the [mailing list](https://groups.google.com/d/forum/devdocs).
-
## Coding conventions
* two spaces; no tabs
@@ -80,4 +71,4 @@ Besides new docs and features, here are other ways you can contribute:
## Questions?
-If you have any questions, please feel free to ask on the [mailing list](https://groups.google.com/d/forum/devdocs).
+If you have any questions, please feel free to ask them on the contributor chat room on [Gitter](https://gitter.im/FreeCodeCamp/DevDocs).
diff --git a/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md
similarity index 73%
rename from ISSUE_TEMPLATE.md
rename to .github/ISSUE_TEMPLATE.md
index 4b173394..807f88e0 100644
--- a/ISSUE_TEMPLATE.md
+++ b/.github/ISSUE_TEMPLATE.md
@@ -1,6 +1,6 @@
+- [ ] Added these files to the public/icons/*your_scraper_name*/ directory:
+ - [ ] `16.png`: a 16×16 pixel icon for the doc
+ - [ ] `16@2x.png`: a 32×32 pixel icon for the doc
+ - [ ] `SOURCE`: A text file containing the URL to the page the image can be found on or the URL of the original image itself
+
+
diff --git a/README.md b/README.md
index 119c6fe1..630142d4 100644
--- a/README.md
+++ b/README.md
@@ -1,25 +1,24 @@
-# [DevDocs](https://devdocs.io) [![Build Status](https://travis-ci.org/freeCodeCamp/devdocs.svg?branch=master)](https://travis-ci.org/freeCodeCamp/devdocs)
+# [DevDocs](https://devdocs.io) — API Documentation Browser [![Build Status](https://travis-ci.org/freeCodeCamp/devdocs.svg?branch=master)](https://travis-ci.org/freeCodeCamp/devdocs)
-DevDocs combines multiple API documentations in a fast, organized, and searchable interface.
+DevDocs combines multiple developer documentations in a clean and organized web UI with instant search, offline support, mobile version, dark theme, keyboard shortcuts, and more.
-* Created by [Thibaut Courouble](https://thibaut.me)
+DevDocs was created by [Thibaut Courouble](https://thibaut.me) and is operated by [freeCodeCamp](https://www.freecodecamp.org).
Keep track of development news:
* Join the contributor chat room on [Gitter](https://gitter.im/FreeCodeCamp/DevDocs)
* Watch the repository on [GitHub](https://github.com/freeCodeCamp/devdocs/subscription)
* Follow [@DevDocs](https://twitter.com/DevDocs) on Twitter
-* Join the [mailing list](https://groups.google.com/d/forum/devdocs)
-**Table of Contents:** [Quick Start](#quick-start) · [Vision](#vision) · [App](#app) · [Scraper](#scraper) · [Commands](#available-commands) · [Contributing](#contributing) · [License](#copyright--license) · [Questions?](#questions)
+**Table of Contents:** [Quick Start](#quick-start) · [Vision](#vision) · [App](#app) · [Scraper](#scraper) · [Commands](#available-commands) · [Contributing](#contributing) · [Documentation](#documentation) · [Plugins and Extensions](#plugins-and-extensions) · [License](#copyright--license) · [Questions?](#questions)
## Quick Start
-Unless you wish to contribute to the project, I recommend using the hosted version at [devdocs.io](https://devdocs.io). It's up-to-date and works offline out-of-the-box.
+Unless you wish to contribute to the project, we recommend using the hosted version at [devdocs.io](https://devdocs.io). It's up-to-date and works offline out-of-the-box.
DevDocs is made of two pieces: a Ruby scraper that generates the documentation and metadata, and a JavaScript app powered by a small Sinatra app.
-DevDocs requires Ruby 2.5.1, libcurl, and a JavaScript runtime supported by [ExecJS](https://github.com/rails/execjs#readme) (included in OS X and Windows; [Node.js](https://nodejs.org/en/) on Linux). Once you have these installed, run the following commands:
+DevDocs requires Ruby 2.6.0, libcurl, and a JavaScript runtime supported by [ExecJS](https://github.com/rails/execjs#readme) (included in OS X and Windows; [Node.js](https://nodejs.org/en/) on Linux). Once you have these installed, run the following commands:
```
git clone https://github.com/freeCodeCamp/devdocs.git && cd devdocs
@@ -60,18 +59,14 @@ The web app is all client-side JavaScript, written in [CoffeeScript](http://coff
Many of the code's design decisions were driven by the fact that the app uses XHR to load content directly into the main frame. This includes stripping the original documents of most of their HTML markup (e.g. scripts and stylesheets) to avoid polluting the main frame, and prefixing all CSS class names with an underscore to prevent conflicts.
-Another driving factor is performance and the fact that everything happens in the browser. `applicationCache` (which comes with its own set of constraints) and `localStorage` are used to speed up the boot time, while memory consumption is kept in check by allowing the user to pick his/her own set of documentations. The search algorithm is kept simple because it needs to be fast even searching through 100,000 strings.
+Another driving factor is performance and the fact that everything happens in the browser. A service worker (which comes with its own set of constraints) and `localStorage` are used to speed up the boot time, while memory consumption is kept in check by allowing the user to pick his/her own set of documentations. The search algorithm is kept simple because it needs to be fast even searching through 100,000 strings.
DevDocs being a developer tool, the browser requirements are high:
-1. On the desktop:
- * Recent version of Chrome, Firefox, or Opera
- * Safari 8+
- * IE / Edge 10+
-2. On mobile:
- * iOS 8+
- * Android 4.1+
- * Windows Phone 8+
+* Recent versions of Firefox, Chrome, or Opera
+* Safari 11.1+
+* Edge 17+
+* iOS 11.3+
This allows the code to take advantage of the latest DOM and HTML5 APIs and make developing DevDocs a lot more fun!
@@ -88,12 +83,13 @@ Modifications made to each document include:
* replacing all external (not scraped) URLs with their fully qualified counterpart
* replacing all internal (scraped) URLs with their unqualified and relative counterpart
* adding content, such as a title and link to the original document
+* ensuring correct syntax highlighting using [Prism](http://prismjs.com/)
These modifications are applied via a set of filters using the [HTML::Pipeline](https://github.com/jch/html-pipeline) library. Each scraper includes filters specific to itself, one of which is tasked with figuring out the pages' metadata.
The end result is a set of normalized HTML partials and two JSON files (index + offline data). Because the index files are loaded separately by the [app](#app) following the user's preferences, the scraper also creates a JSON manifest file containing information about the documentations currently available on the system (such as their name, version, update date, etc.).
-More information about scrapers and filters is available on the [wiki](https://github.com/freeCodeCamp/devdocs/wiki).
+More information about [scrapers](./docs/scraper-reference.md) and [filters](./docs/filter-reference.md) is available in the `docs` folder.
## Available Commands
@@ -133,20 +129,45 @@ If multiple versions of Ruby are installed on your system, commands must be run
## Contributing
-Contributions are welcome. Please read the [contributing guidelines](https://github.com/freeCodeCamp/devdocs/blob/master/CONTRIBUTING.md).
-
-DevDocs's own documentation is available on the [wiki](https://github.com/freeCodeCamp/devdocs/wiki).
+Contributions are welcome. Please read the [contributing guidelines](./.github/CONTRIBUTING.md).
+
+## Documentation
+
+* [Adding documentations to DevDocs](./docs/adding-docs.md)
+* [Scraper Reference](./docs/scraper-reference.md)
+* [Filter Reference](./docs/filter-reference.md)
+* [Maintainers’ Guide](./docs/maintainers.md)
+
+## Plugins and Extensions
+
+* [Chrome web app](https://chrome.google.com/webstore/detail/devdocs/mnfehgbmkapmjnhcnbodoamcioleeooe)
+* [Ubuntu Touch app](https://uappexplorer.com/app/devdocsunofficial.berkes)
+* [Sublime Text plugin](https://sublime.wbond.net/packages/DevDocs)
+* [Atom plugin](https://atom.io/packages/devdocs)
+* [Brackets extension](https://github.com/gruehle/dev-docs-viewer)
+* [Fluid](http://fluidapp.com) for turning DevDocs into a real OS X app
+* [GTK shell / Vim integration](https://github.com/naquad/devdocs-shell)
+* [Emacs lookup](https://github.com/skeeto/devdocs-lookup)
+* [Alfred Workflow](https://github.com/yannickglt/alfred-devdocs)
+* [Vim search plugin with Devdocs in its defaults](https://github.com/waiting-for-dev/vim-www) Just set `let g:www_shortcut_engines = { 'devdocs': ['Devdocs', 'dd'] }` to have a `:Devdocs` command and a `dd` mapping.
+* [Visual Studio Code plugin](https://marketplace.visualstudio.com/items?itemName=akfish.vscode-devdocs ) (1)
+* [Visual Studio Code plugin](https://marketplace.visualstudio.com/items?itemName=deibit.devdocs) (2)
+* [Desktop application](https://github.com/egoist/devdocs-desktop)
+* [Doc Browser](https://github.com/qwfy/doc-browser) is a native Linux app that supports DevDocs docsets
+* [GNOME Application](https://github.com/hardpixel/devdocs-desktop) GTK3 application with search integrated in headerbar
+* [macOS Application](https://github.com/dteoh/devdocs-macos)
+* [Android Application](https://github.com/Merith-TK/devdocs_webapp_kotlin) is a fully working, advanced WebView
## Copyright / License
-Copyright 2013-2018 Thibaut Courouble and [other contributors](https://github.com/freeCodeCamp/devdocs/graphs/contributors)
+Copyright 2013-2019 Thibaut Courouble and [other contributors](https://github.com/freeCodeCamp/devdocs/graphs/contributors)
-This software is licensed under the terms of the Mozilla Public License v2.0. See the [COPYRIGHT](https://github.com/freeCodeCamp/devdocs/blob/master/COPYRIGHT) and [LICENSE](https://github.com/freeCodeCamp/devdocs/blob/master/LICENSE) files.
+This software is licensed under the terms of the Mozilla Public License v2.0. See the [COPYRIGHT](./COPYRIGHT) and [LICENSE](./LICENSE) files.
-Please do not use the name DevDocs to endorse or promote products derived from this software without my permission, except as may be necessary to comply with the notice/attribution requirements.
+Please do not use the name DevDocs to endorse or promote products derived from this software without the maintainers' permission, except as may be necessary to comply with the notice/attribution requirements.
-I also wish that any documentation file generated using this software be attributed to DevDocs. Let's be fair to all contributors by giving credit where credit's due. Thanks!
+We also wish that any documentation file generated using this software be attributed to DevDocs. Let's be fair to all contributors by giving credit where credit's due. Thanks!
## Questions?
-If you have any questions, please feel free to ask them on the [mailing list](https://groups.google.com/d/forum/devdocs).
+If you have any questions, please feel free to ask them on the contributor chat room on [Gitter](https://gitter.im/FreeCodeCamp/DevDocs).
diff --git a/Rakefile b/Rakefile
index 3904cbd7..705c6ec1 100644
--- a/Rakefile
+++ b/Rakefile
@@ -3,6 +3,7 @@
require 'bundler/setup'
require 'thor'
+Bundler.require :default
$LOAD_PATH.unshift 'lib'
task :default do
@@ -13,6 +14,9 @@ end
namespace :assets do
desc 'Compile all assets'
task :precompile do
+ load 'tasks/docs.thor'
+ DocsCLI.new.prepare_deploy
+
load 'tasks/assets.thor'
AssetsCLI.new.compile
end
diff --git a/assets/images/docs-2.png b/assets/images/docs-2.png
index 2af0f5b9..bd9d44a8 100644
Binary files a/assets/images/docs-2.png and b/assets/images/docs-2.png differ
diff --git a/assets/images/docs-2@2x.png b/assets/images/docs-2@2x.png
index c781b248..512ea7a5 100644
Binary files a/assets/images/docs-2@2x.png and b/assets/images/docs-2@2x.png differ
diff --git a/assets/javascripts/app/app.coffee b/assets/javascripts/app/app.coffee
index eb92b595..1e230368 100644
--- a/assets/javascripts/app/app.coffee
+++ b/assets/javascripts/app/app.coffee
@@ -13,10 +13,12 @@
@el = $('._app')
@localStorage = new LocalStorageStore
- @appCache = new app.AppCache if app.AppCache.isEnabled()
+ @serviceWorker = new app.ServiceWorker if app.ServiceWorker.isEnabled()
@settings = new app.Settings
@db = new app.DB()
+ @settings.initLayout()
+
@docs = new app.collections.Docs
@disabledDocs = new app.collections.Docs
@entries = new app.collections.Entries
@@ -150,7 +152,7 @@
saveDocs: ->
@settings.setDocs(doc.slug for doc in @docs.all())
@db.migrate()
- @appCache?.updateInBackground()
+ @serviceWorker?.updateInBackground()
welcomeBack: ->
visitCount = @settings.get('count')
@@ -160,17 +162,24 @@
new app.views.Updates()
@updateChecker = new app.UpdateChecker()
+ reboot: ->
+ if location.pathname isnt '/' and location.pathname isnt '/settings'
+ window.location = "/##{location.pathname}"
+ else
+ window.location = '/'
+ return
+
reload: ->
@docs.clearCache()
@disabledDocs.clearCache()
- if @appCache then @appCache.reload() else window.location = '/'
+ if @serviceWorker then @serviceWorker.reload() else @reboot()
return
reset: ->
@localStorage.reset()
@settings.reset()
@db?.reset()
- @appCache?.update()
+ @serviceWorker?.update()
window.location = '/'
return
@@ -189,9 +198,9 @@
return
indexHost: ->
- # Can't load the index files from the host/CDN when applicationCache is
+ # Can't load the index files from the host/CDN when service worker is
# enabled because it doesn't support caching URLs that use CORS.
- @config[if @appCache and @settings.hasDocs() then 'index_path' else 'docs_origin']
+ @config[if @serviceWorker and @settings.hasDocs() then 'index_path' else 'docs_origin']
onBootError: (args...) ->
@trigger 'bootError'
@@ -248,7 +257,7 @@
matchMedia: !!window.matchMedia
insertAdjacentHTML: !!document.body.insertAdjacentHTML
defaultPrevented: document.createEvent('CustomEvent').defaultPrevented is false
- cssGradients: supportsCssGradients()
+ cssVariables: !!CSS?.supports?('(--t: 0)')
for key, value of features when not value
Raven.captureMessage "unsupported/#{key}", level: 'info'
@@ -271,9 +280,4 @@
isInvalidLocation: ->
@config.env is 'production' and location.host.indexOf(app.config.production_host) isnt 0
-supportsCssGradients = ->
- el = document.createElement('div')
- el.style.cssText = "background-image: -webkit-linear-gradient(top, #000, #fff); background-image: linear-gradient(to top, #000, #fff);"
- el.style.backgroundImage.indexOf('gradient') >= 0
-
$.extend app, Events
diff --git a/assets/javascripts/app/appcache.coffee b/assets/javascripts/app/appcache.coffee
deleted file mode 100644
index d2606ab1..00000000
--- a/assets/javascripts/app/appcache.coffee
+++ /dev/null
@@ -1,42 +0,0 @@
-class app.AppCache
- $.extend @prototype, Events
-
- @isEnabled: ->
- try
- applicationCache and applicationCache.status isnt applicationCache.UNCACHED
- catch
-
- constructor: ->
- @cache = applicationCache
- @notifyUpdate = true
- @onUpdateReady() if @cache.status is @cache.UPDATEREADY
-
- $.on @cache, 'progress', @onProgress
- $.on @cache, 'updateready', @onUpdateReady
-
- update: ->
- @notifyUpdate = true
- @notifyProgress = true
- try @cache.update() catch
- return
-
- updateInBackground: ->
- @notifyUpdate = false
- @notifyProgress = false
- try @cache.update() catch
- return
-
- reload: ->
- $.on @cache, 'updateready noupdate error', -> window.location = '/'
- @notifyUpdate = false
- @notifyProgress = true
- try @cache.update() catch
- return
-
- onProgress: (event) =>
- @trigger 'progress', event if @notifyProgress
- return
-
- onUpdateReady: =>
- @trigger 'updateready' if @notifyUpdate
- return
diff --git a/assets/javascripts/app/config.coffee.erb b/assets/javascripts/app/config.coffee.erb
index ec26b697..dba368e0 100644
--- a/assets/javascripts/app/config.coffee.erb
+++ b/assets/javascripts/app/config.coffee.erb
@@ -13,3 +13,5 @@ app.config =
version: <%= Time.now.to_i %>
release: <%= Time.now.utc.httpdate.to_json %>
mathml_stylesheet: '<%= App.cdn_origin %>/mathml.css'
+ service_worker_path: '/service-worker.js'
+ service_worker_enabled: <%= App.environment == :production || ENV['ENABLE_SERVICE_WORKER'] == 'true' %>
diff --git a/assets/javascripts/app/serviceworker.coffee b/assets/javascripts/app/serviceworker.coffee
new file mode 100644
index 00000000..40235566
--- /dev/null
+++ b/assets/javascripts/app/serviceworker.coffee
@@ -0,0 +1,49 @@
+class app.ServiceWorker
+ $.extend @prototype, Events
+
+ @isEnabled: ->
+ !!navigator.serviceWorker and app.config.service_worker_enabled
+
+ constructor: ->
+ @registration = null
+ @notifyUpdate = true
+
+ navigator.serviceWorker.register(app.config.service_worker_path, {scope: '/'})
+ .then(
+ (registration) => @updateRegistration(registration),
+ (error) -> console.error('Could not register service worker:', error)
+ )
+
+ update: ->
+ return unless @registration
+ @notifyUpdate = true
+ return @registration.update().catch(->)
+
+ updateInBackground: ->
+ return unless @registration
+ @notifyUpdate = false
+ return @registration.update().catch(->)
+
+ reload: ->
+ return @updateInBackground().then(() -> app.reboot())
+
+ updateRegistration: (registration) ->
+ @registration = registration
+ $.on @registration, 'updatefound', @onUpdateFound
+ return
+
+ onUpdateFound: =>
+ $.off @installingRegistration, 'statechange', @onStateChange() if @installingRegistration
+ @installingRegistration = @registration.installing
+ $.on @installingRegistration, 'statechange', @onStateChange
+ return
+
+ onStateChange: =>
+ if @installingRegistration and @installingRegistration.state == 'installed' and navigator.serviceWorker.controller
+ @installingRegistration = null
+ @onUpdateReady()
+ return
+
+ onUpdateReady: ->
+ @trigger 'updateready' if @notifyUpdate
+ return
diff --git a/assets/javascripts/app/settings.coffee b/assets/javascripts/app/settings.coffee
index ab5d128c..b2734dfe 100644
--- a/assets/javascripts/app/settings.coffee
+++ b/assets/javascripts/app/settings.coffee
@@ -5,6 +5,7 @@ class app.Settings
'manualUpdate'
'fastScroll'
'arrowScroll'
+ 'analyticsConsent'
'docs'
'dark'
'layout'
@@ -20,6 +21,8 @@ class app.Settings
'news'
]
+ LAYOUTS: ['_max-width', '_sidebar-hidden', '_native-scrollbars']
+
@defaults:
count: 0
hideDisabled: false
@@ -27,6 +30,7 @@ class app.Settings
news: 0
manualUpdate: false
schema: 1
+ analyticsConsent: false
constructor: ->
@store = new CookieStore
@@ -39,6 +43,7 @@ class app.Settings
set: (key, value) ->
@store.set(key, value)
delete @cache[key]
+ @toggleDark(value) if key == 'dark'
return
del: (key) ->
@@ -64,6 +69,8 @@ class app.Settings
return
setLayout: (name, enable) ->
+ @toggleLayout(name, enable)
+
layout = (@store.get('layout') || '').split(' ')
$.arrayDelete(layout, '')
@@ -105,3 +112,28 @@ class app.Settings
@store.reset()
@cache = {}
return
+
+ initLayout: ->
+ @toggleDark(@get('dark') is 1)
+ @toggleLayout(layout, @hasLayout(layout)) for layout in @LAYOUTS
+ @initSidebarWidth()
+ return
+
+ toggleDark: (enable) ->
+ classList = document.documentElement.classList
+ classList.toggle('_theme-default', !enable)
+ classList.toggle('_theme-dark', enable)
+ color = getComputedStyle(document.documentElement).getPropertyValue('--headerBackground').trim()
+ $('meta[name=theme-color]').setAttribute('content', color)
+ return
+
+ toggleLayout: (layout, enable) ->
+ classList = document.body.classList
+ classList.toggle(layout, enable) unless layout is '_sidebar-hidden'
+ classList.toggle('_overlay-scrollbars', $.overlayScrollbarsEnabled())
+ return
+
+ initSidebarWidth: ->
+ size = @get('size')
+ document.documentElement.style.setProperty('--sidebarWidth', size + 'px') if size
+ return
diff --git a/assets/javascripts/app/update_checker.coffee b/assets/javascripts/app/update_checker.coffee
index 5630b488..3558d6bc 100644
--- a/assets/javascripts/app/update_checker.coffee
+++ b/assets/javascripts/app/update_checker.coffee
@@ -3,13 +3,13 @@ class app.UpdateChecker
@lastCheck = Date.now()
$.on window, 'focus', @onFocus
- app.appCache.on 'updateready', @onUpdateReady if app.appCache
+ app.serviceWorker?.on 'updateready', @onUpdateReady
setTimeout @checkDocs, 0
check: ->
- if app.appCache
- app.appCache.update()
+ if app.serviceWorker
+ app.serviceWorker.update()
else
ajax
url: $('script[src*="application"]').getAttribute('src')
diff --git a/assets/javascripts/lib/license.coffee b/assets/javascripts/lib/license.coffee
index 8ff7c6e2..7f7ca938 100644
--- a/assets/javascripts/lib/license.coffee
+++ b/assets/javascripts/lib/license.coffee
@@ -1,5 +1,5 @@
###
- * Copyright 2013-2018 Thibaut Courouble and other contributors
+ * Copyright 2013-2019 Thibaut Courouble and other contributors
*
* This source code is licensed under the terms of the Mozilla
* Public License, v. 2.0, a copy of which may be obtained at:
diff --git a/assets/javascripts/lib/page.coffee b/assets/javascripts/lib/page.coffee
index 8df7422e..ba2f2647 100644
--- a/assets/javascripts/lib/page.coffee
+++ b/assets/javascripts/lib/page.coffee
@@ -190,7 +190,7 @@ isSameOrigin = (url) ->
updateCanonicalLink = ->
@canonicalLink ||= document.head.querySelector('link[rel="canonical"]')
- @canonicalLink.setAttribute('href', "http://#{location.host}#{location.pathname}")
+ @canonicalLink.setAttribute('href', "https://#{location.host}#{location.pathname}")
trackers = []
@@ -199,5 +199,21 @@ page.track = (fn) ->
return
track = ->
- tracker.call() for tracker in trackers
+ consentGiven = Cookies.get('analyticsConsent')
+ consentAsked = Cookies.get('analyticsConsentAsked')
+
+ if consentGiven == '1'
+ tracker.call() for tracker in trackers
+ else if consentGiven == undefined and consentAsked == undefined
+ # Only ask for consent once per browser session
+ Cookies.set('analyticsConsentAsked', '1')
+
+ new app.views.Notif 'AnalyticsConsent', autoHide: null
+ return
+
+@resetAnalytics = ->
+ for cookie in document.cookie.split(/;\s?/)
+ name = cookie.split('=')[0]
+ if name[0] == '_'
+ Cookies.expire(name)
return
diff --git a/assets/javascripts/lib/util.coffee b/assets/javascripts/lib/util.coffee
index 058106fd..001b13de 100644
--- a/assets/javascripts/lib/util.coffee
+++ b/assets/javascripts/lib/util.coffee
@@ -352,6 +352,10 @@ isIE = null
$.isIE = ->
isIE ?= navigator.userAgent?.indexOf('MSIE') >= 0 || navigator.userAgent?.indexOf('rv:11.0') >= 0
+isChromeForAndroid = null
+$.isChromeForAndroid = ->
+ isChromeForAndroid ?= navigator.userAgent?.indexOf('Android') >= 0 && /Chrome\/([.0-9])+ Mobile/.test(navigator.userAgent)
+
isAndroid = null
$.isAndroid = ->
isAndroid ?= navigator.userAgent?.indexOf('Android') >= 0
diff --git a/assets/javascripts/news.json b/assets/javascripts/news.json
index aff770f4..a2d18a47 100644
--- a/assets/javascripts/news.json
+++ b/assets/javascripts/news.json
@@ -1,5 +1,12 @@
[
[
+ "2019-07-19",
+ "Replaced the AppCache with a Service Worker (which makes DevDocs an installable PWA) and fixed layout preferences on Firefox."
+ ],
+ [
+ "2018-09-23",
+ "New documentations: Puppeteer and Handlebars.js"
+ ], [
"2018-08-12",
"New documentations: Dart and Qt"
], [
diff --git a/assets/javascripts/templates/error_tmpl.coffee b/assets/javascripts/templates/error_tmpl.coffee
index 9c19c0a6..9cca1f9d 100644
--- a/assets/javascripts/templates/error_tmpl.coffee
+++ b/assets/javascripts/templates/error_tmpl.coffee
@@ -12,8 +12,8 @@ app.templates.notFoundPage = ->
app.templates.pageLoadError = ->
error """ The page failed to load. """,
- """ It may be missing from the server (try reloading the app) or you could be offline.
- If you keep seeing this, you're likely behind a proxy or firewall that blocks cross-domain requests. """,
+ """ It may be missing from the server (try reloading the app) or you could be offline (try installing the documentation for offline usage when online again).
+ If you're online and you keep seeing this, you're likely behind a proxy or firewall that blocks cross-domain requests. """,
""" #{back} · Reload
· Retry """
@@ -56,21 +56,18 @@ app.templates.unsupportedBrowser = """
Your browser is unsupported, sorry.
DevDocs is an API documentation browser which supports the following browsers:
-
Recent versions of Chrome and Firefox
-
Safari 5.1+
-
Opera 12.1+
-
Internet Explorer 10+
-
iOS 6+
-
Android 4.1+
-
Windows Phone 8+
+
Recent versions of Firefox, Chrome, or Opera
+
Safari 11.1+
+
Edge 17+
+
iOS 11.3+
- If you're unable to upgrade, I apologize.
- I decided to prioritize speed and new features over support for older browsers.
+ If you're unable to upgrade, we apologize.
+ We decided to prioritize speed and new features over support for older browsers.
Note: if you're already using one of the browsers above, check your settings and add-ons.
The app uses feature detection, not user agent sniffing.
- — Thibaut @DevDocs
+ — @DevDocs
"""
diff --git a/assets/javascripts/templates/notif_tmpl.coffee b/assets/javascripts/templates/notif_tmpl.coffee
index 93611a5c..0821036e 100644
--- a/assets/javascripts/templates/notif_tmpl.coffee
+++ b/assets/javascripts/templates/notif_tmpl.coffee
@@ -68,3 +68,9 @@ app.templates.notifShare = ->
app.templates.notifUpdateDocs = ->
textNotif """ Documentation updates available. """,
""" Install them as soon as possible to avoid broken pages. """
+
+app.templates.notifAnalyticsConsent = ->
+ textNotif """ Tracking cookies """,
+ """ We would like to gather usage data about how DevDocs is used through Google Analytics and Gauges. We only collect anonymous traffic information.
+ Please confirm if you accept our tracking cookies. You can always change your decision in the settings.
+ Accept or Decline """
diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee
index 629682fb..e7b4cc80 100644
--- a/assets/javascripts/templates/pages/about_tmpl.coffee
+++ b/assets/javascripts/templates/pages/about_tmpl.coffee
@@ -11,22 +11,18 @@ app.templates.aboutPage = -> """
DevDocs: API Documentation Browser
-
DevDocs combines multiple API documentations in a clean and organized web UI with instant search, offline support, mobile version, dark theme, keyboard shortcuts, and more.
-
DevDocs combines multiple developer documentations in a clean and organized web UI with instant search, offline support, mobile version, dark theme, keyboard shortcuts, and more.
+
- Copyright 2013–2018 Thibaut Courouble and other contributors
+ Copyright 2013–2019 Thibaut Courouble and other contributors
This software is licensed under the terms of the Mozilla Public License v2.0.
You may obtain a copy of the source code at github.com/freeCodeCamp/devdocs.
For more information, see the COPYRIGHT
@@ -48,11 +44,10 @@ app.templates.aboutPage = -> """
Where can I suggest new docs and features?
You can suggest and vote for new docs on the Trello board.
If you have a specific feature request, add it to the issue tracker.
- Otherwise use the mailing list.
+ Otherwise, come talk to us in the Gitter chat room.
We do not collect personal information through the app.
+
We use Google Analytics and Gauges to collect anonymous traffic information if you have given consent to this. You can change your decision in the settings.
+
We use Sentry to collect crash data and improve the app.
The app uses cookies to store user preferences.
By using the app, you signify your acceptance of this policy. If you do not agree to this policy, please do not use the app.
-
If you have any questions regarding privacy, please email thibaut@devdocs.io.
+
Each page is cached as a key-value pair in IndexedDB (downloaded from a single file).
- The app also uses AppCache and localStorage to cache the assets and index files.
+
Each page is cached as a key-value pair in IndexedDB (downloaded from a single file).
+ The app also uses Service Workers and localStorage to cache the assets and index files.
Can I close the tab/browser?
#{canICloseTheTab()}
What if I don't update a documentation?
@@ -41,10 +41,15 @@ app.templates.offlinePage = (docs) -> """
"""
canICloseTheTab = ->
- if app.AppCache.isEnabled()
+ if app.ServiceWorker.isEnabled()
""" Yes! Even offline, you can open a new tab, go to devdocs.io, and everything will work as if you were online (provided you installed all the documentations you want to use beforehand). """
else
- """ No. AppCache isn't available in your browser (or is disabled), so loading devdocs.io offline won't work.
+ reason = "aren't available in your browser (or are disabled)"
+
+ if app.config.env != 'production'
+ reason = "are disabled in your development instance of DevDocs (enable them by setting the ENABLE_SERVICE_WORKER environment variable to true)"
+
+ """ No. Service Workers #{reason}, so loading devdocs.io offline won't work.
The current tab will continue to function even when you go offline (provided you installed all the documentations beforehand). """
app.templates.offlineDoc = (doc, status) ->
diff --git a/assets/javascripts/templates/pages/root_tmpl.coffee.erb b/assets/javascripts/templates/pages/root_tmpl.coffee.erb
index ef5ee8e6..714e0e20 100644
--- a/assets/javascripts/templates/pages/root_tmpl.coffee.erb
+++ b/assets/javascripts/templates/pages/root_tmpl.coffee.erb
@@ -8,13 +8,13 @@ app.templates.intro = """
Thanks for downloading DevDocs. Here are a few things you should know:
Your local version of DevDocs won't self-update. Unless you're modifying the code,
- I recommend using the hosted version at devdocs.io.
+ we recommend using the hosted version at devdocs.io.
Run thor docs:list to see all available documentations.
Run thor docs:download <name> to download documentations.
Run thor docs:download --installed to update all downloaded documentations.
To be notified about new versions, don't forget to watch the repository on GitHub.
The issue tracker is the preferred channel for bug reports and
- feature requests. For everything else, use the mailing list.
+ feature requests. For everything else, use Gitter.
DevDocs is licensed under the terms of the Mozilla Public License v2.0. For more information,
see the COPYRIGHT and
@@ -39,7 +39,7 @@ app.templates.intro = """
DevDocs works offline, on mobile, and can be installed on Chrome.
When using the HTTPS version, your preferences will carry over automatically, but your offline data will be reset. Simply re-download documentation in the Offline area, and you'll be all set to use DevDocs securely offline.
-
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.
-