├── .gitignore ├── LICENSE ├── README.md ├── composer.json ├── composer.lock ├── phpunit.xml ├── src └── indieweb │ └── comments.php └── tests ├── BasicTest.php ├── bootstrap.php └── data ├── post-bnvk-1.json └── post-tantek-1.json /.gitignore: -------------------------------------------------------------------------------- 1 | vendor/ 2 | .idea/ 3 | .DS_Store 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Comments Presentation 2 | ===================== 3 | 4 | Given an [h-entry](http://indiewebcamp.com/h-entry), returns author info as well as truncated post text suitable for display. 5 | 6 | Installation 7 | ------------ 8 | 9 | Install via composer: 10 | 11 | ```json 12 | { 13 | "indieweb/comments": "0.1.*", 14 | } 15 | ``` 16 | 17 | Or just require the one file: 18 | 19 | ```php 20 | require_once('src/indieweb/comments.php'); 21 | ``` 22 | 23 | 24 | Usage 25 | ----- 26 | 27 | The function accepts a PHP array in the format returned by the [microformats2 parser](https://github.com/indieweb/php-mf2) 28 | and returns a new array that looks like the following: 29 | 30 | Original HTML: 31 | ```html 32 |
33 |
34 | 35 | Aaron Parecki 36 |
37 |

Example Note

38 |

this text is displayed as the comment

39 | 40 | in reply to caseorganic.com 41 |
42 | ``` 43 | 44 | Parsed Microformats: 45 | ```json 46 | { 47 | "type": [ 48 | "h-entry" 49 | ], 50 | "properties": { 51 | "author": [ 52 | { 53 | "type": [ 54 | "h-card" 55 | ], 56 | "properties": { 57 | "photo": [ 58 | "http:\/\/aaronparecki.com\/images\/aaronpk.png" 59 | ], 60 | "name": [ 61 | "Aaron Parecki" 62 | ], 63 | "url": [ 64 | "http:\/\/aaronparecki.com" 65 | ] 66 | }, 67 | "value": "Aaron Parecki" 68 | } 69 | ], 70 | "name": [ 71 | "Example Note" 72 | ], 73 | "published": [ 74 | "2014-02-16T18:48:17-0800" 75 | ], 76 | "in-reply-to": [ 77 | "http:\/\/caseorganic.com\/post\/1" 78 | ], 79 | "content": [ 80 | { 81 | "html": "this text is displayed as the comment", 82 | "value": "this text is displayed as the comment" 83 | } 84 | ] 85 | } 86 | } 87 | ``` 88 | 89 | Parse for comment display: 90 | 91 | ```php 92 | $result = IndieWeb\comments\parse($input, $refURL, $maxLength, $maxLines); 93 | ``` 94 | 95 | Resulting PHP array: 96 | 97 | ```php 98 | $result = array( 99 | 'type' => 'reply', 100 | 'author' => array( 101 | 'name' => 'Aaron Parecki', 102 | 'photo' => 'http://aaronparecki.com/images/aaronpk.png', 103 | 'url' => 'http://aaronparecki.com/' 104 | ), 105 | 'published' => '2014-02-16T18:48:17-0800', 106 | 'name' => 'Example Note', 107 | 'text' => 'this text is displayed as the comment', 108 | 'url' => 'http://aaronparecki.com/post/1' 109 | ) 110 | ``` 111 | 112 | This function will return an array with all of the keys above. One or more values may 113 | be empty depending on what information was available in the post, such as author name/photo. 114 | 115 | The `text` property will always be within your maximum desired length as passed to the `parse()` function. 116 | 117 | The function follows the algorithm described at [comments-presentation](http://indiewebcamp.com/comments-presentation#How_to_display) 118 | for deciding whether to show the `p-name`, `p-summary` or `e-content` properties and truncating appropriately. 119 | 120 | 121 | Post Types 122 | ---------- 123 | 124 | The parser also attempts to determine what type of post this is relative to the primary URL. 125 | 126 | A key named `type` will always be returned with one of the following values: 127 | 128 | * mention - default 129 | * reply - when the post contains explicit `in-reply-to` markup 130 | * rsvp - if the post contains an RSVP yes/no/maybe value 131 | * like 132 | * repost 133 | 134 | When the type is "rsvp", there will also be an `rsvp` key set to the value of the RSVP, usually "yes", "no" or "maybe". 135 | 136 | 137 | Post Names 138 | ---------- 139 | 140 | If the post has a "name" property that is not the same as the content, then it will also 141 | be included in the parsed result. This is so that the calling code can choose to display 142 | the post name linked to the full post rather than the content. 143 | 144 | 145 | ```php 146 | $result = array( 147 | 'type' => 'mention', 148 | 'author' => array( 149 | 'name' => 'Aaron Parecki', 150 | 'photo' => 'http://aaronparecki.com/images/aaronpk.png', 151 | 'url' => 'http://aaronparecki.com/' 152 | ), 153 | 'published' => '2014-02-16T18:48:17-0800', 154 | 'name' => 'Post Name', 155 | 'text' => 'this is the text of the article', 156 | 'url' => 'http://aaronparecki.com/post/1' 157 | ) 158 | ``` 159 | 160 | 161 | Tests 162 | ----- 163 | 164 | Please see the [tests](tests/BasicTest.php) for more complete examples of parsing different posts. 165 | 166 | 167 | License 168 | ------- 169 | 170 | Copyright 2014 by Aaron Parecki 171 | 172 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 173 | 174 | http://www.apache.org/licenses/LICENSE-2.0 175 | 176 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 177 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "indieweb/comments", 3 | "type": "library", 4 | "keywords": ["indieweb", "comments"], 5 | "license": "Apache-2.0", 6 | "authors" : [ 7 | { 8 | "name": "Aaron Parecki", 9 | "homepage": "http://aaronparecki.com" 10 | } 11 | ], 12 | "require": { 13 | "tantek/cassis": "^0.3" 14 | }, 15 | "require-dev": { 16 | "phpunit/phpunit": "^8.5" 17 | }, 18 | "autoload": { 19 | "files": [ 20 | "src/indieweb/comments.php" 21 | ] 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "b8ce603d703887811d6043acd6fca4ab", 8 | "packages": [ 9 | { 10 | "name": "tantek/cassis", 11 | "version": "v0.3.19425", 12 | "source": { 13 | "type": "git", 14 | "url": "https://github.com/tantek/cassis.git", 15 | "reference": "7aaddd1883f4ac0f9447298d2f121ff72af46316" 16 | }, 17 | "dist": { 18 | "type": "zip", 19 | "url": "https://api.github.com/repos/tantek/cassis/zipball/7aaddd1883f4ac0f9447298d2f121ff72af46316", 20 | "reference": "7aaddd1883f4ac0f9447298d2f121ff72af46316", 21 | "shasum": "" 22 | }, 23 | "type": "library", 24 | "autoload": { 25 | "files": [ 26 | "cassis.php" 27 | ] 28 | }, 29 | "notification-url": "https://packagist.org/downloads/", 30 | "license": [ 31 | "CC-BY-SA-4.0" 32 | ], 33 | "support": { 34 | "issues": "https://github.com/tantek/cassis/issues", 35 | "source": "https://github.com/tantek/cassis/tree/v0.3.19425" 36 | }, 37 | "time": "2023-03-10T00:36:40+00:00" 38 | } 39 | ], 40 | "packages-dev": [ 41 | { 42 | "name": "doctrine/instantiator", 43 | "version": "1.5.0", 44 | "source": { 45 | "type": "git", 46 | "url": "https://github.com/doctrine/instantiator.git", 47 | "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b" 48 | }, 49 | "dist": { 50 | "type": "zip", 51 | "url": "https://api.github.com/repos/doctrine/instantiator/zipball/0a0fa9780f5d4e507415a065172d26a98d02047b", 52 | "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b", 53 | "shasum": "" 54 | }, 55 | "require": { 56 | "php": "^7.1 || ^8.0" 57 | }, 58 | "require-dev": { 59 | "doctrine/coding-standard": "^9 || ^11", 60 | "ext-pdo": "*", 61 | "ext-phar": "*", 62 | "phpbench/phpbench": "^0.16 || ^1", 63 | "phpstan/phpstan": "^1.4", 64 | "phpstan/phpstan-phpunit": "^1", 65 | "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", 66 | "vimeo/psalm": "^4.30 || ^5.4" 67 | }, 68 | "type": "library", 69 | "autoload": { 70 | "psr-4": { 71 | "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" 72 | } 73 | }, 74 | "notification-url": "https://packagist.org/downloads/", 75 | "license": [ 76 | "MIT" 77 | ], 78 | "authors": [ 79 | { 80 | "name": "Marco Pivetta", 81 | "email": "ocramius@gmail.com", 82 | "homepage": "https://ocramius.github.io/" 83 | } 84 | ], 85 | "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", 86 | "homepage": "https://www.doctrine-project.org/projects/instantiator.html", 87 | "keywords": [ 88 | "constructor", 89 | "instantiate" 90 | ], 91 | "support": { 92 | "issues": "https://github.com/doctrine/instantiator/issues", 93 | "source": "https://github.com/doctrine/instantiator/tree/1.5.0" 94 | }, 95 | "funding": [ 96 | { 97 | "url": "https://www.doctrine-project.org/sponsorship.html", 98 | "type": "custom" 99 | }, 100 | { 101 | "url": "https://www.patreon.com/phpdoctrine", 102 | "type": "patreon" 103 | }, 104 | { 105 | "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", 106 | "type": "tidelift" 107 | } 108 | ], 109 | "time": "2022-12-30T00:15:36+00:00" 110 | }, 111 | { 112 | "name": "myclabs/deep-copy", 113 | "version": "1.11.1", 114 | "source": { 115 | "type": "git", 116 | "url": "https://github.com/myclabs/DeepCopy.git", 117 | "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c" 118 | }, 119 | "dist": { 120 | "type": "zip", 121 | "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", 122 | "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", 123 | "shasum": "" 124 | }, 125 | "require": { 126 | "php": "^7.1 || ^8.0" 127 | }, 128 | "conflict": { 129 | "doctrine/collections": "<1.6.8", 130 | "doctrine/common": "<2.13.3 || >=3,<3.2.2" 131 | }, 132 | "require-dev": { 133 | "doctrine/collections": "^1.6.8", 134 | "doctrine/common": "^2.13.3 || ^3.2.2", 135 | "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" 136 | }, 137 | "type": "library", 138 | "autoload": { 139 | "files": [ 140 | "src/DeepCopy/deep_copy.php" 141 | ], 142 | "psr-4": { 143 | "DeepCopy\\": "src/DeepCopy/" 144 | } 145 | }, 146 | "notification-url": "https://packagist.org/downloads/", 147 | "license": [ 148 | "MIT" 149 | ], 150 | "description": "Create deep copies (clones) of your objects", 151 | "keywords": [ 152 | "clone", 153 | "copy", 154 | "duplicate", 155 | "object", 156 | "object graph" 157 | ], 158 | "support": { 159 | "issues": "https://github.com/myclabs/DeepCopy/issues", 160 | "source": "https://github.com/myclabs/DeepCopy/tree/1.11.1" 161 | }, 162 | "funding": [ 163 | { 164 | "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", 165 | "type": "tidelift" 166 | } 167 | ], 168 | "time": "2023-03-08T13:26:56+00:00" 169 | }, 170 | { 171 | "name": "phar-io/manifest", 172 | "version": "2.0.4", 173 | "source": { 174 | "type": "git", 175 | "url": "https://github.com/phar-io/manifest.git", 176 | "reference": "54750ef60c58e43759730615a392c31c80e23176" 177 | }, 178 | "dist": { 179 | "type": "zip", 180 | "url": "https://api.github.com/repos/phar-io/manifest/zipball/54750ef60c58e43759730615a392c31c80e23176", 181 | "reference": "54750ef60c58e43759730615a392c31c80e23176", 182 | "shasum": "" 183 | }, 184 | "require": { 185 | "ext-dom": "*", 186 | "ext-libxml": "*", 187 | "ext-phar": "*", 188 | "ext-xmlwriter": "*", 189 | "phar-io/version": "^3.0.1", 190 | "php": "^7.2 || ^8.0" 191 | }, 192 | "type": "library", 193 | "extra": { 194 | "branch-alias": { 195 | "dev-master": "2.0.x-dev" 196 | } 197 | }, 198 | "autoload": { 199 | "classmap": [ 200 | "src/" 201 | ] 202 | }, 203 | "notification-url": "https://packagist.org/downloads/", 204 | "license": [ 205 | "BSD-3-Clause" 206 | ], 207 | "authors": [ 208 | { 209 | "name": "Arne Blankerts", 210 | "email": "arne@blankerts.de", 211 | "role": "Developer" 212 | }, 213 | { 214 | "name": "Sebastian Heuer", 215 | "email": "sebastian@phpeople.de", 216 | "role": "Developer" 217 | }, 218 | { 219 | "name": "Sebastian Bergmann", 220 | "email": "sebastian@phpunit.de", 221 | "role": "Developer" 222 | } 223 | ], 224 | "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", 225 | "support": { 226 | "issues": "https://github.com/phar-io/manifest/issues", 227 | "source": "https://github.com/phar-io/manifest/tree/2.0.4" 228 | }, 229 | "funding": [ 230 | { 231 | "url": "https://github.com/theseer", 232 | "type": "github" 233 | } 234 | ], 235 | "time": "2024-03-03T12:33:53+00:00" 236 | }, 237 | { 238 | "name": "phar-io/version", 239 | "version": "3.2.1", 240 | "source": { 241 | "type": "git", 242 | "url": "https://github.com/phar-io/version.git", 243 | "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74" 244 | }, 245 | "dist": { 246 | "type": "zip", 247 | "url": "https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74", 248 | "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74", 249 | "shasum": "" 250 | }, 251 | "require": { 252 | "php": "^7.2 || ^8.0" 253 | }, 254 | "type": "library", 255 | "autoload": { 256 | "classmap": [ 257 | "src/" 258 | ] 259 | }, 260 | "notification-url": "https://packagist.org/downloads/", 261 | "license": [ 262 | "BSD-3-Clause" 263 | ], 264 | "authors": [ 265 | { 266 | "name": "Arne Blankerts", 267 | "email": "arne@blankerts.de", 268 | "role": "Developer" 269 | }, 270 | { 271 | "name": "Sebastian Heuer", 272 | "email": "sebastian@phpeople.de", 273 | "role": "Developer" 274 | }, 275 | { 276 | "name": "Sebastian Bergmann", 277 | "email": "sebastian@phpunit.de", 278 | "role": "Developer" 279 | } 280 | ], 281 | "description": "Library for handling version information and constraints", 282 | "support": { 283 | "issues": "https://github.com/phar-io/version/issues", 284 | "source": "https://github.com/phar-io/version/tree/3.2.1" 285 | }, 286 | "time": "2022-02-21T01:04:05+00:00" 287 | }, 288 | { 289 | "name": "phpunit/php-code-coverage", 290 | "version": "7.0.17", 291 | "source": { 292 | "type": "git", 293 | "url": "https://github.com/sebastianbergmann/php-code-coverage.git", 294 | "reference": "40a4ed114a4aea5afd6df8d0f0c9cd3033097f66" 295 | }, 296 | "dist": { 297 | "type": "zip", 298 | "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/40a4ed114a4aea5afd6df8d0f0c9cd3033097f66", 299 | "reference": "40a4ed114a4aea5afd6df8d0f0c9cd3033097f66", 300 | "shasum": "" 301 | }, 302 | "require": { 303 | "ext-dom": "*", 304 | "ext-xmlwriter": "*", 305 | "php": ">=7.2", 306 | "phpunit/php-file-iterator": "^2.0.2", 307 | "phpunit/php-text-template": "^1.2.1", 308 | "phpunit/php-token-stream": "^3.1.3 || ^4.0", 309 | "sebastian/code-unit-reverse-lookup": "^1.0.1", 310 | "sebastian/environment": "^4.2.2", 311 | "sebastian/version": "^2.0.1", 312 | "theseer/tokenizer": "^1.1.3" 313 | }, 314 | "require-dev": { 315 | "phpunit/phpunit": "^8.2.2" 316 | }, 317 | "suggest": { 318 | "ext-xdebug": "^2.7.2" 319 | }, 320 | "type": "library", 321 | "extra": { 322 | "branch-alias": { 323 | "dev-master": "7.0-dev" 324 | } 325 | }, 326 | "autoload": { 327 | "classmap": [ 328 | "src/" 329 | ] 330 | }, 331 | "notification-url": "https://packagist.org/downloads/", 332 | "license": [ 333 | "BSD-3-Clause" 334 | ], 335 | "authors": [ 336 | { 337 | "name": "Sebastian Bergmann", 338 | "email": "sebastian@phpunit.de", 339 | "role": "lead" 340 | } 341 | ], 342 | "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", 343 | "homepage": "https://github.com/sebastianbergmann/php-code-coverage", 344 | "keywords": [ 345 | "coverage", 346 | "testing", 347 | "xunit" 348 | ], 349 | "support": { 350 | "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", 351 | "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/7.0.17" 352 | }, 353 | "funding": [ 354 | { 355 | "url": "https://github.com/sebastianbergmann", 356 | "type": "github" 357 | } 358 | ], 359 | "time": "2024-03-02T06:09:37+00:00" 360 | }, 361 | { 362 | "name": "phpunit/php-file-iterator", 363 | "version": "2.0.6", 364 | "source": { 365 | "type": "git", 366 | "url": "https://github.com/sebastianbergmann/php-file-iterator.git", 367 | "reference": "69deeb8664f611f156a924154985fbd4911eb36b" 368 | }, 369 | "dist": { 370 | "type": "zip", 371 | "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/69deeb8664f611f156a924154985fbd4911eb36b", 372 | "reference": "69deeb8664f611f156a924154985fbd4911eb36b", 373 | "shasum": "" 374 | }, 375 | "require": { 376 | "php": ">=7.1" 377 | }, 378 | "require-dev": { 379 | "phpunit/phpunit": "^8.5" 380 | }, 381 | "type": "library", 382 | "extra": { 383 | "branch-alias": { 384 | "dev-master": "2.0.x-dev" 385 | } 386 | }, 387 | "autoload": { 388 | "classmap": [ 389 | "src/" 390 | ] 391 | }, 392 | "notification-url": "https://packagist.org/downloads/", 393 | "license": [ 394 | "BSD-3-Clause" 395 | ], 396 | "authors": [ 397 | { 398 | "name": "Sebastian Bergmann", 399 | "email": "sebastian@phpunit.de", 400 | "role": "lead" 401 | } 402 | ], 403 | "description": "FilterIterator implementation that filters files based on a list of suffixes.", 404 | "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", 405 | "keywords": [ 406 | "filesystem", 407 | "iterator" 408 | ], 409 | "support": { 410 | "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", 411 | "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/2.0.6" 412 | }, 413 | "funding": [ 414 | { 415 | "url": "https://github.com/sebastianbergmann", 416 | "type": "github" 417 | } 418 | ], 419 | "time": "2024-03-01T13:39:50+00:00" 420 | }, 421 | { 422 | "name": "phpunit/php-text-template", 423 | "version": "1.2.1", 424 | "source": { 425 | "type": "git", 426 | "url": "https://github.com/sebastianbergmann/php-text-template.git", 427 | "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" 428 | }, 429 | "dist": { 430 | "type": "zip", 431 | "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", 432 | "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", 433 | "shasum": "" 434 | }, 435 | "require": { 436 | "php": ">=5.3.3" 437 | }, 438 | "type": "library", 439 | "autoload": { 440 | "classmap": [ 441 | "src/" 442 | ] 443 | }, 444 | "notification-url": "https://packagist.org/downloads/", 445 | "license": [ 446 | "BSD-3-Clause" 447 | ], 448 | "authors": [ 449 | { 450 | "name": "Sebastian Bergmann", 451 | "email": "sebastian@phpunit.de", 452 | "role": "lead" 453 | } 454 | ], 455 | "description": "Simple template engine.", 456 | "homepage": "https://github.com/sebastianbergmann/php-text-template/", 457 | "keywords": [ 458 | "template" 459 | ], 460 | "support": { 461 | "issues": "https://github.com/sebastianbergmann/php-text-template/issues", 462 | "source": "https://github.com/sebastianbergmann/php-text-template/tree/1.2.1" 463 | }, 464 | "time": "2015-06-21T13:50:34+00:00" 465 | }, 466 | { 467 | "name": "phpunit/php-timer", 468 | "version": "2.1.4", 469 | "source": { 470 | "type": "git", 471 | "url": "https://github.com/sebastianbergmann/php-timer.git", 472 | "reference": "a691211e94ff39a34811abd521c31bd5b305b0bb" 473 | }, 474 | "dist": { 475 | "type": "zip", 476 | "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/a691211e94ff39a34811abd521c31bd5b305b0bb", 477 | "reference": "a691211e94ff39a34811abd521c31bd5b305b0bb", 478 | "shasum": "" 479 | }, 480 | "require": { 481 | "php": ">=7.1" 482 | }, 483 | "require-dev": { 484 | "phpunit/phpunit": "^8.5" 485 | }, 486 | "type": "library", 487 | "extra": { 488 | "branch-alias": { 489 | "dev-master": "2.1-dev" 490 | } 491 | }, 492 | "autoload": { 493 | "classmap": [ 494 | "src/" 495 | ] 496 | }, 497 | "notification-url": "https://packagist.org/downloads/", 498 | "license": [ 499 | "BSD-3-Clause" 500 | ], 501 | "authors": [ 502 | { 503 | "name": "Sebastian Bergmann", 504 | "email": "sebastian@phpunit.de", 505 | "role": "lead" 506 | } 507 | ], 508 | "description": "Utility class for timing", 509 | "homepage": "https://github.com/sebastianbergmann/php-timer/", 510 | "keywords": [ 511 | "timer" 512 | ], 513 | "support": { 514 | "issues": "https://github.com/sebastianbergmann/php-timer/issues", 515 | "source": "https://github.com/sebastianbergmann/php-timer/tree/2.1.4" 516 | }, 517 | "funding": [ 518 | { 519 | "url": "https://github.com/sebastianbergmann", 520 | "type": "github" 521 | } 522 | ], 523 | "time": "2024-03-01T13:42:41+00:00" 524 | }, 525 | { 526 | "name": "phpunit/php-token-stream", 527 | "version": "4.0.4", 528 | "source": { 529 | "type": "git", 530 | "url": "https://github.com/sebastianbergmann/php-token-stream.git", 531 | "reference": "a853a0e183b9db7eed023d7933a858fa1c8d25a3" 532 | }, 533 | "dist": { 534 | "type": "zip", 535 | "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/a853a0e183b9db7eed023d7933a858fa1c8d25a3", 536 | "reference": "a853a0e183b9db7eed023d7933a858fa1c8d25a3", 537 | "shasum": "" 538 | }, 539 | "require": { 540 | "ext-tokenizer": "*", 541 | "php": "^7.3 || ^8.0" 542 | }, 543 | "require-dev": { 544 | "phpunit/phpunit": "^9.0" 545 | }, 546 | "type": "library", 547 | "extra": { 548 | "branch-alias": { 549 | "dev-master": "4.0-dev" 550 | } 551 | }, 552 | "autoload": { 553 | "classmap": [ 554 | "src/" 555 | ] 556 | }, 557 | "notification-url": "https://packagist.org/downloads/", 558 | "license": [ 559 | "BSD-3-Clause" 560 | ], 561 | "authors": [ 562 | { 563 | "name": "Sebastian Bergmann", 564 | "email": "sebastian@phpunit.de" 565 | } 566 | ], 567 | "description": "Wrapper around PHP's tokenizer extension.", 568 | "homepage": "https://github.com/sebastianbergmann/php-token-stream/", 569 | "keywords": [ 570 | "tokenizer" 571 | ], 572 | "support": { 573 | "issues": "https://github.com/sebastianbergmann/php-token-stream/issues", 574 | "source": "https://github.com/sebastianbergmann/php-token-stream/tree/master" 575 | }, 576 | "funding": [ 577 | { 578 | "url": "https://github.com/sebastianbergmann", 579 | "type": "github" 580 | } 581 | ], 582 | "abandoned": true, 583 | "time": "2020-08-04T08:28:15+00:00" 584 | }, 585 | { 586 | "name": "phpunit/phpunit", 587 | "version": "8.5.38", 588 | "source": { 589 | "type": "git", 590 | "url": "https://github.com/sebastianbergmann/phpunit.git", 591 | "reference": "1ecad678646c817a29e55a32c930f3601c3f5a8c" 592 | }, 593 | "dist": { 594 | "type": "zip", 595 | "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/1ecad678646c817a29e55a32c930f3601c3f5a8c", 596 | "reference": "1ecad678646c817a29e55a32c930f3601c3f5a8c", 597 | "shasum": "" 598 | }, 599 | "require": { 600 | "doctrine/instantiator": "^1.3.1", 601 | "ext-dom": "*", 602 | "ext-json": "*", 603 | "ext-libxml": "*", 604 | "ext-mbstring": "*", 605 | "ext-xml": "*", 606 | "ext-xmlwriter": "*", 607 | "myclabs/deep-copy": "^1.10.0", 608 | "phar-io/manifest": "^2.0.3", 609 | "phar-io/version": "^3.0.2", 610 | "php": ">=7.2", 611 | "phpunit/php-code-coverage": "^7.0.12", 612 | "phpunit/php-file-iterator": "^2.0.4", 613 | "phpunit/php-text-template": "^1.2.1", 614 | "phpunit/php-timer": "^2.1.2", 615 | "sebastian/comparator": "^3.0.5", 616 | "sebastian/diff": "^3.0.2", 617 | "sebastian/environment": "^4.2.3", 618 | "sebastian/exporter": "^3.1.5", 619 | "sebastian/global-state": "^3.0.0", 620 | "sebastian/object-enumerator": "^3.0.3", 621 | "sebastian/resource-operations": "^2.0.1", 622 | "sebastian/type": "^1.1.3", 623 | "sebastian/version": "^2.0.1" 624 | }, 625 | "suggest": { 626 | "ext-soap": "To be able to generate mocks based on WSDL files", 627 | "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage", 628 | "phpunit/php-invoker": "To allow enforcing time limits" 629 | }, 630 | "bin": [ 631 | "phpunit" 632 | ], 633 | "type": "library", 634 | "extra": { 635 | "branch-alias": { 636 | "dev-master": "8.5-dev" 637 | } 638 | }, 639 | "autoload": { 640 | "classmap": [ 641 | "src/" 642 | ] 643 | }, 644 | "notification-url": "https://packagist.org/downloads/", 645 | "license": [ 646 | "BSD-3-Clause" 647 | ], 648 | "authors": [ 649 | { 650 | "name": "Sebastian Bergmann", 651 | "email": "sebastian@phpunit.de", 652 | "role": "lead" 653 | } 654 | ], 655 | "description": "The PHP Unit Testing framework.", 656 | "homepage": "https://phpunit.de/", 657 | "keywords": [ 658 | "phpunit", 659 | "testing", 660 | "xunit" 661 | ], 662 | "support": { 663 | "issues": "https://github.com/sebastianbergmann/phpunit/issues", 664 | "security": "https://github.com/sebastianbergmann/phpunit/security/policy", 665 | "source": "https://github.com/sebastianbergmann/phpunit/tree/8.5.38" 666 | }, 667 | "funding": [ 668 | { 669 | "url": "https://phpunit.de/sponsors.html", 670 | "type": "custom" 671 | }, 672 | { 673 | "url": "https://github.com/sebastianbergmann", 674 | "type": "github" 675 | }, 676 | { 677 | "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit", 678 | "type": "tidelift" 679 | } 680 | ], 681 | "time": "2024-04-05T04:31:23+00:00" 682 | }, 683 | { 684 | "name": "sebastian/code-unit-reverse-lookup", 685 | "version": "1.0.3", 686 | "source": { 687 | "type": "git", 688 | "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", 689 | "reference": "92a1a52e86d34cde6caa54f1b5ffa9fda18e5d54" 690 | }, 691 | "dist": { 692 | "type": "zip", 693 | "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/92a1a52e86d34cde6caa54f1b5ffa9fda18e5d54", 694 | "reference": "92a1a52e86d34cde6caa54f1b5ffa9fda18e5d54", 695 | "shasum": "" 696 | }, 697 | "require": { 698 | "php": ">=5.6" 699 | }, 700 | "require-dev": { 701 | "phpunit/phpunit": "^8.5" 702 | }, 703 | "type": "library", 704 | "extra": { 705 | "branch-alias": { 706 | "dev-master": "1.0.x-dev" 707 | } 708 | }, 709 | "autoload": { 710 | "classmap": [ 711 | "src/" 712 | ] 713 | }, 714 | "notification-url": "https://packagist.org/downloads/", 715 | "license": [ 716 | "BSD-3-Clause" 717 | ], 718 | "authors": [ 719 | { 720 | "name": "Sebastian Bergmann", 721 | "email": "sebastian@phpunit.de" 722 | } 723 | ], 724 | "description": "Looks up which function or method a line of code belongs to", 725 | "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", 726 | "support": { 727 | "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", 728 | "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/1.0.3" 729 | }, 730 | "funding": [ 731 | { 732 | "url": "https://github.com/sebastianbergmann", 733 | "type": "github" 734 | } 735 | ], 736 | "time": "2024-03-01T13:45:45+00:00" 737 | }, 738 | { 739 | "name": "sebastian/comparator", 740 | "version": "3.0.5", 741 | "source": { 742 | "type": "git", 743 | "url": "https://github.com/sebastianbergmann/comparator.git", 744 | "reference": "1dc7ceb4a24aede938c7af2a9ed1de09609ca770" 745 | }, 746 | "dist": { 747 | "type": "zip", 748 | "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1dc7ceb4a24aede938c7af2a9ed1de09609ca770", 749 | "reference": "1dc7ceb4a24aede938c7af2a9ed1de09609ca770", 750 | "shasum": "" 751 | }, 752 | "require": { 753 | "php": ">=7.1", 754 | "sebastian/diff": "^3.0", 755 | "sebastian/exporter": "^3.1" 756 | }, 757 | "require-dev": { 758 | "phpunit/phpunit": "^8.5" 759 | }, 760 | "type": "library", 761 | "extra": { 762 | "branch-alias": { 763 | "dev-master": "3.0-dev" 764 | } 765 | }, 766 | "autoload": { 767 | "classmap": [ 768 | "src/" 769 | ] 770 | }, 771 | "notification-url": "https://packagist.org/downloads/", 772 | "license": [ 773 | "BSD-3-Clause" 774 | ], 775 | "authors": [ 776 | { 777 | "name": "Sebastian Bergmann", 778 | "email": "sebastian@phpunit.de" 779 | }, 780 | { 781 | "name": "Jeff Welch", 782 | "email": "whatthejeff@gmail.com" 783 | }, 784 | { 785 | "name": "Volker Dusch", 786 | "email": "github@wallbash.com" 787 | }, 788 | { 789 | "name": "Bernhard Schussek", 790 | "email": "bschussek@2bepublished.at" 791 | } 792 | ], 793 | "description": "Provides the functionality to compare PHP values for equality", 794 | "homepage": "https://github.com/sebastianbergmann/comparator", 795 | "keywords": [ 796 | "comparator", 797 | "compare", 798 | "equality" 799 | ], 800 | "support": { 801 | "issues": "https://github.com/sebastianbergmann/comparator/issues", 802 | "source": "https://github.com/sebastianbergmann/comparator/tree/3.0.5" 803 | }, 804 | "funding": [ 805 | { 806 | "url": "https://github.com/sebastianbergmann", 807 | "type": "github" 808 | } 809 | ], 810 | "time": "2022-09-14T12:31:48+00:00" 811 | }, 812 | { 813 | "name": "sebastian/diff", 814 | "version": "3.0.6", 815 | "source": { 816 | "type": "git", 817 | "url": "https://github.com/sebastianbergmann/diff.git", 818 | "reference": "98ff311ca519c3aa73ccd3de053bdb377171d7b6" 819 | }, 820 | "dist": { 821 | "type": "zip", 822 | "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/98ff311ca519c3aa73ccd3de053bdb377171d7b6", 823 | "reference": "98ff311ca519c3aa73ccd3de053bdb377171d7b6", 824 | "shasum": "" 825 | }, 826 | "require": { 827 | "php": ">=7.1" 828 | }, 829 | "require-dev": { 830 | "phpunit/phpunit": "^7.5 || ^8.0", 831 | "symfony/process": "^2 || ^3.3 || ^4" 832 | }, 833 | "type": "library", 834 | "extra": { 835 | "branch-alias": { 836 | "dev-master": "3.0-dev" 837 | } 838 | }, 839 | "autoload": { 840 | "classmap": [ 841 | "src/" 842 | ] 843 | }, 844 | "notification-url": "https://packagist.org/downloads/", 845 | "license": [ 846 | "BSD-3-Clause" 847 | ], 848 | "authors": [ 849 | { 850 | "name": "Sebastian Bergmann", 851 | "email": "sebastian@phpunit.de" 852 | }, 853 | { 854 | "name": "Kore Nordmann", 855 | "email": "mail@kore-nordmann.de" 856 | } 857 | ], 858 | "description": "Diff implementation", 859 | "homepage": "https://github.com/sebastianbergmann/diff", 860 | "keywords": [ 861 | "diff", 862 | "udiff", 863 | "unidiff", 864 | "unified diff" 865 | ], 866 | "support": { 867 | "issues": "https://github.com/sebastianbergmann/diff/issues", 868 | "source": "https://github.com/sebastianbergmann/diff/tree/3.0.6" 869 | }, 870 | "funding": [ 871 | { 872 | "url": "https://github.com/sebastianbergmann", 873 | "type": "github" 874 | } 875 | ], 876 | "time": "2024-03-02T06:16:36+00:00" 877 | }, 878 | { 879 | "name": "sebastian/environment", 880 | "version": "4.2.5", 881 | "source": { 882 | "type": "git", 883 | "url": "https://github.com/sebastianbergmann/environment.git", 884 | "reference": "56932f6049a0482853056ffd617c91ffcc754205" 885 | }, 886 | "dist": { 887 | "type": "zip", 888 | "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/56932f6049a0482853056ffd617c91ffcc754205", 889 | "reference": "56932f6049a0482853056ffd617c91ffcc754205", 890 | "shasum": "" 891 | }, 892 | "require": { 893 | "php": ">=7.1" 894 | }, 895 | "require-dev": { 896 | "phpunit/phpunit": "^7.5" 897 | }, 898 | "suggest": { 899 | "ext-posix": "*" 900 | }, 901 | "type": "library", 902 | "extra": { 903 | "branch-alias": { 904 | "dev-master": "4.2-dev" 905 | } 906 | }, 907 | "autoload": { 908 | "classmap": [ 909 | "src/" 910 | ] 911 | }, 912 | "notification-url": "https://packagist.org/downloads/", 913 | "license": [ 914 | "BSD-3-Clause" 915 | ], 916 | "authors": [ 917 | { 918 | "name": "Sebastian Bergmann", 919 | "email": "sebastian@phpunit.de" 920 | } 921 | ], 922 | "description": "Provides functionality to handle HHVM/PHP environments", 923 | "homepage": "http://www.github.com/sebastianbergmann/environment", 924 | "keywords": [ 925 | "Xdebug", 926 | "environment", 927 | "hhvm" 928 | ], 929 | "support": { 930 | "issues": "https://github.com/sebastianbergmann/environment/issues", 931 | "source": "https://github.com/sebastianbergmann/environment/tree/4.2.5" 932 | }, 933 | "funding": [ 934 | { 935 | "url": "https://github.com/sebastianbergmann", 936 | "type": "github" 937 | } 938 | ], 939 | "time": "2024-03-01T13:49:59+00:00" 940 | }, 941 | { 942 | "name": "sebastian/exporter", 943 | "version": "3.1.6", 944 | "source": { 945 | "type": "git", 946 | "url": "https://github.com/sebastianbergmann/exporter.git", 947 | "reference": "1939bc8fd1d39adcfa88c5b35335910869214c56" 948 | }, 949 | "dist": { 950 | "type": "zip", 951 | "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/1939bc8fd1d39adcfa88c5b35335910869214c56", 952 | "reference": "1939bc8fd1d39adcfa88c5b35335910869214c56", 953 | "shasum": "" 954 | }, 955 | "require": { 956 | "php": ">=7.2", 957 | "sebastian/recursion-context": "^3.0" 958 | }, 959 | "require-dev": { 960 | "ext-mbstring": "*", 961 | "phpunit/phpunit": "^8.5" 962 | }, 963 | "type": "library", 964 | "extra": { 965 | "branch-alias": { 966 | "dev-master": "3.1.x-dev" 967 | } 968 | }, 969 | "autoload": { 970 | "classmap": [ 971 | "src/" 972 | ] 973 | }, 974 | "notification-url": "https://packagist.org/downloads/", 975 | "license": [ 976 | "BSD-3-Clause" 977 | ], 978 | "authors": [ 979 | { 980 | "name": "Sebastian Bergmann", 981 | "email": "sebastian@phpunit.de" 982 | }, 983 | { 984 | "name": "Jeff Welch", 985 | "email": "whatthejeff@gmail.com" 986 | }, 987 | { 988 | "name": "Volker Dusch", 989 | "email": "github@wallbash.com" 990 | }, 991 | { 992 | "name": "Adam Harvey", 993 | "email": "aharvey@php.net" 994 | }, 995 | { 996 | "name": "Bernhard Schussek", 997 | "email": "bschussek@gmail.com" 998 | } 999 | ], 1000 | "description": "Provides the functionality to export PHP variables for visualization", 1001 | "homepage": "http://www.github.com/sebastianbergmann/exporter", 1002 | "keywords": [ 1003 | "export", 1004 | "exporter" 1005 | ], 1006 | "support": { 1007 | "issues": "https://github.com/sebastianbergmann/exporter/issues", 1008 | "source": "https://github.com/sebastianbergmann/exporter/tree/3.1.6" 1009 | }, 1010 | "funding": [ 1011 | { 1012 | "url": "https://github.com/sebastianbergmann", 1013 | "type": "github" 1014 | } 1015 | ], 1016 | "time": "2024-03-02T06:21:38+00:00" 1017 | }, 1018 | { 1019 | "name": "sebastian/global-state", 1020 | "version": "3.0.5", 1021 | "source": { 1022 | "type": "git", 1023 | "url": "https://github.com/sebastianbergmann/global-state.git", 1024 | "reference": "91c7c47047a971f02de57ed6f040087ef110c5d9" 1025 | }, 1026 | "dist": { 1027 | "type": "zip", 1028 | "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/91c7c47047a971f02de57ed6f040087ef110c5d9", 1029 | "reference": "91c7c47047a971f02de57ed6f040087ef110c5d9", 1030 | "shasum": "" 1031 | }, 1032 | "require": { 1033 | "php": ">=7.2", 1034 | "sebastian/object-reflector": "^1.1.1", 1035 | "sebastian/recursion-context": "^3.0" 1036 | }, 1037 | "require-dev": { 1038 | "ext-dom": "*", 1039 | "phpunit/phpunit": "^8.0" 1040 | }, 1041 | "suggest": { 1042 | "ext-uopz": "*" 1043 | }, 1044 | "type": "library", 1045 | "extra": { 1046 | "branch-alias": { 1047 | "dev-master": "3.0-dev" 1048 | } 1049 | }, 1050 | "autoload": { 1051 | "classmap": [ 1052 | "src/" 1053 | ] 1054 | }, 1055 | "notification-url": "https://packagist.org/downloads/", 1056 | "license": [ 1057 | "BSD-3-Clause" 1058 | ], 1059 | "authors": [ 1060 | { 1061 | "name": "Sebastian Bergmann", 1062 | "email": "sebastian@phpunit.de" 1063 | } 1064 | ], 1065 | "description": "Snapshotting of global state", 1066 | "homepage": "http://www.github.com/sebastianbergmann/global-state", 1067 | "keywords": [ 1068 | "global state" 1069 | ], 1070 | "support": { 1071 | "issues": "https://github.com/sebastianbergmann/global-state/issues", 1072 | "source": "https://github.com/sebastianbergmann/global-state/tree/3.0.5" 1073 | }, 1074 | "funding": [ 1075 | { 1076 | "url": "https://github.com/sebastianbergmann", 1077 | "type": "github" 1078 | } 1079 | ], 1080 | "time": "2024-03-02T06:13:16+00:00" 1081 | }, 1082 | { 1083 | "name": "sebastian/object-enumerator", 1084 | "version": "3.0.5", 1085 | "source": { 1086 | "type": "git", 1087 | "url": "https://github.com/sebastianbergmann/object-enumerator.git", 1088 | "reference": "ac5b293dba925751b808e02923399fb44ff0d541" 1089 | }, 1090 | "dist": { 1091 | "type": "zip", 1092 | "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/ac5b293dba925751b808e02923399fb44ff0d541", 1093 | "reference": "ac5b293dba925751b808e02923399fb44ff0d541", 1094 | "shasum": "" 1095 | }, 1096 | "require": { 1097 | "php": ">=7.0", 1098 | "sebastian/object-reflector": "^1.1.1", 1099 | "sebastian/recursion-context": "^3.0" 1100 | }, 1101 | "require-dev": { 1102 | "phpunit/phpunit": "^6.0" 1103 | }, 1104 | "type": "library", 1105 | "extra": { 1106 | "branch-alias": { 1107 | "dev-master": "3.0.x-dev" 1108 | } 1109 | }, 1110 | "autoload": { 1111 | "classmap": [ 1112 | "src/" 1113 | ] 1114 | }, 1115 | "notification-url": "https://packagist.org/downloads/", 1116 | "license": [ 1117 | "BSD-3-Clause" 1118 | ], 1119 | "authors": [ 1120 | { 1121 | "name": "Sebastian Bergmann", 1122 | "email": "sebastian@phpunit.de" 1123 | } 1124 | ], 1125 | "description": "Traverses array structures and object graphs to enumerate all referenced objects", 1126 | "homepage": "https://github.com/sebastianbergmann/object-enumerator/", 1127 | "support": { 1128 | "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", 1129 | "source": "https://github.com/sebastianbergmann/object-enumerator/tree/3.0.5" 1130 | }, 1131 | "funding": [ 1132 | { 1133 | "url": "https://github.com/sebastianbergmann", 1134 | "type": "github" 1135 | } 1136 | ], 1137 | "time": "2024-03-01T13:54:02+00:00" 1138 | }, 1139 | { 1140 | "name": "sebastian/object-reflector", 1141 | "version": "1.1.3", 1142 | "source": { 1143 | "type": "git", 1144 | "url": "https://github.com/sebastianbergmann/object-reflector.git", 1145 | "reference": "1d439c229e61f244ff1f211e5c99737f90c67def" 1146 | }, 1147 | "dist": { 1148 | "type": "zip", 1149 | "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/1d439c229e61f244ff1f211e5c99737f90c67def", 1150 | "reference": "1d439c229e61f244ff1f211e5c99737f90c67def", 1151 | "shasum": "" 1152 | }, 1153 | "require": { 1154 | "php": ">=7.0" 1155 | }, 1156 | "require-dev": { 1157 | "phpunit/phpunit": "^6.0" 1158 | }, 1159 | "type": "library", 1160 | "extra": { 1161 | "branch-alias": { 1162 | "dev-master": "1.1-dev" 1163 | } 1164 | }, 1165 | "autoload": { 1166 | "classmap": [ 1167 | "src/" 1168 | ] 1169 | }, 1170 | "notification-url": "https://packagist.org/downloads/", 1171 | "license": [ 1172 | "BSD-3-Clause" 1173 | ], 1174 | "authors": [ 1175 | { 1176 | "name": "Sebastian Bergmann", 1177 | "email": "sebastian@phpunit.de" 1178 | } 1179 | ], 1180 | "description": "Allows reflection of object attributes, including inherited and non-public ones", 1181 | "homepage": "https://github.com/sebastianbergmann/object-reflector/", 1182 | "support": { 1183 | "issues": "https://github.com/sebastianbergmann/object-reflector/issues", 1184 | "source": "https://github.com/sebastianbergmann/object-reflector/tree/1.1.3" 1185 | }, 1186 | "funding": [ 1187 | { 1188 | "url": "https://github.com/sebastianbergmann", 1189 | "type": "github" 1190 | } 1191 | ], 1192 | "time": "2024-03-01T13:56:04+00:00" 1193 | }, 1194 | { 1195 | "name": "sebastian/recursion-context", 1196 | "version": "3.0.2", 1197 | "source": { 1198 | "type": "git", 1199 | "url": "https://github.com/sebastianbergmann/recursion-context.git", 1200 | "reference": "9bfd3c6f1f08c026f542032dfb42813544f7d64c" 1201 | }, 1202 | "dist": { 1203 | "type": "zip", 1204 | "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/9bfd3c6f1f08c026f542032dfb42813544f7d64c", 1205 | "reference": "9bfd3c6f1f08c026f542032dfb42813544f7d64c", 1206 | "shasum": "" 1207 | }, 1208 | "require": { 1209 | "php": ">=7.0" 1210 | }, 1211 | "require-dev": { 1212 | "phpunit/phpunit": "^6.0" 1213 | }, 1214 | "type": "library", 1215 | "extra": { 1216 | "branch-alias": { 1217 | "dev-master": "3.0.x-dev" 1218 | } 1219 | }, 1220 | "autoload": { 1221 | "classmap": [ 1222 | "src/" 1223 | ] 1224 | }, 1225 | "notification-url": "https://packagist.org/downloads/", 1226 | "license": [ 1227 | "BSD-3-Clause" 1228 | ], 1229 | "authors": [ 1230 | { 1231 | "name": "Sebastian Bergmann", 1232 | "email": "sebastian@phpunit.de" 1233 | }, 1234 | { 1235 | "name": "Jeff Welch", 1236 | "email": "whatthejeff@gmail.com" 1237 | }, 1238 | { 1239 | "name": "Adam Harvey", 1240 | "email": "aharvey@php.net" 1241 | } 1242 | ], 1243 | "description": "Provides functionality to recursively process PHP variables", 1244 | "homepage": "http://www.github.com/sebastianbergmann/recursion-context", 1245 | "support": { 1246 | "issues": "https://github.com/sebastianbergmann/recursion-context/issues", 1247 | "source": "https://github.com/sebastianbergmann/recursion-context/tree/3.0.2" 1248 | }, 1249 | "funding": [ 1250 | { 1251 | "url": "https://github.com/sebastianbergmann", 1252 | "type": "github" 1253 | } 1254 | ], 1255 | "time": "2024-03-01T14:07:30+00:00" 1256 | }, 1257 | { 1258 | "name": "sebastian/resource-operations", 1259 | "version": "2.0.3", 1260 | "source": { 1261 | "type": "git", 1262 | "url": "https://github.com/sebastianbergmann/resource-operations.git", 1263 | "reference": "72a7f7674d053d548003b16ff5a106e7e0e06eee" 1264 | }, 1265 | "dist": { 1266 | "type": "zip", 1267 | "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/72a7f7674d053d548003b16ff5a106e7e0e06eee", 1268 | "reference": "72a7f7674d053d548003b16ff5a106e7e0e06eee", 1269 | "shasum": "" 1270 | }, 1271 | "require": { 1272 | "php": ">=7.1" 1273 | }, 1274 | "type": "library", 1275 | "extra": { 1276 | "branch-alias": { 1277 | "dev-master": "2.0-dev" 1278 | } 1279 | }, 1280 | "autoload": { 1281 | "classmap": [ 1282 | "src/" 1283 | ] 1284 | }, 1285 | "notification-url": "https://packagist.org/downloads/", 1286 | "license": [ 1287 | "BSD-3-Clause" 1288 | ], 1289 | "authors": [ 1290 | { 1291 | "name": "Sebastian Bergmann", 1292 | "email": "sebastian@phpunit.de" 1293 | } 1294 | ], 1295 | "description": "Provides a list of PHP built-in functions that operate on resources", 1296 | "homepage": "https://www.github.com/sebastianbergmann/resource-operations", 1297 | "support": { 1298 | "source": "https://github.com/sebastianbergmann/resource-operations/tree/2.0.3" 1299 | }, 1300 | "funding": [ 1301 | { 1302 | "url": "https://github.com/sebastianbergmann", 1303 | "type": "github" 1304 | } 1305 | ], 1306 | "time": "2024-03-01T13:59:09+00:00" 1307 | }, 1308 | { 1309 | "name": "sebastian/type", 1310 | "version": "1.1.5", 1311 | "source": { 1312 | "type": "git", 1313 | "url": "https://github.com/sebastianbergmann/type.git", 1314 | "reference": "18f071c3a29892b037d35e6b20ddf3ea39b42874" 1315 | }, 1316 | "dist": { 1317 | "type": "zip", 1318 | "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/18f071c3a29892b037d35e6b20ddf3ea39b42874", 1319 | "reference": "18f071c3a29892b037d35e6b20ddf3ea39b42874", 1320 | "shasum": "" 1321 | }, 1322 | "require": { 1323 | "php": ">=7.2" 1324 | }, 1325 | "require-dev": { 1326 | "phpunit/phpunit": "^8.2" 1327 | }, 1328 | "type": "library", 1329 | "extra": { 1330 | "branch-alias": { 1331 | "dev-master": "1.1-dev" 1332 | } 1333 | }, 1334 | "autoload": { 1335 | "classmap": [ 1336 | "src/" 1337 | ] 1338 | }, 1339 | "notification-url": "https://packagist.org/downloads/", 1340 | "license": [ 1341 | "BSD-3-Clause" 1342 | ], 1343 | "authors": [ 1344 | { 1345 | "name": "Sebastian Bergmann", 1346 | "email": "sebastian@phpunit.de", 1347 | "role": "lead" 1348 | } 1349 | ], 1350 | "description": "Collection of value objects that represent the types of the PHP type system", 1351 | "homepage": "https://github.com/sebastianbergmann/type", 1352 | "support": { 1353 | "issues": "https://github.com/sebastianbergmann/type/issues", 1354 | "source": "https://github.com/sebastianbergmann/type/tree/1.1.5" 1355 | }, 1356 | "funding": [ 1357 | { 1358 | "url": "https://github.com/sebastianbergmann", 1359 | "type": "github" 1360 | } 1361 | ], 1362 | "time": "2024-03-01T14:04:07+00:00" 1363 | }, 1364 | { 1365 | "name": "sebastian/version", 1366 | "version": "2.0.1", 1367 | "source": { 1368 | "type": "git", 1369 | "url": "https://github.com/sebastianbergmann/version.git", 1370 | "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" 1371 | }, 1372 | "dist": { 1373 | "type": "zip", 1374 | "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", 1375 | "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", 1376 | "shasum": "" 1377 | }, 1378 | "require": { 1379 | "php": ">=5.6" 1380 | }, 1381 | "type": "library", 1382 | "extra": { 1383 | "branch-alias": { 1384 | "dev-master": "2.0.x-dev" 1385 | } 1386 | }, 1387 | "autoload": { 1388 | "classmap": [ 1389 | "src/" 1390 | ] 1391 | }, 1392 | "notification-url": "https://packagist.org/downloads/", 1393 | "license": [ 1394 | "BSD-3-Clause" 1395 | ], 1396 | "authors": [ 1397 | { 1398 | "name": "Sebastian Bergmann", 1399 | "email": "sebastian@phpunit.de", 1400 | "role": "lead" 1401 | } 1402 | ], 1403 | "description": "Library that helps with managing the version number of Git-hosted PHP projects", 1404 | "homepage": "https://github.com/sebastianbergmann/version", 1405 | "support": { 1406 | "issues": "https://github.com/sebastianbergmann/version/issues", 1407 | "source": "https://github.com/sebastianbergmann/version/tree/master" 1408 | }, 1409 | "time": "2016-10-03T07:35:21+00:00" 1410 | }, 1411 | { 1412 | "name": "theseer/tokenizer", 1413 | "version": "1.2.3", 1414 | "source": { 1415 | "type": "git", 1416 | "url": "https://github.com/theseer/tokenizer.git", 1417 | "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2" 1418 | }, 1419 | "dist": { 1420 | "type": "zip", 1421 | "url": "https://api.github.com/repos/theseer/tokenizer/zipball/737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", 1422 | "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", 1423 | "shasum": "" 1424 | }, 1425 | "require": { 1426 | "ext-dom": "*", 1427 | "ext-tokenizer": "*", 1428 | "ext-xmlwriter": "*", 1429 | "php": "^7.2 || ^8.0" 1430 | }, 1431 | "type": "library", 1432 | "autoload": { 1433 | "classmap": [ 1434 | "src/" 1435 | ] 1436 | }, 1437 | "notification-url": "https://packagist.org/downloads/", 1438 | "license": [ 1439 | "BSD-3-Clause" 1440 | ], 1441 | "authors": [ 1442 | { 1443 | "name": "Arne Blankerts", 1444 | "email": "arne@blankerts.de", 1445 | "role": "Developer" 1446 | } 1447 | ], 1448 | "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", 1449 | "support": { 1450 | "issues": "https://github.com/theseer/tokenizer/issues", 1451 | "source": "https://github.com/theseer/tokenizer/tree/1.2.3" 1452 | }, 1453 | "funding": [ 1454 | { 1455 | "url": "https://github.com/theseer", 1456 | "type": "github" 1457 | } 1458 | ], 1459 | "time": "2024-03-03T12:36:25+00:00" 1460 | } 1461 | ], 1462 | "aliases": [], 1463 | "minimum-stability": "stable", 1464 | "stability-flags": [], 1465 | "prefer-stable": false, 1466 | "prefer-lowest": false, 1467 | "platform": [], 1468 | "platform-dev": [], 1469 | "plugin-api-version": "2.3.0" 1470 | } 1471 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | tests 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/indieweb/comments.php: -------------------------------------------------------------------------------- 1 | $maxLines) { 13 | $newContent = array(); 14 | $visibleLinesAdded = 0; 15 | $i = 0; 16 | while($visibleLinesAdded < $maxLines && $i < count($lines)) { 17 | $line = $lines[$i]; 18 | $newContent[] = $line; 19 | if(trim($line) != '') 20 | $visibleLinesAdded++; 21 | $i++; 22 | } 23 | $text = implode("\n", $newContent); 24 | // Tack on extra chars and then tell cassis to ellipsize it shorter to take advantage of proper ellipsizing logic. 25 | // This is for when the full text is shorter than $maxTextLength but has more lines than $maxLines 26 | $text .= ' ....'; 27 | $text = truncateString($text, min($maxTextLength, strlen($text)-1)); 28 | } else { 29 | $text = truncateString($text, $maxTextLength); 30 | } 31 | return $text; 32 | } 33 | 34 | // Collects all URLs found in the input array, and remove the scheme. 35 | // An input object may be a string URL or also an mf2 object with properties.url 36 | function collectURLs(&$urls) { 37 | if(is_array($urls) && array_key_exists(0, $urls)) { 38 | foreach($urls as $i=>$u) { 39 | collectURLs($urls[$i]); 40 | } 41 | } elseif(is_array($urls) 42 | && array_key_exists('type', $urls) 43 | && array_key_exists('properties', $urls) 44 | && array_key_exists('url', $urls['properties']) 45 | ) { 46 | // Flatten the object and turn it just into the URL 47 | $urls = preg_replace('/^https?/', '', $urls['properties']['url'][0]); 48 | } elseif(is_string($urls)) { 49 | $urls = preg_replace('/^https?/', '', $urls); 50 | } 51 | } 52 | 53 | function parse($mf, $refURL=false, $maxTextLength=150, $maxLines=2) { 54 | // When parsing a comment, the $refURL is the URL being commented on. 55 | // This is used to check for an explicit in-reply-to property set to this URL. 56 | 57 | // Remove the scheme from the refURL and treat http and https links as the same 58 | collectURLs($refURL); 59 | 60 | $type = 'mention'; 61 | $published = false; 62 | $name = false; 63 | $text = false; 64 | $url = false; 65 | $author = array( 66 | 'name' => false, 67 | 'photo' => false, 68 | 'url' => false 69 | ); 70 | $rsvp = null; 71 | 72 | if(array_key_exists('type', $mf) && in_array('h-entry', $mf['type']) && array_key_exists('properties', $mf)) { 73 | $properties = $mf['properties']; 74 | 75 | if(array_key_exists('author', $properties)) { 76 | $authorProperty = $properties['author'][0]; 77 | if(is_array($authorProperty)) { 78 | 79 | if(array_key_exists('name', $authorProperty['properties'])) { 80 | $author['name'] = $authorProperty['properties']['name'][0]; 81 | } 82 | 83 | if(array_key_exists('url', $authorProperty['properties'])) { 84 | $author['url'] = $authorProperty['properties']['url'][0]; 85 | } 86 | 87 | if(array_key_exists('photo', $authorProperty['properties'])) { 88 | $author['photo'] = $authorProperty['properties']['photo'][0]; 89 | } 90 | 91 | } elseif(is_string($authorProperty)) { 92 | $author['url'] = $authorProperty; 93 | } 94 | } 95 | 96 | if(array_key_exists('published', $properties)) { 97 | $published = $properties['published'][0]; 98 | } 99 | 100 | if(array_key_exists('url', $properties)) { 101 | $url = $properties['url'][0]; 102 | } 103 | 104 | // If the post has an explicit in-reply-to property, verify it matches $refURL and set the type to "reply" 105 | if($refURL && array_key_exists('in-reply-to', $properties)) { 106 | // in-reply-to may be a string or an h-cite 107 | foreach($properties['in-reply-to'] as $check) { 108 | collectURLs($check); 109 | if(is_string($check) && $check == $refURL) { 110 | $type = 'reply'; 111 | continue; 112 | } elseif(is_array($check)) { 113 | if(array_key_exists('type', $check) && in_array('h-cite', $check['type'])) { 114 | if(array_key_exists('properties', $check) && array_key_exists('url', $check['properties'])) { 115 | if(in_array($refURL, $check['properties']['url'])) { 116 | $type = 'reply'; 117 | } 118 | } 119 | } 120 | } 121 | } 122 | } 123 | 124 | // Check if the reply is an RSVP 125 | if(array_key_exists('rsvp', $properties)) { 126 | $rsvp = $properties['rsvp'][0]; 127 | $type = 'rsvp'; 128 | } 129 | 130 | // Check if the reply is an invitation 131 | if(array_key_exists('invitee', $properties)) { 132 | $inviteeProperty = $properties['invitee'][0]; 133 | if(is_array($inviteeProperty)) { 134 | 135 | if(array_key_exists('name', $inviteeProperty['properties'])) { 136 | $invitee['name'] = $inviteeProperty['properties']['name'][0]; 137 | } 138 | 139 | if(array_key_exists('url', $inviteeProperty['properties'])) { 140 | $invitee['url'] = $inviteeProperty['properties']['url'][0]; 141 | } 142 | 143 | if(array_key_exists('photo', $inviteeProperty['properties'])) { 144 | $invitee['photo'] = $inviteeProperty['properties']['photo'][0]; 145 | } 146 | 147 | } elseif(is_string($inviteeProperty)) { 148 | $invitee['url'] = $inviteeProperty; 149 | } 150 | $type = 'invite'; 151 | } 152 | 153 | // Check if this post is a "repost" 154 | if($refURL && array_key_exists('repost-of', $properties)) { 155 | collectURLs($properties['repost-of']); 156 | if(in_array($refURL, $properties['repost-of'])) 157 | $type = 'repost'; 158 | } 159 | 160 | // Also check for "u-repost" since some people are sending that. Probably "u-repost-of" will win out. 161 | if($refURL && array_key_exists('repost', $properties)) { 162 | collectURLs($properties['repost']); 163 | if(in_array($refURL, $properties['repost'])) 164 | $type = 'repost'; 165 | } 166 | 167 | // Check if this post is a "like-of" 168 | if($refURL && array_key_exists('like-of', $properties)) { 169 | collectURLs($properties['like-of']); 170 | if(in_array($refURL, $properties['like-of'])) 171 | $type = 'like'; 172 | } 173 | 174 | // Check if this post is a "like" (Should be deprecated in the future) 175 | if($refURL && array_key_exists('like', $properties)) { 176 | collectURLs($properties['like']); 177 | if(in_array($refURL, $properties['like'])) 178 | $type = 'like'; 179 | } 180 | 181 | // Check if this post is a "bookmark-of" 182 | if($refURL && array_key_exists('bookmark-of', $properties)) { 183 | collectURLs($properties['bookmark-of']); 184 | if(in_array($refURL, $properties['bookmark-of'])) 185 | $type = 'bookmark'; 186 | } 187 | 188 | // From http://indiewebcamp.com/comments-presentation#How_to_display 189 | 190 | // If the entry has an e-content, and if the content is not too long, use that 191 | if(array_key_exists('content', $properties)) { 192 | $content = $properties['content'][0]; 193 | if ((is_array($content) && array_key_exists('value', $content)) || is_string($content)) { 194 | if (is_array($content)) { 195 | $content = $content['value']; 196 | } 197 | 198 | $visibleLines = array_filter(explode("\n", $content)); 199 | if(strlen($content) <= $maxTextLength && count($visibleLines) <= $maxLines) { 200 | $text = $content; 201 | } 202 | } 203 | // If the content is not a string or array with “value”, something is wrong. 204 | } 205 | 206 | // If there is no e-content, or if it is too long 207 | if($text == false) { 208 | // if the h-entry has a p-summary, and the text is not too long, use that 209 | if(array_key_exists('summary', $properties)) { 210 | $summary = $properties['summary'][0]; 211 | if(is_array($summary) && array_key_exists('value', $summary)) 212 | $summary = $summary['value']; 213 | 214 | if(strlen($summary) <= $maxTextLength) { 215 | $text = $summary; 216 | } else { 217 | // if the p-summary is too long, then truncate the p-summary 218 | $text = truncate($summary, $maxTextLength, $maxLines); 219 | } 220 | } else { 221 | // if no p-summary, but there is an e-content, use a truncated e-content 222 | if(array_key_exists('content', $properties)) { 223 | // $content already exists from line 127, and is guaranteed to be a string. 224 | $text = truncate($content, $maxTextLength, $maxLines); 225 | } 226 | } 227 | } 228 | 229 | // If there is no e-content and no p-summary 230 | if($text == false) { 231 | // If there is a p-name, and it's not too long, use that 232 | if(array_key_exists('name', $properties)) { 233 | $pname = $properties['name'][0]; 234 | if(strlen($pname) <= $maxTextLength) { 235 | $text = $pname; 236 | } else { 237 | // if the p-name is too long, truncate it 238 | $text = truncate($pname, $maxTextLength, $maxLines); 239 | } 240 | } 241 | } 242 | 243 | // Now see if the "name" property of the h-entry is unique or part of the content 244 | if(array_key_exists('name', $properties)) { 245 | $nameSanitized = strtolower(strip_tags($properties['name'][0])); 246 | $nameSanitized = preg_replace('/ ?\.+$/', '', $nameSanitized); // Remove trailing ellipses 247 | // Using the already truncated version of the content here. But the "name" would not have been truncated so may be longer than the content. 248 | $contentSanitized = strtolower(strip_tags($text)); 249 | $contentSanitized = preg_replace('/ ?\.+$/', '', $contentSanitized); // Remove trailing ellipses 250 | 251 | // If this is a "mention" instead of a "reply", and if there is no "content" property, 252 | // then we actually want to use the "name" property as the name and leave "text" blank. 253 | if($type == 'mention' && !array_key_exists('content', $properties)) { 254 | $name = truncate($properties['name'][0], $maxTextLength, $maxLines); 255 | $text = false; 256 | } else { 257 | if($nameSanitized != $contentSanitized and $nameSanitized !== '') { 258 | // If the name is the beginning of the content, we don't care 259 | // Same if the content is the beginning of the name (like with really long notes) 260 | if($contentSanitized === '' 261 | || (!(strpos($contentSanitized, $nameSanitized) === 0) && !(strpos($nameSanitized, $contentSanitized) === 0)) 262 | ) { 263 | // The name was determined to be different from the content, so return it 264 | $name = $properties['name'][0]; //truncate($properties['name'][0], $maxTextLength, $maxLines); 265 | } 266 | } 267 | } 268 | } 269 | 270 | } 271 | 272 | $result = array( 273 | 'author' => $author, 274 | 'published' => $published, 275 | 'name' => $name, 276 | 'text' => $text, 277 | 'url' => $url, 278 | 'type' => $type 279 | ); 280 | 281 | if($type == 'invite') 282 | $result['invitee'] = $invitee; 283 | 284 | if($rsvp !== null) { 285 | $result['rsvp'] = $rsvp; 286 | } 287 | 288 | return $result; 289 | } 290 | -------------------------------------------------------------------------------- /tests/BasicTest.php: -------------------------------------------------------------------------------- 1 | array('h-entry'), 13 | 'properties' => array( 14 | 'author' => array( 15 | ($author ?: array( 16 | 'type' => array('h-card'), 17 | 'properties' => array( 18 | 'name' => array('Aaron Parecki'), 19 | 'url' => array('http://aaronparecki.com/'), 20 | 'photo' => array('http://aaronparecki.com/images/aaronpk.png') 21 | ) 22 | )) 23 | ), 24 | 'published' => array('2014-02-16T18:48:17-0800'), 25 | 'url' => array('http://aaronparecki.com/post/1'), 26 | ) 27 | ); 28 | if($replyTo === true) { 29 | $entry['properties']['in-reply-to'] = array($this->_refURL); 30 | } 31 | if(is_array($replyTo)) { 32 | $entry['properties']['in-reply-to'] = array($replyTo); 33 | } 34 | if(array_key_exists('content', $input)) { 35 | if(is_string($input['content'])) { 36 | $entry['properties']['content'] = array(array( 37 | 'html' => $input['content'], 38 | 'value' => strip_tags($input['content']) 39 | )); 40 | } else { 41 | $entry['properties']['content'] = array($input['content']); 42 | } 43 | unset($input['content']); 44 | } 45 | // The rest of the properties are all simple properties. Loop through and add them all as properties. 46 | foreach($input as $key=>$val) { 47 | $entry['properties'][$key] = array($val); 48 | } 49 | return $entry; 50 | } 51 | 52 | public function testBasicExample() { 53 | $result = IndieWeb\comments\parse($this->buildHEntry(array( 54 | 'name' => 'post name', 55 | 'summary' => 'post summary', 56 | 'content' => 'this is some content' 57 | )), $this->_refURL, 90); 58 | $this->assertEquals(array( 59 | 'type' => 'reply', 60 | 'author' => array( 61 | 'name' => 'Aaron Parecki', 62 | 'photo' => 'http://aaronparecki.com/images/aaronpk.png', 63 | 'url' => 'http://aaronparecki.com/' 64 | ), 65 | 'published' => '2014-02-16T18:48:17-0800', 66 | 'name' => 'post name', 67 | 'text' => 'this is some content', 68 | 'url' => 'http://aaronparecki.com/post/1' 69 | ), $result); 70 | } 71 | 72 | public function testContentTooLongSummaryIsOk() { 73 | $result = IndieWeb\comments\parse($this->buildHEntry(array( 74 | 'name' => 'post name', 75 | 'summary' => 'post summary', 76 | 'content' => '

this is some content but it is longer than 90 characters so the summary will be used instead

' 77 | )), $this->_refURL, 90); 78 | $this->assertEquals('reply', $result['type']); 79 | $this->assertEquals('post summary', $result['text']); 80 | } 81 | 82 | public function testContentTooLongSummaryTooLong() { 83 | $result = IndieWeb\comments\parse($this->buildHEntry(array( 84 | 'name' => 'post name', 85 | 'summary' => 'in this case the post summary is also too long, so a truncated version should be displayed instead', 86 | 'content' => '

this is some content but it is longer than 90 characters so the summary will be used instead

' 87 | )), $this->_refURL, 90); 88 | $this->assertEquals('reply', $result['type']); 89 | $this->assertEquals('in this case the post summary is also too long, so a truncated version should be ...', $result['text']); 90 | } 91 | 92 | public function testContentTooLongNoSummary() { 93 | $result = IndieWeb\comments\parse($this->buildHEntry(array( 94 | 'name' => 'post name', 95 | 'content' => '

this is some content but it is longer than 90 characters so it will be truncated because there is no summary

' 96 | )), $this->_refURL, 90); 97 | $this->assertEquals('reply', $result['type']); 98 | $this->assertEquals('this is some content but it is longer than 90 characters so it will be truncated ...', $result['text']); 99 | } 100 | 101 | public function testReplyNoContentNoSummaryNameOk() { 102 | // This one's tricky. If there is no content, the comments-presentation algorithm says to use the name. 103 | // So the parser won't return a value for the "name" property since the value would already 104 | // be used in the comment text, but only when it is a reply. 105 | $result = IndieWeb\comments\parse($this->buildHEntry(array( 106 | 'name' => 'post name' 107 | )), $this->_refURL, 90); 108 | $this->assertEquals('reply', $result['type']); 109 | $this->assertEquals('', $result['name']); 110 | $this->assertEquals('post name', $result['text']); 111 | } 112 | 113 | public function testMentionNoContentNoSummaryNameOk() { 114 | // This one's tricky. If there is no content, the comments-presentation algorithm says to use the name. 115 | // BUT, since this one is a mention, not a reply, it is returned in the "name" instead, with blank "text". 116 | $result = IndieWeb\comments\parse($this->buildHEntry(array( 117 | 'name' => 'post name' 118 | ), false, false), $this->_refURL, 90); 119 | $this->assertEquals('mention', $result['type']); 120 | $this->assertEquals('post name', $result['name']); 121 | $this->assertEquals('', $result['text']); 122 | } 123 | 124 | public function testNoContentNoSummaryNameTooLong() { 125 | $result = IndieWeb\comments\parse($this->buildHEntry(array( 126 | 'name' => 'this is a really long post name' 127 | )), $this->_refURL, 20); 128 | $this->assertEquals('reply', $result['type']); 129 | $this->assertEquals('this is a really ...', $result['text']); 130 | } 131 | 132 | public function testNameIsSubstringOfContent() { 133 | $result = IndieWeb\comments\parse($this->buildHEntry(array( 134 | 'name' => 'The name of the note', 135 | 'content' => 'The name of the note is a substring of the content' 136 | )), $this->_refURL, 200); 137 | $this->assertEquals('reply', $result['type']); 138 | $this->assertEquals('', $result['name']); 139 | $this->assertEquals('The name of the note is a substring of the content', $result['text']); 140 | } 141 | 142 | public function testNameIsEllipsizedAndSubstringOfContent() { 143 | $result = IndieWeb\comments\parse($this->buildHEntry(array( 144 | 'name' => 'The name of the note ...', 145 | 'content' => 'The name of the note is a substring of the content' 146 | )), $this->_refURL, 200); 147 | $this->assertEquals('reply', $result['type']); 148 | $this->assertEquals('', $result['name']); 149 | $this->assertEquals('The name of the note is a substring of the content', $result['text']); 150 | } 151 | 152 | public function testNamedArticleWithShortContent() { 153 | $result = IndieWeb\comments\parse($this->buildHEntry(array( 154 | 'name' => 'Post Name', 155 | 'content' => 'The name of the post is different from the content' 156 | )), $this->_refURL, 200); 157 | $this->assertEquals('reply', $result['type']); 158 | $this->assertEquals('Post Name', $result['name']); 159 | $this->assertEquals('The name of the post is different from the content', $result['text']); 160 | } 161 | 162 | public function testNamedArticleWithLongContent() { 163 | $result = IndieWeb\comments\parse($this->buildHEntry(array( 164 | 'name' => 'Post Name', 165 | 'content' => 'The name of the post is different from the content, but in this case the content is too long and should be truncated.' 166 | )), $this->_refURL, 40); 167 | $this->assertEquals('reply', $result['type']); 168 | $this->assertEquals('Post Name', $result['name']); 169 | $this->assertEquals('The name of the post is different ...', $result['text']); 170 | } 171 | 172 | public function testNameIsReturned() { 173 | $result = IndieWeb\comments\parse($this->buildHEntry(array( 174 | 'name' => 'Post Name', 175 | 'content' => 'The name of the post is different from the content, but in this case the content is too long and should be truncated.' 176 | ), false, false), $this->_refURL, 40); 177 | $this->assertEquals('mention', $result['type']); 178 | $this->assertEquals('Post Name', $result['name']); 179 | $this->assertEquals('The name of the post is different ...', $result['text']); 180 | } 181 | 182 | public function testNameIsTooLong() { 183 | $result = IndieWeb\comments\parse($this->buildHEntry(array( 184 | 'name' => 'This is the name of the post but it is far too long. This sometimes happens when the name was generated from the implied parsing rules.' 185 | ), false, false), $this->_refURL, 40); 186 | $this->assertEquals('mention', $result['type']); 187 | $this->assertEquals('This is the name of the post but it ...', $result['name']); 188 | $this->assertEquals('', $result['text']); 189 | } 190 | 191 | public function testNoMicroformatsIsMention() { 192 | $result = IndieWeb\comments\parse(array(), $this->_refURL, 200); 193 | $this->assertEquals('mention', $result['type']); 194 | $this->assertEquals('', $result['text']); 195 | } 196 | 197 | public function testHCiteIsReply() { 198 | $result = IndieWeb\comments\parse($this->buildHEntry(array( 199 | 'name' => 'Post Name', 200 | ), false, array( 201 | 'type' => array('h-cite'), 202 | 'properties' => array( 203 | 'url' => array($this->_refURL), 204 | ) 205 | )), $this->_refURL, 40); 206 | $this->assertEquals('reply', $result['type']); 207 | $this->assertEquals('Post Name', $result['text']); 208 | } 209 | 210 | /*************************************************************************** 211 | * Multi-line comments 212 | */ 213 | 214 | public function testMultiLineCommentFitsWithinLimits() { 215 | $result = IndieWeb\comments\parse($this->buildHEntry(array( 216 | 'content' => array( 217 | 'value' => 'Line one 218 | Line two 219 | Line three' 220 | ) 221 | ), false, false), $this->_refURL, 400, 3); 222 | $this->assertEquals('', $result['name']); 223 | $this->assertEquals('Line one 224 | Line two 225 | Line three', $result['text']); 226 | } 227 | 228 | public function testTrimMultiLineCommentHalfWayThroughThirdLine() { 229 | $result = IndieWeb\comments\parse($this->buildHEntry(array( 230 | 'content' => array( 231 | 'html' => '#HouseOfCards s2e1 was good. 232 | But the best thing yesterday was getting to try a Boosted electric skateboard: http://boostedboards.com/ 233 | 234 | Amazing. Handheld trigger remote control via Bluetooth. Forward and reverse. And I only tried it in "turtle" mode. In "rabbit" mode it can apparently do 20 miles an hour. Up hill. Jetsons-like motor sound included. 235 | 236 | Forget about Segway, Boosted's electric skateboard feels like an object from the future dropped into the present, more in the realm of Marty's hoverboard (Back To The Future II & III) and Y.T.'s Smartwheels skateboard (Snow Crash).', 237 | 'value' => "#HouseOfCards s2e1 was good. 238 | But the best thing yesterday was getting to try a Boosted electric skateboard: http://boostedboards.com/ 239 | 240 | Amazing. Handheld trigger remote control via Bluetooth. Forward and reverse. And I only tried it in \"turtle\" mode. In \"rabbit\" mode it can apparently do 20 miles an hour. Up hill. Jetsons-like motor sound included. 241 | 242 | Forget about Segway, Boosted's electric skateboard feels like an object from the future dropped into the present, more in the realm of Marty's hoverboard (Back To The Future II & III) and Y.T.'s Smartwheels skateboard (Snow Crash)." 243 | ) 244 | ), false, false), $this->_refURL, 197, 3); 245 | $this->assertEquals('mention', $result['type']); 246 | $this->assertEquals('', $result['name']); 247 | $this->assertEquals("#HouseOfCards s2e1 was good. 248 | But the best thing yesterday was getting to try a Boosted electric skateboard: http://boostedboards.com/ 249 | 250 | Amazing. Handheld trigger remote control via Bluetooth. ...", $result['text']); 251 | } 252 | 253 | public function testTrimShortTextMultiLineComment() { 254 | $result = IndieWeb\comments\parse($this->buildHEntry(array( 255 | 'name' => 'Post Name', 256 | 'content' => array( 257 | 'html' => '', 258 | 'value' => "This comment spans multiple lines.\nOnly the first two lines should be returned.\nThe rest should be truncated." 259 | ) 260 | ), false, false), $this->_refURL, 400, 2); 261 | $this->assertEquals('mention', $result['type']); 262 | $this->assertEquals('Post Name', $result['name']); 263 | $this->assertEquals("This comment spans multiple lines.\nOnly the first two lines should be returned. ...", $result['text']); 264 | } 265 | 266 | public function testMultiLineCommentWithReallyLongName() { 267 | $result = IndieWeb\comments\parse($this->loadFile('post-tantek-1.json'), 'http://aaronparecki.com/events/2013/09/30/1/indieweb-dinner-at-21st-amendment', 400, 2); 268 | $this->assertEquals('mention', $result['type']); 269 | $this->assertEquals('', $result['name']); 270 | $this->assertEquals('Well done @aaronpk! Real-time #indieweb comments: 271 | http://aaronparecki.com/articles/2013/10/13/1/realtime-indieweb-comments ...', $result['text']); 272 | } 273 | 274 | public function testBnvk() { 275 | // bnvk linked to the https version of my post, but the site checks exclusively for http mentions 276 | $result = IndieWeb\comments\parse($this->loadFile('post-bnvk-1.json'), 'http://aaronparecki.com/notes/2013/10/12/2/indieweb', 400, 2); 277 | $this->assertEquals('reply', $result['type']); 278 | $this->assertEquals('', $result['name']); 279 | $this->assertEquals("Hi ho, hi ho, it's a manual loading and sending of Webmention from my site! 280 | \t\tReplied at 281 | \t\tMar 30, 2014", $result['text']); 282 | } 283 | 284 | public function testMentionNoNameWithContent() { 285 | $result = IndieWeb\comments\parse($this->buildHEntry(array( 286 | 'name' => '', 287 | 'content' => 'post name' 288 | )), false, 90); 289 | $this->assertEquals('mention', $result['type']); 290 | $this->assertEquals('', $result['name']); 291 | $this->assertEquals('post name', $result['text']); 292 | } 293 | 294 | public function testMentionCommentedContentWithName() { 295 | // It's possible for the plaintext to end up with an HTML comment for various reasons. 296 | // Version 0.2.* of php-mf2 failed to remove the contents of leading to an HTML comment in the text. 298 | // Also
<!-- Hello World -->
will result in what looks like HTML comment in the value. 299 | $result = IndieWeb\comments\parse($this->buildHEntry(array( 300 | 'name' => "post name", 301 | 'content' => [ 302 | 'html' => "

", 303 | 'value' => "" 304 | ] 305 | )), false, 500); 306 | $this->assertEquals('mention', $result['type']); 307 | $this->assertEquals('post name', $result['name']); 308 | } 309 | 310 | /*************************************************************************** 311 | * Other post types 312 | */ 313 | 314 | public function testReplyIsRSVP() { 315 | $result = IndieWeb\comments\parse($this->buildHEntry(array( 316 | 'name' => 'RSVP Yes', 317 | 'content' => 'Going to tonight\'s #IndieWeb Dinner @21stAmendment, 18:00. Hope to see you there!', 318 | 'rsvp' => 'yes' 319 | )), $this->_refURL, 200); 320 | $this->assertEquals('rsvp', $result['type']); 321 | $this->assertEquals('Going to tonight\'s #IndieWeb Dinner @21stAmendment, 18:00. Hope to see you there!', $result['text']); 322 | $this->assertEquals('yes', $result['rsvp']); 323 | } 324 | 325 | public function testIsLike() { 326 | $result = IndieWeb\comments\parse($this->buildHEntry(array( 327 | 'name' => 'Liked this', 328 | 'content' => 'liked this post', 329 | 'like' => $this->_refURL 330 | )), $this->_refURL, 200); 331 | $this->assertEquals('like', $result['type']); 332 | $this->assertEquals('liked this post', $result['text']); 333 | } 334 | 335 | public function testIsLikeOf() { 336 | $result = IndieWeb\comments\parse($this->buildHEntry(array( 337 | 'name' => 'Liked this', 338 | 'content' => 'liked this post', 339 | 'like-of' => $this->_refURL 340 | )), $this->_refURL, 200); 341 | $this->assertEquals('like', $result['type']); 342 | $this->assertEquals('liked this post', $result['text']); 343 | } 344 | 345 | public function testIsBookmarkOf() { 346 | $result = IndieWeb\comments\parse($this->buildHEntry(array( 347 | 'name' => 'Bookmarked this', 348 | 'content' => 'bookmarked this post', 349 | 'bookmark-of' => $this->_refURL 350 | )), $this->_refURL, 200); 351 | $this->assertEquals('bookmark', $result['type']); 352 | $this->assertEquals('bookmarked this post', $result['text']); 353 | } 354 | 355 | public function testIsRepostOf() { 356 | $result = IndieWeb\comments\parse($this->buildHEntry(array( 357 | 'name' => 'Reposted this', 358 | 'content' => 'Reposted this', 359 | 'repost-of' => $this->_refURL 360 | )), $this->_refURL, 200); 361 | $this->assertEquals('repost', $result['type']); 362 | $this->assertEquals('Reposted this', $result['text']); 363 | } 364 | 365 | public function testIsRepost() { 366 | $result = IndieWeb\comments\parse($this->buildHEntry(array( 367 | 'name' => 'Reposted this', 368 | 'content' => 'Reposted this', 369 | 'repost' => $this->_refURL 370 | )), $this->_refURL, 200); 371 | $this->assertEquals('repost', $result['type']); 372 | $this->assertEquals('Reposted this', $result['text']); 373 | } 374 | 375 | public function testIsNotInReplyTo() { 376 | $result = IndieWeb\comments\parse($this->buildHEntry(array( 377 | 'name' => 'Post Name', 378 | 'content' => 'The name of the post is different from the content, but in this case the content is too long and should be truncated.' 379 | ), false, false), $this->_refURL, 40); 380 | $this->assertEquals('mention', $result['type']); 381 | $this->assertEquals('The name of the post is different ...', $result['text']); 382 | } 383 | 384 | public function testIsLikeOfHCite() { 385 | $result = IndieWeb\comments\parse($this->buildHEntry(array( 386 | 'name' => 'Liked this', 387 | 'content' => 'liked this post', 388 | 'like-of' => array( 389 | 'type' => 'h-cite', 390 | 'properties' => array( 391 | 'url' => array($this->_refURL) 392 | ) 393 | ) 394 | )), $this->_refURL, 200); 395 | $this->assertEquals('like', $result['type']); 396 | $this->assertEquals('liked this post', $result['text']); 397 | } 398 | 399 | /*************************************************************************** 400 | * Author tests 401 | */ 402 | 403 | public function testAuthorIsURL() { 404 | $result = IndieWeb\comments\parse($this->buildHEntry(array( 405 | 'name' => 'post name', 406 | 'summary' => 'post summary', 407 | 'content' => '

this is some content

' 408 | ), 'http://aaronparecki.com/'), $this->_refURL, 200); 409 | $author = $result['author']; 410 | $this->assertEquals('reply', $result['type']); 411 | $this->assertEquals(false, $author['name']); 412 | $this->assertEquals(false, $author['photo']); 413 | $this->assertEquals('http://aaronparecki.com/', $author['url']); 414 | } 415 | 416 | public function testAuthorIsHCard() { 417 | $result = IndieWeb\comments\parse($this->buildHEntry(array( 418 | 'name' => 'post name', 419 | 'summary' => 'post summary', 420 | 'content' => '

this is some content

' 421 | )), $this->_refURL, 200); 422 | $author = $result['author']; 423 | $this->assertEquals('reply', $result['type']); 424 | $this->assertEquals('Aaron Parecki', $author['name']); 425 | $this->assertEquals('http://aaronparecki.com/images/aaronpk.png', $author['photo']); 426 | $this->assertEquals('http://aaronparecki.com/', $author['url']); 427 | } 428 | 429 | public function testAuthorIsHCardWithNoPhoto() { 430 | $result = IndieWeb\comments\parse($this->buildHEntry(array( 431 | 'name' => 'post name', 432 | 'summary' => 'post summary', 433 | 'content' => '

this is some content

' 434 | ), array( 435 | 'type' => array('h-card'), 436 | 'properties' => array( 437 | 'name' => array('Aaron Parecki'), 438 | 'url' => array('http://aaronparecki.com') 439 | ) 440 | ) 441 | ), $this->_refURL, 200); 442 | $this->assertEquals('reply', $result['type']); 443 | $this->assertEquals('Aaron Parecki', $result['author']['name']); 444 | $this->assertEquals('', $result['author']['photo']); 445 | $this->assertEquals('http://aaronparecki.com', $result['author']['url']); 446 | } 447 | 448 | /** 449 | * @see https://github.com/indieweb/php-comments/issues/1 450 | * @see https://github.com/indieweb/php-comments/issues/3 451 | */ 452 | public function testWorksWithNonEParsedContentProperty() { 453 | $result = IndieWeb\comments\parse([ 454 | 'type' => ['h-entry'], 455 | 'properties' => [ 456 | 'content' => ['This is a scalar string content property as might have been parsed from p-content but very long This is a scalar string content property as might have been parsed from p-content'] 457 | ] 458 | ]); 459 | 460 | $this->assertEquals('This is a scalar string content property as might have been parsed from p-content but very long This is a scalar string content property as might ...', $result['text']); 461 | } 462 | 463 | /** 464 | * @see https://github.com/indieweb/php-comments/issues/2 465 | */ 466 | public function testHandlesHEntryWithEmptyNameCorrectly() { 467 | $result = Indieweb\comments\parse([ 468 | 'type' => ['h-entry'], 469 | 'properties' => [ 470 | 'name' => [''], 471 | 'content' => ['Blah blah blah'] 472 | ] 473 | ]); 474 | 475 | $this->assertFalse($result['name']); 476 | } 477 | 478 | } 479 | 480 | -------------------------------------------------------------------------------- /tests/bootstrap.php: -------------------------------------------------------------------------------- 1 | <\/br>\n\t\tReplied at\n\t\t@aaronpk<\/a>! Real-time #indieweb comments:\nhttp:\/\/aaronparecki.com\/articles\/2013\/10\/13\/1\/realtime-indieweb-comments<\/a>\n\nI only mentioned the idea at the @indiewebcamp<\/a> dinner at 21st Amendment http:\/\/aaronparecki.com\/events\/2013\/09\/30\/1\/indieweb-dinner-at-21st-amendment<\/a> and he's already implemented it live on his site! \n\nAt the dinner, Aaron & Amber had noted they were going to attend a realtime conference and asked if I had any suggestions for things to show or talk about. I pointed out that the only silo (AFAIK) that was really \"realtime\" was Facebook, since pages you were viewing updated automatically when others added to them, e.g. comments.\n\nI said wouldn't it be awesome if indieweb comments worked like that too, because then we'd instantly have something that Twitter, G+, etc. all the other silos did NOT have. Plus it would make for a great indieweb demo.\n\nAnd there it is:\n\n<\/img><\/a>\n\nRead Aaron's whole blog post on the design and implementation (you know, the stuff that counts, as ideas are cheap :) with source:\n\nhttp:\/\/aaronparecki.com\/articles\/2013\/10\/13\/1\/realtime-indieweb-comments<\/a>\n\nUpdate: showing this off 2013-10-14 to folks at the New York Times.", 77 | "value": "Well done @aaronpk! Real-time #indieweb comments:\nhttp:\/\/aaronparecki.com\/articles\/2013\/10\/13\/1\/realtime-indieweb-comments\n\nI only mentioned the idea at the @indiewebcamp dinner at 21st Amendment http:\/\/aaronparecki.com\/events\/2013\/09\/30\/1\/indieweb-dinner-at-21st-amendment and he's already implemented it live on his site! \n\nAt the dinner, Aaron & Amber had noted they were going to attend a realtime conference and asked if I had any suggestions for things to show or talk about. I pointed out that the only silo (AFAIK) that was really \"realtime\" was Facebook, since pages you were viewing updated automatically when others added to them, e.g. comments.\n\nI said wouldn't it be awesome if indieweb comments worked like that too, because then we'd instantly have something that Twitter, G+, etc. all the other silos did NOT have. Plus it would make for a great indieweb demo.\n\nAnd there it is:\n\n\n\nRead Aaron's whole blog post on the design and implementation (you know, the stuff that counts, as ideas are cheap :) with source:\n\nhttp:\/\/aaronparecki.com\/articles\/2013\/10\/13\/1\/realtime-indieweb-comments\n\nUpdate: showing this off 2013-10-14 to folks at the New York Times." 78 | } 79 | ] 80 | }, 81 | "children": [ 82 | { 83 | "type": [ 84 | "h-x-username" 85 | ], 86 | "properties": { 87 | "name": [ 88 | "@aaronpk" 89 | ], 90 | "url": [ 91 | "https:\/\/twitter.com\/aaronpk" 92 | ] 93 | }, 94 | "value": "@aaronpk" 95 | }, 96 | { 97 | "type": [ 98 | "h-x-username" 99 | ], 100 | "properties": { 101 | "name": [ 102 | "@indiewebcamp" 103 | ], 104 | "url": [ 105 | "https:\/\/twitter.com\/indiewebcamp" 106 | ] 107 | }, 108 | "value": "@indiewebcamp" 109 | } 110 | ] 111 | } --------------------------------------------------------------------------------