├── .gitignore ├── routing.yml ├── package.json ├── gulpfile.js ├── Controller └── UserChatController.php ├── README.md ├── Plugin.php ├── Message.php └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | # Do not index node.js modules that are used for building 2 | node_modules 3 | package-lock.json 4 | 5 | # Do not index releases 6 | release 7 | -------------------------------------------------------------------------------- /routing.yml: -------------------------------------------------------------------------------- 1 | chat_user_start: 2 | path: /chat 3 | defaults: 4 | _controller: Mibew\Mibew\Plugin\FirstMessage\Controller\UserChatController::startAction 5 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.1", 3 | "devDependencies": { 4 | "gulp": "~4.0.0", 5 | "event-stream": "3.3.4", 6 | "gulp-zip": "~3.0.2", 7 | "gulp-tar": "~3.1.0", 8 | "gulp-gzip": "~1.1.0", 9 | "gulp-chmod": "~3.0.0", 10 | "gulp-rename": "~1.2.2" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | var eventStream = require('event-stream'), 2 | gulp = require('gulp'), 3 | chmod = require('gulp-chmod'), 4 | zip = require('gulp-zip'), 5 | tar = require('gulp-tar'), 6 | gzip = require('gulp-gzip'), 7 | rename = require('gulp-rename'); 8 | 9 | gulp.task('prepare-release', function() { 10 | var version = require('./package.json').version; 11 | 12 | return eventStream.merge( 13 | getSources() 14 | .pipe(zip('first-message-plugin-' + version + '.zip')), 15 | getSources() 16 | .pipe(tar('first-message-plugin-' + version + '.tar')) 17 | .pipe(gzip()) 18 | ) 19 | .pipe(chmod(0644)) 20 | .pipe(gulp.dest('release')); 21 | }); 22 | 23 | // Builds and packs plugins sources 24 | gulp.task('default', gulp.series('prepare-release')); 25 | 26 | /** 27 | * Returns files stream with the plugin sources. 28 | * 29 | * @returns {Object} Stream with VinylFS files. 30 | */ 31 | var getSources = function() { 32 | return gulp.src([ 33 | 'Controller/*', 34 | 'Message.php', 35 | 'Plugin.php', 36 | 'README.md', 37 | 'LICENSE', 38 | 'routing.yml' 39 | ], 40 | {base: './'} 41 | ) 42 | .pipe(rename(function(path) { 43 | path.dirname = 'Mibew/Mibew/Plugin/FirstMessage/' + path.dirname; 44 | })); 45 | }; 46 | -------------------------------------------------------------------------------- /Controller/UserChatController.php: -------------------------------------------------------------------------------- 1 | . 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | namespace Mibew\Mibew\Plugin\FirstMessage\Controller; 21 | 22 | use Mibew\Controller\Chat\UserChatController as BaseController; 23 | use Symfony\Component\HttpFoundation\Request; 24 | use Mibew\Mibew\Plugin\FirstMessage\Message; 25 | 26 | /** 27 | * A controller which handles user's chat start actions. 28 | * 29 | * It's just a decorator for {@link \Mibew\Controller\Chat\UserChatController}. 30 | */ 31 | class UserChatController extends BaseController 32 | { 33 | /** 34 | * Saves custom user's message and starts chat for him. 35 | * 36 | * @param Request $request Incoming request 37 | * @return \Symfony\Component\HttpFoundation\Response 38 | */ 39 | public function startAction(Request $request) 40 | { 41 | // Check if there is a message that should be posted to the thread 42 | $first_message = $request->query->get('first_message'); 43 | 44 | if ($first_message) { 45 | $visitor_data = visitor_from_request(); 46 | $user_id = $visitor_data['id']; 47 | 48 | $message = Message::loadByUserId($user_id); 49 | if (!$message) { 50 | $message = new Message($user_id); 51 | } 52 | 53 | $message->setMessage($first_message); 54 | $message->save(); 55 | } 56 | 57 | return parent::startAction($request); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Mibew First Message plugin 2 | 3 | It provides a way to send custom first message as if it was sent by the user. 4 | 5 | 6 | ## Installation 7 | 8 | 1. Get the archive with the plugin sources. You can download it from the 9 | [official site](https://mibew.org/plugins#mibew-first-message) or build the 10 | plugin from sources. 11 | 12 | 2. Untar/unzip the plugin's archive. 13 | 14 | 3. Put files of the plugins to the `/plugins` folder. 15 | 16 | 4. (optional) Add plugins configs to "plugins" structure in 17 | "``/configs/config.yml". If the "plugins" stucture looks like 18 | `plugins: []` it will become: 19 | ```yaml 20 | plugins: 21 | "Mibew:FirstMessage": # Plugin's configurations are described below 22 | template: "{message}" 23 | ``` 24 | 25 | 5. Navigate to "``/operator/plugin" page and enable the plugin. 26 | 27 | 6. Alter button code and add GET parameter `first_message` to chat start URLs 28 | (see below). 29 | 30 | 31 | ### Rendering button's code 32 | 33 | You can provide any custom message with simple GET parameter `first_message`. To 34 | do so you have to alter Mibew button's code. Let's assume that the original code 35 | is (indentation are addeded for readability): 36 | 37 | ```html 38 | 39 | 40 | 41 | 42 | 43 | 55 | 56 | ``` 57 | 58 | and the target site uses simple PHP files as templates system. Then altered button code is: 59 | 60 | ```php 61 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 84 | 85 | ``` 86 | 87 | If you set `template` config variable to `I'm interesting in {message}` you can 88 | get in the chat window something like the following: 89 | 90 | ``` 91 | 15:10:37 Thank you for contacting us. An operator will be with you shortly. 92 | 15:10:38 Guest: I'm interesting in Adventure Time comics. 93 | ``` 94 | 95 | 96 | ## Plugin's configurations 97 | 98 | The plugin can be configured with values in "``/configs/config.yml" 99 | file. 100 | 101 | ### config.template 102 | 103 | Type: `String` 104 | 105 | Default: `{message}` 106 | 107 | Can be used to customize user's message. To show user's message `{message}` 108 | placeholder can be used inside of the template. This value is optional and can 109 | be skipped. 110 | 111 | 112 | ## Build from sources 113 | 114 | There are several actions one should do before use the latest version of the 115 | plugin from the repository: 116 | 117 | 1. Obtain a copy of the repository using `git clone`, download button, or 118 | another way. 119 | 2. Install [node.js](http://nodejs.org/) and [npm](https://www.npmjs.org/). 120 | 3. Install [Gulp](http://gulpjs.com/). 121 | 4. Install npm dependencies using `npm install`. 122 | 5. Run Gulp to build the sources using `gulp default`. 123 | 124 | Finally `.tar.gz` and `.zip` archives of the ready-to-use Plugin will be 125 | available in `release` directory. 126 | 127 | 128 | ## License 129 | 130 | [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0.html) 131 | -------------------------------------------------------------------------------- /Plugin.php: -------------------------------------------------------------------------------- 1 | . 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | /** 21 | * @file The main file of Mibew:FirstMessage plugin. 22 | */ 23 | 24 | namespace Mibew\Mibew\Plugin\FirstMessage; 25 | 26 | use Mibew\Database; 27 | use Mibew\EventDispatcher\EventDispatcher; 28 | use Mibew\EventDispatcher\Events; 29 | use Mibew\Thread; 30 | 31 | /** 32 | * Represents the plugin. 33 | */ 34 | class Plugin extends \Mibew\Plugin\AbstractPlugin implements \Mibew\Plugin\PluginInterface 35 | { 36 | /** 37 | * Class constructor. 38 | * 39 | * @param array $config List of the plugin config. The following options are 40 | * supported: 41 | * - "template": string, can be used to customize user's message. 42 | * To show user's message "{message}" placeholder can be used inside of 43 | * the template. The default value is "{message}". 44 | */ 45 | public function __construct($config) 46 | { 47 | parent::__construct($config + array( 48 | 'template' => '{message}', 49 | )); 50 | } 51 | 52 | /** 53 | * {@inheritdoc} 54 | */ 55 | public function initialized() 56 | { 57 | // Extra configs are not required so the plugin is always ready to work. 58 | return true; 59 | } 60 | 61 | /** 62 | * Registers event handlers. 63 | */ 64 | public function run() 65 | { 66 | // Attach CSS and JS files of the plugin to chat window. 67 | $dispatcher = EventDispatcher::getInstance(); 68 | $dispatcher->attachListener(Events::THREAD_USER_IS_READY, $this, 'sendFirstMessage'); 69 | $dispatcher->attachListener(Events::THREAD_CLOSE, $this, 'removeOldMessage'); 70 | } 71 | 72 | /** 73 | * Sends first user's message to the chat. 74 | * 75 | * It's a listener of 76 | * {@link \Mibew\EventDispatcher\Events::THREAD_USER_IS_READY} event. 77 | * 78 | * @param array $args List of arguments that are passed to the event. 79 | */ 80 | public function sendFirstMessage(&$args) 81 | { 82 | $thread = $args['thread']; 83 | if ($thread->userId) { 84 | $message = Message::loadByUserId($thread->userId); 85 | if ($message) { 86 | $prepared_message = str_replace( 87 | '{message}', 88 | $message->getMessage(), 89 | $this->config['template'] 90 | ); 91 | 92 | $thread->postMessage( 93 | Thread::KIND_USER, 94 | $prepared_message, 95 | array('name' => $thread->userName) 96 | ); 97 | 98 | // The message is not needed anymore. 99 | $message->delete(); 100 | } 101 | } 102 | } 103 | 104 | /** 105 | * Removes messages for threads that are closed. 106 | * 107 | * It's a listener of {@link \Mibew\EventDispatcher\Events::THREAD_CLOSE} 108 | * event. 109 | * 110 | * @param array $args List of arguments that is passed to the event. 111 | */ 112 | public function removeOldMessage(&$args) 113 | { 114 | $thread = $args['thread']; 115 | if ($thread->userId) { 116 | $message = Message::loadByUserId($thread->userId); 117 | if ($message) { 118 | // There is a first message associated with the user ID. Delete 119 | // it because the thread is closed now and the message cannot be 120 | // used anymore. 121 | $message->delete(); 122 | } 123 | } 124 | } 125 | 126 | /** 127 | * Specify version of the plugin. 128 | * 129 | * @return string Plugin's version. 130 | */ 131 | public static function getVersion() 132 | { 133 | return '1.0.1'; 134 | } 135 | 136 | /** 137 | * Specifies system requirements of the plugin. 138 | * 139 | * @return array List of requirements. 140 | */ 141 | public static function getSystemRequirements() 142 | { 143 | return array( 144 | 'mibew' => '>=2.1.0' 145 | ); 146 | } 147 | 148 | /** 149 | * {@inheritdoc} 150 | */ 151 | public static function install() 152 | { 153 | return Database::getInstance()->query( 154 | 'CREATE TABLE {mibew_firstmessage} ( ' 155 | . 'id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, ' 156 | . 'userid VARCHAR(255), ' 157 | . 'message TEXT, ' 158 | . 'UNIQUE KEY userid (userid) ' 159 | . ') charset utf8 ENGINE=InnoDb' 160 | ); 161 | } 162 | 163 | /** 164 | * {@inheritdoc} 165 | */ 166 | public static function uninstall() 167 | { 168 | return Database::getInstance()->query('DROP TABLE {mibew_firstmessage}'); 169 | } 170 | } 171 | -------------------------------------------------------------------------------- /Message.php: -------------------------------------------------------------------------------- 1 | . 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | namespace Mibew\Mibew\Plugin\FirstMessage; 21 | 22 | use Mibew\Database; 23 | 24 | /** 25 | * Represents a message which is sent be an user. 26 | */ 27 | class Message 28 | { 29 | /** 30 | * Internal unique ID of the message. 31 | * 32 | * @var int|bool 33 | */ 34 | protected $id = false; 35 | 36 | /** 37 | * ID of the user who sent the message. 38 | * 39 | * @var string 40 | */ 41 | protected $userId = false; 42 | 43 | /** 44 | * The message sent by user. 45 | * 46 | * @var string 47 | */ 48 | protected $message = ''; 49 | 50 | /** 51 | * Class constructor. 52 | * 53 | * @param string $user_id ID of the user who sent the message. 54 | * 55 | * @throws \InvalidArgumentException If the ID is invalid. 56 | */ 57 | public function __construct($user_id) 58 | { 59 | if (!$user_id) { 60 | throw new \InvalidArgumentException('User ID cannot be empty'); 61 | } 62 | 63 | $this->userId = $user_id; 64 | } 65 | 66 | /** 67 | * Retrieves ID of the user who sent the message. 68 | * 69 | * @return string 70 | */ 71 | public function getUserId() 72 | { 73 | return $this->userId; 74 | } 75 | 76 | /** 77 | * Retrieves message's body. 78 | * 79 | * @return string 80 | */ 81 | public function getMessage() 82 | { 83 | return $this->message; 84 | } 85 | 86 | /** 87 | * Sets message's body. 88 | * 89 | * @param string $message 90 | */ 91 | public function setMessage($message) 92 | { 93 | $this->message = $message; 94 | } 95 | 96 | /** 97 | * Saves the message. 98 | * 99 | * @return bool True if the message is saved successfully and false on 100 | * error. 101 | */ 102 | public function save() 103 | { 104 | $db = Database::getInstance(); 105 | 106 | if ($this->id === false) { 107 | return $db->query( 108 | ('INSERT INTO {mibew_firstmessage} (userid, message) ' 109 | . 'VALUES (:user_id, :message)'), 110 | array( 111 | ':user_id' => $this->getUserId(), 112 | ':message' => $this->getMessage(), 113 | ) 114 | ); 115 | } else { 116 | return $db->query( 117 | ('UPDATE {mibew_firstmessage} SET message = :message ' 118 | . 'WHERE userid = :user_id'), 119 | array( 120 | ':user_id' => $this->getUserId(), 121 | ':message' => $this->getMessage(), 122 | ) 123 | ); 124 | } 125 | } 126 | 127 | /** 128 | * Removes previously saved message. 129 | */ 130 | public function delete() 131 | { 132 | Database::getInstance()->query( 133 | 'DELETE FROM {mibew_firstmessage} WHERE userid = :user_id', 134 | array(':user_id' => $this->getUserId()) 135 | ); 136 | } 137 | 138 | /** 139 | * Loads message object by it's ID. 140 | * 141 | * @param int $id Internal ID of the message. 142 | * @return Message|boolean An instance of 143 | * {@link \Mibew\Mibew\Plugin\FirstMessage\Message} or boolean false if 144 | * there is no message with specified ID. 145 | * 146 | * @throws \InvalidArgumentException If the ID is invalid. 147 | */ 148 | public static function load($id) 149 | { 150 | if (!$id) { 151 | throw new \InvalidArgumentException('Message ID cannot be empty'); 152 | } 153 | 154 | $info = Database::getInstance()->query( 155 | 'SELECT * FROM {mibew_firstmessage} WHERE id = :id', 156 | array(':id' => $id), 157 | array('return_rows' => Database::RETURN_ONE_ROW) 158 | ); 159 | 160 | if (!$info) { 161 | return false; 162 | } 163 | 164 | return self::buildFromDbFields($info); 165 | } 166 | 167 | /** 168 | * Loads message by user ID. 169 | * 170 | * @param string $user_id ID of the user who sent message. 171 | * @return Message|boolean An instance of 172 | * {@link \Mibew\Mibew\Plugin\FirstMessage\Message} or boolean false if 173 | * there is no message related with specified user ID. 174 | * 175 | * @throws \InvalidArgumentException If the user ID is invalid. 176 | */ 177 | public static function loadByUserId($user_id) 178 | { 179 | if (!$user_id) { 180 | throw new \InvalidArgumentException('User ID cannot be empty'); 181 | } 182 | 183 | $info = Database::getInstance()->query( 184 | 'SELECT * FROM {mibew_firstmessage} WHERE userid = :user_id', 185 | array(':user_id' => $user_id), 186 | array('return_rows' => Database::RETURN_ONE_ROW) 187 | ); 188 | 189 | if (!$info) { 190 | return false; 191 | } 192 | 193 | return self::buildFromDbFields($info); 194 | } 195 | 196 | /** 197 | * Builds an instance of Message based on database fields. 198 | * 199 | * @param array $fields List of database fields related with the message. 200 | * 201 | * @return Message 202 | */ 203 | protected static function buildFromDbFields($fields) 204 | { 205 | $message = new self($fields['userid']); 206 | 207 | $message->id = $fields['id']; 208 | $message->setMessage($fields['message']); 209 | 210 | return $message; 211 | } 212 | } 213 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | --------------------------------------------------------------------------------