-
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 039775c
Showing
14 changed files
with
7,723 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,11 @@ | ||
/node_modules | ||
/vendor | ||
/logs | ||
.env.exemple | ||
phpunit.xml | ||
.phpunit.result.cache | ||
Homestead.json | ||
Homestead.yaml | ||
npm-debug.log | ||
yarn-error.log | ||
*.sublime-* |
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 @@ | ||
# Changelog | ||
|
||
All notable changes to **[sniptbot](https://github.com/snippetify/laravel-sniptbot)** will be documented in this file | ||
|
||
## 1.0.0 - 2020-06-30 | ||
|
||
- initial release | ||
|
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,44 @@ | ||
# Contributing | ||
|
||
Contributions are **welcome** and will be fully **credited**. | ||
|
||
Please read and understand the contribution guide before creating an issue or pull request. | ||
|
||
## Etiquette | ||
|
||
This project is open source, and as such, the maintainers give their free time to build and maintain the source code held within. They make the code freely available in the hope that it will be of use to other developers. It would be extremely unfair for them to suffer abuse or anger for their hard work. | ||
|
||
Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the world that developers are civilized and selfless people. | ||
|
||
It's the duty of the maintainer to ensure that all submissions to the project are of sufficient quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used. | ||
|
||
## Viability | ||
|
||
When requesting or submitting new features, first consider whether it might be useful to others. Open source projects are used by many developers, who may have entirely different needs to your own. Think about whether or not your feature is likely to be used by other users of the project. | ||
|
||
## Procedure | ||
|
||
Before filing an issue: | ||
|
||
- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident. | ||
- Check to make sure your feature suggestion isn't already present within the project. | ||
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress. | ||
- Check the pull requests tab to ensure that the feature isn't already in progress. | ||
|
||
Before submitting a pull request: | ||
|
||
- Check the codebase to ensure that your feature doesn't already exist. | ||
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix. | ||
|
||
## Requirements | ||
|
||
If the project maintainer has any additional requirements, you will find them listed here. | ||
|
||
- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer). | ||
- **Add tests!** - Your patch won't be accepted if it doesn't have tests. | ||
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. | ||
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option. | ||
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. | ||
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. | ||
|
||
**Happy coding**! |
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) 2020 Snippetify LLC | ||
|
||
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,139 @@ | ||
# Laravel Sniptbot | ||
|
||
This repository implements a simple [ServiceProvider](https://laravel.com/docs/master/providers) that makes the instances of the Snippet **Crawler** and **Sniffer** easily accessible via a [Facade](https://laravel.com/docs/master/facades) in [Laravel](http://laravel.com). See [@Snippetify/Snippet-sniffer](https://github.com/snippetify/snippet-sniffer) for more information about the PHP Snippet sniffing and its interfaces. | ||
|
||
## What it does | ||
|
||
This library allows you | ||
|
||
1. To get code snippets using search engine api (Google) | ||
2. To get code snippets from any web page by crawling url seeds. | ||
|
||
## How to use it | ||
|
||
```bash | ||
$ composer require snippetify/laravel-sniptbot | ||
``` | ||
|
||
```php | ||
php artisan vendor:publish --provider="Snippetify\Sniptbot\SniptbotServiceProvider" | ||
``` | ||
|
||
##### Configuration | ||
|
||
Open the created file in the `config/sniptbot.php` and customize the configuration options to your liking. | ||
|
||
```php | ||
return [ | ||
// Search engine api configuration keys | ||
'provider' => [ | ||
// Your google Search engine ID | ||
// https://developers.google.com/custom-search/v1/introduction | ||
'cx' => env('SNIPTBOT_PROVIDER_CX', ''), | ||
// Your google API key | ||
// https://developers.google.com/custom-search/v1/overview#api_key | ||
'key' => env('SNIPTBOT_PROVIDER_KEY', ''), | ||
'name' => env('SNIPTBOT_PROVIDER_NAME', 'google'), // provider name (google) | ||
], | ||
|
||
// Optional | ||
// Useful for adding meta information to each snippet | ||
'app' => [ | ||
'name' => env('SNIPTBOT_NAME', 'Sniptbot'), // your sniptbot name | ||
'version' => env('SNIPTBOT_VERSION', '1.0.0'), // your sniptbot version | ||
], | ||
|
||
// Optional | ||
// Useful for logging | ||
'logger' => [ | ||
'name' => env('SNIPTBOT_NAME', 'Sniptbot'), // logger name | ||
'file' => storage_path('logs/sniptbot.log'), // logger file path | ||
], | ||
|
||
// Optional | ||
// Useful for scraping | ||
'html_tags' => [ | ||
'index' => 'h1, h2, h3, h4, h5, h6, p, li', // Tags to index | ||
'snippet' => 'pre[class] code, div[class] code, .highlight pre, code[class]', // Tags to fetch snippets | ||
], | ||
|
||
// Optional | ||
// Useful for adding new scrapers | ||
// The name must be the website host without the scheme i.e. not https://foo.com but foo.com | ||
'scrapers' => [ | ||
// 'scraper_name' => ScraperClass::class, // You can add as many as you want | ||
], | ||
|
||
// Optional | ||
// Useful for adding new providers | ||
'providers' => [ | ||
// 'provider_name' => ProviderClass::class, // You can add as many as you want | ||
], | ||
|
||
// Optional | ||
// Useful for web crawling | ||
// Please follow the link below for more information as we use Spatie crawler | ||
// https://github.com/spatie/crawler | ||
'crawler' => [ | ||
// 'langs' => ['en'], | ||
// 'profile' => Snippetify\SnippetSniffer\Profiles\CrawlSubdomainsAndUniqueUri::class, | ||
// 'user_agent' => Snippetify\SnippetSniffer\Core::CRAWLER_USER_AGENT, | ||
// 'concurrency' => 10, | ||
// 'ignore_robots' => false, | ||
// 'maximum_depth' => null, | ||
// 'execute_javascript' => false, | ||
// 'maximum_crawl_count' => null, | ||
// 'parseable_mime_types' => ['text/html'], | ||
// 'maximum_response_size' => 1024 * 1024 * 3, | ||
// 'delay_between_requests' => 250, | ||
] | ||
]; | ||
``` | ||
|
||
##### Sniffing from search engine api | ||
|
||
```php | ||
use Snippetify\Sniptbot\Facades\Sniffer; | ||
|
||
// Important: You must set your search engine keys before using it | ||
// @return Snippetify\SnippetSniffer\Common\Snippet[] | ||
$snippets = Sniffer::fetch('js array contains value'); | ||
``` | ||
|
||
##### Crawl url seeds | ||
|
||
```php | ||
use Snippetify\Sniptbot\Facades\Crawler; | ||
|
||
// @return Snippetify\SnippetSniffer\Common\MetaSnippetCollection[] | ||
$snippets = Crawler::fetch(['your urls']); | ||
``` | ||
|
||
|
||
|
||
## Changelog | ||
|
||
Please see [CHANGELOG](https://github.com/snippetify/laravel-sniptbot/blob/master/CHANGELOG.md) for more information what has changed recently. | ||
|
||
## Testing | ||
|
||
You must set the **PROVIDER_NAME**, **PROVIDER_CX**, **PROVIDER_KEY**, **CRAWLER_URI**, keys in phpunit.xml file before running tests. | ||
|
||
**Important:** Those links must contains at least one snippet otherwise the tests will failed. | ||
|
||
```bash | ||
composer test | ||
``` | ||
|
||
## Contributing | ||
|
||
Please see [CONTRIBUTING](https://github.com/snippetify/laravel-sniptbot/blob/master/CONTRIBUTING.md) for details. | ||
|
||
## Credits | ||
|
||
1. [Evens Pierre](https://github.com/pierrevensy) | ||
|
||
## License | ||
|
||
The MIT License (MIT). Please see [License File](https://github.com/snippetify/laravel-sniptbot/blob/master/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,63 @@ | ||
{ | ||
"name": "snippetify/laravel-sniptbot", | ||
"description": "Sniptbot for laravel", | ||
"type": "library", | ||
"homepage": "https://github.com/snippetify/laravel-sniptbot", | ||
"keywords": [ | ||
"crawler", | ||
"scraper", | ||
"sniffer", | ||
"spider", | ||
"sniptbot", | ||
"sniffing", | ||
"crawling", | ||
"scraping", | ||
"snippet", | ||
"code snippet", | ||
"sniptbot" | ||
], | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Evens Pierre", | ||
"email": "pierrevensy@gmail.com" | ||
}, | ||
{ | ||
"name": "Snippetify Community", | ||
"homepage": "https://github.com/snippetify" | ||
} | ||
], | ||
"minimum-stability": "dev", | ||
"autoload": { | ||
"psr-4": { | ||
"Snippetify\\Sniptbot\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Snippetify\\Sniptbot\\Tests\\": "tests/" | ||
} | ||
}, | ||
"require": { | ||
"php": "^7.3.0", | ||
"illuminate/support": "^5|^6|^7", | ||
"snippetify/snippet-sniffer": "dev-master" | ||
}, | ||
"require-dev": { | ||
"orchestra/testbench": "^3.8|^4.0|^5.0" | ||
}, | ||
"scripts": { | ||
"test": "phpunit" | ||
}, | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"Snippetify\\Sniptbot\\SniptbotServiceProvider" | ||
], | ||
"aliases": { | ||
"Sniffer": "Snippetify\\Sniptbot\\Facades\\Sniffer", | ||
"Crawler": "Snippetify\\Sniptbot\\Facades\\Crawler" | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.