diff --git a/.gitignore b/.gitignore index 4514284..c4c4fa1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .idea -*.patch \ No newline at end of file +*.patch +node_modules \ No newline at end of file diff --git a/composer.json b/composer.json index c02fd70..939ee28 100644 --- a/composer.json +++ b/composer.json @@ -1,8 +1,9 @@ { - "require": { - "php-imap/php-imap": "~2.0" - }, - "config": { - "vendor-dir": "src/backend-libs" - } + "require": { + "php-imap/php-imap": "~2.0", + "gnugat/PronounceableWord": "*" + }, + "config": { + "vendor-dir": "src/backend-libs" + } } diff --git a/composer.lock b/composer.lock index e7d1308..c7e9542 100644 --- a/composer.lock +++ b/composer.lock @@ -4,9 +4,51 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "18ba77805fd530e1972050e6de7cd151", - "content-hash": "357059f60b3f57be6e5f15b1df393a72", + "hash": "781cc38d2f745ec4bfba29e440111b80", + "content-hash": "70878ea12bce14861844baa8032688de", "packages": [ + { + "name": "gnugat/PronounceableWord", + "version": "2.0.0", + "source": { + "type": "git", + "url": "git@github.com:gnugat/PronounceableWord.git", + "reference": "60a19dc7148e92de35ea536b9f873b86365d48f0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/gnugat/PronounceableWord/zipball/60a19dc7148e92de35ea536b9f873b86365d48f0", + "reference": "60a19dc7148e92de35ea536b9f873b86365d48f0", + "shasum": "" + }, + "require": { + "php": ">=5.2" + }, + "type": "library", + "autoload": { + "psr-0": { + "PronounceableWord_": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Loïc Chardonnet" + } + ], + "description": "A light, customizable and simple library generating random and pronounceable words without using dictionaries or Markov chains.", + "homepage": "https://github.com/gnugat/PronounceableWord", + "keywords": [ + "generator", + "pronounceable", + "word" + ], + "abandoned": true, + "time": "2012-01-08 19:36:58" + }, { "name": "php-imap/php-imap", "version": "2.0.3", diff --git a/src/backend-libs/autoload.php b/src/backend-libs/autoload.php index 1f97304..afd06f9 100644 --- a/src/backend-libs/autoload.php +++ b/src/backend-libs/autoload.php @@ -2,6 +2,6 @@ // autoload.php @generated by Composer -require_once __DIR__ . '/composer' . '/autoload_real.php'; +require_once __DIR__ . '/composer/autoload_real.php'; return ComposerAutoloaderInit125dddd280a32cf75b181166154246ec::getLoader(); diff --git a/src/backend-libs/composer/autoload_namespaces.php b/src/backend-libs/composer/autoload_namespaces.php index cdeeac8..b72d58d 100644 --- a/src/backend-libs/composer/autoload_namespaces.php +++ b/src/backend-libs/composer/autoload_namespaces.php @@ -6,5 +6,6 @@ $vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname(dirname($vendorDir)); return array( + 'PronounceableWord_' => array($vendorDir . '/gnugat/PronounceableWord/src'), 'PhpImap' => array($vendorDir . '/php-imap/php-imap/src'), ); diff --git a/src/backend-libs/composer/autoload_static.php b/src/backend-libs/composer/autoload_static.php index efb5ede..cc9b8e0 100644 --- a/src/backend-libs/composer/autoload_static.php +++ b/src/backend-libs/composer/autoload_static.php @@ -9,6 +9,10 @@ class ComposerStaticInit125dddd280a32cf75b181166154246ec public static $prefixesPsr0 = array ( 'P' => array ( + 'PronounceableWord_' => + array ( + 0 => __DIR__ . '/..' . '/gnugat/PronounceableWord/src', + ), 'PhpImap' => array ( 0 => __DIR__ . '/..' . '/php-imap/php-imap/src', diff --git a/src/backend-libs/composer/installed.json b/src/backend-libs/composer/installed.json index 65aabc5..e3ce17a 100644 --- a/src/backend-libs/composer/installed.json +++ b/src/backend-libs/composer/installed.json @@ -43,5 +43,49 @@ "mail", "php" ] + }, + { + "name": "gnugat/PronounceableWord", + "version": "2.0.0", + "version_normalized": "2.0.0.0", + "source": { + "type": "git", + "url": "git@github.com:gnugat/PronounceableWord.git", + "reference": "60a19dc7148e92de35ea536b9f873b86365d48f0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/gnugat/PronounceableWord/zipball/60a19dc7148e92de35ea536b9f873b86365d48f0", + "reference": "60a19dc7148e92de35ea536b9f873b86365d48f0", + "shasum": "" + }, + "require": { + "php": ">=5.2" + }, + "time": "2012-01-08 19:36:58", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "PronounceableWord_": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Loïc Chardonnet" + } + ], + "description": "A light, customizable and simple library generating random and pronounceable words without using dictionaries or Markov chains.", + "homepage": "https://github.com/gnugat/PronounceableWord", + "keywords": [ + "generator", + "pronounceable", + "word" + ], + "abandoned": true } ] diff --git a/src/backend-libs/gnugat/PronounceableWord/.gitignore b/src/backend-libs/gnugat/PronounceableWord/.gitignore new file mode 100644 index 0000000..00495dc --- /dev/null +++ b/src/backend-libs/gnugat/PronounceableWord/.gitignore @@ -0,0 +1 @@ +/nbproject \ No newline at end of file diff --git a/src/backend-libs/gnugat/PronounceableWord/CHANGELOG.rst b/src/backend-libs/gnugat/PronounceableWord/CHANGELOG.rst new file mode 100644 index 0000000..525540f --- /dev/null +++ b/src/backend-libs/gnugat/PronounceableWord/CHANGELOG.rst @@ -0,0 +1,35 @@ +Change log +========== + +This file will provide the main changes between each new versions. + +To get the diff for a specific change, go to https://github.com/gnugat/PronounceableWord/commit/XXX +where XXX is the change hash. + +To get the diff between two versions, go to https://github.com/gnugat/PronounceableWord/compare/X.Y.Z...A.B.C +where X.Y.Z and A.B.C are the tag names. + +2.0.0 (2012-01-08) +------------------ + +* b9b3583: compatibility woth composer; +* 01a495a: using lower probability for LinkedLetters configuration; +* 8b27028: using a dependency injection container; +* 24bd26c: using dependency injection pattern; +* fe00216: complying to PSR-0 standard; +* c6c7ea1: importing documentation from wiki. + +1.0.2 (2012-01-03) +------------------ + +* 1e34020: updating the version number. + +1.0.1 (2012-01-03) +------------------ + +* 3af0bff: copyright extended to 2012. + +1.0.0 (2011-12-17) +------------------ + +* a86dcea: Initial stable release. diff --git a/src/backend-libs/gnugat/PronounceableWord/LICENSE.rst b/src/backend-libs/gnugat/PronounceableWord/LICENSE.rst new file mode 100644 index 0000000..5e90a43 --- /dev/null +++ b/src/backend-libs/gnugat/PronounceableWord/LICENSE.rst @@ -0,0 +1,27 @@ +LICENSE +======= + +License for the PronounceableWord PHP library + +The MIT license +--------------- + +Copyright (c) 2011-2012 Loic Chardonnet + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/src/backend-libs/gnugat/PronounceableWord/README.rst b/src/backend-libs/gnugat/PronounceableWord/README.rst new file mode 100644 index 0000000..c347ed6 --- /dev/null +++ b/src/backend-libs/gnugat/PronounceableWord/README.rst @@ -0,0 +1,107 @@ +PronounceableWord PHP library +============================= + +A light, customizable and simple PHP (>= 5.2) library, used to generate +randomly pronounceable words, names and passwords without using database of +existing words or big samples of text like with Markov chains. + +**Warning** + +Offensive or insulting words might be generated because of the random nature +of the generator (see how to manage them in +``./doc/manageOffensiveAndInsultingWords.rst``). + +Installation and usage +====================== + +First, get the last stable version, and put it in an accessible directory. + +You can use composer to do so (http://packagist.org/), by adding in the +``require`` of your file ``./composer.json`` the following entry: +``"gnugat/PronounceableWord": "*"``. + +You should have a fully operationnal pronounceable word generator:: + + getGenerator(); + $word = $generator->generateWordOfGivenLength($length); + +Configuration +------------- + +To customize the algorithm, the letters used, the linked letters or the types, +just copy and modify as you wish the files in the +``./src/PronounceableWord/Configuration`` directory and then pass your +configuration classes to the container (see how to configure in +``./doc/configuration.rst``). + +Tests +----- + +Tests are done using PHPUnit (https://github.com/sebastianbergmann/phpunit/) +(>=3.5) in the ``./test`` directory (see how to test in ``./doc/tests.rst``). + +Examples +-------- + +Here is a sample of examples that can be generated (use the +``./bin/generateExamples.php`` script for more): + +======= ====== ======= ======== ========= +Length 5 6 7 8 +======= ====== ======= ======== ========= +1 vicas panori eropops absugrit +2 ramsa verifu simbous nimpiowi +3 kiclu impriar rubleru entumecu +4 posup bivary kitocra vemolior +5 utler rugisi kanomev pactabie +======= ====== ======= ======== ========= + +Algorithm +========= + +Basically, the library will generate a word following these rules: + +1. Choose randomly a letter; +2. choose randomly a linked letter of different type; +3. choose randomly a linked letter, of different type if the last letter is + of consecutive types. + +Where: + +* "linked letter" is an arbitrary chosen letter that is expected to follow + well the previous letter; +* "types" would be voyels and consonants; +* "consecutive" would be a group of two letters from the same "type". + +The step 3 is repeated as many times as necessary. + +Documentation +============= + +You can find more documentation at the following links: + +* Copyright and MIT license: ``./LICENSE.rst``; +* version and change log: ``./VERSION.rst`` and ``CHANGELOG.rst``; +* technical and usage documentation: ``./doc/``. + +Contributing +============ + +1. Fork it: https://github.com/gnugat/PronounceableWord/fork_select ; +2. create a branch (``git checkout -b my_branch``); +3. commit your changes (``git commit -am "Changes description message"``); +4. push to the branch (``git push origin my_branch``); +5. create an Issue (https://github.com/gnugat/PronounceableWord/issues) with a + link to your branch; +6. wait for it to be accepted/argued. diff --git a/src/backend-libs/gnugat/PronounceableWord/VERSION.rst b/src/backend-libs/gnugat/PronounceableWord/VERSION.rst new file mode 100644 index 0000000..d98974c --- /dev/null +++ b/src/backend-libs/gnugat/PronounceableWord/VERSION.rst @@ -0,0 +1,10 @@ +VERSION +======= + +The purpose of this file is to point out the version of the PronounceableWord +library. + +Current version +--------------- + +2.0.0 diff --git a/src/backend-libs/gnugat/PronounceableWord/bin/generateExamples.php b/src/backend-libs/gnugat/PronounceableWord/bin/generateExamples.php new file mode 100644 index 0000000..9c6fd62 --- /dev/null +++ b/src/backend-libs/gnugat/PronounceableWord/bin/generateExamples.php @@ -0,0 +1,26 @@ +#!/usr/bin/env php + +getGenerator(); + +$maximumGenerationNumber = 20; +for ($generationNumber = 0; $generationNumber < $maximumGenerationNumber; $generationNumber++) { + $length = rand(MINIMUM_LENGTH, MAXIMUM_LENGTH); + + echo $generator->generateWordOfGivenLength($length) . "\n"; +} diff --git a/src/backend-libs/gnugat/PronounceableWord/composer.json b/src/backend-libs/gnugat/PronounceableWord/composer.json new file mode 100644 index 0000000..4f9ffe5 --- /dev/null +++ b/src/backend-libs/gnugat/PronounceableWord/composer.json @@ -0,0 +1,21 @@ +{ + "name": "gnugat/PronounceableWord", + "type": "library", + "description": "A light, customizable and simple library generating random and pronounceable words without using dictionaries or Markov chains.", + "keywords": ["generator", "pronounceable", "word"], + "homepage": "https://github.com/gnugat/PronounceableWord", + "license": "MIT", + "authors": [ + { + "name": "Loic Chardonnet" + } + ], + "require": { + "php": ">=5.2" + }, + "autoload": { + "psr-0": { + "PronounceableWord_": "src/" + } + } +} diff --git a/src/backend-libs/gnugat/PronounceableWord/doc/configuration.rst b/src/backend-libs/gnugat/PronounceableWord/doc/configuration.rst new file mode 100644 index 0000000..850d9c8 --- /dev/null +++ b/src/backend-libs/gnugat/PronounceableWord/doc/configuration.rst @@ -0,0 +1,210 @@ +Configuration +============= + +To generate pronounceable words, **PronouceableWord** uses three types of +configuration: + +================ ================================ ================================================ +Configuration What it defines What it allows +================ ================================ ================================================ +Linked letters The link between letters To know which letters can follow a letter +Letter types The types of the letters To alternate between consonants, vowels, etc... +Generator The number of consecutive types To know when to alternate the types +================ ================================ ================================================ + +PronouceableWord_Configuration_LinkedLetters +-------------------------------------------- + +This class contains only one attribute (``lettersWithLinkedLetters``), which +is an associative array: + +Key + A string of only one character representing the letter. + +Value + A string representing the letters supposed to follow well the **key**. + +For example, having ``'b' => 'a'`` will allow to compose ``'ba'``. + +PronouceableWord_Configuration_LetterTypes +------------------------------------------ + +This class contains only one attribute (``letterTypesWithLetters``), which is +an associative array: + +Key + The name of the type. + +Value + A string containing the letters of this type. + +For example, defining the vowels would be: ``'vowels' => 'aeiouy'``. + +PronounceableWord_Configuration_Generator +----------------------------------------- + +This class contains two attributes which must be integers superior to 1.: + +===================================== ============================================================================== +Attribute Example value and effect +===================================== ============================================================================== +maximumConsecutiveTypesAtTheBegining 1: if the first letter is a vowel, the second will be a consonant +maximumConsecutiveTypesInTheWord 2: if the second and third letters are vowels, the fourth will be a consonant +===================================== ============================================================================== + +Default configuration +===================== + +The default configuration provides a set of linked letters based on the study +of Data Compression (http://www.data-compression.com/english.shtml#second), +using there statistical study of English text. + +Some changes have been applied: + +* only letters with a probability superior to 0.01 have been selected; +* the letters 'j' and 'q' have been removed. + +How to customize the configuration +================================== + +To customize the configuration, you need to: + +1. copy the configuration classes in + ``./vendor/PronounceableWord/src/PronounceableWord/Configuration`` to your + project configuration (e.g. ``./Configuration``); +2. change the name of your configuration classes to avoid confusion, (e.g. + replacing the prefix ``PronounceableWord`` by ``My``); +3. change the content as you wish; +4. set the configuration attributes in the dependency injection container + with your own classes. + +How to test the configuration +============================= + +To make sure your customized configuration is coherent and won't make +**PronounceableWord** crash, you can test it as follow: + +1. create a unit test extending the configuration test (from + ``./vendor/PronounceableWord/test/PronounceableWord/Tests/Configuration``); +2. override the ``setUp`` method by initializing the ``configuration`` + attribute with your own configuration class. + +To learn more about how to test, see ``./doc/tests.srt``. + +Full Example +============ + +Here is a complete example, to show how it works. + +Customizing +----------- + +The configuration:: + + 'bc', + 'b' => 'ac', + 'c' => 'a0', + '0' => 'abc', + ); + } + + 'a', + 'consonants' => 'bc', + 'numbers' => '0', + ); + } + + configurations['LinkedLetters'] = new My_Configuration_LinkedLetters(); + $container->configurations['LetterTypes'] = new My_Configuration_LetterTypes(); + $container->configurations['Generator'] = new My_Configuration_Generator(); + + $generator = $container->getGenerator(); + $word = $generator->generateWordOfGivenLength($length); + +Testing +------- + +To test it, create the following unit tests:: + + configuration = new PronounceableWord_Configuration_LinkedLetters(); + } + } + + configuration = new PronounceableWord_Configuration_LetterTypes(); + } + } + + configuration = new PronounceableWord_Configuration_Generator(); + } + } diff --git a/src/backend-libs/gnugat/PronounceableWord/doc/manageOffensiveAndInsultingWords.rst b/src/backend-libs/gnugat/PronounceableWord/doc/manageOffensiveAndInsultingWords.rst new file mode 100644 index 0000000..2c521a3 --- /dev/null +++ b/src/backend-libs/gnugat/PronounceableWord/doc/manageOffensiveAndInsultingWords.rst @@ -0,0 +1,59 @@ +Offensive and insulting words management +======================================== + +Because PronounceableWord uses an algorithm using randomness, +offensive or insulting words might be generated. The best way to manage them +is to ceate a function that will filter them afterward. + +These offensive words might be surrounded by other letters that would be fine +otherwise, so you should replace it by a non-offensive one instead of just +removing it. + +To avoid generating unpronounceable words with this filter, try to be +consistent with the configuration. + +Example +------- + +Here is an example on how to manage them. With the default configuration, the +word "insult" can be generated. Let's replace it by "insalt": the letter "s" +has "a" as a linked letter, and the letter "a" has "l" has a linked letter:: + + 'insalt', + ); + + public function filter($word) { + foreach ($this->offensiveAndInsultingWords as $offensiveAndInsultingWord => $replacement) { + $word = str_replace($offensiveAndInsultingWord, $replacement, $word); + } + + return $word; + } + } + +Now, after generating your words with ``PronounceableWord_Generator``, you can +use ``OffensiveAndInsultingWords`` to filter any words you might find offensive +or insulting:: + + getGenerator(); + $offensiveAndInsultingWordManager = new OffensiveAndInsultingWords(); + + $word = $generator->generateWordOfGivenLength($length); + $word = offensiveAndInsultingWordManager->filter($word); diff --git a/src/backend-libs/gnugat/PronounceableWord/doc/passwordExample.rst b/src/backend-libs/gnugat/PronounceableWord/doc/passwordExample.rst new file mode 100644 index 0000000..05abfab --- /dev/null +++ b/src/backend-libs/gnugat/PronounceableWord/doc/passwordExample.rst @@ -0,0 +1,175 @@ +The password generator example +============================== + +This page is intended to provide an example of usage and configuration, to +generate passwords with PronounceableWord. + +First create your project. You should have something like:: + + getGenerator(); + $password = $generator->generateWordOfGivenLength($length); + +Configuration +============= + +Let's say that the standard configuration doesn't please you, because you think +that password should also contain integers. + +Linked letters configuration +---------------------------- + +The first thing is to create your own linked letters configuration, with +integers:: + + 'bcdgiklmnprstvy0123456789', + 'b' => 'aeilorstuy0123456789', + 'c' => 'acehiklortu0123456789', + 'd' => 'aeiorsu0123456789', + 'e' => 'acdeilmnprstvxy0123456789', + 'f' => 'aefilortu0123456789', + 'g' => 'aeghilnorsu0123456789', + 'h' => 'aeiortu0123456789', + 'i' => 'acdefglmnorstv0123456789', + 'k' => 'aeilnos0123456789', + 'l' => 'adefilostuy0123456789', + 'm' => 'abeimoprsuy0123456789', + 'n' => 'acdegiosty0123456789', + 'o' => 'cdfklmnoprstuvw0123456789', + 'p' => 'aehiloprstu0123456789', + 'r' => 'acdegilmnorstuy0123456789', + 's' => 'acehilopstu0123456789', + 't' => 'aehilorstuy0123456789', + 'u' => 'abcdegilmnprst0123456789', + 'v' => 'aeino0123456789', + 'w' => 'aehinos0123456789', + 'x' => 'acehiptu0123456789', + 'y' => 'eiost0123456789', + 'z' => 'aeiloyz0123456789', + '0' => 'abcdefghiklmnoprstuvwxyz0123456789', + '1' => 'abcdefghiklmnoprstuvwxyz0123456789', + '2' => 'abcdefghiklmnoprstuvwxyz0123456789', + '3' => 'abcdefghiklmnoprstuvwxyz0123456789', + '4' => 'abcdefghiklmnoprstuvwxyz0123456789', + '5' => 'abcdefghiklmnoprstuvwxyz0123456789', + '6' => 'abcdefghiklmnoprstuvwxyz0123456789', + '7' => 'abcdefghiklmnoprstuvwxyz0123456789', + '8' => 'abcdefghiklmnoprstuvwxyz0123456789', + '9' => 'abcdefghiklmnoprstuvwxyz0123456789', + ); + } + +Letter type configuration +------------------------- + +Then create the letter types configuration with integers:: + + 'aeiouy', + 'consonants' => 'bcdfghklmnprstvwxz', + 'integers' => '0123456789', + ); + } + +Adding your configuration +------------------------- + +Finally, simply add your configuration into the container:: + + configurations['LinkedLetters'] = new My_Configuration_LinkedLetters(); + $container->configurations['LetterTypes'] = new My_Configuration_LetterTypes(); + + $generator = $container->getGenerator(); + $password = $generator->generateWordOfGivenLength($length); + +Conclusion +========== + +You now have a pronounceable password generator. If you want to use upper and +lower case, you should use a function aferwards:: + + configurations['LinkedLetters'] = new My_Configuration_LinkedLetters(); + $container->configurations['LetterTypes'] = new My_Configuration_LetterTypes(); + + $generator = $container->getGenerator(); + $password = $generator->generateWordOfGivenLength($length); + + $password = addUppercase($password); diff --git a/src/backend-libs/gnugat/PronounceableWord/doc/roadmap.rst b/src/backend-libs/gnugat/PronounceableWord/doc/roadmap.rst new file mode 100644 index 0000000..b0113ee --- /dev/null +++ b/src/backend-libs/gnugat/PronounceableWord/doc/roadmap.rst @@ -0,0 +1,31 @@ +Roadmap +======= + +This file will establish the fetaures plan for the next versions. + +2.1.0 +----- + +The following features must be implemented to reach the version 2.1.0: + +* Choice of first letter based on the letters following 'SPACE' in the + Data Compression study: http://www.data-compression.com/english.shtml#second; +* choice of last letter based on the letters coming before 'SPACE' in the + Data Compression study: http://www.data-compression.com/english.shtml#second. + +2.0.0 +----- + +In order to reach the version 2.0.0, the following features must be +implemented: + +* moving the documentation from the Github wiki to the git repository; +* conforming to the standard PSR-0: + https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md; +* using the Dependency Injection design pattern to load configuration: + http://en.wikipedia.org/wiki/Dependency_injection; +* using Dependency Injection Container; +* using, as the linked letters default configuration, letters from the Data + Compression study superior to 0.01 instead of 0.001: + http://www.data-compression.com/english.shtml#second; +* being compatible with composer. diff --git a/src/backend-libs/gnugat/PronounceableWord/doc/tests.rst b/src/backend-libs/gnugat/PronounceableWord/doc/tests.rst new file mode 100644 index 0000000..5b795a1 --- /dev/null +++ b/src/backend-libs/gnugat/PronounceableWord/doc/tests.rst @@ -0,0 +1,40 @@ +Tests +===== + +In order to keep PronounceableWordGenerator stable and to maintain a high +quality, tests have been written using PHPUnit >= 3.5 +(https://github.com/sebastianbergmann/phpunit/). + +Installation +============ + +Before doing any test, you must do some installations. + +Installing PEAR +--------------- + +PEAR (http://pear.php.net/) is necessary to use PHPUnit. To install it, follow +these instructions: http://pear.php.net/manual/en/installation.getting.php + +If you are on Windows, and using WAMP or EasyPHP (or maybe others web +development plateforms), you might encounter the following error:: + + phar "C:\wamp\bin\php\php5.3.0\PEAR\go-pear.phar" does not have a signature PHP Warning: require_once(phar://go-pear.par/index.php): failed to open stream: phar error: invalid url or non-existent phar "phar://go-pear.phar/index.php" in C:\wamp\bin\php\php5.3.0\PEAR\go-pear.phar on line 1236 + + Warning: require_once(phar://go-pear.par/index.php): failed to open stream: phar error: invalid url or non-existent phar "phar://go-pear.phar/index.php" in C:\wamp\bin\php\php5.3.0\PEAR\go-pear.phar on line 1236 Press any key to continue... + +This is because the PHP setting "phar.require_hash" is set to "On" by default. +If you set it to "Off" in your "php.ini", you should be able to continue. + +Installing PHPUnit +------------------ + +Once PEAR is installed, you can use it to install PHPUnit by following these +instructions: http://www.phpunit.de/manual/3.0/en/installation.html + +Running the tests +================= + +Tests can be run by CLI, using the following command:: + + phpunit ./test diff --git a/src/backend-libs/gnugat/PronounceableWord/doc/versionning.rst b/src/backend-libs/gnugat/PronounceableWord/doc/versionning.rst new file mode 100644 index 0000000..0c1bd22 --- /dev/null +++ b/src/backend-libs/gnugat/PronounceableWord/doc/versionning.rst @@ -0,0 +1,54 @@ +Versionning +=========== + +This file will document the versionning process of the PHP library +PronounceableWord. + +Version number +============== + +The version number will follow the X.Y.Z format. The following table describes +the meaning of incrementation for each number: + +======== ============================================================================================= +Version Description +======== ============================================================================================= +#.0.0 Modification impacting on the public usage +0.#.0 Modification not impacting on the public usage +0.0.# Small modification not impacting on the public usage, like bug fixes and adding of new tests +======== ============================================================================================= + +Branching model +=============== + +The PronounceableWord project uses Git to its full potential, following +the advice of this article: +http://nvie.com/posts/a-successful-git-branching-model/ . + +================== =============== ================================= ==================================== +Repository/Branch Pull from Merge to Description +================== =============== ================================= ==================================== +origin/master Stable branch, actual release. +origin/develop origin/master origin/master Stable branch, for next release. +x/hotfix-* origin/master origin/master and origin/develop Bug fixes branch for origin/master. +x/x origin/develop origin/develop Feature branch. +================== =============== ================================= ==================================== + +Tags +---- + +Tags are created from the origin/master branch, incrementing the version number. + +x/hotfix-* branches +------------------- + +The repository is named x because it can be from another repository (through +forks), and the branch is called hotfix-* because it is suffixed by "hotfix-" +and named after the feature it will fix. + +x/x branches +------------ + +The repository is named x because it can be from another repository (through +forks), and the branch is called x because it is named after the feature it +will implement. diff --git a/src/backend-libs/gnugat/PronounceableWord/src/PronounceableWord/Configuration/Generator.php b/src/backend-libs/gnugat/PronounceableWord/src/PronounceableWord/Configuration/Generator.php new file mode 100644 index 0000000..bb0cea1 --- /dev/null +++ b/src/backend-libs/gnugat/PronounceableWord/src/PronounceableWord/Configuration/Generator.php @@ -0,0 +1,5 @@ + 'aeiouy', + 'consonants' => 'bcdfghklmnprstvwxz', + ); +} diff --git a/src/backend-libs/gnugat/PronounceableWord/src/PronounceableWord/Configuration/LinkedLetters.php b/src/backend-libs/gnugat/PronounceableWord/src/PronounceableWord/Configuration/LinkedLetters.php new file mode 100644 index 0000000..4bb7ad5 --- /dev/null +++ b/src/backend-libs/gnugat/PronounceableWord/src/PronounceableWord/Configuration/LinkedLetters.php @@ -0,0 +1,29 @@ + 'bcdgiklmnprstvy', + 'b' => 'aeilorstuy', + 'c' => 'acehiklortu', + 'd' => 'aeiorsu', + 'e' => 'acdeilmnprstvxy', + 'f' => 'aefilortu', + 'g' => 'aeghilnorsu', + 'h' => 'aeiortu', + 'i' => 'acdefglmnorstv', + 'k' => 'aeilnos', + 'l' => 'adefilostuy', + 'm' => 'abeimoprsuy', + 'n' => 'acdegiosty', + 'o' => 'cdfklmnoprstuvw', + 'p' => 'aehiloprstu', + 'r' => 'acdegilmnorstuy', + 's' => 'acehilopstu', + 't' => 'aehilorstuy', + 'u' => 'abcdegilmnprst', + 'v' => 'aeino', + 'w' => 'aehinos', + 'x' => 'acehiptu', + 'y' => 'eiost', + 'z' => 'aeiloyz', + ); +} diff --git a/src/backend-libs/gnugat/PronounceableWord/src/PronounceableWord/DependencyInjectionContainer.php b/src/backend-libs/gnugat/PronounceableWord/src/PronounceableWord/DependencyInjectionContainer.php new file mode 100644 index 0000000..d84dc0f --- /dev/null +++ b/src/backend-libs/gnugat/PronounceableWord/src/PronounceableWord/DependencyInjectionContainer.php @@ -0,0 +1,66 @@ +configurations['Generator'] = new PronounceableWord_Configuration_Generator(); + $this->configurations['LinkedLetters'] = new PronounceableWord_Configuration_LinkedLetters(); + $this->configurations['LetterTypes'] = new PronounceableWord_Configuration_LetterTypes(); + + $this->classNames['LinkedLetters'] = 'PronounceableWord_LinkedLetters'; + $this->classNames['LetterTypes'] = 'PronounceableWord_LetterTypes'; + $this->classNames['LastLettersConsecutiveTypes'] = 'PronounceableWord_LastLettersConsecutiveTypes'; + $this->classNames['Generator'] = 'PronounceableWord_Generator'; + } + + public function getGenerator() { + $generatorClass = $this->classNames['Generator']; + $generatorInstance = new $generatorClass( + $this->getLinkedLetters(), + $this->getLetterTypes(), + $this->getLastLettersConsecutiveTypes(), + $this->configurations['Generator'] + ); + + return $generatorInstance; + } + + public function getLinkedLetters() { + $linkedLettersClass = $this->classNames['LinkedLetters']; + $linkedLettersInstance = new $linkedLettersClass($this->configurations['LinkedLetters']); + + return $linkedLettersInstance; + } + + public function getLetterTypes() { + $lettersTypesClass = $this->classNames['LetterTypes']; + $lettersTypesInstance = new $lettersTypesClass($this->configurations['LetterTypes']); + + return $lettersTypesInstance; + } + + public function getLastLettersConsecutiveTypes() { + $lastLettersConsecutiveTypesClass = $this->classNames['LastLettersConsecutiveTypes']; + $lastLettersConsecutiveTypesInstance = new $lastLettersConsecutiveTypesClass($this->getLetterTypes()); + + return $lastLettersConsecutiveTypesInstance; + } +} diff --git a/src/backend-libs/gnugat/PronounceableWord/src/PronounceableWord/Generator.php b/src/backend-libs/gnugat/PronounceableWord/src/PronounceableWord/Generator.php new file mode 100644 index 0000000..e7e1d0d --- /dev/null +++ b/src/backend-libs/gnugat/PronounceableWord/src/PronounceableWord/Generator.php @@ -0,0 +1,76 @@ +linkedLetters = $linkedLetter; + $this->letterTypes = $letterTypes; + $this->lastLettersConsecutiveTypes = $lastLettersConsecutiveTypes; + $this->configuration = $configuration; + } + + public function generateWordOfGivenLength($givenLength) { + $this->word = ''; + $this->length = 0; + for ($letterNumber = 0; $letterNumber < $givenLength; $letterNumber++) { + $this->word .= $this->pickNextLetter(); + $this->length = strlen($this->word); + } + + return $this->word; + } + + protected function pickNextLetter() { + $pickedLetter = ''; + + if (0 === $this->length) { + $pickedLetter = $this->pickFirstLetter(); + } elseif ($this->length <= $this->configuration->maximumConsecutiveTypesAtTheBegining) { + $pickedLetter = $this->pickLinkedLetterOfDifferentType($this->word[0]); + } else { + $pickedLetter = $this->pickLinkedLetterOfDifferentTypeIfLastLettersAreOfConsecutiveTypes(); + } + + return $pickedLetter; + } + + protected function pickFirstLetter() { + return $this->linkedLetters->pickLetter(); + } + + protected function pickLinkedLetterOfDifferentType($letter) { + $letterType = $this->letterTypes->getLetterType($letter); + $lettersToAvoid = $this->letterTypes->getLettersOfGivenType($letterType); + + return $this->linkedLetters->pickLinkedLetterDifferentFromGivenLetters($letter, $lettersToAvoid); + } + + protected function pickLinkedLetterOfDifferentTypeIfLastLettersAreOfConsecutiveTypes() { + $lastLetter = $this->word[$this->length - 1]; + $consecutiveTypes = $this->lastLettersConsecutiveTypes->countFromWord($this->word); + + $pickedLetter = ''; + if ($consecutiveTypes === $this->configuration->maximumConsecutiveTypesInTheWord) { + $pickedLetter = $this->pickLinkedLetterOfDifferentType($lastLetter); + } else { + $pickedLetter = $this->linkedLetters->pickLinkedLetter($lastLetter); + } + + return $pickedLetter; + } +} diff --git a/src/backend-libs/gnugat/PronounceableWord/src/PronounceableWord/LastLettersConsecutiveTypes.php b/src/backend-libs/gnugat/PronounceableWord/src/PronounceableWord/LastLettersConsecutiveTypes.php new file mode 100644 index 0000000..d64ef2e --- /dev/null +++ b/src/backend-libs/gnugat/PronounceableWord/src/PronounceableWord/LastLettersConsecutiveTypes.php @@ -0,0 +1,34 @@ +letterTypes = $letterTypes; + } + + public function countFromWord($word) { + $letterIndex = strlen($word) - 1; + $letter = $word[$letterIndex]; + $type = $this->letterTypes->getLetterType($letter); + $consecutiveTypesCount = 1; + + for ($letterIndex = $letterIndex - 1; $letterIndex >= 0; $letterIndex--) { + $letter = $word[$letterIndex]; + if ($this->letterTypes->getLetterType($letter) !== $type) { + break; + } + $consecutiveTypesCount++; + } + + return $consecutiveTypesCount; + } +} diff --git a/src/backend-libs/gnugat/PronounceableWord/src/PronounceableWord/LetterTypes.php b/src/backend-libs/gnugat/PronounceableWord/src/PronounceableWord/LetterTypes.php new file mode 100644 index 0000000..1fa932a --- /dev/null +++ b/src/backend-libs/gnugat/PronounceableWord/src/PronounceableWord/LetterTypes.php @@ -0,0 +1,33 @@ +configuration = $configuration; + } + + public function getLetterType($letter) { + $type = ''; + foreach ($this->configuration->letterTypesWithLetters as $letterType => $letters) { + if (false !== strpos($letters, $letter)) { + $type = $letterType; + break; + } + } + + return $type; + } + + public function getLettersOfGivenType($type) { + return $this->configuration->letterTypesWithLetters[$type]; + } +} diff --git a/src/backend-libs/gnugat/PronounceableWord/src/PronounceableWord/LinkedLetters.php b/src/backend-libs/gnugat/PronounceableWord/src/PronounceableWord/LinkedLetters.php new file mode 100644 index 0000000..2e0c093 --- /dev/null +++ b/src/backend-libs/gnugat/PronounceableWord/src/PronounceableWord/LinkedLetters.php @@ -0,0 +1,55 @@ +configuration = $configuration; + } + public function pickLetter() { + $pickedLetter = array_rand($this->configuration->lettersWithLinkedLetters); + + return $pickedLetter; + } + + public function pickLinkedLetter($letter) { + $linkedLetters = $this->configuration->lettersWithLinkedLetters[$letter]; + + return $this->pickLetterFromGivenLetters($linkedLetters); + } + + protected function pickLetterFromGivenLetters($letters) { + $minLetterIndex = 0; + $maxLetterIndex = strlen($letters) - 1; + $pickedLetterIndex = rand($minLetterIndex, $maxLetterIndex); + + $pickedLetter = $letters[$pickedLetterIndex]; + + return $pickedLetter; + } + + public function pickLinkedLetterDifferentFromGivenLetters($letter, $letters) { + $linkedLetters = $this->configuration->lettersWithLinkedLetters[$letter]; + + $letterChoices = $this->removeGivenLettersFromGivenLinkedLetters($letters, $linkedLetters); + + return $this->pickLetterFromGivenLetters($letterChoices); + } + + protected function removeGivenLettersFromGivenLinkedLetters($letters, $linkedLetters) { + $maximumLetterIndex = strlen($letters); + for ($letterIndex = 0; $letterIndex < $maximumLetterIndex; $letterIndex++) { + $linkedLetters = str_replace($letters[$letterIndex], '', $linkedLetters); + } + + return $linkedLetters; + } +} diff --git a/src/backend-libs/gnugat/PronounceableWord/test/PronounceableWord/Tests/Configuration/GeneratorTest.php b/src/backend-libs/gnugat/PronounceableWord/test/PronounceableWord/Tests/Configuration/GeneratorTest.php new file mode 100644 index 0000000..e2013f8 --- /dev/null +++ b/src/backend-libs/gnugat/PronounceableWord/test/PronounceableWord/Tests/Configuration/GeneratorTest.php @@ -0,0 +1,27 @@ +configuration = new PronounceableWord_Configuration_Generator(); + } + + public function testIsMaximumConsecutiveTypesAtTheBeginingPositive() { + $this->assertGreaterThanOrEqual($this->minimumPositiveNumber, $this->configuration->maximumConsecutiveTypesAtTheBegining); + } + + public function testIsMaximumConsecutiveTypesInTheWordPositive() { + $this->assertGreaterThanOrEqual($this->minimumPositiveNumber, $this->configuration->maximumConsecutiveTypesInTheWord); + } +} diff --git a/src/backend-libs/gnugat/PronounceableWord/test/PronounceableWord/Tests/Configuration/LetterTypesTest.php b/src/backend-libs/gnugat/PronounceableWord/test/PronounceableWord/Tests/Configuration/LetterTypesTest.php new file mode 100644 index 0000000..1c488e9 --- /dev/null +++ b/src/backend-libs/gnugat/PronounceableWord/test/PronounceableWord/Tests/Configuration/LetterTypesTest.php @@ -0,0 +1,37 @@ +configuration = new PronounceableWord_Configuration_LetterTypes(); + } + public function testAreLettersInOnlyOneType() { + foreach ($this->configuration->letterTypesWithLetters as $currentType => $lettersOfCurrentType) { + $maximumLetterIndex = strlen($lettersOfCurrentType); + $areLettersInOnlyOneType = true; + foreach ($this->configuration->letterTypesWithLetters as $checkedType => $lettersOfCheckedType) { + if ($currentType !== $checkedType) { + for ($letterIndex = 0; $letterIndex < $maximumLetterIndex; $letterIndex++) { + $isLetterInLetters = strpos($lettersOfCheckedType, $lettersOfCurrentType[$letterIndex]); + + if (false !== $isLetterInLetters) { + $areLettersInOnlyOneType = false; + break 2; + } + } + } + } + + $this->assertTrue($areLettersInOnlyOneType); + } + } +} diff --git a/src/backend-libs/gnugat/PronounceableWord/test/PronounceableWord/Tests/Configuration/LinkedLettersAndTypesTest.php b/src/backend-libs/gnugat/PronounceableWord/test/PronounceableWord/Tests/Configuration/LinkedLettersAndTypesTest.php new file mode 100644 index 0000000..02e6905 --- /dev/null +++ b/src/backend-libs/gnugat/PronounceableWord/test/PronounceableWord/Tests/Configuration/LinkedLettersAndTypesTest.php @@ -0,0 +1,58 @@ +letterTypesConfiguration = new PronounceableWord_Configuration_LetterTypes(); + $this->linkedLettersConfiguration = new PronounceableWord_Configuration_LinkedLetters(); + } + + public function testAreAllLettersFromLinkedLettersInLettersFromLetterTypes() { + foreach ($this->linkedLettersConfiguration->lettersWithLinkedLetters as $letter => $linkedLettersToIgnore) { + $isLetterInTypes = false; + foreach ($this->letterTypesConfiguration->letterTypesWithLetters as $lettersOfType) { + $isLetterInLetters = strpos($lettersOfType, $letter); + + if (false !== $isLetterInLetters) { + $isLetterInTypes = true; + break; + } + } + + $this->assertTrue($isLetterInTypes); + } + } + + public function testHaveLettersAtLeastOneLinkedLetterOfDifferentType() { + $letterTypes = new PronounceableWord_LetterTypes($this->letterTypesConfiguration); + $linkedLettersConfiguration = new PronounceableWord_Configuration_LinkedLetters(); + + foreach ($this->linkedLettersConfiguration->lettersWithLinkedLetters as $letter => $linkedLetters) { + $letterType = $letterTypes->getLetterType($letter); + + $hasOneDifferentType = false; + $maximumLetterIndex = strlen($linkedLetters); + for ($letterIndex = 0; $letterIndex < $maximumLetterIndex; $letterIndex++) { + $linkedLetterType = $letterTypes->getLetterType($linkedLetters[$letterIndex]); + + if ($letterType !== $linkedLetterType) { + $hasOneDifferentType = true; + break; + } + } + + $this->assertTrue($hasOneDifferentType); + } + } +} diff --git a/src/backend-libs/gnugat/PronounceableWord/test/PronounceableWord/Tests/Configuration/LinkedLettersTest.php b/src/backend-libs/gnugat/PronounceableWord/test/PronounceableWord/Tests/Configuration/LinkedLettersTest.php new file mode 100644 index 0000000..4e37f88 --- /dev/null +++ b/src/backend-libs/gnugat/PronounceableWord/test/PronounceableWord/Tests/Configuration/LinkedLettersTest.php @@ -0,0 +1,49 @@ +configuration = new PronounceableWord_Configuration_LinkedLetters(); + } + + public function testAreAllLettersInAtLeastOneLinkedLetters() { + foreach ($this->configuration->lettersWithLinkedLetters as $letter => $linkedLettersToIgnore) { + $isInAtLeastOneLinkedLetters = false; + foreach ($this->configuration->lettersWithLinkedLetters as $letterToIgnore => $linkedLetters) { + $isLetterInLinkedLetters = strpos($linkedLetters, $letter); + + if (false !== $isLetterInLinkedLetters) { + $isInAtLeastOneLinkedLetters = true; + break; + } + } + + $this->assertTrue($isInAtLeastOneLinkedLetters); + } + } + + public function testAreAllLinkedLettersInLetters() { + foreach ($this->configuration->lettersWithLinkedLetters as $letterToIgnore => $linkedLetters) { + $isLinkedLetterInLetters = false; + foreach ($this->configuration->lettersWithLinkedLetters as $letter => $linkedLettersToIgnore) { + $isLetterInLinkedLetters = strpos($linkedLetters, $letter); + + if (false !== $isLetterInLinkedLetters) { + $isInAtLeastOneLinkedLetters = true; + break; + } + } + + $this->assertTrue($isInAtLeastOneLinkedLetters); + } + } +} diff --git a/src/backend-libs/gnugat/PronounceableWord/test/PronounceableWord/Tests/DependencyInjectionContainerTest.php b/src/backend-libs/gnugat/PronounceableWord/test/PronounceableWord/Tests/DependencyInjectionContainerTest.php new file mode 100644 index 0000000..92ac993 --- /dev/null +++ b/src/backend-libs/gnugat/PronounceableWord/test/PronounceableWord/Tests/DependencyInjectionContainerTest.php @@ -0,0 +1,44 @@ +classNames as $classType => $className) { + $expectedClassName = 'PronounceableWord_' . $classType; + $this->assertSame($expectedClassName, $className); + } + } + + + public function testClassNamesAndInstances() { + $container = new PronounceableWord_DependencyInjectionContainer(); + + foreach ($container->classNames as $classType => $className) { + $getMethodName = 'get' . $classType; + $instance = $container->{$getMethodName}(); + + $this->assertInstanceOf($className, $instance); + } + } + + public function testConfigurations() { + $container = new PronounceableWord_DependencyInjectionContainer(); + + foreach ($container->configurations as $className => $configurationInstance) { + $configurationClassName = 'PronounceableWord_Configuration_' . $className; + + $this->assertInstanceOf($configurationClassName, $configurationInstance); + } + } +} diff --git a/src/backend-libs/gnugat/PronounceableWord/test/PronounceableWord/Tests/GeneratorTest.php b/src/backend-libs/gnugat/PronounceableWord/test/PronounceableWord/Tests/GeneratorTest.php new file mode 100644 index 0000000..2f05074 --- /dev/null +++ b/src/backend-libs/gnugat/PronounceableWord/test/PronounceableWord/Tests/GeneratorTest.php @@ -0,0 +1,38 @@ +generateWordOfGivenLength($length); + + $this->assertEquals($length, strlen($generatedWord)); + } + } +} diff --git a/src/backend-libs/gnugat/PronounceableWord/test/PronounceableWord/Tests/LastLettersConsecutiveTypesTest.php b/src/backend-libs/gnugat/PronounceableWord/test/PronounceableWord/Tests/LastLettersConsecutiveTypesTest.php new file mode 100644 index 0000000..8200af6 --- /dev/null +++ b/src/backend-libs/gnugat/PronounceableWord/test/PronounceableWord/Tests/LastLettersConsecutiveTypesTest.php @@ -0,0 +1,57 @@ +letterTypesWithLetters as $letterType => $letters) { + $maximumLetterNumber = strlen($letters); + $word = ''; + for ($letterNumber = 1; $letterNumber < $maximumLetterNumber; $letterNumber++) { + $letter = rand(0, strlen($letters) - 1); + $word .= $letters[$letter]; + + $this->assertSame($letterNumber, $lastLettersConsecutiveTypes->countFromWord($word)); + } + } + } + + public function testCountFromWordOfMultipleTypes() { + $letterTypesConfiguration = new PronounceableWord_Configuration_LetterTypes(); + $letterTypes = new PronounceableWord_LetterTypes($letterTypesConfiguration); + $lastLettersConsecutiveTypes = new PronounceableWord_LastLettersConsecutiveTypes($letterTypes); + + foreach ($letterTypesConfiguration->letterTypesWithLetters as $letterType => $letters) { + $maximumLetterNumber = strlen($letters); + + foreach ($letterTypesConfiguration->letterTypesWithLetters as $otherLetterType => $otherLetters) { + if ($otherLetterType != $letterType) { + $word = $otherLetters; + break; + } + } + + for ($letterNumber = 1; $letterNumber < $maximumLetterNumber; $letterNumber++) { + $letter = rand(0, strlen($letters) - 1); + $word .= $letters[$letter]; + + $this->assertSame($letterNumber, $lastLettersConsecutiveTypes->countFromWord($word)); + } + } + } +} + diff --git a/src/backend-libs/gnugat/PronounceableWord/test/PronounceableWord/Tests/LetterTypesTest.php b/src/backend-libs/gnugat/PronounceableWord/test/PronounceableWord/Tests/LetterTypesTest.php new file mode 100644 index 0000000..240d8b5 --- /dev/null +++ b/src/backend-libs/gnugat/PronounceableWord/test/PronounceableWord/Tests/LetterTypesTest.php @@ -0,0 +1,45 @@ +letterTypesWithLetters as $letterType => $letters) { + $maximumLetterIndex = strlen($letters); + for ($letterIndex = 0; $letterIndex < $maximumLetterIndex; $letterIndex++) { + $letter = $letters[$letterIndex]; + + $this->assertSame($letterType, $letterTypes->getLetterType($letter)); + } + } + } + + public function testGetLettersOfGivenType() { + $configuration = new PronounceableWord_Configuration_LetterTypes(); + $letterTypes = new PronounceableWord_LetterTypes($configuration); + + foreach ($configuration->letterTypesWithLetters as $letterType => $letters) { + $this->assertSame($letters, $letterTypes->getLettersOfGivenType($letterType)); + $maximumLetterIndex = strlen($letters); + } + } + + public function testIsThereAtLeastTwoTypes() { + $configuration = new PronounceableWord_Configuration_LetterTypes(); + $minimumLetterTypesNumber = 2; + + $this->assertGreaterThanOrEqual($minimumLetterTypesNumber, $configuration->letterTypesWithLetters); + } +} diff --git a/src/backend-libs/gnugat/PronounceableWord/test/PronounceableWord/Tests/LinkedLettersTest.php b/src/backend-libs/gnugat/PronounceableWord/test/PronounceableWord/Tests/LinkedLettersTest.php new file mode 100644 index 0000000..77cc4a8 --- /dev/null +++ b/src/backend-libs/gnugat/PronounceableWord/test/PronounceableWord/Tests/LinkedLettersTest.php @@ -0,0 +1,68 @@ +pickLetter(); + + $this->assertArrayHasKey($chosenLetter, $configuration->lettersWithLinkedLetters); + } + } + + public function testPickLinkedLetter() { + $configuration = new PronounceableWord_Configuration_LinkedLetters(); + $linkedLetters = new PronounceableWord_LinkedLetters($configuration); + + $maximumTestNumber = 1000; + foreach ($configuration->lettersWithLinkedLetters as $currentLetter => $currentLinkedLetters) { + for ($currentTestNumber = 0; $currentTestNumber < $maximumTestNumber; $currentTestNumber++) { + $chosenLinkedLetter = $linkedLetters->pickLinkedLetter($currentLetter); + + $isChosenLetterInLinkedLetters = strpos($currentLinkedLetters, $chosenLinkedLetter); + + $this->assertNotEquals(false, $isChosenLetterInLinkedLetters); + } + } + } + + public function testPickLinkedLetterDifferentFromGivenLetters() { + $configuration = new PronounceableWord_Configuration_LinkedLetters(); + $linkedLetters = new PronounceableWord_LinkedLetters($configuration); + + $maximumTestNumber = 1000; + foreach ($configuration->lettersWithLinkedLetters as $currentLetter => $currentLinkedLetters) { + for ($currentTestNumber = 0; $currentTestNumber < $maximumTestNumber; $currentTestNumber++) { + $chosenLinkedLetter = $linkedLetters->pickLinkedLetterDifferentFromGivenLetters($currentLetter, $currentLetter); + + $isChosenLetterInLinkedLetters = strpos($currentLinkedLetters, $chosenLinkedLetter); + + $isChosenLetterDifferentThanCurrentLetter = false; + if ($chosenLinkedLetter !== $currentLetter) { + $isChosenLetterDifferentThanCurrentLetter = true; + } + + $isChosenLetterValid = false; + if (false !== $isChosenLetterInLinkedLetters && true === $isChosenLetterDifferentThanCurrentLetter) { + $isChosenLetterValid = true; + } + + $this->assertTrue($isChosenLetterValid); + } + } + } +} diff --git a/src/backend.php b/src/backend.php index fb67dd1..71e08eb 100644 --- a/src/backend.php +++ b/src/backend.php @@ -22,10 +22,10 @@ function error($status, $text) { /** * print all mails for the given $user. - * @param $username string username * @param $address string email address + * @return array */ -function print_emails($username, $address) { +function get_emails($address) { global $mailbox; // Search for mails with the recipient $address in TO or CC. @@ -34,8 +34,7 @@ function print_emails($username, $address) { $mail_ids = array_merge($mailsIdsTo, $mailsIdsCc); $emails = _load_emails($mail_ids, $address); - header('Content-type: application/json'); - print(json_encode(array("mails" => $emails, 'username' => $username, 'address' => $address))); + return $emails; } @@ -126,6 +125,25 @@ function _clean_username($username) { return preg_replace('/[^A-Za-z0-9_.+-]/', "", $username); // remove special characters } +function _clean_domain($username) { + $username = strtolower($username); + $username = preg_replace('/^.*@/', "", $username); // remove part before @ + return preg_replace('/[^A-Za-z0-9_.+-]/', "", $username); // remove special characters +} + +function redirect_to_random($domains) { + $wordLength = rand(3, 8); + $container = new PronounceableWord_DependencyInjectionContainer(); + $generator = $container->getGenerator(); + $word = $generator->generateWordOfGivenLength($wordLength); + $nr = rand(51, 91); + $name = $word . $nr; + + $domain = $domains[array_rand($domains)]; + + header("location: ?address=$name@$domain"); +} + /** * deletes messages older than X days. */ @@ -139,30 +157,11 @@ function delete_old_messages() { $mailbox->expungeDeletedMails(); } -// Never cache requests: -header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -if (isset($_GET['username'])) { - // perform common validation: - $username = _clean_username($_GET['username']); - if (strlen($username) === 0) { - error(400, 'invalid username'); - } - $address = $username . "@" . $config['mailHostname']; - - // simple router: - if (isset($_GET['download_email_id'])) { - download_email($_GET['download_email_id'], $address); - } else if (isset($_GET['delete_email_id'])) { - delete_email($_GET['delete_email_id'], $address); - } else { - print_emails($username, $address); - } -} else { - error(400, 'invalid action'); -} +// +//// Never cache requests: +//header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); +//header("Cache-Control: post-check=0, pre-check=0", false); +//header("Pragma: no-cache"); // run on every request delete_old_messages(); diff --git a/src/client-libs/angular-stickyfill-0.1.0/angular-stickyfill.css b/src/client-libs/angular-stickyfill-0.1.0/angular-stickyfill.css deleted file mode 100755 index 780f0dc..0000000 --- a/src/client-libs/angular-stickyfill-0.1.0/angular-stickyfill.css +++ /dev/null @@ -1,12 +0,0 @@ -[ec-stickyfill] { - position: -webkit-sticky; - position: sticky; - top: 0px; -} - -[ec-stickyfill]:before, -[ec-stickyfill]:after { - content: ''; - display: table; -} - diff --git a/src/client-libs/angular-stickyfill-0.1.0/angular-stickyfill.js b/src/client-libs/angular-stickyfill-0.1.0/angular-stickyfill.js deleted file mode 100755 index 28bbd90..0000000 --- a/src/client-libs/angular-stickyfill-0.1.0/angular-stickyfill.js +++ /dev/null @@ -1,8 +0,0 @@ -/** - * An Angular directive for stickyfill (position sticky polyfill) - * - * @version v0.1.0 - 2016-08-31 - * @author Corey Wilson - * @license Unlicense, http://unlicense.org/ - */ -!function(e,i){"use strict";if("function"==typeof define&&define.amd)define(["angular","stickyfill"],i);else{if("undefined"==typeof module||"object"!=typeof module.exports)return i(e.angular,e.Stickyfill);module.exports=i(require("angular"),require("stickyfill"))}}(window,function(e,i){"use strict";function t(){function e(e,t,n){if("object"!=typeof i)throw new Error("stickyfill.js not loaded");i.add(t[0]),e.$on("$destroy",function(){i.remove(t[0])})}var t={link:e,restrict:"A"};return t}if("function"==typeof i)var i=i();var n="ec.stickyfill";return e.module(n,[]).directive("ecStickyfill",t),n}); diff --git a/src/client-libs/index.js b/src/client-libs/index.js deleted file mode 100644 index e3f30f0..0000000 --- a/src/client-libs/index.js +++ /dev/null @@ -1,137 +0,0 @@ -// config: -var reload_interval_ms = 10000; -var backend_url = './backend.php'; - -function generateRandomUsername() { - var username = ""; - if (chance.bool()) { - username += chance.first(); - if (chance.bool()) { - username += chance.last(); - } - } else { - username += chance.word({syllables: 3}) - } - if (chance.bool()) { - username += chance.integer({min: 30, max: 99}); - } - return username.toLowerCase(); -} - -var app = angular.module('app', ["ngSanitize"]); - -// http://stackoverflow.com/a/20033625/79461 -app.filter("nl2br", function () { - return function (data) { - if (!data) return data; - return data.replace(/\r?\n/g, '
'); - } - } -); - -// http://stackoverflow.com/a/20033625/79461 -app.filter("autolink", function () { - return function (data) { - return Autolinker.link(data, {truncate: {length: 50, location: 'middle', newWindow: true}}); - } -}); - -app.controller('MailboxController', ["$interval", "$http", "$log", function ($interval, $http, $log) { - var self = this; - - self.backend_url = backend_url; - - self.updateUsername = function (username) { - username = username.replace(/[@].*$/, ''); // remove part after "@" - if (self.username !== username) { - // changed - self.username = username; - hasher.setHash(self.username); - - if (self.username.length > 0) { - self.address = self.username; // use username until real address has been loaded - self.updateMails(); - } else { - self.randomize(); - } - } - self.inputFieldUsername = self.username; - }; - - - self.randomize = function () { - self.updateUsername(generateRandomUsername()); - }; - - - self.onHashChange = function (hash) { - self.updateUsername(hash); - }; - - self.$onInit = function () { - hasher.changed.add(self.onHashChange.bind(self)); - hasher.initialized.add(self.onHashChange.bind(self)); //add initialized listener (to grab initial value in case it is already set) - hasher.init(); //initialize hasher (start listening for history changes) - - $interval(self.updateMails, reload_interval_ms); - }; - - self.updateMails = function () { - if (self.username) { - self.loadEmailsAsync(self.username); - } - }; - - self.loadEmailsAsync = function (username) { - $http.get(backend_url, {params: {username: username}}) - .then(function successCallback(response) { - if (response.data.mails) { - self.error = null; - self.mails = response.data.mails; - self.address = response.data.address; - self.username = response.data.username; - if (self.inputFieldUsername === self.username) { - self.inputFieldUsername = self.address; - } - } else { - self.error = { - title: "JSON_ERROR", - desc: "The JSON from the response can not be read.", - detail: response - }; - $log.error(response); - } - }, function errorCallback(response) { - $log.error(response, this); - self.error = { - title: "HTTP_ERROR", - desc: "There is a problem with loading the data. (HTTP_ERROR).", - detail: response - }; - }); - }; - - self.deleteMail = function (mail, index) { - // instantly remove from frontend. - self.mails.splice(index, 1); - - // remove on backend. - var firstTo = Object.keys(mail.to)[0]; - $http.get(backend_url, {params: {username: firstTo, delete_email_id: mail.id}}) - .then( - function successCallback(response) { - self.updateMails(); - }, - function errorCallback(response) { - $log.error(response, this); - self.error = { - title: "HTTP_ERROR", - desc: "There is a problem with deleting the mail. (HTTP_ERROR).", - detail: response - }; - }); - }; - - // Initial load - self.updateMails() -}]); diff --git a/src/config.sample.php b/src/config.sample.php index 9c03143..481e677 100644 --- a/src/config.sample.php +++ b/src/config.sample.php @@ -3,22 +3,20 @@ // set your time zone: date_default_timezone_set('Europe/Paris'); -// enable while testing: -error_reporting(E_ALL); // enable in production: -// error_reporting(0); +error_reporting(0); + +// enable while testing: +//error_reporting(E_ALL); -// configure this option if you want to allow requests from clients from other domains: -// see https://en.wikipedia.org/wiki/Cross-origin_resource_sharing -// header("Access-Control-Allow-Origin: *"); // Change IMAP settings (check SSL flags on http://php.net/manual/en/function.imap-open.php) -$config['imap']['url'] = '{example.com/imap/ssl}INBOX'; -$config['imap']['username'] = "test"; -$config['imap']['password'] = "test"; +$config['imap']['url'] = '{imap.example.com/imap/ssl}INBOX'; +$config['imap']['username'] = "myuser"; +$config['imap']['password'] = "mypassword"; -// email domain, usually different from imap hostname: -$config['mailHostname'] = "example.com"; +// email domains, usually different from imap hostname: +$config['domains'] = array('mydomain.com', 'example.com'); // When to delete old messages? $config['delete_messages_older_than'] = '30 days ago'; \ No newline at end of file diff --git a/src/index.html b/src/index.html deleted file mode 100644 index 1b480f8..0000000 --- a/src/index.html +++ /dev/null @@ -1,150 +0,0 @@ - - - - - Mailbox - - - - - - - - - - - - -
-
-
- -
- - - You have {{$ctrl.mails.length}} mails in your - mailbox: - - -
-
- - -
-
- -
-
-
-
-
- -
-
- - -
-
-
-

Your mailbox {{$ctrl.address}} is ready.

-

Emails will appear here automatically. They will be deleted after 30 days.

-
-
-
-
-
-
-
-
-
-
- -
-
-
- - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/index.php b/src/index.php new file mode 100644 index 0000000..9083226 --- /dev/null +++ b/src/index.php @@ -0,0 +1,240 @@ + + + + + + Mailbox <?php echo $address ?> + + + + + + + + + + + + + + + + + + +
+
+ + change username: + + +
+
+ +
+ +
+
+ +
+ +
+ or   + generate random + +
+
+
+
+
+ + +
+
+ + +
+
+
+

Your mailbox is ready.

+

Emails will appear here automatically. They will be deleted after 30 + days.

+
+
+
+
+
+
+
+
+
+
+ + + + + +
+
+ + \ No newline at end of file diff --git a/src/client-libs/spinner.css b/src/spinner.css similarity index 100% rename from src/client-libs/spinner.css rename to src/spinner.css diff --git a/src/client-libs/style.css b/src/style.css similarity index 71% rename from src/client-libs/style.css rename to src/style.css index 28aa1d2..44f5487 100644 --- a/src/client-libs/style.css +++ b/src/style.css @@ -19,22 +19,18 @@ div.min-height { header { background-color: #D9E2E9; - /* leave some space on top */ + padding-top: 5px; } #openRandomButton { - /* center vertically */ + margin-top: 6px; } .email-table > .email { border-top: 5px solid #7C96AB; - /* idea: card shadow arround: - see https://blog.alexdevero.com/mastering-card-design-with-bootstrap-4/ - box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12); - */ } .header-shadow { @@ -47,7 +43,6 @@ header { background-color: white; } - .waiting-screen { padding: 40px 15px; text-align: center; @@ -57,3 +52,7 @@ div.min-height { min-height: 400px; } +.random-column { + border-left: 1px dashed #333; + +} \ No newline at end of file diff --git a/src/turbolinks.js b/src/turbolinks.js new file mode 100644 index 0000000..4f32e63 --- /dev/null +++ b/src/turbolinks.js @@ -0,0 +1,6 @@ +/* +Turbolinks 5.1.0 +Copyright © 2018 Basecamp, LLC + */ +(function(){this.Turbolinks={supported:function(){return null!=window.history.pushState&&null!=window.requestAnimationFrame&&null!=window.addEventListener}(),visit:function(t,e){return Turbolinks.controller.visit(t,e)},clearCache:function(){return Turbolinks.controller.clearCache()},setProgressBarDelay:function(t){return Turbolinks.controller.setProgressBarDelay(t)}}}).call(this),function(){var t,e,r,n=[].slice;Turbolinks.copyObject=function(t){var e,r,n;r={};for(e in t)n=t[e],r[e]=n;return r},Turbolinks.closest=function(e,r){return t.call(e,r)},t=function(){var t,r;return t=document.documentElement,null!=(r=t.closest)?r:function(t){var r;for(r=this;r;){if(r.nodeType===Node.ELEMENT_NODE&&e.call(r,t))return r;r=r.parentNode}}}(),Turbolinks.defer=function(t){return setTimeout(t,1)},Turbolinks.throttle=function(t){var e;return e=null,function(){var r;return r=1<=arguments.length?n.call(arguments,0):[],null!=e?e:e=requestAnimationFrame(function(n){return function(){return e=null,t.apply(n,r)}}(this))}},Turbolinks.dispatch=function(t,e){var n,o,i,s,a,u;return a=null!=e?e:{},u=a.target,n=a.cancelable,o=a.data,i=document.createEvent("Events"),i.initEvent(t,!0,n===!0),i.data=null!=o?o:{},i.cancelable&&!r&&(s=i.preventDefault,i.preventDefault=function(){return this.defaultPrevented||Object.defineProperty(this,"defaultPrevented",{get:function(){return!0}}),s.call(this)}),(null!=u?u:document).dispatchEvent(i),i},r=function(){var t;return t=document.createEvent("Events"),t.initEvent("test",!0,!0),t.preventDefault(),t.defaultPrevented}(),Turbolinks.match=function(t,r){return e.call(t,r)},e=function(){var t,e,r,n;return t=document.documentElement,null!=(e=null!=(r=null!=(n=t.matchesSelector)?n:t.webkitMatchesSelector)?r:t.msMatchesSelector)?e:t.mozMatchesSelector}(),Turbolinks.uuid=function(){var t,e,r;for(r="",t=e=1;36>=e;t=++e)r+=9===t||14===t||19===t||24===t?"-":15===t?"4":20===t?(Math.floor(4*Math.random())+8).toString(16):Math.floor(15*Math.random()).toString(16);return r}}.call(this),function(){Turbolinks.Location=function(){function t(t){var e,r;null==t&&(t=""),r=document.createElement("a"),r.href=t.toString(),this.absoluteURL=r.href,e=r.hash.length,2>e?this.requestURL=this.absoluteURL:(this.requestURL=this.absoluteURL.slice(0,-e),this.anchor=r.hash.slice(1))}var e,r,n,o;return t.wrap=function(t){return t instanceof this?t:new this(t)},t.prototype.getOrigin=function(){return this.absoluteURL.split("/",3).join("/")},t.prototype.getPath=function(){var t,e;return null!=(t=null!=(e=this.requestURL.match(/\/\/[^\/]*(\/[^?;]*)/))?e[1]:void 0)?t:"/"},t.prototype.getPathComponents=function(){return this.getPath().split("/").slice(1)},t.prototype.getLastPathComponent=function(){return this.getPathComponents().slice(-1)[0]},t.prototype.getExtension=function(){var t,e;return null!=(t=null!=(e=this.getLastPathComponent().match(/\.[^.]*$/))?e[0]:void 0)?t:""},t.prototype.isHTML=function(){return this.getExtension().match(/^(?:|\.(?:htm|html|xhtml))$/)},t.prototype.isPrefixedBy=function(t){var e;return e=r(t),this.isEqualTo(t)||o(this.absoluteURL,e)},t.prototype.isEqualTo=function(t){return this.absoluteURL===(null!=t?t.absoluteURL:void 0)},t.prototype.toCacheKey=function(){return this.requestURL},t.prototype.toJSON=function(){return this.absoluteURL},t.prototype.toString=function(){return this.absoluteURL},t.prototype.valueOf=function(){return this.absoluteURL},r=function(t){return e(t.getOrigin()+t.getPath())},e=function(t){return n(t,"/")?t:t+"/"},o=function(t,e){return t.slice(0,e.length)===e},n=function(t,e){return t.slice(-e.length)===e},t}()}.call(this),function(){var t=function(t,e){return function(){return t.apply(e,arguments)}};Turbolinks.HttpRequest=function(){function e(e,r,n){this.delegate=e,this.requestCanceled=t(this.requestCanceled,this),this.requestTimedOut=t(this.requestTimedOut,this),this.requestFailed=t(this.requestFailed,this),this.requestLoaded=t(this.requestLoaded,this),this.requestProgressed=t(this.requestProgressed,this),this.url=Turbolinks.Location.wrap(r).requestURL,this.referrer=Turbolinks.Location.wrap(n).absoluteURL,this.createXHR()}return e.NETWORK_FAILURE=0,e.TIMEOUT_FAILURE=-1,e.timeout=60,e.prototype.send=function(){var t;return this.xhr&&!this.sent?(this.notifyApplicationBeforeRequestStart(),this.setProgress(0),this.xhr.send(),this.sent=!0,"function"==typeof(t=this.delegate).requestStarted?t.requestStarted():void 0):void 0},e.prototype.cancel=function(){return this.xhr&&this.sent?this.xhr.abort():void 0},e.prototype.requestProgressed=function(t){return t.lengthComputable?this.setProgress(t.loaded/t.total):void 0},e.prototype.requestLoaded=function(){return this.endRequest(function(t){return function(){var e;return 200<=(e=t.xhr.status)&&300>e?t.delegate.requestCompletedWithResponse(t.xhr.responseText,t.xhr.getResponseHeader("Turbolinks-Location")):(t.failed=!0,t.delegate.requestFailedWithStatusCode(t.xhr.status,t.xhr.responseText))}}(this))},e.prototype.requestFailed=function(){return this.endRequest(function(t){return function(){return t.failed=!0,t.delegate.requestFailedWithStatusCode(t.constructor.NETWORK_FAILURE)}}(this))},e.prototype.requestTimedOut=function(){return this.endRequest(function(t){return function(){return t.failed=!0,t.delegate.requestFailedWithStatusCode(t.constructor.TIMEOUT_FAILURE)}}(this))},e.prototype.requestCanceled=function(){return this.endRequest()},e.prototype.notifyApplicationBeforeRequestStart=function(){return Turbolinks.dispatch("turbolinks:request-start",{data:{url:this.url,xhr:this.xhr}})},e.prototype.notifyApplicationAfterRequestEnd=function(){return Turbolinks.dispatch("turbolinks:request-end",{data:{url:this.url,xhr:this.xhr}})},e.prototype.createXHR=function(){return this.xhr=new XMLHttpRequest,this.xhr.open("GET",this.url,!0),this.xhr.timeout=1e3*this.constructor.timeout,this.xhr.setRequestHeader("Accept","text/html, application/xhtml+xml"),this.xhr.setRequestHeader("Turbolinks-Referrer",this.referrer),this.xhr.onprogress=this.requestProgressed,this.xhr.onload=this.requestLoaded,this.xhr.onerror=this.requestFailed,this.xhr.ontimeout=this.requestTimedOut,this.xhr.onabort=this.requestCanceled},e.prototype.endRequest=function(t){return this.xhr?(this.notifyApplicationAfterRequestEnd(),null!=t&&t.call(this),this.destroy()):void 0},e.prototype.setProgress=function(t){var e;return this.progress=t,"function"==typeof(e=this.delegate).requestProgressed?e.requestProgressed(this.progress):void 0},e.prototype.destroy=function(){var t;return this.setProgress(1),"function"==typeof(t=this.delegate).requestFinished&&t.requestFinished(),this.delegate=null,this.xhr=null},e}()}.call(this),function(){var t=function(t,e){return function(){return t.apply(e,arguments)}};Turbolinks.ProgressBar=function(){function e(){this.trickle=t(this.trickle,this),this.stylesheetElement=this.createStylesheetElement(),this.progressElement=this.createProgressElement()}var r;return r=300,e.defaultCSS=".turbolinks-progress-bar {\n position: fixed;\n display: block;\n top: 0;\n left: 0;\n height: 3px;\n background: #0076ff;\n z-index: 9999;\n transition: width "+r+"ms ease-out, opacity "+r/2+"ms "+r/2+"ms ease-in;\n transform: translate3d(0, 0, 0);\n}",e.prototype.show=function(){return this.visible?void 0:(this.visible=!0,this.installStylesheetElement(),this.installProgressElement(),this.startTrickling())},e.prototype.hide=function(){return this.visible&&!this.hiding?(this.hiding=!0,this.fadeProgressElement(function(t){return function(){return t.uninstallProgressElement(),t.stopTrickling(),t.visible=!1,t.hiding=!1}}(this))):void 0},e.prototype.setValue=function(t){return this.value=t,this.refresh()},e.prototype.installStylesheetElement=function(){return document.head.insertBefore(this.stylesheetElement,document.head.firstChild)},e.prototype.installProgressElement=function(){return this.progressElement.style.width=0,this.progressElement.style.opacity=1,document.documentElement.insertBefore(this.progressElement,document.body),this.refresh()},e.prototype.fadeProgressElement=function(t){return this.progressElement.style.opacity=0,setTimeout(t,1.5*r)},e.prototype.uninstallProgressElement=function(){return this.progressElement.parentNode?document.documentElement.removeChild(this.progressElement):void 0},e.prototype.startTrickling=function(){return null!=this.trickleInterval?this.trickleInterval:this.trickleInterval=setInterval(this.trickle,r)},e.prototype.stopTrickling=function(){return clearInterval(this.trickleInterval),this.trickleInterval=null},e.prototype.trickle=function(){return this.setValue(this.value+Math.random()/100)},e.prototype.refresh=function(){return requestAnimationFrame(function(t){return function(){return t.progressElement.style.width=10+90*t.value+"%"}}(this))},e.prototype.createStylesheetElement=function(){var t;return t=document.createElement("style"),t.type="text/css",t.textContent=this.constructor.defaultCSS,t},e.prototype.createProgressElement=function(){var t;return t=document.createElement("div"),t.className="turbolinks-progress-bar",t},e}()}.call(this),function(){var t=function(t,e){return function(){return t.apply(e,arguments)}};Turbolinks.BrowserAdapter=function(){function e(e){this.controller=e,this.showProgressBar=t(this.showProgressBar,this),this.progressBar=new Turbolinks.ProgressBar}var r,n,o;return o=Turbolinks.HttpRequest,r=o.NETWORK_FAILURE,n=o.TIMEOUT_FAILURE,e.prototype.visitProposedToLocationWithAction=function(t,e){return this.controller.startVisitToLocationWithAction(t,e)},e.prototype.visitStarted=function(t){return t.issueRequest(),t.changeHistory(),t.loadCachedSnapshot()},e.prototype.visitRequestStarted=function(t){return this.progressBar.setValue(0),t.hasCachedSnapshot()||"restore"!==t.action?this.showProgressBarAfterDelay():this.showProgressBar()},e.prototype.visitRequestProgressed=function(t){return this.progressBar.setValue(t.progress)},e.prototype.visitRequestCompleted=function(t){return t.loadResponse()},e.prototype.visitRequestFailedWithStatusCode=function(t,e){switch(e){case r:case n:return this.reload();default:return t.loadResponse()}},e.prototype.visitRequestFinished=function(t){return this.hideProgressBar()},e.prototype.visitCompleted=function(t){return t.followRedirect()},e.prototype.pageInvalidated=function(){return this.reload()},e.prototype.showProgressBarAfterDelay=function(){return this.progressBarTimeout=setTimeout(this.showProgressBar,this.controller.progressBarDelay)},e.prototype.showProgressBar=function(){return this.progressBar.show()},e.prototype.hideProgressBar=function(){return this.progressBar.hide(),clearTimeout(this.progressBarTimeout)},e.prototype.reload=function(){return window.location.reload()},e}()}.call(this),function(){var t=function(t,e){return function(){return t.apply(e,arguments)}};Turbolinks.History=function(){function e(e){this.delegate=e,this.onPageLoad=t(this.onPageLoad,this),this.onPopState=t(this.onPopState,this)}return e.prototype.start=function(){return this.started?void 0:(addEventListener("popstate",this.onPopState,!1),addEventListener("load",this.onPageLoad,!1),this.started=!0)},e.prototype.stop=function(){return this.started?(removeEventListener("popstate",this.onPopState,!1),removeEventListener("load",this.onPageLoad,!1),this.started=!1):void 0},e.prototype.push=function(t,e){return t=Turbolinks.Location.wrap(t),this.update("push",t,e)},e.prototype.replace=function(t,e){return t=Turbolinks.Location.wrap(t),this.update("replace",t,e)},e.prototype.onPopState=function(t){var e,r,n,o;return this.shouldHandlePopState()&&(o=null!=(r=t.state)?r.turbolinks:void 0)?(e=Turbolinks.Location.wrap(window.location),n=o.restorationIdentifier,this.delegate.historyPoppedToLocationWithRestorationIdentifier(e,n)):void 0},e.prototype.onPageLoad=function(t){return Turbolinks.defer(function(t){return function(){return t.pageLoaded=!0}}(this))},e.prototype.shouldHandlePopState=function(){return this.pageIsLoaded()},e.prototype.pageIsLoaded=function(){return this.pageLoaded||"complete"===document.readyState},e.prototype.update=function(t,e,r){var n;return n={turbolinks:{restorationIdentifier:r}},history[t+"State"](n,null,e)},e}()}.call(this),function(){Turbolinks.Snapshot=function(){function t(t){var e,r;r=t.head,e=t.body,this.head=null!=r?r:document.createElement("head"),this.body=null!=e?e:document.createElement("body")}return t.wrap=function(t){return t instanceof this?t:this.fromHTML(t)},t.fromHTML=function(t){var e;return e=document.createElement("html"),e.innerHTML=t,this.fromElement(e)},t.fromElement=function(t){return new this({head:t.querySelector("head"),body:t.querySelector("body")})},t.prototype.clone=function(){return new t({head:this.head.cloneNode(!0),body:this.body.cloneNode(!0)})},t.prototype.getRootLocation=function(){var t,e;return e=null!=(t=this.getSetting("root"))?t:"/",new Turbolinks.Location(e)},t.prototype.getCacheControlValue=function(){return this.getSetting("cache-control")},t.prototype.getElementForAnchor=function(t){try{return this.body.querySelector("[id='"+t+"'], a[name='"+t+"']")}catch(e){}},t.prototype.hasAnchor=function(t){return null!=this.getElementForAnchor(t)},t.prototype.isPreviewable=function(){return"no-preview"!==this.getCacheControlValue()},t.prototype.isCacheable=function(){return"no-cache"!==this.getCacheControlValue()},t.prototype.isVisitable=function(){return"reload"!==this.getSetting("visit-control")},t.prototype.getSetting=function(t){var e,r;return r=this.head.querySelectorAll("meta[name='turbolinks-"+t+"']"),e=r[r.length-1],null!=e?e.getAttribute("content"):void 0},t}()}.call(this),function(){var t=[].slice;Turbolinks.Renderer=function(){function e(){}var r;return e.render=function(){var e,r,n,o;return n=arguments[0],r=arguments[1],e=3<=arguments.length?t.call(arguments,2):[],o=function(t,e,r){r.prototype=t.prototype;var n=new r,o=t.apply(n,e);return Object(o)===o?o:n}(this,e,function(){}),o.delegate=n,o.render(r),o},e.prototype.renderView=function(t){return this.delegate.viewWillRender(this.newBody),t(),this.delegate.viewRendered(this.newBody)},e.prototype.invalidateView=function(){return this.delegate.viewInvalidated()},e.prototype.createScriptElement=function(t){var e;return"false"===t.getAttribute("data-turbolinks-eval")?t:(e=document.createElement("script"),e.textContent=t.textContent,e.async=!1,r(e,t),e)},r=function(t,e){var r,n,o,i,s,a,u;for(i=e.attributes,a=[],r=0,n=i.length;n>r;r++)s=i[r],o=s.name,u=s.value,a.push(t.setAttribute(o,u));return a},e}()}.call(this),function(){Turbolinks.HeadDetails=function(){function t(t){var e,r,i,s,a,u,l;for(this.element=t,this.elements={},l=this.element.childNodes,s=0,u=l.length;u>s;s++)i=l[s],i.nodeType===Node.ELEMENT_NODE&&(a=i.outerHTML,r=null!=(e=this.elements)[a]?e[a]:e[a]={type:o(i),tracked:n(i),elements:[]},r.elements.push(i))}var e,r,n,o;return t.prototype.hasElementWithKey=function(t){return t in this.elements},t.prototype.getTrackedElementSignature=function(){var t,e;return function(){var r,n;r=this.elements,n=[];for(t in r)e=r[t].tracked,e&&n.push(t);return n}.call(this).join("")},t.prototype.getScriptElementsNotInDetails=function(t){return this.getElementsMatchingTypeNotInDetails("script",t)},t.prototype.getStylesheetElementsNotInDetails=function(t){return this.getElementsMatchingTypeNotInDetails("stylesheet",t)},t.prototype.getElementsMatchingTypeNotInDetails=function(t,e){var r,n,o,i,s,a;o=this.elements,s=[];for(n in o)i=o[n],a=i.type,r=i.elements,a!==t||e.hasElementWithKey(n)||s.push(r[0]);return s},t.prototype.getProvisionalElements=function(){var t,e,r,n,o,i,s;r=[],n=this.elements;for(e in n)o=n[e],s=o.type,i=o.tracked,t=o.elements,null!=s||i?t.length>1&&r.push.apply(r,t.slice(1)):r.push.apply(r,t);return r},o=function(t){return e(t)?"script":r(t)?"stylesheet":void 0},n=function(t){return"reload"===t.getAttribute("data-turbolinks-track")},e=function(t){var e;return e=t.tagName.toLowerCase(),"script"===e},r=function(t){var e;return e=t.tagName.toLowerCase(),"style"===e||"link"===e&&"stylesheet"===t.getAttribute("rel")},t}()}.call(this),function(){var t=function(t,r){function n(){this.constructor=t}for(var o in r)e.call(r,o)&&(t[o]=r[o]);return n.prototype=r.prototype,t.prototype=new n,t.__super__=r.prototype,t},e={}.hasOwnProperty;Turbolinks.SnapshotRenderer=function(e){function r(t,e,r){this.currentSnapshot=t,this.newSnapshot=e,this.isPreview=r,this.currentHeadDetails=new Turbolinks.HeadDetails(this.currentSnapshot.head),this.newHeadDetails=new Turbolinks.HeadDetails(this.newSnapshot.head),this.newBody=this.newSnapshot.body}return t(r,e),r.prototype.render=function(t){return this.shouldRender()?(this.mergeHead(),this.renderView(function(e){return function(){return e.replaceBody(),e.isPreview||e.focusFirstAutofocusableElement(),t()}}(this))):this.invalidateView()},r.prototype.mergeHead=function(){return this.copyNewHeadStylesheetElements(),this.copyNewHeadScriptElements(),this.removeCurrentHeadProvisionalElements(),this.copyNewHeadProvisionalElements()},r.prototype.replaceBody=function(){return this.activateBodyScriptElements(),this.importBodyPermanentElements(),this.assignNewBody()},r.prototype.shouldRender=function(){return this.newSnapshot.isVisitable()&&this.trackedElementsAreIdentical()},r.prototype.trackedElementsAreIdentical=function(){return this.currentHeadDetails.getTrackedElementSignature()===this.newHeadDetails.getTrackedElementSignature()},r.prototype.copyNewHeadStylesheetElements=function(){var t,e,r,n,o;for(n=this.getNewHeadStylesheetElements(),o=[],e=0,r=n.length;r>e;e++)t=n[e],o.push(document.head.appendChild(t));return o},r.prototype.copyNewHeadScriptElements=function(){var t,e,r,n,o;for(n=this.getNewHeadScriptElements(),o=[],e=0,r=n.length;r>e;e++)t=n[e],o.push(document.head.appendChild(this.createScriptElement(t)));return o},r.prototype.removeCurrentHeadProvisionalElements=function(){var t,e,r,n,o;for(n=this.getCurrentHeadProvisionalElements(),o=[],e=0,r=n.length;r>e;e++)t=n[e],o.push(document.head.removeChild(t));return o},r.prototype.copyNewHeadProvisionalElements=function(){var t,e,r,n,o;for(n=this.getNewHeadProvisionalElements(),o=[],e=0,r=n.length;r>e;e++)t=n[e],o.push(document.head.appendChild(t));return o},r.prototype.importBodyPermanentElements=function(){var t,e,r,n,o,i;for(n=this.getNewBodyPermanentElements(),i=[],e=0,r=n.length;r>e;e++)o=n[e],(t=this.findCurrentBodyPermanentElement(o))?i.push(o.parentNode.replaceChild(t,o)):i.push(void 0);return i},r.prototype.activateBodyScriptElements=function(){var t,e,r,n,o,i;for(n=this.getNewBodyScriptElements(),i=[],e=0,r=n.length;r>e;e++)o=n[e],t=this.createScriptElement(o),i.push(o.parentNode.replaceChild(t,o));return i},r.prototype.assignNewBody=function(){return document.body=this.newBody},r.prototype.focusFirstAutofocusableElement=function(){var t;return null!=(t=this.findFirstAutofocusableElement())?t.focus():void 0},r.prototype.getNewHeadStylesheetElements=function(){return this.newHeadDetails.getStylesheetElementsNotInDetails(this.currentHeadDetails)},r.prototype.getNewHeadScriptElements=function(){return this.newHeadDetails.getScriptElementsNotInDetails(this.currentHeadDetails)},r.prototype.getCurrentHeadProvisionalElements=function(){return this.currentHeadDetails.getProvisionalElements()},r.prototype.getNewHeadProvisionalElements=function(){return this.newHeadDetails.getProvisionalElements()},r.prototype.getNewBodyPermanentElements=function(){return this.newBody.querySelectorAll("[id][data-turbolinks-permanent]")},r.prototype.findCurrentBodyPermanentElement=function(t){return document.body.querySelector("#"+t.id+"[data-turbolinks-permanent]")},r.prototype.getNewBodyScriptElements=function(){return this.newBody.querySelectorAll("script")},r.prototype.findFirstAutofocusableElement=function(){return document.body.querySelector("[autofocus]")},r}(Turbolinks.Renderer)}.call(this),function(){var t=function(t,r){function n(){this.constructor=t}for(var o in r)e.call(r,o)&&(t[o]=r[o]);return n.prototype=r.prototype,t.prototype=new n,t.__super__=r.prototype,t},e={}.hasOwnProperty;Turbolinks.ErrorRenderer=function(e){function r(t){this.html=t}return t(r,e),r.prototype.render=function(t){return this.renderView(function(e){return function(){return e.replaceDocumentHTML(),e.activateBodyScriptElements(),t()}}(this))},r.prototype.replaceDocumentHTML=function(){return document.documentElement.innerHTML=this.html},r.prototype.activateBodyScriptElements=function(){var t,e,r,n,o,i;for(n=this.getScriptElements(),i=[],e=0,r=n.length;r>e;e++)o=n[e],t=this.createScriptElement(o),i.push(o.parentNode.replaceChild(t,o));return i},r.prototype.getScriptElements=function(){return document.documentElement.querySelectorAll("script")},r}(Turbolinks.Renderer)}.call(this),function(){Turbolinks.View=function(){function t(t){this.delegate=t,this.element=document.documentElement}return t.prototype.getRootLocation=function(){return this.getSnapshot().getRootLocation()},t.prototype.getElementForAnchor=function(t){return this.getSnapshot().getElementForAnchor(t)},t.prototype.getSnapshot=function(){return Turbolinks.Snapshot.fromElement(this.element)},t.prototype.render=function(t,e){var r,n,o;return o=t.snapshot,r=t.error,n=t.isPreview,this.markAsPreview(n),null!=o?this.renderSnapshot(o,n,e):this.renderError(r,e)},t.prototype.markAsPreview=function(t){return t?this.element.setAttribute("data-turbolinks-preview",""):this.element.removeAttribute("data-turbolinks-preview")},t.prototype.renderSnapshot=function(t,e,r){return Turbolinks.SnapshotRenderer.render(this.delegate,r,this.getSnapshot(),Turbolinks.Snapshot.wrap(t),e)},t.prototype.renderError=function(t,e){return Turbolinks.ErrorRenderer.render(this.delegate,e,t)},t}()}.call(this),function(){var t=function(t,e){return function(){return t.apply(e,arguments)}};Turbolinks.ScrollManager=function(){function e(e){this.delegate=e,this.onScroll=t(this.onScroll,this),this.onScroll=Turbolinks.throttle(this.onScroll)}return e.prototype.start=function(){return this.started?void 0:(addEventListener("scroll",this.onScroll,!1),this.onScroll(),this.started=!0)},e.prototype.stop=function(){return this.started?(removeEventListener("scroll",this.onScroll,!1),this.started=!1):void 0},e.prototype.scrollToElement=function(t){return t.scrollIntoView()},e.prototype.scrollToPosition=function(t){var e,r;return e=t.x,r=t.y,window.scrollTo(e,r)},e.prototype.onScroll=function(t){return this.updatePosition({x:window.pageXOffset,y:window.pageYOffset})},e.prototype.updatePosition=function(t){var e;return this.position=t,null!=(e=this.delegate)?e.scrollPositionChanged(this.position):void 0},e}()}.call(this),function(){Turbolinks.SnapshotCache=function(){function t(t){this.size=t,this.keys=[],this.snapshots={}}var e;return t.prototype.has=function(t){var r;return r=e(t),r in this.snapshots},t.prototype.get=function(t){var e;if(this.has(t))return e=this.read(t),this.touch(t),e},t.prototype.put=function(t,e){return this.write(t,e),this.touch(t),e},t.prototype.read=function(t){var r;return r=e(t),this.snapshots[r]},t.prototype.write=function(t,r){var n;return n=e(t),this.snapshots[n]=r},t.prototype.touch=function(t){var r,n;return n=e(t),r=this.keys.indexOf(n),r>-1&&this.keys.splice(r,1),this.keys.unshift(n),this.trim()},t.prototype.trim=function(){var t,e,r,n,o;for(n=this.keys.splice(this.size),o=[],t=0,r=n.length;r>t;t++)e=n[t],o.push(delete this.snapshots[e]);return o},e=function(t){return Turbolinks.Location.wrap(t).toCacheKey()},t}()}.call(this),function(){var t=function(t,e){return function(){return t.apply(e,arguments)}};Turbolinks.Visit=function(){function e(e,r,n){this.controller=e,this.action=n,this.performScroll=t(this.performScroll,this),this.identifier=Turbolinks.uuid(),this.location=Turbolinks.Location.wrap(r),this.adapter=this.controller.adapter,this.state="initialized",this.timingMetrics={}}var r;return e.prototype.start=function(){return"initialized"===this.state?(this.recordTimingMetric("visitStart"),this.state="started",this.adapter.visitStarted(this)):void 0},e.prototype.cancel=function(){var t;return"started"===this.state?(null!=(t=this.request)&&t.cancel(),this.cancelRender(),this.state="canceled"):void 0},e.prototype.complete=function(){var t;return"started"===this.state?(this.recordTimingMetric("visitEnd"),this.state="completed","function"==typeof(t=this.adapter).visitCompleted&&t.visitCompleted(this),this.controller.visitCompleted(this)):void 0},e.prototype.fail=function(){var t;return"started"===this.state?(this.state="failed","function"==typeof(t=this.adapter).visitFailed?t.visitFailed(this):void 0):void 0},e.prototype.changeHistory=function(){var t,e;return this.historyChanged?void 0:(t=this.location.isEqualTo(this.referrer)?"replace":this.action,e=r(t),this.controller[e](this.location,this.restorationIdentifier),this.historyChanged=!0)},e.prototype.issueRequest=function(){return this.shouldIssueRequest()&&null==this.request?(this.progress=0,this.request=new Turbolinks.HttpRequest(this,this.location,this.referrer),this.request.send()):void 0},e.prototype.getCachedSnapshot=function(){var t;return!(t=this.controller.getCachedSnapshotForLocation(this.location))||null!=this.location.anchor&&!t.hasAnchor(this.location.anchor)||"restore"!==this.action&&!t.isPreviewable()?void 0:t},e.prototype.hasCachedSnapshot=function(){return null!=this.getCachedSnapshot()},e.prototype.loadCachedSnapshot=function(){var t,e;return(e=this.getCachedSnapshot())?(t=this.shouldIssueRequest(),this.render(function(){var r;return this.cacheSnapshot(),this.controller.render({snapshot:e,isPreview:t},this.performScroll),"function"==typeof(r=this.adapter).visitRendered&&r.visitRendered(this),t?void 0:this.complete()})):void 0},e.prototype.loadResponse=function(){return null!=this.response?this.render(function(){var t,e;return this.cacheSnapshot(),this.request.failed?(this.controller.render({error:this.response},this.performScroll),"function"==typeof(t=this.adapter).visitRendered&&t.visitRendered(this),this.fail()):(this.controller.render({snapshot:this.response},this.performScroll),"function"==typeof(e=this.adapter).visitRendered&&e.visitRendered(this),this.complete())}):void 0},e.prototype.followRedirect=function(){return this.redirectedToLocation&&!this.followedRedirect?(this.location=this.redirectedToLocation,this.controller.replaceHistoryWithLocationAndRestorationIdentifier(this.redirectedToLocation,this.restorationIdentifier),this.followedRedirect=!0):void 0},e.prototype.requestStarted=function(){var t;return this.recordTimingMetric("requestStart"),"function"==typeof(t=this.adapter).visitRequestStarted?t.visitRequestStarted(this):void 0},e.prototype.requestProgressed=function(t){var e;return this.progress=t,"function"==typeof(e=this.adapter).visitRequestProgressed?e.visitRequestProgressed(this):void 0},e.prototype.requestCompletedWithResponse=function(t,e){return this.response=t,null!=e&&(this.redirectedToLocation=Turbolinks.Location.wrap(e)),this.adapter.visitRequestCompleted(this)},e.prototype.requestFailedWithStatusCode=function(t,e){return this.response=e,this.adapter.visitRequestFailedWithStatusCode(this,t)},e.prototype.requestFinished=function(){var t;return this.recordTimingMetric("requestEnd"),"function"==typeof(t=this.adapter).visitRequestFinished?t.visitRequestFinished(this):void 0},e.prototype.performScroll=function(){return this.scrolled?void 0:("restore"===this.action?this.scrollToRestoredPosition()||this.scrollToTop():this.scrollToAnchor()||this.scrollToTop(),this.scrolled=!0)},e.prototype.scrollToRestoredPosition=function(){var t,e;return t=null!=(e=this.restorationData)?e.scrollPosition:void 0,null!=t?(this.controller.scrollToPosition(t),!0):void 0},e.prototype.scrollToAnchor=function(){return null!=this.location.anchor?(this.controller.scrollToAnchor(this.location.anchor),!0):void 0},e.prototype.scrollToTop=function(){return this.controller.scrollToPosition({x:0,y:0})},e.prototype.recordTimingMetric=function(t){var e;return null!=(e=this.timingMetrics)[t]?e[t]:e[t]=(new Date).getTime()},e.prototype.getTimingMetrics=function(){return Turbolinks.copyObject(this.timingMetrics)},r=function(t){switch(t){case"replace":return"replaceHistoryWithLocationAndRestorationIdentifier";case"advance":case"restore":return"pushHistoryWithLocationAndRestorationIdentifier"}},e.prototype.shouldIssueRequest=function(){return"restore"===this.action?!this.hasCachedSnapshot():!0},e.prototype.cacheSnapshot=function(){return this.snapshotCached?void 0:(this.controller.cacheSnapshot(),this.snapshotCached=!0)},e.prototype.render=function(t){return this.cancelRender(),this.frame=requestAnimationFrame(function(e){return function(){return e.frame=null,t.call(e)}}(this))},e.prototype.cancelRender=function(){return this.frame?cancelAnimationFrame(this.frame):void 0},e}()}.call(this),function(){var t=function(t,e){return function(){return t.apply(e,arguments)}};Turbolinks.Controller=function(){function e(){this.clickBubbled=t(this.clickBubbled,this),this.clickCaptured=t(this.clickCaptured,this),this.pageLoaded=t(this.pageLoaded,this),this.history=new Turbolinks.History(this),this.view=new Turbolinks.View(this),this.scrollManager=new Turbolinks.ScrollManager(this),this.restorationData={},this.clearCache(),this.setProgressBarDelay(500)}return e.prototype.start=function(){return Turbolinks.supported&&!this.started?(addEventListener("click",this.clickCaptured,!0),addEventListener("DOMContentLoaded",this.pageLoaded,!1),this.scrollManager.start(),this.startHistory(),this.started=!0,this.enabled=!0):void 0},e.prototype.disable=function(){return this.enabled=!1},e.prototype.stop=function(){return this.started?(removeEventListener("click",this.clickCaptured,!0),removeEventListener("DOMContentLoaded",this.pageLoaded,!1),this.scrollManager.stop(),this.stopHistory(),this.started=!1):void 0},e.prototype.clearCache=function(){return this.cache=new Turbolinks.SnapshotCache(10)},e.prototype.visit=function(t,e){var r,n;return null==e&&(e={}),t=Turbolinks.Location.wrap(t),this.applicationAllowsVisitingLocation(t)?this.locationIsVisitable(t)?(r=null!=(n=e.action)?n:"advance",this.adapter.visitProposedToLocationWithAction(t,r)):window.location=t:void 0},e.prototype.startVisitToLocationWithAction=function(t,e,r){var n;return Turbolinks.supported?(n=this.getRestorationDataForIdentifier(r),this.startVisit(t,e,{restorationData:n})):window.location=t},e.prototype.setProgressBarDelay=function(t){return this.progressBarDelay=t},e.prototype.startHistory=function(){return this.location=Turbolinks.Location.wrap(window.location),this.restorationIdentifier=Turbolinks.uuid(),this.history.start(),this.history.replace(this.location,this.restorationIdentifier)},e.prototype.stopHistory=function(){return this.history.stop()},e.prototype.pushHistoryWithLocationAndRestorationIdentifier=function(t,e){return this.restorationIdentifier=e,this.location=Turbolinks.Location.wrap(t),this.history.push(this.location,this.restorationIdentifier)},e.prototype.replaceHistoryWithLocationAndRestorationIdentifier=function(t,e){return this.restorationIdentifier=e,this.location=Turbolinks.Location.wrap(t),this.history.replace(this.location,this.restorationIdentifier)},e.prototype.historyPoppedToLocationWithRestorationIdentifier=function(t,e){var r;return this.restorationIdentifier=e,this.enabled?(r=this.getRestorationDataForIdentifier(this.restorationIdentifier),this.startVisit(t,"restore",{restorationIdentifier:this.restorationIdentifier,restorationData:r,historyChanged:!0}),this.location=Turbolinks.Location.wrap(t)):this.adapter.pageInvalidated()},e.prototype.getCachedSnapshotForLocation=function(t){var e;return e=this.cache.get(t),e?e.clone():void 0},e.prototype.shouldCacheSnapshot=function(){return this.view.getSnapshot().isCacheable()},e.prototype.cacheSnapshot=function(){var t;return this.shouldCacheSnapshot()?(this.notifyApplicationBeforeCachingSnapshot(),t=this.view.getSnapshot(),this.cache.put(this.lastRenderedLocation,t.clone())):void 0},e.prototype.scrollToAnchor=function(t){var e;return(e=this.view.getElementForAnchor(t))?this.scrollToElement(e):this.scrollToPosition({x:0,y:0})},e.prototype.scrollToElement=function(t){return this.scrollManager.scrollToElement(t)},e.prototype.scrollToPosition=function(t){return this.scrollManager.scrollToPosition(t)},e.prototype.scrollPositionChanged=function(t){var e;return e=this.getCurrentRestorationData(),e.scrollPosition=t},e.prototype.render=function(t,e){return this.view.render(t,e)},e.prototype.viewInvalidated=function(){return this.adapter.pageInvalidated()},e.prototype.viewWillRender=function(t){return this.notifyApplicationBeforeRender(t)},e.prototype.viewRendered=function(){return this.lastRenderedLocation=this.currentVisit.location,this.notifyApplicationAfterRender()},e.prototype.pageLoaded=function(){ +return this.lastRenderedLocation=this.location,this.notifyApplicationAfterPageLoad()},e.prototype.clickCaptured=function(){return removeEventListener("click",this.clickBubbled,!1),addEventListener("click",this.clickBubbled,!1)},e.prototype.clickBubbled=function(t){var e,r,n;return this.enabled&&this.clickEventIsSignificant(t)&&(r=this.getVisitableLinkForNode(t.target))&&(n=this.getVisitableLocationForLink(r))&&this.applicationAllowsFollowingLinkToLocation(r,n)?(t.preventDefault(),e=this.getActionForLink(r),this.visit(n,{action:e})):void 0},e.prototype.applicationAllowsFollowingLinkToLocation=function(t,e){var r;return r=this.notifyApplicationAfterClickingLinkToLocation(t,e),!r.defaultPrevented},e.prototype.applicationAllowsVisitingLocation=function(t){var e;return e=this.notifyApplicationBeforeVisitingLocation(t),!e.defaultPrevented},e.prototype.notifyApplicationAfterClickingLinkToLocation=function(t,e){return Turbolinks.dispatch("turbolinks:click",{target:t,data:{url:e.absoluteURL},cancelable:!0})},e.prototype.notifyApplicationBeforeVisitingLocation=function(t){return Turbolinks.dispatch("turbolinks:before-visit",{data:{url:t.absoluteURL},cancelable:!0})},e.prototype.notifyApplicationAfterVisitingLocation=function(t){return Turbolinks.dispatch("turbolinks:visit",{data:{url:t.absoluteURL}})},e.prototype.notifyApplicationBeforeCachingSnapshot=function(){return Turbolinks.dispatch("turbolinks:before-cache")},e.prototype.notifyApplicationBeforeRender=function(t){return Turbolinks.dispatch("turbolinks:before-render",{data:{newBody:t}})},e.prototype.notifyApplicationAfterRender=function(){return Turbolinks.dispatch("turbolinks:render")},e.prototype.notifyApplicationAfterPageLoad=function(t){return null==t&&(t={}),Turbolinks.dispatch("turbolinks:load",{data:{url:this.location.absoluteURL,timing:t}})},e.prototype.startVisit=function(t,e,r){var n;return null!=(n=this.currentVisit)&&n.cancel(),this.currentVisit=this.createVisit(t,e,r),this.currentVisit.start(),this.notifyApplicationAfterVisitingLocation(t)},e.prototype.createVisit=function(t,e,r){var n,o,i,s,a;return o=null!=r?r:{},s=o.restorationIdentifier,i=o.restorationData,n=o.historyChanged,a=new Turbolinks.Visit(this,t,e),a.restorationIdentifier=null!=s?s:Turbolinks.uuid(),a.restorationData=Turbolinks.copyObject(i),a.historyChanged=n,a.referrer=this.location,a},e.prototype.visitCompleted=function(t){return this.notifyApplicationAfterPageLoad(t.getTimingMetrics())},e.prototype.clickEventIsSignificant=function(t){return!(t.defaultPrevented||t.target.isContentEditable||t.which>1||t.altKey||t.ctrlKey||t.metaKey||t.shiftKey)},e.prototype.getVisitableLinkForNode=function(t){return this.nodeIsVisitable(t)?Turbolinks.closest(t,"a[href]:not([target]):not([download])"):void 0},e.prototype.getVisitableLocationForLink=function(t){var e;return e=new Turbolinks.Location(t.getAttribute("href")),this.locationIsVisitable(e)?e:void 0},e.prototype.getActionForLink=function(t){var e;return null!=(e=t.getAttribute("data-turbolinks-action"))?e:"advance"},e.prototype.nodeIsVisitable=function(t){var e;return(e=Turbolinks.closest(t,"[data-turbolinks]"))?"false"!==e.getAttribute("data-turbolinks"):!0},e.prototype.locationIsVisitable=function(t){return t.isPrefixedBy(this.view.getRootLocation())&&t.isHTML()},e.prototype.getCurrentRestorationData=function(){return this.getRestorationDataForIdentifier(this.restorationIdentifier)},e.prototype.getRestorationDataForIdentifier=function(t){var e;return null!=(e=this.restorationData)[t]?e[t]:e[t]={}},e}()}.call(this),function(){!function(){var t,e;if((t=e=document.currentScript)&&!e.hasAttribute("data-turbolinks-suppress-warning"))for(;t=t.parentNode;)if(t===document.body)return console.warn("You are loading Turbolinks from a