diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..03c17bf8 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,11 @@ +root = true + +[*] +charset = utf-8 +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 72% rename from CONTRIBUTING.md rename to .github/CONTRIBUTING.md index fd4bd534..99fd8584 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/Thibaut/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/Thibaut/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. @@ -57,20 +55,12 @@ In addition to the [guidelines for contributing code](#contributing-code-and-fea * Remove as much content and HTML markup as possible, particularly content not associated with any entry (e.g. introduction, changelog, etc.). * Names must be as short as possible and unique across the documentation. * The number of types (categories) should ideally be less than 100. -* Don't modify the icon sprite. I'll do it after your pull request is merged. ## Updating existing documentations Please don't submit a pull request updating the version number of a documentation, unless a change is required in the scraper and you've verified that it works. -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). +To ask that an existing documentation be updated, first check the last two [documentation versions reports](https://github.com/freeCodeCamp/devdocs/issues?utf8=%E2%9C%93&q=Documentation+versions+report+is%3Aissue+author%3Adevdocs-bot+sort%3Acreated-desc). Only create an issue if the documentation has been wrongly marked as up-to-date. ## Coding conventions @@ -80,4 +70,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/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 00000000..0fb624d4 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,7 @@ + diff --git a/.github/no-response.yml b/.github/no-response.yml new file mode 100644 index 00000000..ab687134 --- /dev/null +++ b/.github/no-response.yml @@ -0,0 +1,8 @@ +daysUntilClose: 30 +responseRequiredLabel: needs-info +closeComment: > + This issue has been automatically closed because there has been no response + to our request for more information from the original author. With only the + information that’s currently in the issue, we don’t have enough information + to take action. Please comment if you have or find the answer we need so we + can investigate further. diff --git a/.gitignore b/.gitignore index 8b222826..f89ecb61 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,9 @@ .DS_Store .bundle -*.pxm -*.sketch +log tmp public/assets public/fonts public/docs/**/* -!public/docs/docs.json -!public/docs/**/index.json +docs/**/* +!docs/*.md diff --git a/.ruby-version b/.ruby-version index acdc3f1b..ec1cf33c 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.4.2 \ No newline at end of file +2.6.3 diff --git a/.slugignore b/.slugignore new file mode 100644 index 00000000..9daeafb9 --- /dev/null +++ b/.slugignore @@ -0,0 +1 @@ +test diff --git a/.travis.yml b/.travis.yml index f819a513..6c59f0be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1 +1,26 @@ language: ruby + +addons: + apt: + packages: + - libcurl4-openssl-dev + +cache: bundler + +before_install: + - "echo 'gem: --no-document' > ~/.gemrc" + - gem update --system + - gem install bundler + +script: + - if [ "$TRAVIS_EVENT_TYPE" != "cron" ]; then bundle exec rake; fi + - if [ "$TRAVIS_EVENT_TYPE" = "cron" ]; then bundle exec thor updates:check --github-token $GH_TOKEN --upload; fi + +deploy: + provider: heroku + app: devdocs + on: + branch: master + condition: $TRAVIS_EVENT_TYPE != cron + api_key: + secure: "4p1klvWJZSOImzFcKOduILjP93hlOlAhceWlYMKS4tU+TCFE8qTBzdKdFPSCsCgjB+YR9pBss+L0lJpVVMjSwFHXqpKe6EeUSltO2k7DFHfW7kXLUM/L0AfqXz+YXk76XUyZMhvOEbldPfaMaj10e8vgDOQCSHABDyK/4CU+hnI=" diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..26f8ab09 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,2 @@ + +> Our Code of Conduct is available here: diff --git a/COPYRIGHT b/COPYRIGHT index e194cf37..c71d2d7a 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -1,13 +1,13 @@ -Copyright 2013-2017 Thibaut Courouble and other contributors +Copyright 2013-2019 Thibaut Courouble and other contributors This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 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. +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 +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. \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index b064a215..b033427a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,12 @@ -FROM ruby:2.4.2 +FROM ruby:2.6.3 + +ENV LANG=C.UTF-8 +ENV ENABLE_SERVICE_WORKER=true WORKDIR /devdocs RUN apt-get update && \ - apt-get -y install git nodejs && \ + apt-get -y install git nodejs libcurl4 && \ gem install bundler && \ rm -rf /var/lib/apt/lists/* diff --git a/Dockerfile-alpine b/Dockerfile-alpine index e226842a..33a06b0e 100644 --- a/Dockerfile-alpine +++ b/Dockerfile-alpine @@ -1,10 +1,13 @@ -FROM ruby:2.4.2-alpine +FROM ruby:2.6.3-alpine + +ENV LANG=C.UTF-8 +ENV ENABLE_SERVICE_WORKER=true WORKDIR /devdocs COPY . /devdocs -RUN apk --update add nodejs build-base libstdc++ gzip git zlib-dev && \ +RUN apk --update add nodejs build-base libstdc++ gzip git zlib-dev libcurl && \ gem install bundler && \ bundle install --system --without test && \ thor docs:download --all && \ diff --git a/Gemfile b/Gemfile index b2305f81..3c9ce68b 100644 --- a/Gemfile +++ b/Gemfile @@ -1,16 +1,20 @@ source 'https://rubygems.org' -ruby '2.4.2' +ruby '2.6.3' gem 'rake' gem 'thor' -gem 'pry', '~> 0.11.0' -gem 'activesupport', '~> 5.1', require: false +gem 'pry', '~> 0.12.0' +gem 'activesupport', '~> 5.2', require: false gem 'yajl-ruby', require: false +gem 'html-pipeline' +gem 'typhoeus' +gem 'nokogiri' group :app do gem 'rack' gem 'sinatra' gem 'sinatra-contrib' + gem 'rack-ssl-enforcer' gem 'thin' gem 'sprockets' gem 'sprockets-helpers' @@ -18,10 +22,13 @@ group :app do gem 'browser' gem 'sass' gem 'coffee-script' + gem 'chunky_png' + gem 'sprockets-sass' end group :production do gem 'uglifier' + gem 'newrelic_rpm' end group :development do @@ -29,14 +36,13 @@ group :development do end group :docs do - gem 'typhoeus' - gem 'nokogiri' - gem 'html-pipeline' gem 'image_optim' gem 'image_optim_pack', platforms: :ruby gem 'progress_bar', require: false gem 'unix_utils', require: false gem 'tty-pager', require: false + gem 'net-sftp', '>= 2.1.3.rc2', require: false + gem 'terminal-table', require: false end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index ec112f54..d1abb66b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,139 +1,156 @@ GEM remote: https://rubygems.org/ specs: - activesupport (5.1.4) + activesupport (5.2.3) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (~> 0.7) + i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) - backports (3.9.1) - better_errors (2.3.0) + backports (3.15.0) + better_errors (2.5.1) coderay (>= 1.0.0) erubi (>= 1.0.0) rack (>= 0.9.0) - browser (2.5.1) + browser (2.6.1) + chunky_png (1.3.11) coderay (1.1.2) coffee-script (2.4.1) coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.0.5) - daemons (1.2.4) - erubi (1.6.1) - ethon (0.10.1) + concurrent-ruby (1.1.5) + daemons (1.3.1) + erubi (1.8.0) + ethon (0.12.0) ffi (>= 1.3.0) - eventmachine (1.2.5) + eventmachine (1.2.7) execjs (2.7.0) - exifr (1.3.2) - ffi (1.9.18) - fspath (3.1.0) - highline (1.7.8) - html-pipeline (2.7.1) + exifr (1.3.6) + ffi (1.11.1) + fspath (3.1.2) + highline (2.0.2) + html-pipeline (2.11.1) activesupport (>= 2) nokogiri (>= 1.4) - i18n (0.8.6) - image_optim (0.25.0) + i18n (1.6.0) + concurrent-ruby (~> 1.0) + image_optim (0.26.5) exifr (~> 1.2, >= 1.2.2) fspath (~> 3.0) - image_size (~> 1.5) + image_size (>= 1.5, < 3) in_threads (~> 1.3) progress (~> 3.0, >= 3.0.1) - image_optim_pack (0.5.0.20171001) + image_optim_pack (0.5.6) fspath (>= 2.1, < 4) image_optim (~> 0.19) - image_size (1.5.0) - in_threads (1.4.0) - method_source (0.9.0) - mini_portile2 (2.3.0) - minitest (5.10.3) - multi_json (1.12.2) - mustermann (1.0.1) - nokogiri (1.8.1) - mini_portile2 (~> 2.3.0) + image_size (2.0.2) + in_threads (1.5.3) + method_source (0.9.2) + mini_portile2 (2.4.0) + minitest (5.11.3) + multi_json (1.13.1) + mustermann (1.0.3) + net-sftp (3.0.0.beta1) + net-ssh (>= 5.0.0, < 6.0.0) + net-ssh (5.2.0) + newrelic_rpm (6.5.0.357) + nokogiri (1.10.3) + mini_portile2 (~> 2.4.0) options (2.3.2) - progress (3.3.1) - progress_bar (1.1.0) - highline (~> 1.6) + progress (3.5.2) + progress_bar (1.3.0) + highline (>= 1.6, < 3) options (~> 2.3.0) - pry (0.11.1) + pry (0.12.2) coderay (~> 1.1.0) method_source (~> 0.9.0) - rack (2.0.3) - rack-protection (2.0.0) + rack (2.0.7) + rack-protection (2.0.5) rack - rack-test (0.7.0) + rack-ssl-enforcer (0.2.9) + rack-test (1.1.0) rack (>= 1.0, < 3) - rake (12.1.0) - rb-fsevent (0.10.2) - rb-inotify (0.9.10) - ffi (>= 0.5.0, < 2) + rake (12.3.2) + rb-fsevent (0.10.3) + rb-inotify (0.10.0) + ffi (~> 1.0) rr (1.2.1) - sass (3.5.2) + sass (3.7.4) sass-listen (~> 4.0.0) sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) - sinatra (2.0.0) + sinatra (2.0.5) mustermann (~> 1.0) rack (~> 2.0) - rack-protection (= 2.0.0) + rack-protection (= 2.0.5) tilt (~> 2.0) - sinatra-contrib (2.0.0) - backports (>= 2.0) + sinatra-contrib (2.0.5) + backports (>= 2.8.2) multi_json mustermann (~> 1.0) - rack-protection (= 2.0.0) - sinatra (= 2.0.0) + rack-protection (= 2.0.5) + sinatra (= 2.0.5) tilt (>= 1.3, < 3) - sprockets (3.7.1) + sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-helpers (1.2.1) sprockets (>= 2.2) + sprockets-sass (2.0.0.beta2) + sprockets (>= 2.0, < 4.0) + strings (0.1.5) + strings-ansi (~> 0.1) + unicode-display_width (~> 1.5) + unicode_utils (~> 1.4) + strings-ansi (0.1.0) + terminal-table (1.8.0) + unicode-display_width (~> 1.1, >= 1.1.1) thin (1.7.2) daemons (~> 1.0, >= 1.0.9) eventmachine (~> 1.0, >= 1.0.4) rack (>= 1, < 3) - thor (0.20.0) + thor (0.20.3) thread_safe (0.3.6) - tilt (2.0.8) - tty-pager (0.9.0) - tty-screen (~> 0.5.0) - tty-which (~> 0.3.0) - verse (~> 0.5.0) - tty-screen (0.5.0) - tty-which (0.3.0) - typhoeus (1.3.0) + tilt (2.0.9) + tty-pager (0.12.1) + strings (~> 0.1.4) + tty-screen (~> 0.6) + tty-which (~> 0.4) + tty-screen (0.7.0) + tty-which (0.4.1) + typhoeus (1.3.1) ethon (>= 0.9.0) - tzinfo (1.2.3) + tzinfo (1.2.5) thread_safe (~> 0.1) - uglifier (3.2.0) + uglifier (4.1.20) execjs (>= 0.3.0, < 3) - unicode-display_width (1.1.3) + unicode-display_width (1.6.0) unicode_utils (1.4.0) unix_utils (0.0.15) - verse (0.5.0) - unicode-display_width (~> 1.1.0) - unicode_utils (~> 1.4.0) - yajl-ruby (1.3.0) + yajl-ruby (1.4.1) PLATFORMS ruby DEPENDENCIES - activesupport (~> 5.1) + activesupport (~> 5.2) better_errors browser + chunky_png coffee-script erubi html-pipeline image_optim image_optim_pack minitest + net-sftp (>= 2.1.3.rc2) + newrelic_rpm nokogiri progress_bar - pry (~> 0.11.0) + pry (~> 0.12.0) rack + rack-ssl-enforcer rack-test rake rr @@ -142,6 +159,8 @@ DEPENDENCIES sinatra-contrib sprockets sprockets-helpers + sprockets-sass + terminal-table thin thor tty-pager @@ -151,7 +170,7 @@ DEPENDENCIES yajl-ruby RUBY VERSION - ruby 2.4.2p198 + ruby 2.6.3p62 BUNDLED WITH - 1.15.4 + 2.0.2 diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md deleted file mode 100644 index 90890e07..00000000 --- a/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..0df55970 --- /dev/null +++ b/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,11 @@ +If you’re adding a new scraper, please ensure that you have: + +- [ ] Tested the scraper on a local copy of DevDocs +- [ ] Ensured that the docs are styled similarly to other docs on DevDocs + +- [ ] 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/Procfile b/Procfile new file mode 100644 index 00000000..8c995585 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: bundle exec rackup config.ru -p $PORT diff --git a/README.md b/README.md index f6859b90..630142d4 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,27 @@ -# [DevDocs](http://devdocs.io) [![Build Status](https://travis-ci.org/Thibaut/devdocs.svg?branch=master)](https://travis-ci.org/Thibaut/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: -* Watch the repository on [GitHub](https://github.com/Thibaut/devdocs/subscription) +* 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) -DevDocs is free and open source. If you like it, please consider supporting my work on [Gratipay](https://gratipay.com/devdocs/). Thanks! - -**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](http://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.4.2, 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/Thibaut/devdocs.git && cd devdocs +git clone https://github.com/freeCodeCamp/devdocs.git && cd devdocs gem install bundler bundle install bundle exec thor docs:download --default @@ -34,13 +32,13 @@ Finally, point your browser at [localhost:9292](http://localhost:9292) (the firs The `thor docs:download` command is used to download pre-generated documentations from DevDocs's servers (e.g. `thor docs:download html css`). You can see the list of available documentations and versions by running `thor docs:list`. To update all downloaded documentations, run `thor docs:download --installed`. -**Note:** there is currently no update mechanism other than `git pull origin master` to update the code and `thor docs:download --installed` to download the latest version of the docs. To stay informed about new releases, be sure to [watch](https://github.com/Thibaut/devdocs/subscription) this repository. +**Note:** there is currently no update mechanism other than `git pull origin master` to update the code and `thor docs:download --installed` to download the latest version of the docs. To stay informed about new releases, be sure to [watch](https://github.com/freeCodeCamp/devdocs/subscription) this repository. Alternatively, DevDocs may be started as a Docker container: ``` # First, build the image -git clone https://github.com/Thibaut/devdocs.git && cd devdocs +git clone https://github.com/freeCodeCamp/devdocs.git && cd devdocs docker build -t thibaut/devdocs . # Finally, start a DevDocs container (access http://localhost:9292) @@ -61,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! @@ -89,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/Thibaut/devdocs/wiki). +More information about [scrapers](./docs/scraper-reference.md) and [filters](./docs/filter-reference.md) is available in the `docs` folder. ## Available Commands @@ -134,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/Thibaut/devdocs/blob/master/CONTRIBUTING.md). - -DevDocs's own documentation is available on the [wiki](https://github.com/Thibaut/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-2017 Thibaut Courouble and [other contributors](https://github.com/Thibaut/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/Thibaut/devdocs/blob/master/COPYRIGHT) and [LICENSE](https://github.com/Thibaut/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/.gitignore b/assets/images/.gitignore new file mode 100644 index 00000000..4a72ec74 --- /dev/null +++ b/assets/images/.gitignore @@ -0,0 +1 @@ +sprites/**/* diff --git a/assets/images/docs-1.png b/assets/images/docs-1.png deleted file mode 100644 index e1c9ce11..00000000 Binary files a/assets/images/docs-1.png and /dev/null differ diff --git a/assets/images/docs-1@2x.png b/assets/images/docs-1@2x.png deleted file mode 100644 index 33eeaa4f..00000000 Binary files a/assets/images/docs-1@2x.png and /dev/null differ diff --git a/assets/images/docs-2.png b/assets/images/docs-2.png deleted file mode 100644 index 0aa1a105..00000000 Binary files a/assets/images/docs-2.png and /dev/null differ diff --git a/assets/images/docs-2@2x.png b/assets/images/docs-2@2x.png deleted file mode 100644 index e6e018aa..00000000 Binary files a/assets/images/docs-2@2x.png and /dev/null differ diff --git a/assets/javascripts/app/app.coffee b/assets/javascripts/app/app.coffee index 979ea353..b55e552c 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 @@ -76,7 +78,7 @@ .install() @previousErrorHandler = onerror window.onerror = @onWindowError.bind(@) - CookieStore.onBlocked = @onCookieBlocked + CookiesStore.onBlocked = @onCookieBlocked return bootOne: -> @@ -138,7 +140,10 @@ @docs.sort() @initDoc(doc) @saveDocs() - _onSuccess() + if app.settings.get('autoInstall') + doc.install(_onSuccess, onError) + else + _onSuccess() return doc.load onSuccess, onError, writeCache: true @@ -147,7 +152,7 @@ saveDocs: -> @settings.setDocs(doc.slug for doc in @docs.all()) @db.migrate() - @appCache?.updateInBackground() + @serviceWorker?.updateInBackground() welcomeBack: -> visitCount = @settings.get('count') @@ -157,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 @@ -186,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' @@ -245,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' @@ -268,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..a822f7e2 100644 --- a/assets/javascripts/app/config.coffee.erb +++ b/assets/javascripts/app/config.coffee.erb @@ -13,3 +13,6 @@ app.config = version: <%= Time.now.to_i %> release: <%= Time.now.utc.httpdate.to_json %> mathml_stylesheet: '<%= App.cdn_origin %>/mathml.css' + favicon_spritesheet: '<%= image_path('sprites/docs.png') %>' + 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 8d309c41..350a08c0 100644 --- a/assets/javascripts/app/settings.coffee +++ b/assets/javascripts/app/settings.coffee @@ -5,11 +5,13 @@ class app.Settings 'manualUpdate' 'fastScroll' 'arrowScroll' + 'analyticsConsent' 'docs' 'dark' 'layout' 'size' 'tips' + 'autoInstall' ] INTERNAL_KEYS = [ @@ -19,6 +21,8 @@ class app.Settings 'news' ] + LAYOUTS: ['_max-width', '_sidebar-hidden', '_native-scrollbars'] + @defaults: count: 0 hideDisabled: false @@ -26,9 +30,10 @@ class app.Settings news: 0 manualUpdate: false schema: 1 + analyticsConsent: false constructor: -> - @store = new CookieStore + @store = new CookiesStore @cache = {} get: (key) -> @@ -38,6 +43,7 @@ class app.Settings set: (key, value) -> @store.set(key, value) delete @cache[key] + @toggleDark(value) if key == 'dark' return del: (key) -> @@ -63,6 +69,8 @@ class app.Settings return setLayout: (name, enable) -> + @toggleLayout(name, enable) + layout = (@store.get('layout') || '').split(' ') $.arrayDelete(layout, '') @@ -104,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/shortcuts.coffee b/assets/javascripts/app/shortcuts.coffee index 5bc24806..5755a71d 100644 --- a/assets/javascripts/app/shortcuts.coffee +++ b/assets/javascripts/app/shortcuts.coffee @@ -149,6 +149,9 @@ class app.Shortcuts when 40 @trigger 'altDown' false + when 68 + @trigger 'altD' + false when 70 @trigger 'altF', event when 71 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/cookie_store.coffee b/assets/javascripts/lib/cookies_store.coffee similarity index 76% rename from assets/javascripts/lib/cookie_store.coffee rename to assets/javascripts/lib/cookies_store.coffee index 3b340571..eaf1bd4f 100644 --- a/assets/javascripts/lib/cookie_store.coffee +++ b/assets/javascripts/lib/cookies_store.coffee @@ -1,4 +1,8 @@ -class @CookieStore +class @CookiesStore + # Intentionally called CookiesStore instead of CookieStore + # Calling it CookieStore causes issues when the Experimental Web Platform features flag is enabled in Chrome + # Related issue: https://github.com/freeCodeCamp/devdocs/issues/932 + INT = /^\d+$/ @onBlocked: -> diff --git a/assets/javascripts/lib/favicon.coffee b/assets/javascripts/lib/favicon.coffee new file mode 100644 index 00000000..2f2d9f93 --- /dev/null +++ b/assets/javascripts/lib/favicon.coffee @@ -0,0 +1,64 @@ +defaultUrl = null +currentSlug = null + +imageCache = {} +urlCache = {} + +withImage = (url, action) -> + if imageCache[url] + action(imageCache[url]) + else + img = new Image() + img.crossOrigin = 'anonymous' + img.src = url + img.onload = () => + imageCache[url] = img + action(img) + +@setFaviconForDoc = (doc) -> + return if currentSlug == doc.slug + + favicon = $('link[rel="icon"]') + + if defaultUrl == null + defaultUrl = favicon.href + + if urlCache[doc.slug] + favicon.href = urlCache[doc.slug] + currentSlug = doc.slug + return + + styles = window.getComputedStyle($("._icon-#{doc.slug.split('~')[0]}"), ':before') + + bgUrl = app.config.favicon_spritesheet + sourceSize = 16 + sourceX = Math.abs(parseInt(styles['background-position-x'].slice(0, -2))) + sourceY = Math.abs(parseInt(styles['background-position-y'].slice(0, -2))) + + withImage(bgUrl, (docImg) -> + withImage(defaultUrl, (defaultImg) -> + size = defaultImg.width + + canvas = document.createElement('canvas') + ctx = canvas.getContext('2d') + + canvas.width = size + canvas.height = size + ctx.drawImage(defaultImg, 0, 0) + + docIconPercentage = 65 + destinationCoords = size / 100 * (100 - docIconPercentage) + destinationSize = size / 100 * docIconPercentage + ctx.drawImage(docImg, sourceX, sourceY, sourceSize, sourceSize, destinationCoords, destinationCoords, destinationSize, destinationSize) + + urlCache[doc.slug] = canvas.toDataURL() + favicon.href = urlCache[doc.slug] + + currentSlug = doc.slug + ) + ) + +@resetFavicon = () -> + if defaultUrl != null and currentSlug != null + $('link[rel="icon"]').href = defaultUrl + currentSlug = null diff --git a/assets/javascripts/lib/license.coffee b/assets/javascripts/lib/license.coffee index 484d865c..7f7ca938 100644 --- a/assets/javascripts/lib/license.coffee +++ b/assets/javascripts/lib/license.coffee @@ -1,5 +1,5 @@ ### - * Copyright 2013-2017 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 59e2a1a1..001b13de 100644 --- a/assets/javascripts/lib/util.coffee +++ b/assets/javascripts/lib/util.coffee @@ -124,7 +124,7 @@ $.empty = (el) -> return # Calls the function while the element is off the DOM to avoid triggering -# unecessary reflows and repaints. +# unnecessary reflows and repaints. $.batchUpdate = (el, fn) -> parent = el.parentNode sibling = el.nextSibling @@ -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/models/doc.coffee b/assets/javascripts/models/doc.coffee index 2d5f7e4a..c51e13fa 100644 --- a/assets/javascripts/models/doc.coffee +++ b/assets/javascripts/models/doc.coffee @@ -142,4 +142,6 @@ class app.models.Doc extends app.Model return isOutdated: (status) -> - status and status.installed and @mtime isnt status.mtime + return false if not status + isInstalled = status.installed or app.settings.get('autoInstall') + isInstalled and @mtime isnt status.mtime diff --git a/assets/javascripts/news.json b/assets/javascripts/news.json index e53b9f10..0266dea3 100644 --- a/assets/javascripts/news.json +++ b/assets/javascripts/news.json @@ -1,5 +1,37 @@ [ [ + "2019-07-21", + "Fixed several bugs, added an option to automatically download documentation and more." + ], + [ + "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" + ], [ + "2018-07-29", + "New documentations: Bash, Graphite and Pygame" + ], [ + "2018-07-08", + "New documentations: Leaflet, Terraform and Koa" + ], [ + "2018-03-26", + "DevDocs is joining the freeCodeCamp community. Read the announcement here." + ], [ + "2018-02-04", + "New documentations: Babel, Jekyll and JSDoc" + ], [ + "2017-11-26", + "New documentations: Bluebird, ESLint and Homebrew" + ], [ + "2017-11-18", + "Added print & PDF stylesheet.\nFeedback welcome on Twitter and GitHub." + ], [ "2017-09-10", "Preferences can now be exported and imported." ], [ @@ -110,7 +142,7 @@ "New documentations: Q and OpenTSDB" ], [ "2015-07-26", - "Added search aliases (e.g. $ is an alias for jQuery).\nClick here to see the full list. Feel free to suggest more on GitHub.", + "Added search aliases (e.g. $ is an alias for jQuery).\nClick here to see the full list. Feel free to suggest more on GitHub.", "Added shift + ↓/↑ shortcut for scrolling (same as alt + ↓/↑)." ], [ "2015-07-05", @@ -151,7 +183,7 @@ "New Python 2 documentation" ], [ "2014-11-09", - "New design\nFeedback welcome on Twitter and GitHub." + "New design\nFeedback welcome on Twitter and GitHub." ], [ "2014-10-19", "New SVG, Marionette.js, and Mongoose documentations" @@ -236,7 +268,7 @@ "New Ruby documentation" ], [ "2013-10-24", - "DevDocs is now open source." + "DevDocs is now open source." ], [ "2013-10-09", "DevDocs is now available as a Chrome web app." diff --git a/assets/javascripts/templates/error_tmpl.coffee b/assets/javascripts/templates/error_tmpl.coffee index 9dc311d9..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 """ @@ -37,10 +37,10 @@ app.templates.offlineError = (reason, exception) -> """ Your browser appears to be running in private mode.
This prevents DevDocs from caching documentations for offline access.""" when 'exception' - """ An error occured when trying to open the IndexedDB database:
+ """ An error occurred when trying to open the IndexedDB database:
#{exception.name}: #{exception.message} """ when 'cant_open' - """ An error occured when trying to open the IndexedDB database:
+ """ An error occurred when trying to open the IndexedDB database:
#{exception.name}: #{exception.message}
This could be because you're browsing in private mode or have disallowed offline storage on the domain. """ when 'version' @@ -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/notice_tmpl.coffee b/assets/javascripts/templates/notice_tmpl.coffee index 75818967..10cc534e 100644 --- a/assets/javascripts/templates/notice_tmpl.coffee +++ b/assets/javascripts/templates/notice_tmpl.coffee @@ -2,7 +2,7 @@ notice = (text) -> """

#{text}

""" app.templates.singleDocNotice = (doc) -> notice """ You're browsing the #{doc.fullName} documentation. To browse all docs, go to - #{app.config.production_host} (or press esc). """ + #{app.config.production_host} (or press esc). """ app.templates.disabledDocNotice = -> notice """ This documentation is disabled. diff --git a/assets/javascripts/templates/notif_tmpl.coffee b/assets/javascripts/templates/notif_tmpl.coffee index 0cd8531c..0821036e 100644 --- a/assets/javascripts/templates/notif_tmpl.coffee +++ b/assets/javascripts/templates/notif_tmpl.coffee @@ -13,10 +13,10 @@ app.templates.notifUpdateReady = -> """Reload the page to use the new version.""" app.templates.notifError = -> - textNotif """ Oops, an error occured. """, + textNotif """ Oops, an error occurred. """, """ Try reloading, and if the problem persists, resetting the app.
- You can also report this issue on GitHub. """ + You can also report this issue on GitHub. """ app.templates.notifQuotaExceeded = -> textNotif """ The offline database has exceeded its size limitation. """, @@ -31,7 +31,7 @@ app.templates.notifInvalidLocation = -> """ Otherwise things are likely to break. """ app.templates.notifImportInvalid = -> - textNotif """ Oops, an error occured. """, + textNotif """ Oops, an error occurred. """, """ The file you selected is invalid. """ app.templates.notifNews = (news) -> @@ -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 6b3ca71b..0981b9a3 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/assets/javascripts/templates/pages/about_tmpl.coffee @@ -11,28 +11,22 @@ 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. +

DevDocs is free and open source. It was created by Thibaut Courouble and is operated by freeCodeCamp.

To keep up-to-date with the latest news:

-

If you like DevDocs, please spread the word and consider supporting my work on - Gratipay. Thanks!

- Copyright 2013–2017 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/Thibaut/devdocs.
- For more information, see the COPYRIGHT - and LICENSE files. + You may obtain a copy of the source code at github.com/freeCodeCamp/devdocs.
+ For more information, see the COPYRIGHT + and LICENSE files.

Plugins and Extensions

    @@ -49,20 +43,19 @@ 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. + If you have a specific feature request, add it to the issue tracker.
    + Otherwise, come talk to us in the Gitter chat room.
    Where can I report bugs? -
    In the issue tracker. Thanks! +
    In the issue tracker. Thanks!
    -

    For anything else, feel free to email me at thibaut@devdocs.io.

    Credits

    Special thanks to:

    @@ -78,43 +71,59 @@ app.templates.aboutPage = -> """

    Privacy Policy

      -
    • devdocs.io ("App") is operated by Thibaut Courouble ("We"). -
    • We do not collect personal information. -
    • We use Google Analytics, Gauges and Sentry to collect anonymous traffic information and improve the app. +
    • devdocs.io ("App") is operated by freeCodeCamp ("We"). +
    • 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. +
    • If you have any questions regarding privacy, please email privacy@freecodecamp.org.
    """ credits = [ [ 'Angular
    Angular.js', - '2010-2017 Google, Inc.', + '2010-2018 Google, Inc.', 'CC BY', 'https://creativecommons.org/licenses/by/4.0/' ], [ 'Ansible', - '2012-2017 Michael DeHaan
    © 2017 Red Hat, Inc.', + '2012-2018 Michael DeHaan
    © 2018–2019 Red Hat, Inc.', 'GPLv3', 'https://raw.githubusercontent.com/ansible/ansible/devel/COPYING' ], [ 'Apache HTTP Server
    Apache Pig', - '2017 The Apache Software Foundation
    Apache and the Apache feather logo are trademarks of The Apache Software Foundation.', + '2018 The Apache Software Foundation
    Apache and the Apache feather logo are trademarks of The Apache Software Foundation.', 'Apache', 'https://www.apache.org/licenses/LICENSE-2.0' ], [ 'Async', - '2010-2017 Caolan McMahon', + '2010-2018 Caolan McMahon', 'MIT', 'https://raw.githubusercontent.com/caolan/async/master/LICENSE' + ], [ + 'Babel', + '2018 Sebastian McKenzie', + 'MIT', + 'https://raw.githubusercontent.com/babel/website/master/LICENSE' ], [ 'Backbone.js', '2010-2016 Jeremy Ashkenas, DocumentCloud', 'MIT', 'https://raw.githubusercontent.com/jashkenas/backbone/master/LICENSE' + ], [ + 'Bash', + '2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.', + 'GFDL', + 'https://www.gnu.org/licenses/fdl-1.3.en.html' + ], [ + 'Bluebird', + '2013-2017 Petka Antonov', + 'MIT', + 'https://raw.githubusercontent.com/petkaantonov/bluebird/master/LICENSE' ], [ 'Bootstrap', - '2011-2017 Twitter, Inc.
    2011-2017 The Bootstrap Authors', + '2011-2019 Twitter, Inc.
    2011-2019 The Bootstrap Authors', 'CC BY', 'https://creativecommons.org/licenses/by/3.0/' ], [ @@ -124,7 +133,7 @@ credits = [ 'https://raw.githubusercontent.com/bottlepy/bottle/master/LICENSE' ], [ 'Bower', - '2017 Bower contributors', + '2018 Bower contributors', 'MIT', 'https://github.com/bower/bower.github.io/blob/1057905c18d899106f91372e6cca7ef54a91d60f/package.json#L20' ], [ @@ -134,9 +143,9 @@ credits = [ 'http://en.cppreference.com/w/Cppreference:Copyright/CC-BY-SA' ], [ 'CakePHP', - '2005-2017 The Cake Software Foundation, Inc.', + '2005-2018 The Cake Software Foundation, Inc.', 'MIT', - 'https://raw.githubusercontent.com/cakephp/cakephp/master/LICENSE.txt' + 'https://raw.githubusercontent.com/cakephp/cakephp/master/LICENSE' ], [ 'Chai', '2016 Chai.js Assertion Library', @@ -154,12 +163,12 @@ credits = [ 'https://github.com/clojure/clojure/blob/master/epl-v10.html' ], [ 'CMake', - '2000-2017 Kitware, Inc. and Contributors', + '2000-2019 Kitware, Inc. and Contributors', 'BSD', 'https://cmake.org/licensing/' ], [ 'Codeception', - '2011-2017 Michael Bodnarchuk and contributors', + '2011 Michael Bodnarchuk and contributors', 'MIT', 'https://raw.githubusercontent.com/Codeception/Codeception/master/LICENSE' ], [ @@ -169,17 +178,17 @@ credits = [ 'https://raw.githubusercontent.com/Codeception/CodeceptJS/master/LICENSE' ], [ 'CodeIgniter', - '2014-2017 British Columbia Institute of Technology', + '2014-2018 British Columbia Institute of Technology', 'MIT', 'https://raw.githubusercontent.com/bcit-ci/CodeIgniter/develop/license.txt' ], [ 'CoffeeScript', - '2009-2017 Jeremy Ashkenas', + '2009-2018 Jeremy Ashkenas', 'MIT', - 'https://raw.githubusercontent.com/jashkenas/coffee-script/master/LICENSE' + 'https://raw.githubusercontent.com/jashkenas/coffeescript/master/LICENSE' ], [ 'Cordova', - '2012-2017 The Apache Software Foundation', + '2012-2018 The Apache Software Foundation', 'Apache', 'https://raw.githubusercontent.com/apache/cordova-docs/master/LICENSE' ], [ @@ -194,14 +203,19 @@ credits = [ 'https://raw.githubusercontent.com/crystal-lang/crystal/master/LICENSE' ], [ 'D', - '1999-2017 The D Language Foundation', + '1999-2018 The D Language Foundation', 'Boost', 'https://raw.githubusercontent.com/dlang/phobos/master/LICENSE_1_0.txt' ], [ 'D3.js', - '2010-2017 Michael Bostock', + '2010-2018 Michael Bostock', 'BSD', 'https://raw.githubusercontent.com/d3/d3/master/LICENSE' + ], [ + 'Dart', + '2012 the Dart project authors', + 'CC BY-SA', + 'https://creativecommons.org/licenses/by-sa/4.0/' ], [ 'Django', 'Django Software Foundation and individual contributors', @@ -209,7 +223,7 @@ credits = [ 'https://raw.githubusercontent.com/django/django/master/LICENSE' ], [ 'Docker', - '2017 Docker, Inc.
    Docker and the Docker logo are trademarks of Docker, Inc.', + '2019 Docker, Inc.
    Docker and the Docker logo are trademarks of Docker, Inc.', 'Apache', 'https://raw.githubusercontent.com/docker/docker.github.io/master/LICENSE' ], [ @@ -224,12 +238,12 @@ credits = [ 'https://api.drupal.org/api/drupal/LICENSE.txt' ], [ 'Electron', - '2013-2017 GitHub Inc.', + '2013-2018 GitHub Inc.', 'MIT', 'https://raw.githubusercontent.com/electron/electron/master/LICENSE' ], [ 'Elixir', - '2012-2017 Plataformatec', + '2012 Plataformatec', 'Apache', 'https://raw.githubusercontent.com/elixir-lang/elixir/master/LICENSE' ], [ @@ -242,6 +256,11 @@ credits = [ '2010-2017 Ericsson AB', 'Apache', 'https://raw.githubusercontent.com/erlang/otp/maint/LICENSE.txt' + ], [ + 'ESLint', + 'JS Foundation and other contributors', + 'MIT', + 'https://raw.githubusercontent.com/eslint/eslint/master/LICENSE' ], [ 'Express', '2017 StrongLoop, IBM, and other expressjs.com contributors.', @@ -264,7 +283,7 @@ credits = [ 'https://www.gnu.org/licenses/fdl-1.3.en.html' ], [ 'Git', - '2005-2017 Linus Torvalds and others', + '2005-2018 Linus Torvalds and others', 'GPLv2', 'https://raw.githubusercontent.com/git/git/master/COPYING' ], [ @@ -274,14 +293,24 @@ credits = [ 'https://creativecommons.org/licenses/by/3.0/' ], [ 'Godot', - '2014-2017 Juan Linietsky, Ariel Manzur, Godot Engine contributors', + '2014-2018 Juan Linietsky, Ariel Manzur, Godot Engine contributors', 'MIT', 'https://raw.githubusercontent.com/godotengine/godot/master/LICENSE.txt' + ], [ + 'Graphite', + '2008-2012 Chris Davis
    © 2011-2016 The Graphite Project', + 'Apache', + 'https://raw.githubusercontent.com/graphite-project/graphite-web/master/LICENSE' ], [ 'Grunt', 'GruntJS Team', 'MIT', 'https://github.com/gruntjs/grunt-docs/blob/master/package.json#L10' + ], [ + 'Handlebars', + '2011-2017 Yehuda Katz', + 'MIT', + 'https://raw.githubusercontent.com/wycats/handlebars.js/master/LICENSE' ], [ 'Haskell', 'The University of Glasgow', @@ -289,9 +318,14 @@ credits = [ 'https://www.haskell.org/ghc/license' ], [ 'Haxe', - '2005-2016 Haxe Foundation', + '2005-2018 Haxe Foundation', 'MIT', - 'http://haxe.org/foundation/open-source.html' + 'https://haxe.org/foundation/open-source.html' + ], [ + 'Homebrew', + '2009-present Homebrew contributors', + 'BSD', + 'https://raw.githubusercontent.com/Homebrew/brew/master/LICENSE.txt' ], [ 'Immutable.js', '2014-2016 Facebook, Inc.', @@ -307,6 +341,11 @@ credits = [ '2008-2017 Pivotal Labs', 'MIT', 'https://raw.githubusercontent.com/jasmine/jasmine/master/MIT.LICENSE' + ], [ + 'Jekyll', + '2008-2018 Tom Preston-Werner and Jekyll contributors', + 'MIT', + 'https://raw.githubusercontent.com/jekyll/jekyll/master/LICENSE' ], [ 'Jest', '2014-present Facebook Inc.', @@ -329,17 +368,27 @@ credits = [ 'https://raw.githubusercontent.com/jquery/api.jqueryui.com/master/LICENSE.txt' ], [ 'Julia', - '2009-2016 Jeff Bezanson, Stefan Karpinski, Viral B. Shah, and other contributors', + '2009-2018 Jeff Bezanson, Stefan Karpinski, Viral B. Shah, and other contributors', 'MIT', 'https://raw.githubusercontent.com/JuliaLang/julia/master/LICENSE.md' + ], [ + 'JSDoc', + '2011-2017 the contributors to the JSDoc 3 documentation project', + 'CC BY-SA', + 'https://raw.githubusercontent.com/jsdoc3/jsdoc3.github.com/master/LICENSE' ], [ 'Knockout.js', 'Steven Sanderson, the Knockout.js team, and other contributors', 'MIT', 'https://raw.githubusercontent.com/knockout/knockout/master/LICENSE' + ], [ + 'Koa', + '2018 Koa contributors', + 'MIT', + 'https://raw.githubusercontent.com/koajs/koa/master/LICENSE' ], [ 'Kotlin', - '2010-2017 JetBrains s.r.o.', + '2010-2019 JetBrains s.r.o.', 'Apache', 'https://raw.githubusercontent.com/JetBrains/kotlin/master/license/LICENSE.txt' ], [ @@ -347,6 +396,11 @@ credits = [ 'Taylor Otwell', 'MIT', 'https://raw.githubusercontent.com/laravel/framework/master/LICENSE.txt' + ], [ + 'Leaflet', + '2010-2019 Vladimir Agafonkin
    © 2010-2011, CloudMade
    Maps © OpenStreetMap contributors.', + 'BSD', + 'https://raw.githubusercontent.com/Leaflet/Leaflet/master/LICENSE' ], [ 'Less', '2009-2016 The Core Less Team', @@ -359,9 +413,9 @@ credits = [ 'https://raw.githubusercontent.com/Shopify/liquid/master/LICENSE' ], [ 'Lo-Dash', - '2012-2016 The Dojo Foundation', + 'JS Foundation and other contributors', 'MIT', - 'https://raw.githubusercontent.com/lodash/lodash/master/LICENSE.txt' + 'https://raw.githubusercontent.com/lodash/lodash/master/LICENSE' ], [ 'Lua', '1994–2017 Lua.org, PUC-Rio', @@ -384,7 +438,7 @@ credits = [ 'https://daringfireball.net/projects/markdown/license' ], [ 'Matplotlib', - '2012-2017 Matplotlib Development Team. All rights reserved.', + '2012-2018 Matplotlib Development Team. All rights reserved.', 'Custom', 'https://raw.githubusercontent.com/matplotlib/matplotlib/master/LICENSE/LICENSE' ], [ @@ -399,7 +453,7 @@ credits = [ 'https://github.com/seattlerb/minitest/blob/master/README.rdoc#license' ], [ 'Mocha', - '2016 JS Foundation and contributors', + '2011-2018 JS Foundation and contributors', 'CC BY', 'https://creativecommons.org/licenses/by/4.0/' ], [ @@ -419,12 +473,12 @@ credits = [ 'https://github.com/LearnBoost/mongoose/blob/master/README.md#license' ], [ 'nginx', - '2002-2017 Igor Sysoev
    © 2011-2017 Nginx, Inc.', + '2002-2019 Igor Sysoev
    © 2011-2019 Nginx, Inc.', 'BSD', 'http://nginx.org/LICENSE' ], [ 'nginx / Lua Module', - '2009-2016 Xiaozhe Wang (chaoslawful)
    © 2009-2017 Yichun "agentzh" Zhang (章亦春), OpenResty Inc.', + '2009-2017 Xiaozhe Wang (chaoslawful)
    © 2009-2018 Yichun "agentzh" Zhang (章亦春), OpenResty Inc.', 'BSD', 'https://github.com/openresty/lua-nginx-module#copyright-and-license' ], [ @@ -464,7 +518,7 @@ credits = [ 'https://raw.githubusercontent.com/OpenTSDB/opentsdb.net/gh-pages/COPYING.LESSER' ], [ 'Padrino', - '2010-2016 Padrino', + '2010-2019 Padrino', 'MIT', 'https://raw.githubusercontent.com/padrino/padrino-framework/master/padrino/LICENSE.txt' ], [ @@ -494,7 +548,7 @@ credits = [ 'https://raw.githubusercontent.com/phoenixframework/phoenix/master/LICENSE.md' ], [ 'PHP', - '1997-2017 The PHP Documentation Group', + '1997-2018 The PHP Documentation Group', 'CC BY', 'https://secure.php.net/manual/en/copyright.php' ], [ @@ -504,12 +558,22 @@ credits = [ 'https://creativecommons.org/licenses/by/3.0/' ], [ 'PostgreSQL', - '1996-2017 The PostgreSQL Global Development Group
    © 1994 The Regents of the University of California', + '1996-2018 The PostgreSQL Global Development Group
    © 1994 The Regents of the University of California', 'PostgreSQL', 'https://www.postgresql.org/about/licence/' + ], [ + 'Puppeteer', + '2017 Google Inc', + 'Apache', + 'https://raw.githubusercontent.com/GoogleChrome/puppeteer/master/LICENSE' + ], [ + 'Pygame', + 'Pygame Developers', + 'LGPLv2.1', + 'https://raw.githubusercontent.com/pygame/pygame/master/LICENSE' ], [ 'Python', - '2001-2017 Python Software Foundation
    Python is a trademark of the Python Software Foundation.', + '2001-2018 Python Software Foundation
    Python is a trademark of the Python Software Foundation.', 'PSFL', 'https://docs.python.org/3/license.html' ], [ @@ -517,6 +581,11 @@ credits = [ '2009-2017 Kristopher Michael Kowal', 'MIT', 'https://raw.githubusercontent.com/kriskowal/q/master/LICENSE' + ], [ + 'Qt', + '2012-2018 The Qt Company Ltd', + 'GFDL', + 'https://doc.qt.io/qt-5/licensing.html' ], [ 'Ramda', '2013-2016 Scott Sauyet and Michael Hurley', @@ -524,12 +593,12 @@ credits = [ 'https://raw.githubusercontent.com/ramda/ramda/master/LICENSE.txt' ], [ 'React, React Native, Flow, Relay', - '2013-2017 Facebook Inc.', - 'CC BY', - 'https://raw.githubusercontent.com/facebook/react/master/LICENSE-docs' + '2013-present Facebook Inc.', + 'MIT', + 'https://raw.githubusercontent.com/facebook/react/master/LICENSE' ], [ 'Redis', - '2009-2017 Salvatore Sanfilippo', + '2009-2018 Salvatore Sanfilippo', 'CC BY-SA', 'https://creativecommons.org/licenses/by-sa/4.0/' ], [ @@ -574,12 +643,12 @@ credits = [ 'http://scikit-image.org/docs/dev/license.html' ], [ 'scikit-learn', - '2007-2017 The scikit-learn developers', + '2007-2018 The scikit-learn developers', 'BSD', 'https://raw.githubusercontent.com/scikit-learn/scikit-learn/master/COPYING' ], [ 'Sinon', - '2010-2017 Christian Johansen', + '2010-2018 Christian Johansen', 'BSD', 'https://raw.githubusercontent.com/sinonjs/sinon/master/LICENSE' ], [ @@ -609,14 +678,19 @@ credits = [ 'http://tcl.tk/software/tcltk/license.html' ], [ 'TensorFlow', - '2017 The TensorFlow Authors', + '2018 The TensorFlow Authors', 'CC BY', 'https://creativecommons.org/licenses/by/3.0/' + ], [ + 'Terraform', + '2018 HashiCorp', + 'MPL', + 'https://raw.githubusercontent.com/hashicorp/terraform-website/master/LICENSE.md' ], [ 'Twig', - '2009-2017 The Twig Team', + '2009-2018 The Twig Team', 'BSD', - 'https://twig.sensiolabs.org/license' + 'https://twig.symfony.com/license' ], [ 'TypeScript', 'Microsoft and other contributors', @@ -624,17 +698,17 @@ credits = [ 'https://raw.githubusercontent.com/Microsoft/TypeScript-Handbook/master/LICENSE' ], [ 'Underscore.js', - '2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors', + '2009-2018 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors', 'MIT', 'https://raw.githubusercontent.com/jashkenas/underscore/master/LICENSE' ], [ 'Vagrant', - '2010-2017 Mitchell Hashimoto', + '2010-2018 Mitchell Hashimoto', 'MPL', 'https://raw.githubusercontent.com/mitchellh/vagrant/master/website/LICENSE.md' ], [ 'Vue.js', - '2013-2017 Evan You, Vue.js contributors', + '2013-2018 Evan You, Vue.js contributors', 'MIT', 'https://raw.githubusercontent.com/vuejs/vue/master/LICENSE' ], [ @@ -649,7 +723,7 @@ credits = [ 'https://creativecommons.org/licenses/by/4.0/' ], [ 'Yarn', - '2016-2017 Yarn Contributors', + '2016-present Yarn Contributors', 'BSD', 'https://raw.githubusercontent.com/yarnpkg/yarn/master/LICENSE' ], [ diff --git a/assets/javascripts/templates/pages/help_tmpl.coffee b/assets/javascripts/templates/pages/help_tmpl.coffee index 3f09a9ce..9fb4ed48 100644 --- a/assets/javascripts/templates/pages/help_tmpl.coffee +++ b/assets/javascripts/templates/pages/help_tmpl.coffee @@ -20,7 +20,7 @@ app.templates.helpPage = ->
-

User Guide

+

User Guide

Managing Documentations

@@ -57,9 +57,7 @@ app.templates.helpPage = ->

  • On Chrome, the setup is done automatically. Simply press tab when devdocs.io is autocompleted in the omnibox (to set a custom keyword, click Manage search engines\u2026 in Chrome's settings). -
  • On Firefox, open the search engine list (icon in the search bar) and click Add "DevDocs Search". - DevDocs is now available in the search bar. You can also search from the location bar by following - these instructions. +
  • On Firefox, right-click the DevDocs search field and select Add a Keyword for this Search…. Then, type the added keyword followed by a query in the address bar to search DevDocs.

    Note: the above search features only work for documentations that are enabled. @@ -133,6 +131,9 @@ app.templates.helpPage = ->

    alt + s
    Search on Stack Overflow +
    + alt + d +
    Search on DuckDuckGo

    Tip: If the cursor is no longer in the search field, press / or @@ -153,5 +154,5 @@ app.templates.helpPage = -> #{("#{key}#{value}" for key, value of aliases_two).join('')} -

    Feel free to suggest new aliases on GitHub. +

    Feel free to suggest new aliases on GitHub. """ diff --git a/assets/javascripts/templates/pages/news_tmpl.coffee.erb b/assets/javascripts/templates/pages/news_tmpl.coffee.erb index f4045bd7..f6760a61 100644 --- a/assets/javascripts/templates/pages/news_tmpl.coffee.erb +++ b/assets/javascripts/templates/pages/news_tmpl.coffee.erb @@ -4,7 +4,7 @@ app.templates.newsPage = -> """

    Changelog

    For the latest news, follow @DevDocs.
    - For development updates, follow the project on GitHub. + For development updates, follow the project on GitHub.

    #{app.templates.newsList app.news}
    """ app.templates.newsList = (news, options = {}) -> diff --git a/assets/javascripts/templates/pages/offline_tmpl.coffee b/assets/javascripts/templates/pages/offline_tmpl.coffee index fe42f19d..bb9e06e8 100644 --- a/assets/javascripts/templates/pages/offline_tmpl.coffee +++ b/assets/javascripts/templates/pages/offline_tmpl.coffee @@ -25,14 +25,14 @@ app.templates.offlinePage = (docs) -> """

    Questions & Answers

    How does this work? -
    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?
    You'll see outdated content and some pages will be missing or broken, because the rest of the app (including data for the search and sidebar) uses a different caching mechanism that's updated automatically.
    I found a bug, where do I report it? -
    In the issue tracker. Thanks! +
    In the issue tracker. Thanks!
    How do I uninstall/reset the app?
    Click here.
    Why aren't all documentations listed above? @@ -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 bfb3f3d6..714e0e20 100644 --- a/assets/javascripts/templates/pages/root_tmpl.coffee.erb +++ b/assets/javascripts/templates/pages/root_tmpl.coffee.erb @@ -8,18 +8,17 @@ app.templates.intro = """

    Thanks for downloading DevDocs. Here are a few things you should know:

    1. 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.
    2. Run thor docs:list to see all available documentations.
    3. Run thor docs:download <name> to download documentations.
    4. Run thor docs:download --installed to update all downloaded documentations. -
    5. To be notified about new versions, don't forget to watch the repository on GitHub. -
    6. The issue tracker is the preferred channel for bug reports and - feature requests. For everything else, use the mailing list. -
    7. Contributions are welcome. See the guidelines. +
    8. To be notified about new versions, don't forget to watch the repository on GitHub. +
    9. The issue tracker is the preferred channel for bug reports and + feature requests. For everything else, use Gitter. +
    10. Contributions are welcome. See the guidelines.
    11. DevDocs is licensed under the terms of the Mozilla Public License v2.0. For more information, - see the COPYRIGHT and - LICENSE files. -
    12. If you like the app, please consider supporting the project on Gratipay. Thanks! + see the COPYRIGHT and + LICENSE files.

    Happy coding! @@ -39,9 +38,8 @@ app.templates.intro = """

  • You can search using your browser's address bar — learn how.
  • DevDocs works offline, on mobile, and can be installed on Chrome.
  • For the latest news, follow @DevDocs. -
  • DevDocs is free and open source. - -
  • If you like the app, please consider supporting the project on Gratipay. Thanks! +
  • DevDocs is free and open source. +
  • And if you're new to coding, check out freeCodeCamp's open source curriculum.

    Happy coding! @@ -59,7 +57,7 @@ app.templates.mobileIntro = """

  • The search supports fuzzy matching.
  • To search a specific documentation, type its name (or an abbr.), then Space.
  • For the latest news, follow @DevDocs. -
  • DevDocs is open source. +
  • DevDocs is open source.

    Happy coding! Stop showing this message @@ -71,6 +69,6 @@ app.templates.androidWarning = """

    Hi there

    DevDocs is running inside an Android WebView. Some features may not work properly.

    If you downloaded an app called DevDocs on the Play Store, please uninstall it — it's made by someone who is using (and profiting from) the name DevDocs without permission. -

    To install DevDocs on your phone, visit devdocs.io in Chrome and select "Add to home screen" in the menu. +

    To install DevDocs on your phone, visit devdocs.io in Chrome and select "Add to home screen" in the menu. """ diff --git a/assets/javascripts/templates/pages/settings_tmpl.coffee b/assets/javascripts/templates/pages/settings_tmpl.coffee index 1d439edb..94afe3df 100644 --- a/assets/javascripts/templates/pages/settings_tmpl.coffee +++ b/assets/javascripts/templates/pages/settings_tmpl.coffee @@ -15,6 +15,14 @@ app.templates.settingsPage = (settings) -> """ Automatically hide and show the sidebar Tip: drag the edge of the sidebar to resize it. + + diff --git a/assets/javascripts/tracking.js b/assets/javascripts/tracking.js index ca05b218..a68ca493 100644 --- a/assets/javascripts/tracking.js +++ b/assets/javascripts/tracking.js @@ -1,28 +1,32 @@ try { - if (app.config.env == 'production') { - (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ - (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), - m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) - })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); - ga('create', 'UA-5544833-12', 'devdocs.io'); - page.track(function() { - ga('send', 'pageview', { - page: location.pathname + location.search + location.hash, - dimension1: app.router.context && app.router.context.doc && app.router.context.doc.slug_without_version + if (app.config.env === 'production') { + if (Cookies.get('analyticsConsent') === '1') { + (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ + (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), + m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) + })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); + ga('create', 'UA-5544833-12', 'devdocs.io'); + page.track(function() { + ga('send', 'pageview', { + page: location.pathname + location.search + location.hash, + dimension1: app.router.context && app.router.context.doc && app.router.context.doc.slug_without_version + }); }); - }); - page.track(function() { - if (window._gauges) - _gauges.push(['track']); - else - (function() { - var _gauges=_gauges||[];!function(){var a=document.createElement("script"); - a.type="text/javascript",a.async=!0,a.id="gauges-tracker", - a.setAttribute("data-site-id","51c15f82613f5d7819000067"), - a.src="https://secure.gaug.es/track.js";var b=document.getElementsByTagName("script")[0]; - b.parentNode.insertBefore(a,b)}(); - })(); - }); + page.track(function() { + if (window._gauges) + _gauges.push(['track']); + else + (function() { + var _gauges=_gauges||[];!function(){var a=document.createElement("script"); + a.type="text/javascript",a.async=!0,a.id="gauges-tracker", + a.setAttribute("data-site-id","51c15f82613f5d7819000067"), + a.src="https://secure.gaug.es/track.js";var b=document.getElementsByTagName("script")[0]; + b.parentNode.insertBefore(a,b)}(); + })(); + }); + } else { + resetAnalytics(); + } } } catch(e) { } diff --git a/assets/javascripts/vendor/fastclick.js b/assets/javascripts/vendor/fastclick.js index 3af4f9d6..b6f7b40c 100755 --- a/assets/javascripts/vendor/fastclick.js +++ b/assets/javascripts/vendor/fastclick.js @@ -413,7 +413,7 @@ // when the user next taps anywhere else on the page, new touchstart and touchend events are dispatched // with the same identifier as the touch event that previously triggered the click that triggered the alert. // Sadly, there is an issue on iOS 4 that causes some normal touch events to have the same identifier as an - // immediately preceeding touch event (issue #52), so this fix is unavailable on that platform. + // immediately preceding touch event (issue #52), so this fix is unavailable on that platform. // Issue 120: touch.identifier is 0 when Chrome dev tools 'Emulate touch events' is set with an iOS device UA string, // which causes all touch events to be ignored. As this block only applies to iOS, and iOS identifiers are always long, // random integers, it's safe to to continue if the identifier is 0 here. @@ -805,7 +805,7 @@ } } - // IE11: prefixed -ms-touch-action is no longer supported and it's recomended to use non-prefixed version + // IE11: prefixed -ms-touch-action is no longer supported and it's recommended to use non-prefixed version // http://msdn.microsoft.com/en-us/library/windows/apps/Hh767313.aspx if (layer.style.touchAction === 'none' || layer.style.touchAction === 'manipulation') { return true; diff --git a/assets/javascripts/vendor/prism.js b/assets/javascripts/vendor/prism.js index a23384a3..09d6df87 100644 --- a/assets/javascripts/vendor/prism.js +++ b/assets/javascripts/vendor/prism.js @@ -1,4 +1,5 @@ -/* http://prismjs.com/download.html?themes=prism&languages=markup+css+clike+javascript+c+cpp+coffeescript+ruby+d+elixir+erlang+go+java+json+kotlin+lua+nginx+nim+perl+php+python+jsx+crystal+rust+scss+sql+typescript */ +/* PrismJS 1.15.0 +https://prismjs.com/download.html#themes=prism&languages=markup+css+clike+javascript+c+bash+cpp+coffeescript+ruby+d+dart+django+elixir+markup-templating+erlang+go+java+json+kotlin+lua+crystal+nginx+nim+perl+php+sql+scss+python+jsx+typescript+rust+yaml */ var _self = (typeof window !== 'undefined') ? window // if in browser : ( @@ -16,11 +17,12 @@ var _self = (typeof window !== 'undefined') var Prism = (function(){ // Private helper vars -var lang = /\blang(?:uage)?-(\w+)\b/i; +var lang = /\blang(?:uage)?-([\w-]+)\b/i; var uniqueId = 0; var _ = _self.Prism = { manual: _self.Prism && _self.Prism.manual, + disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler, util: { encode: function (tokens) { if (tokens instanceof Token) { @@ -44,23 +46,38 @@ var _ = _self.Prism = { }, // Deep clone a language definition (e.g. to extend it) - clone: function (o) { + clone: function (o, visited) { var type = _.util.type(o); + visited = visited || {}; switch (type) { case 'Object': + if (visited[_.util.objId(o)]) { + return visited[_.util.objId(o)]; + } var clone = {}; + visited[_.util.objId(o)] = clone; for (var key in o) { if (o.hasOwnProperty(key)) { - clone[key] = _.util.clone(o[key]); + clone[key] = _.util.clone(o[key], visited); } } return clone; case 'Array': - return o.map(function(v) { return _.util.clone(v); }); + if (visited[_.util.objId(o)]) { + return visited[_.util.objId(o)]; + } + var clone = []; + visited[_.util.objId(o)] = clone; + + o.forEach(function (v, i) { + clone[i] = _.util.clone(v, visited); + }); + + return clone; } return o; @@ -155,6 +172,10 @@ var _ = _self.Prism = { plugins: {}, highlightAll: function(async, callback) { + _.highlightAllUnder(document, async, callback); + }, + + highlightAllUnder: function(container, async, callback) { var env = { callback: callback, selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code' @@ -162,7 +183,7 @@ var _ = _self.Prism = { _.hooks.run("before-highlightall", env); - var elements = env.elements || document.querySelectorAll(env.selector); + var elements = env.elements || container.querySelectorAll(env.selector); for (var i=0, element; element = elements[i++];) { _.highlightElement(element, async === true, env.callback); @@ -185,11 +206,13 @@ var _ = _self.Prism = { // Set language on the element, if not present element.className = element.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language; - // Set language on the parent, for styling - parent = element.parentNode; + if (element.parentNode) { + // Set language on the parent, for styling + parent = element.parentNode; - if (/pre/i.test(parent.nodeName)) { - parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language; + if (/pre/i.test(parent.nodeName)) { + parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language; + } } var code = element.textContent; @@ -251,8 +274,15 @@ var _ = _self.Prism = { }, highlight: function (text, grammar, language) { - var tokens = _.tokenize(text, grammar); - return Token.stringify(_.util.encode(tokens), language); + var env = { + code: text, + grammar: grammar, + language: language + }; + _.hooks.run('before-tokenize', env); + env.tokens = _.tokenize(env.code, env.grammar); + _.hooks.run('after-tokenize', env); + return Token.stringify(_.util.encode(env.tokens), env.language); }, matchGrammar: function (text, strarr, grammar, index, startPos, oneshot, target) { @@ -300,15 +330,9 @@ var _ = _self.Prism = { continue; } - pattern.lastIndex = 0; - - var match = pattern.exec(str), - delNum = 1; - - // Greedy patterns can override/remove up to two previously matched tokens - if (!match && greedy && i != strarr.length - 1) { + if (greedy && i != strarr.length - 1) { pattern.lastIndex = pos; - match = pattern.exec(text); + var match = pattern.exec(text); if (!match) { break; } @@ -327,11 +351,8 @@ var _ = _self.Prism = { } } - /* - * If strarr[i] is a Token, then the match starts inside another Token, which is invalid - * If strarr[k - 1] is greedy we are in conflict with another greedy pattern - */ - if (strarr[i] instanceof Token || strarr[k - 1].greedy) { + // If strarr[i] is a Token, then the match starts inside another Token, which is invalid + if (strarr[i] instanceof Token) { continue; } @@ -339,6 +360,11 @@ var _ = _self.Prism = { delNum = k - i; str = text.slice(pos, p); match.index -= pos; + } else { + pattern.lastIndex = 0; + + var match = pattern.exec(str), + delNum = 1; } if (!match) { @@ -350,7 +376,7 @@ var _ = _self.Prism = { } if(lookbehind) { - lookbehindLength = match[1].length; + lookbehindLength = match[1] ? match[1].length : 0; } var from = match.index + lookbehindLength, @@ -460,10 +486,6 @@ Token.stringify = function(o, language, parent) { parent: parent }; - if (env.type == 'comment') { - env.attributes['spellcheck'] = 'true'; - } - if (o.alias) { var aliases = _.util.type(o.alias) === 'Array' ? o.alias : [o.alias]; Array.prototype.push.apply(env.classes, aliases); @@ -484,18 +506,21 @@ Token.stringify = function(o, language, parent) { // // in Node.js // return _self.Prism; // } -// // In worker -// _self.addEventListener('message', function(evt) { -// var message = JSON.parse(evt.data), -// lang = message.language, -// code = message.code, -// immediateClose = message.immediateClose; - -// _self.postMessage(_.highlight(code, _.languages[lang], lang)); -// if (immediateClose) { -// _self.close(); -// } -// }, false); + +// if (!_.disableWorkerMessageHandler) { +// // In worker +// _self.addEventListener('message', function (evt) { +// var message = JSON.parse(evt.data), +// lang = message.language, +// code = message.code, +// immediateClose = message.immediateClose; + +// _self.postMessage(_.highlight(code, _.languages[lang], lang)); +// if (immediateClose) { +// _self.close(); +// } +// }, false); +// } // return _self.Prism; // } @@ -539,7 +564,8 @@ Prism.languages.markup = { 'doctype': //i, 'cdata': //i, 'tag': { - pattern: /<\/?(?!\d)[^\s>\/=$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\s\S])*\1|[^\s'">=]+))?)*\s*\/?>/i, + pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+))?)*\s*\/?>/i, + greedy: true, inside: { 'tag': { pattern: /^<\/?[^\s>\/]+/i, @@ -549,9 +575,15 @@ Prism.languages.markup = { } }, 'attr-value': { - pattern: /=(?:('|")[\s\S]*?(\1)|[^\s>]+)/i, + pattern: /=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+)/i, inside: { - 'punctuation': /[=>"']/ + 'punctuation': [ + /^=/, + { + pattern: /(^|[^\\])["']/, + lookbehind: true + } + ] } }, 'punctuation': /\/?>/, @@ -586,25 +618,25 @@ Prism.languages.svg = Prism.languages.markup; Prism.languages.css = { 'comment': /\/\*[\s\S]*?\*\//, 'atrule': { - pattern: /@[\w-]+?.*?(;|(?=\s*\{))/i, + pattern: /@[\w-]+?.*?(?:;|(?=\s*\{))/i, inside: { 'rule': /@[\w-]+/ // See rest below } }, - 'url': /url\((?:(["'])(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1|.*?)\)/i, - 'selector': /[^\{\}\s][^\{\};]*?(?=\s*\{)/, + 'url': /url\((?:(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1|.*?)\)/i, + 'selector': /[^{}\s][^{};]*?(?=\s*\{)/, 'string': { - pattern: /("|')(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, + pattern: /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, greedy: true }, - 'property': /(\b|\B)[\w-]+(?=\s*:)/i, + 'property': /[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i, 'important': /\B!important\b/i, 'function': /[-a-z0-9]+(?=\()/i, 'punctuation': /[(){};:]/ }; -Prism.languages.css['atrule'].inside.rest = Prism.util.clone(Prism.languages.css); +Prism.languages.css['atrule'].inside.rest = Prism.languages.css; if (Prism.languages.markup) { Prism.languages.insertBefore('markup', 'tag', { @@ -612,13 +644,14 @@ if (Prism.languages.markup) { pattern: /()[\s\S]*?(?=<\/style>)/i, lookbehind: true, inside: Prism.languages.css, - alias: 'language-css' + alias: 'language-css', + greedy: true } }); Prism.languages.insertBefore('inside', 'attr-value', { 'style-attr': { - pattern: /\s*style=("|').*?\1/i, + pattern: /\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i, inside: { 'attr-name': { pattern: /^\s*style/i, @@ -642,63 +675,71 @@ Prism.languages.clike = { }, { pattern: /(^|[^\\:])\/\/.*/, - lookbehind: true + lookbehind: true, + greedy: true } ], 'string': { - pattern: /(["'])(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, + pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, greedy: true }, 'class-name': { - pattern: /((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i, + pattern: /((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[\w.\\]+/i, lookbehind: true, inside: { - punctuation: /(\.|\\)/ + punctuation: /[.\\]/ } }, - 'keyword': /\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/, - 'boolean': /\b(true|false)\b/, + 'keyword': /\b(?:if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/, + 'boolean': /\b(?:true|false)\b/, 'function': /[a-z0-9_]+(?=\()/i, - 'number': /\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i, + 'number': /\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i, 'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/, 'punctuation': /[{}[\];(),.:]/ }; Prism.languages.javascript = Prism.languages.extend('clike', { - 'keyword': /\b(as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield)\b/, - 'number': /\b-?(0[xX][\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/, + 'keyword': /\b(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield)\b/, + 'number': /\b(?:0[xX][\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+|NaN|Infinity)\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee][+-]?\d+)?/, // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444) - 'function': /[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*(?=\()/i, + 'function': /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*\()/i, 'operator': /-[-=]?|\+[+=]?|!=?=?|<>?>?=?|=(?:==?|>)?|&[&=]?|\|[|=]?|\*\*?=?|\/=?|~|\^=?|%=?|\?|\.{3}/ }); Prism.languages.insertBefore('javascript', 'keyword', { 'regex': { - pattern: /(^|[^/])\/(?!\/)(\[[^\]\r\n]+]|\\.|[^/\\\[\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/, + pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s])\s*)\/(\[[^\]\r\n]+]|\\.|[^/\\\[\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})\]]))/, lookbehind: true, greedy: true - } + }, + // This must be declared before keyword because we use "function" inside the look-forward + 'function-variable': { + pattern: /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=\s*(?:function\b|(?:\([^()]*\)|[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/i, + alias: 'function' + }, + 'constant': /\b[A-Z][A-Z\d_]*\b/ }); Prism.languages.insertBefore('javascript', 'string', { 'template-string': { - pattern: /`(?:\\\\|\\?[^\\])*?`/, + pattern: /`(?:\\[\s\S]|\${[^}]+}|[^\\`])*`/, greedy: true, inside: { 'interpolation': { - pattern: /\$\{[^}]+\}/, + pattern: /\${[^}]+}/, inside: { 'interpolation-punctuation': { - pattern: /^\$\{|\}$/, + pattern: /^\${|}$/, alias: 'punctuation' }, - rest: Prism.languages.javascript + rest: null // See below } }, 'string': /[\s\S]+/ } } }); +Prism.languages.javascript['template-string'].inside['interpolation'].inside.rest = Prism.languages.javascript; if (Prism.languages.markup) { Prism.languages.insertBefore('markup', 'tag', { @@ -706,7 +747,8 @@ if (Prism.languages.markup) { pattern: /()[\s\S]*?(?=<\/script>)/i, lookbehind: true, inside: Prism.languages.javascript, - alias: 'language-javascript' + alias: 'language-javascript', + greedy: true } }); } @@ -714,51 +756,145 @@ if (Prism.languages.markup) { Prism.languages.js = Prism.languages.javascript; Prism.languages.c = Prism.languages.extend('clike', { - 'keyword': /\b(_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)\b/, - 'operator': /\-[>-]?|\+\+?|!=?|<>?=?|==?|&&?|\|?\||[~^%?*\/]/, - 'number': /\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)[ful]*\b/i + 'keyword': /\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)\b/, + 'operator': /-[>-]?|\+\+?|!=?|<>?=?|==?|&&?|\|\|?|[~^%?*\/]/, + 'number': /(?:\b0x[\da-f]+|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?)[ful]*/i }); Prism.languages.insertBefore('c', 'string', { 'macro': { // allow for multiline macro definitions // spaces after the # character compile fine with gcc - pattern: /(^\s*)#\s*[a-z]+([^\r\n\\]|\\.|\\(?:\r\n?|\n))*/im, + pattern: /(^\s*)#\s*[a-z]+(?:[^\r\n\\]|\\(?:\r\n|[\s\S]))*/im, lookbehind: true, alias: 'property', inside: { // highlight the path of the include statement as a string 'string': { - pattern: /(#\s*include\s*)(<.+?>|("|')(\\?.)+?\3)/, + pattern: /(#\s*include\s*)(?:<.+?>|("|')(?:\\?.)+?\2)/, lookbehind: true }, // highlight macro directives as keywords 'directive': { - pattern: /(#\s*)\b(define|defined|elif|else|endif|error|ifdef|ifndef|if|import|include|line|pragma|undef|using)\b/, + pattern: /(#\s*)\b(?:define|defined|elif|else|endif|error|ifdef|ifndef|if|import|include|line|pragma|undef|using)\b/, lookbehind: true, alias: 'keyword' } } }, // highlight predefined macros as constants - 'constant': /\b(__FILE__|__LINE__|__DATE__|__TIME__|__TIMESTAMP__|__func__|EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|stdin|stdout|stderr)\b/ + 'constant': /\b(?:__FILE__|__LINE__|__DATE__|__TIME__|__TIMESTAMP__|__func__|EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|stdin|stdout|stderr)\b/ }); delete Prism.languages.c['class-name']; delete Prism.languages.c['boolean']; +(function(Prism) { + var insideString = { + variable: [ + // Arithmetic Environment + { + pattern: /\$?\(\([\s\S]+?\)\)/, + inside: { + // If there is a $ sign at the beginning highlight $(( and )) as variable + variable: [{ + pattern: /(^\$\(\([\s\S]+)\)\)/, + lookbehind: true + }, + /^\$\(\(/ + ], + number: /\b0x[\dA-Fa-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee]-?\d+)?/, + // Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic + operator: /--?|-=|\+\+?|\+=|!=?|~|\*\*?|\*=|\/=?|%=?|<<=?|>>=?|<=?|>=?|==?|&&?|&=|\^=?|\|\|?|\|=|\?|:/, + // If there is no $ sign at the beginning highlight (( and )) as punctuation + punctuation: /\(\(?|\)\)?|,|;/ + } + }, + // Command Substitution + { + pattern: /\$\([^)]+\)|`[^`]+`/, + greedy: true, + inside: { + variable: /^\$\(|^`|\)$|`$/ + } + }, + /\$(?:[\w#?*!@]+|\{[^}]+\})/i + ] + }; + + Prism.languages.bash = { + 'shebang': { + pattern: /^#!\s*\/bin\/bash|^#!\s*\/bin\/sh/, + alias: 'important' + }, + 'comment': { + pattern: /(^|[^"{\\])#.*/, + lookbehind: true + }, + 'string': [ + //Support for Here-Documents https://en.wikipedia.org/wiki/Here_document + { + pattern: /((?:^|[^<])<<\s*)["']?(\w+?)["']?\s*\r?\n(?:[\s\S])*?\r?\n\2/, + lookbehind: true, + greedy: true, + inside: insideString + }, + { + pattern: /(["'])(?:\\[\s\S]|\$\([^)]+\)|`[^`]+`|(?!\1)[^\\])*\1/, + greedy: true, + inside: insideString + } + ], + 'variable': insideString.variable, + // Originally based on http://ss64.com/bash/ + 'function': { + pattern: /(^|[\s;|&])(?:alias|apropos|apt-get|aptitude|aspell|awk|basename|bash|bc|bg|builtin|bzip2|cal|cat|cd|cfdisk|chgrp|chmod|chown|chroot|chkconfig|cksum|clear|cmp|comm|command|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|du|egrep|eject|enable|env|ethtool|eval|exec|expand|expect|export|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|getopts|git|grep|groupadd|groupdel|groupmod|groups|gzip|hash|head|help|hg|history|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|jobs|join|kill|killall|less|link|ln|locate|logname|logout|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|make|man|mkdir|mkfifo|mkisofs|mknod|more|most|mount|mtools|mtr|mv|mmv|nano|netstat|nice|nl|nohup|notify-send|npm|nslookup|open|op|passwd|paste|pathchk|ping|pkill|popd|pr|printcap|printenv|printf|ps|pushd|pv|pwd|quota|quotacheck|quotactl|ram|rar|rcp|read|readarray|readonly|reboot|rename|renice|remsync|rev|rm|rmdir|rsync|screen|scp|sdiff|sed|seq|service|sftp|shift|shopt|shutdown|sleep|slocate|sort|source|split|ssh|stat|strace|su|sudo|sum|suspend|sync|tail|tar|tee|test|time|timeout|times|touch|top|traceroute|trap|tr|tsort|tty|type|ulimit|umask|umount|unalias|uname|unexpand|uniq|units|unrar|unshar|uptime|useradd|userdel|usermod|users|uuencode|uudecode|v|vdir|vi|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yes|zip)(?=$|[\s;|&])/, + lookbehind: true + }, + 'keyword': { + pattern: /(^|[\s;|&])(?:let|:|\.|if|then|else|elif|fi|for|break|continue|while|in|case|function|select|do|done|until|echo|exit|return|set|declare)(?=$|[\s;|&])/, + lookbehind: true + }, + 'boolean': { + pattern: /(^|[\s;|&])(?:true|false)(?=$|[\s;|&])/, + lookbehind: true + }, + 'operator': /&&?|\|\|?|==?|!=?|<<>|<=?|>=?|=~/, + 'punctuation': /\$?\(\(?|\)\)?|\.\.|[{}[\];]/ + }; + + var inside = insideString.variable[1].inside; + inside.string = Prism.languages.bash.string; + inside['function'] = Prism.languages.bash['function']; + inside.keyword = Prism.languages.bash.keyword; + inside['boolean'] = Prism.languages.bash['boolean']; + inside.operator = Prism.languages.bash.operator; + inside.punctuation = Prism.languages.bash.punctuation; + + Prism.languages.shell = Prism.languages.bash; +})(Prism); + Prism.languages.cpp = Prism.languages.extend('c', { - 'keyword': /\b(alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|class|compl|const|constexpr|const_cast|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|float|for|friend|goto|if|inline|int|long|mutable|namespace|new|noexcept|nullptr|operator|private|protected|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/, - 'boolean': /\b(true|false)\b/, - 'operator': /[-+]{1,2}|!=?|<{1,2}=?|>{1,2}=?|\->|:{1,2}|={1,2}|\^|~|%|&{1,2}|\|?\||\?|\*|\/|\b(and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/ + 'keyword': /\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|class|compl|const|constexpr|const_cast|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|float|for|friend|goto|if|inline|int|int8_t|int16_t|int32_t|int64_t|uint8_t|uint16_t|uint32_t|uint64_t|long|mutable|namespace|new|noexcept|nullptr|operator|private|protected|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/, + 'boolean': /\b(?:true|false)\b/, + 'operator': /--?|\+\+?|!=?|<{1,2}=?|>{1,2}=?|->|:{1,2}|={1,2}|\^|~|%|&{1,2}|\|\|?|\?|\*|\/|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/ }); Prism.languages.insertBefore('cpp', 'keyword', { 'class-name': { - pattern: /(class\s+)[a-z0-9_]+/i, + pattern: /(class\s+)\w+/i, lookbehind: true } }); + +Prism.languages.insertBefore('cpp', 'string', { + 'raw-string': { + pattern: /R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/, + alias: 'string', + greedy: true + } +}); + (function(Prism) { // Ignore comments starting with { to privilege string interpolation highlighting @@ -774,20 +910,20 @@ Prism.languages.coffeescript = Prism.languages.extend('javascript', { // Strings are multiline { - pattern: /'(?:\\?[^\\])*?'/, + pattern: /'(?:\\[\s\S]|[^\\'])*'/, greedy: true }, { // Strings are multiline - pattern: /"(?:\\?[^\\])*?"/, + pattern: /"(?:\\[\s\S]|[^\\"])*"/, greedy: true, inside: { 'interpolation': interpolation } } ], - 'keyword': /\b(and|break|by|catch|class|continue|debugger|delete|do|each|else|extend|extends|false|finally|for|if|in|instanceof|is|isnt|let|loop|namespace|new|no|not|null|of|off|on|or|own|return|super|switch|then|this|throw|true|try|typeof|undefined|unless|until|when|while|window|with|yes|yield)\b/, + 'keyword': /\b(?:and|break|by|catch|class|continue|debugger|delete|do|each|else|extend|extends|false|finally|for|if|in|instanceof|is|isnt|let|loop|namespace|new|no|not|null|of|off|on|or|own|return|super|switch|then|this|throw|true|try|typeof|undefined|unless|until|when|while|window|with|yes|yield)\b/, 'class-member': { pattern: /@(?!\d)\w+/, alias: 'variable' @@ -813,7 +949,7 @@ Prism.languages.insertBefore('coffeescript', 'comment', { Prism.languages.insertBefore('coffeescript', 'string', { 'inline-javascript': { - pattern: /`(?:\\?[\s\S])*?`/, + pattern: /`(?:\\[\s\S]|[^\\`])*`/, inside: { 'delimiter': { pattern: /^`|`$/, @@ -859,10 +995,13 @@ delete Prism.languages.coffeescript['template-string']; (function(Prism) { Prism.languages.ruby = Prism.languages.extend('clike', { 'comment': [ - /#(?!\{[^\r\n]*?\}).*/, - /^=begin(?:\r?\n|\r)(?:.*(?:\r?\n|\r))*?=end/m + /#.*/, + { + pattern: /^=begin(?:\r?\n|\r)(?:.*(?:\r?\n|\r))*?=end/m, + greedy: true + } ], - 'keyword': /\b(alias|and|BEGIN|begin|break|case|class|def|define_method|defined|do|each|else|elsif|END|end|ensure|false|for|if|in|module|new|next|nil|not|or|raise|redo|require|rescue|retry|return|self|super|then|throw|true|undef|unless|until|when|while|yield)\b/ + 'keyword': /\b(?:alias|and|BEGIN|begin|break|case|class|def|define_method|defined|do|each|else|elsif|END|end|ensure|false|for|if|in|module|new|next|nil|not|or|protected|private|public|raise|redo|require|rescue|retry|return|self|super|then|throw|true|undef|unless|until|when|while|yield)\b/ }); var interpolation = { @@ -872,14 +1011,14 @@ delete Prism.languages.coffeescript['template-string']; pattern: /^#\{|\}$/, alias: 'tag' }, - rest: Prism.util.clone(Prism.languages.ruby) + rest: Prism.languages.ruby } }; Prism.languages.insertBefore('ruby', 'keyword', { 'regex': [ { - pattern: /%r([^a-zA-Z0-9\s\{\(\[<])(?:[^\\]|\\[\s\S])*?\1[gim]{0,3}/, + pattern: /%r([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1[gim]{0,3}/, greedy: true, inside: { 'interpolation': interpolation @@ -920,18 +1059,21 @@ delete Prism.languages.coffeescript['template-string']; greedy: true } ], - 'variable': /[@$]+[a-zA-Z_][a-zA-Z_0-9]*(?:[?!]|\b)/, - 'symbol': /:[a-zA-Z_][a-zA-Z_0-9]*(?:[?!]|\b)/ + 'variable': /[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/, + 'symbol': { + pattern: /(^|[^:]):[a-zA-Z_]\w*(?:[?!]|\b)/, + lookbehind: true + } }); Prism.languages.insertBefore('ruby', 'number', { - 'builtin': /\b(Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Stat|File|Fixnum|Float|Hash|Integer|IO|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|String|Struct|TMS|Symbol|ThreadGroup|Thread|Time|TrueClass)\b/, - 'constant': /\b[A-Z][a-zA-Z_0-9]*(?:[?!]|\b)/ + 'builtin': /\b(?:Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Stat|Fixnum|Float|Hash|Integer|IO|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|String|Struct|TMS|Symbol|ThreadGroup|Thread|Time|TrueClass)\b/, + 'constant': /\b[A-Z]\w*(?:[?!]|\b)/ }); Prism.languages.ruby.string = [ { - pattern: /%[qQiIwWxs]?([^a-zA-Z0-9\s\{\(\[<])(?:[^\\]|\\[\s\S])*?\1/, + pattern: /%[qQiIwWxs]?([^a-zA-Z0-9\s{(\[<])(?:(?!\1)[^\\]|\\[\s\S])*\1/, greedy: true, inside: { 'interpolation': interpolation @@ -967,7 +1109,7 @@ delete Prism.languages.coffeescript['template-string']; } }, { - pattern: /("|')(#\{[^}]+\}|\\(?:\r?\n|\r)|\\?.)*?\1/, + pattern: /("|')(?:#\{[^}]+\}|\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, greedy: true, inside: { 'interpolation': interpolation @@ -978,7 +1120,7 @@ delete Prism.languages.coffeescript['template-string']; Prism.languages.d = Prism.languages.extend('clike', { 'string': [ // r"", x"" - /\b[rx]"(\\.|[^\\"])*"[cwd]?/, + /\b[rx]"(?:\\[\s\S]|[^\\"])*"[cwd]?/, // q"[]", q"()", q"<>", q"{}" /\bq"(?:\[[\s\S]*?\]|\([\s\S]*?\)|<[\s\S]*?>|\{[\s\S]*?\})"/, // q"IDENT @@ -990,7 +1132,7 @@ Prism.languages.d = Prism.languages.extend('clike', { // Characters /'(?:\\'|\\?[^']+)'/, - /(["`])(\\.|(?!\1)[^\\])*\1[cwd]?/ + /(["`])(?:\\[\s\S]|(?!\1)[^\\])*\1[cwd]?/ ], 'number': [ @@ -1023,7 +1165,7 @@ Prism.languages.d.comment = [ Prism.languages.insertBefore('d', 'comment', { 'token-string': { // Allow one level of nesting - pattern: /\bq\{(?:|\{[^}]*\}|[^}])*\}/, + pattern: /\bq\{(?:\{[^}]*\}|[^}])*\}/, alias: 'string' } }); @@ -1039,20 +1181,86 @@ Prism.languages.insertBefore('d', 'function', { alias: 'variable' } }); +Prism.languages.dart = Prism.languages.extend('clike', { + 'string': [ + { + pattern: /r?("""|''')[\s\S]*?\1/, + greedy: true + }, + { + pattern: /r?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/, + greedy: true + } + ], + 'keyword': [ + /\b(?:async|sync|yield)\*/, + /\b(?:abstract|assert|async|await|break|case|catch|class|const|continue|default|deferred|do|dynamic|else|enum|export|external|extends|factory|final|finally|for|get|if|implements|import|in|library|new|null|operator|part|rethrow|return|set|static|super|switch|this|throw|try|typedef|var|void|while|with|yield)\b/ + ], + 'operator': /\bis!|\b(?:as|is)\b|\+\+|--|&&|\|\||<<=?|>>=?|~(?:\/=?)?|[+\-*\/%&^|=!<>]=?|\?/ +}); + +Prism.languages.insertBefore('dart','function',{ + 'metadata': { + pattern: /@\w+/, + alias: 'symbol' + } +}); +// Django/Jinja2 syntax definition for Prism.js syntax highlighter. +// Mostly it works OK but can paint code incorrectly on complex html/template tag combinations. + +var _django_template = { + 'property': { + pattern: /(?:{{|{%)[\s\S]*?(?:%}|}})/g, + greedy: true, + inside: { + 'string': { + pattern: /("|')(?:\\.|(?!\1)[^\\\r\n])*\1/, + greedy: true + }, + 'keyword': /\b(?:\||load|verbatim|widthratio|ssi|firstof|for|url|ifchanged|csrf_token|lorem|ifnotequal|autoescape|now|templatetag|debug|cycle|ifequal|regroup|comment|filter|endfilter|if|spaceless|with|extends|block|include|else|empty|endif|endfor|as|endblock|endautoescape|endverbatim|trans|endtrans|[Tt]rue|[Ff]alse|[Nn]one|in|is|static|macro|endmacro|call|endcall|set|endset|raw|endraw)\b/, + 'operator' : /[-+=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]|\b(?:or|and|not)\b/, + 'function': /\b(?:_|abs|add|addslashes|attr|batch|callable|capfirst|capitalize|center|count|cut|d|date|default|default_if_none|defined|dictsort|dictsortreversed|divisibleby|e|equalto|escape|escaped|escapejs|even|filesizeformat|first|float|floatformat|force_escape|forceescape|format|get_digit|groupby|indent|int|iriencode|iterable|join|last|length|length_is|linebreaks|linebreaksbr|linenumbers|list|ljust|lower|make_list|map|mapping|number|odd|phone2numeric|pluralize|pprint|random|reject|rejectattr|removetags|replace|reverse|rjust|round|safe|safeseq|sameas|select|selectattr|sequence|slice|slugify|sort|string|stringformat|striptags|sum|time|timesince|timeuntil|title|trim|truncate|truncatechars|truncatechars_html|truncatewords|truncatewords_html|undefined|unordered_list|upper|urlencode|urlize|urlizetrunc|wordcount|wordwrap|xmlattr|yesno)\b/, + 'important': /\b-?\d+(?:\.\d+)?\b/, + 'variable': /\b\w+?\b/, + 'punctuation' : /[[\];(),.:]/ + } + } +}; + +Prism.languages.django = Prism.languages.extend('markup', {'comment': /(?:)/}); +// Updated html tag pattern to allow template tags inside html tags +Prism.languages.django.tag.pattern = /<\/?(?!\d)[^\s>\/=$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^>=]+))?)*\s*\/?>/i; +Prism.languages.insertBefore('django', 'entity', _django_template); +Prism.languages.insertBefore('inside', 'tag', _django_template, Prism.languages.django.tag); + +if (Prism.languages.javascript) { + // Combine js code and template tags painting inside