This repository has been archived by the owner on Jul 31, 2023. It is now read-only.
generated from svenluijten/package-skeleton
-
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 6eb8beb
Showing
36 changed files
with
842 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,19 @@ | ||
; This file is for unifying the coding style for different editors and IDEs. | ||
; More information at http://editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_size = 4 | ||
indent_style = space | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[composer.json] | ||
indent_size = 4 | ||
indent_style = space |
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,8 @@ | ||
* text=auto | ||
|
||
/tests export-ignore | ||
/.editorconfig export-ignore | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/CONTRIBUTING.md export-ignore | ||
/phpunit.xml.dist export-ignore |
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 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: weekly |
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,30 @@ | ||
name: Tests | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
test: | ||
name: PHP ${{ matrix.php }} on ${{ matrix.os }} (${{ matrix.dependency-version }}) | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
php: [8.1, 8.2] | ||
dependency-version: [highest, lowest] | ||
steps: | ||
- uses: actions/[email protected] | ||
|
||
- name: Configure PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
extensions: dom | ||
coverage: none | ||
|
||
- name: Install dependencies | ||
uses: ramsey/composer-install@v2 | ||
with: | ||
dependency-versions: ${{ matrix.dependency-version }} | ||
composer-options: "--prefer-dist" | ||
|
||
- name: Execute tests | ||
run: vendor/bin/phpunit |
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,3 @@ | ||
/composer.phar | ||
/composer.lock | ||
/vendor |
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,93 @@ | ||
# How to contribute | ||
Thank you for considering to contribute to this repository! This file will walk you through all the steps to ensure both | ||
you and I have a good time submitting and reviewing your contribution. First off, some basic rules and reading material: | ||
|
||
- Submit your work in a new branch and make the PR to the master branch. | ||
- [Write a short & descriptive commit message](http://chris.beams.io/posts/git-commit/). | ||
- Rebase before committing the final change. | ||
- Stick to [PSR-2](http://www.php-fig.org/psr/psr-2/). | ||
- Add tests if necessary and ensure all the tests are green on the final commit. | ||
- Make sure the CI tools used by the repository are all in order. If one fails, you should make it pass. | ||
|
||
## Contributing | ||
Here are the steps to follow to contribute to this repository: | ||
|
||
- [Fork this repository on GitHub](#fork-this-repository). | ||
- [Clone your fork to your local machine](#clone-your-fork). | ||
- [Create a feature branch](#create-a-branch). | ||
- [Add an 'upstream' remote](#add-a-remote). | ||
- [Regularly pull & rebase from the upstream remote](#pull-and-rebase). | ||
- [Work on feature branch](#working-on-branch). | ||
- [Make tests pass](#make-tests-pass) | ||
- [Submit a pull request to the master branch](#submitting-pull-request). | ||
|
||
### Fork this repository | ||
Fork the repository right here on GitHub. To learn more about forking a repository, visit | ||
[GitHub's help article](https://help.github.com/articles/fork-a-repo/). | ||
|
||
### Clone your fork | ||
Clone your repository on your local machine to start work on your pull request. | ||
|
||
```bash | ||
$ git clone [email protected]:<USERNAME>/<REPOSITORY>.git | ||
# Or if you prefer HTTPS: | ||
$ git clone https://github.com/<USERNAME>/<REPOSITORY>.git | ||
|
||
$ cd <REPOSITORY> | ||
``` | ||
|
||
### Create a branch | ||
Make your own feature branch in order not to clutter up master. | ||
|
||
```bash | ||
# Think of a good name for your branch: | ||
# fix/typo-in-readme | ||
# feature/some-feature | ||
# bug/some-bug-you-are-fixing | ||
$ git checkout -b <BRANCH_NAME> | ||
``` | ||
|
||
### Add a remote | ||
Add an 'upstream' remote to pull from and to stay up to date with the work being done in there. | ||
|
||
```bash | ||
# List all current remotes | ||
$ git remote -v | ||
origin [email protected]/<USERNAME>/<REPOSITORY>.git (fetch) | ||
origin [email protected]/<USERNAME>/<REPOSITORY>.git (push) | ||
|
||
# Add a new remote called 'upstream' | ||
$ git remote add upstream [email protected]:svenluijten/<REPOSITORY>.git | ||
# Or if you prefer HTTPS: | ||
$ git remote add upstream https://github.com/svenluijten/<REPOSITORY>.git | ||
|
||
# The new remote should now be in the list | ||
$ git remote -v | ||
origin [email protected]/<USERNAME>/<REPOSITORY>.git (fetch) | ||
origin [email protected]/<USERNAME>/<REPOSITORY>.git (push) | ||
upstream [email protected]/svenluijten/<REPOSITORY>.git (fetch) | ||
upstream [email protected]/svenluijten/<REPOSITORY>.git (push) | ||
``` | ||
|
||
### Pull and rebase | ||
Pull from upstream to stay up to date with what others might be doing in this repository. Any merge conflicts that arise | ||
are your responsibility to resolve. | ||
|
||
```bash | ||
$ git pull --rebase upstream master | ||
``` | ||
|
||
### Working on branch | ||
Do your magic and make your fix. I can't help you with this 😉. Once you're happy with the result and all tests pass, | ||
go ahead and push to your feature branch. | ||
|
||
```bash | ||
$ git push origin <BRANCH_NAME> | ||
``` | ||
|
||
### Make tests pass | ||
You can run `composer check` to see if the tests & static analysis pass. Feel free to only run the static analyses at the | ||
very end, this could take a while on bigger projects. To only run the tests, run `composer test`. | ||
|
||
### Submitting pull request | ||
Now, let's head back over to this repository on GitHub and submit the pull request! |
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 @@ | ||
# The MIT License (MIT) | ||
|
||
Copyright (c) Sven Luijten | ||
|
||
> 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,83 @@ | ||
![:package](:hero) | ||
|
||
# :package | ||
|
||
[![Latest Version on Packagist][ico-version]][link-packagist] | ||
[![Total Downloads][ico-downloads]][link-downloads] | ||
[![Software License][ico-license]](LICENSE.md) | ||
[![Build Status][ico-build]][link-build] | ||
[![StyleCI][ico-styleci]][link-styleci] | ||
|
||
Short description of the package. What does it do and why should people download | ||
it? Brag a bit but don't exaggerate. Talk about what's to come and tease small | ||
pieces of functionality. | ||
|
||
> :namespace | ||
> :package | ||
> :styleci | ||
> :hero | ||
## Installation | ||
You'll have to follow a couple of simple steps to install this package. | ||
|
||
### Downloading | ||
Via [composer](http://getcomposer.org): | ||
|
||
```bash | ||
$ composer require sven/:package | ||
``` | ||
|
||
Or add the package to your dependencies in `composer.json` and run | ||
`composer update` on the command line to download the package: | ||
|
||
```json | ||
{ | ||
"require": { | ||
"sven/:package": "*" | ||
} | ||
} | ||
``` | ||
|
||
|
||
### Registering the service provider | ||
> Is this a Laravel package? | ||
Next, add the `ServiceProvider` to your `providers` array in `config/app.php`: | ||
|
||
```php | ||
'providers' => [ | ||
... | ||
Sven\:namespace\ServiceProvider::class, | ||
]; | ||
``` | ||
|
||
If you would like to load this package in certain environments only, take a look | ||
at [sven/env-providers](https://github.com/svenluijten/env-providers). | ||
|
||
## Usage | ||
Some examples of the code. How should people use it, what options does this package | ||
provide? Should people be wary of some functionality? | ||
|
||
```php | ||
Maybe some code? | ||
``` | ||
|
||
## Contributing | ||
All contributions (pull requests, issues and feature requests) are | ||
welcome. Make sure to read through the [CONTRIBUTING.md](CONTRIBUTING.md) first, | ||
though. See the [contributors page](../../graphs/contributors) for all contributors. | ||
|
||
## License | ||
`sven/:package` is licensed under the MIT License (MIT). Please see the | ||
[license file](LICENSE.md) for more information. | ||
|
||
[ico-version]: https://img.shields.io/packagist/v/sven/:package.svg?style=flat-square | ||
[ico-license]: https://img.shields.io/badge/license-MIT-green.svg?style=flat-square | ||
[ico-downloads]: https://img.shields.io/packagist/dt/sven/:package.svg?style=flat-square | ||
[ico-build]: https://img.shields.io/github/workflow/status/svenluijten/:package/Tests?style=flat-square | ||
[ico-styleci]: https://styleci.io/repos/:styleci/shield | ||
|
||
[link-packagist]: https://packagist.org/packages/sven/:package | ||
[link-downloads]: https://packagist.org/packages/sven/:package | ||
[link-build]: https://github.com/svenluijten/:package/actions/workflows/run-tests.yml | ||
[link-styleci]: https://styleci.io/repos/:styleci |
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,34 @@ | ||
{ | ||
"name": "sven/commonmark-dark-mode-images", | ||
"description": "", | ||
"keywords": [], | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Sven Luijten", | ||
"email": "[email protected]", | ||
"homepage": "https://svenluijten.com" | ||
} | ||
], | ||
"require": { | ||
"league/commonmark": "^2.0" | ||
}, | ||
"require-dev": { | ||
"ext-dom": "*", | ||
"phpunit/phpunit": "^10.0", | ||
"spatie/phpunit-snapshot-assertions": "^5.0" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Sven\\CommonMark\\DarkModeImages\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Sven\\CommonMark\\DarkModeImages\\Tests\\": "tests/" | ||
} | ||
}, | ||
"config": { | ||
"sort-packages": 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,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd" | ||
backupGlobals="false" | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
cacheDirectory=".phpunit.cache" | ||
backupStaticProperties="false" | ||
> | ||
<testsuites> | ||
<testsuite name="CommonMark Dark Mode Images Test Suite"> | ||
<directory suffix="Test.php">./tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
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,52 @@ | ||
<?php | ||
|
||
namespace Sven\CommonMark\DarkModeImages; | ||
|
||
use League\CommonMark\Environment\EnvironmentBuilderInterface; | ||
use League\CommonMark\Event\DocumentParsedEvent; | ||
use League\CommonMark\Extension\Attributes\AttributesExtension; | ||
use League\CommonMark\Extension\ConfigurableExtensionInterface; | ||
use League\Config\ConfigurationBuilderInterface; | ||
use Nette\Schema\Expect; | ||
use Sven\CommonMark\DarkModeImages\Event\DarkModeImagesListener; | ||
use Sven\CommonMark\DarkModeImages\Node\Picture; | ||
use Sven\CommonMark\DarkModeImages\Node\Source; | ||
use Sven\CommonMark\DarkModeImages\Renderer\PictureRenderer; | ||
use Sven\CommonMark\DarkModeImages\Renderer\SourceRenderer; | ||
|
||
final class DarkModeImagesExtension implements ConfigurableExtensionInterface | ||
{ | ||
public function register(EnvironmentBuilderInterface $environment): void | ||
{ | ||
$extensions = $environment->getExtensions(); | ||
|
||
$this->assertArrayContainsInstanceOf(AttributesExtension::class, $extensions); | ||
|
||
$environment | ||
->addEventListener(DocumentParsedEvent::class, [new DarkModeImagesListener(), 'processDocument']) | ||
->addRenderer(Picture::class, new PictureRenderer()) | ||
->addRenderer(Source::class, new SourceRenderer()) | ||
; | ||
} | ||
|
||
public function configureSchema(ConfigurationBuilderInterface $builder): void | ||
{ | ||
$builder->addSchema('dark_mode_images', Expect::structure([ | ||
'dark_image_class' => Expect::string()->default('dark-image'), | ||
'light_image_class' => Expect::string()->default('light-image'), | ||
'picture_class' => Expect::string()->default('dark-mode-images-picture'), | ||
'fallback' => Expect::anyOf('light', 'dark')->default('light'), | ||
])); | ||
} | ||
|
||
private function assertArrayContainsInstanceOf(string $class, iterable $extensions): void | ||
{ | ||
foreach ($extensions as $extension) { | ||
if ($extension instanceof $class) { | ||
return; | ||
} | ||
} | ||
|
||
throw new \RuntimeException('The "'.self::class.'" extension requires the "'.$class.'" extension to loaded before it.'); | ||
} | ||
} |
Oops, something went wrong.