-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8003b18
Showing
32 changed files
with
1,635 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 4 | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.{yml,yaml,js}] | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- master | ||
- develop | ||
- feature/** | ||
|
||
jobs: | ||
tests: | ||
name: ${{ matrix.os }} - PHP ${{ matrix.php }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-20.04] | ||
php: [7.4] | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
extensions: mbstring,intl | ||
coverage: pcov | ||
tools: composer,phpunit,phpstan,phpcs | ||
|
||
- name: Install Composer dependencies | ||
run: | | ||
php --version | ||
composer install --quiet --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist | ||
- name: Run code sniffer | ||
run: | | ||
composer run sniff | ||
- name: Run static analysis | ||
run: | | ||
composer run stan | ||
- name: Run the tests | ||
timeout-minutes: 10 | ||
run: | | ||
./vendor/bin/phpunit --version | ||
composer run test-ci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/.idea/ | ||
/composer.lock | ||
/vendor/ | ||
/code-analysis/ | ||
.DS_Store | ||
.phpunit.result.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [1.0.0] - 2022-04-13 | ||
|
||
### Added | ||
|
||
- Initial release supporting CommonMark v1. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# YouTube iframe extension | ||
|
||
An extension for [league/commonmark](https://github.com/thephpleague/commonmark) | ||
version 1 built using PHP 7.4. This replaces YouTube links with the embed iframe. | ||
|
||
The extension supports for tracks, artists, albums and playlists using the embed | ||
URL format. | ||
|
||
Initially based on the [YouTube extension](https://github.com/zoonru/commonmark-ext-youtube-iframe). | ||
|
||
## Installation | ||
|
||
The project should be installed via Composer: | ||
|
||
```bash | ||
composer require surface/commonmark-ext-youtube-iframe | ||
``` | ||
|
||
## Usage | ||
|
||
Configure your CommonMark `Environment` and add the extension. | ||
|
||
```php | ||
use League\CommonMark\CommonMarkConverter as Converter; | ||
// use League\CommonMark\GithubFlavoredMarkdownConverter as Converter; | ||
use League\CommonMark\Environment; | ||
use Surface\CommonMark\Ext\YouTubeIframe\Extension as YouTubeExtension; | ||
|
||
$environment = Environment::createCommonMarkEnvironment(); | ||
$environment->addExtension(new YouTubeExtension()); | ||
|
||
$config = [ | ||
'youtube_width' => '800', | ||
'youtube_height' => '600', | ||
]; | ||
|
||
$converter = new Converter($config, $environment); | ||
|
||
echo $converter->convertToHtml('[](https://youtu.be/xxx)'); | ||
echo $converter->convertToHtml('[](https://www.youtube.com/watch?v=xxx)'); | ||
echo $converter->convertToHtml('[](https://youtu.be/xxx?height=480)'); | ||
echo $converter->convertToHtml('[](https://www.youtube.com/watch?v=xxx&width=640)'); | ||
``` | ||
|
||
### Dimensions | ||
|
||
You can control the dimensions of the videos by using the `youtube_width` and | ||
`youtube_height` configuration options. | ||
|
||
You can also configure the dimensions using query parameters on the embed URL. | ||
You can provide the `height` or `width` or *both*. | ||
|
||
```html | ||
?width=640 | ||
?height=480 | ||
?width=640&height=480 | ||
``` | ||
|
||
## Testing | ||
|
||
There are Unit and Integration tests for the project. These can be run using | ||
the following commands: | ||
|
||
```bash | ||
composer test | ||
composer run test | ||
composer run test-unit | ||
composer run test-integration | ||
``` | ||
|
||
There are also scripts to run code sniffer, mess detector and static analysis: | ||
|
||
```bash | ||
composer run sniff | ||
composer run mess | ||
composer run stan | ||
``` | ||
|
||
## Changelog | ||
|
||
Please refer to the [CHANGELOG](CHANGELOG.md) for more information on what has | ||
changed recently. | ||
|
||
## License | ||
|
||
This library is licensed under the MIT license. See the | ||
[License File](LICENSE.md) for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
{ | ||
"name": "surface/commonmark-ext-youtube-iframe", | ||
"type": "commonmark-extension", | ||
"description": "Extension for league/commonmark to replace YouTube link with an iframe.", | ||
"version": "1.0.0", | ||
"keywords": [ | ||
"markdown", | ||
"commonmark", | ||
"extension", | ||
"youtube", | ||
"iframe", | ||
"embed", | ||
"music" | ||
], | ||
"homepage": "https://github.com/trovster/commonmark-ext-youtube-iframe", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Trevor Morris", | ||
"email": "[email protected]", | ||
"homepage": "https://www.trovster.com", | ||
"role": "Developer" | ||
} | ||
], | ||
"require": { | ||
"php" : "^7.4|^8.0", | ||
"league/commonmark": "^1.6" | ||
}, | ||
"require-dev": { | ||
"phpmd/phpmd": "^2.12", | ||
"phpro/grumphp": "^1.5", | ||
"phpstan/phpstan": "^1.5", | ||
"phpunit/phpunit": "^9.5", | ||
"sirbrillig/phpcs-import-detection": "^1.3", | ||
"slevomat/coding-standard": "^7.1", | ||
"squizlabs/php_codesniffer": "^3.6" | ||
}, | ||
"scripts": { | ||
"post-install-cmd": [ | ||
"@php ./vendor/bin/grumphp git:init" | ||
], | ||
"sniff": [ | ||
"./vendor/bin/phpcs -s" | ||
], | ||
"stan": [ | ||
"@php ./vendor/bin/phpstan analyse -c phpstan.neon --memory-limit=2G" | ||
], | ||
"mess": [ | ||
"@php ./vendor/bin/phpmd ./src text phpmd.xml --reportfile ./code-analysis/phpmd.txt" | ||
], | ||
"grum": [ | ||
"@php ./vendor/bin/grumphp run" | ||
], | ||
"test-unit": [ | ||
"./vendor/bin/phpunit --testsuite Unit --colors=always --log-junit ./code-analysis/junit.xml" | ||
], | ||
"test-integration": [ | ||
"./vendor/bin/phpunit --testsuite Integration --colors=always --log-junit ./code-analysis/junit.xml" | ||
], | ||
"test-ci": [ | ||
"./vendor/bin/phpunit --testsuite Unit,Integration --colors=always --log-junit ./code-analysis/junit.xml" | ||
], | ||
"test": [ | ||
"./vendor/bin/phpunit --testsuite Unit,Integration --colors=always --log-junit ./code-analysis/junit.xml" | ||
] | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Surface\\CommonMark\\Ext\\YouTubeIframe\\": "src" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Surface\\CommonMark\\Ext\\YouTubeIframe\\Tests\\": "tests" | ||
} | ||
}, | ||
"config": { | ||
"optimize-autoloader": true, | ||
"preferred-install": "dist", | ||
"sort-packages": true, | ||
"allow-plugins": { | ||
"dealerdirect/phpcodesniffer-composer-installer": true, | ||
"phpro/grumphp": true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
grumphp: | ||
hooks_dir: ~ | ||
hooks_preset: local | ||
process_timeout: 360 | ||
tasks: | ||
composer: | ||
file: ./composer.json | ||
no_check_all: false | ||
no_check_lock: false | ||
no_check_publish: false | ||
no_local_repository: false | ||
with_dependencies: false | ||
strict: false | ||
phpversion: | ||
project: '7.4' | ||
phpstan: | ||
configuration: phpstan.neon | ||
memory_limit: "2G" | ||
phpcs: | ||
phpmd: | ||
whitelist_patterns: | ||
- /^app\/(.*)/ | ||
report_format: text | ||
ruleset: ['phpmd.xml'] | ||
composer_script: | ||
script: test | ||
clover_coverage: | ||
clover_file: ./code-analysis/clover.xml | ||
level: 90 | ||
git_commit_message: | ||
allow_empty_message: false | ||
enforce_capitalized_subject: false | ||
enforce_no_subject_punctuations: false | ||
enforce_no_subject_trailing_period: true | ||
type_scope_conventions: | ||
- types: | ||
- build | ||
- ci | ||
- chore | ||
- docs | ||
- feat | ||
- fix | ||
- perf | ||
- refactor | ||
- revert | ||
- style | ||
- test | ||
- scopes: [] | ||
max_body_width: 72 | ||
max_subject_width: 80 |
Oops, something went wrong.