Package Data | |
---|---|
Maintainer Username: | caouecs |
Maintainer Contact: | caouecs@caouecs.net (caouecs) |
Package Create Date: | 2013-12-03 |
Package Last Update: | 2024-02-07 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-17 03:02:41 |
Package Statistics | |
---|---|
Total Downloads: | 20,589 |
Monthly Downloads: | 156 |
Daily Downloads: | 0 |
Total Stars: | 55 |
Total Watchers: | 5 |
Total Forks: | 17 |
Total Open Issues: | 1 |
Integrate the tool Sir Trevor JS in a Laravel 5 project.
This package is available through Packagist
and Composer
.
For PHP 7 version, use the branch master :
"caouecs/sirtrevorjs": "~3.0.0"
For Laravel >= 5.2 version parser, use the branch v2.5 :
"caouecs/sirtrevorjs": "~2.5.0"
For Laravel >= 5.1 version js & amp, use the branch v2.4 :
"caouecs/sirtrevorjs": "~2.4.0"
For Laravel >= 5.1 version fb articles, use the branch v2.3 :
"caouecs/sirtrevorjs": "~2.3.0"
For Laravel >= 5.1 version view & amp, use the branch v2.2 :
"caouecs/sirtrevorjs": "~2.2.0"
For Laravel >= 5.1 version base, use the branch v2.1 :
"caouecs/sirtrevorjs": "~2.1.0"
For Laravel 5.0, use the branch v2 :
"caouecs/sirtrevorjs": "~2.0.0"
For Laravel 4, use the branch laravel4 :
"caouecs/sirtrevorjs": "~1.4"
Please read README.md in the choosen branch.
If you want to use routing, controllers, views, binding directly in your project, in your app/config/app.php
, add "Caouecs\Sirtrevorjs\SirtrevorjsServiceProvider"
to your list of providers.
To get tweets, this project uses thujohn/twitter. Please visit the page of the project to know how to install and configure.
Next, you must migrate config :
php artisan vendor:publish caouecs/sirtrevorjs
After installation, the config file is located at app/config/packages/caouecs/sirtrevorjs/sir-trevor-js.php.
You can define :
For stylesheets :
SirTrevorJs::stylesheets()
For scripts, in your Blade files :
SirTrevorJs::scripts()
Function to fix a problem with image block when you add a new image :
string SirTrevorJs::transformText(string $text);
Get first image in text with findImage
method :
string SirTrevorJS::findImage(string $text);
In return, you have url of image or empty string.
Get all elements in text, in specified blocktype with find
method :
mixed SirTrevorJS::find(string $text, string $blocktype [, string $output = "json"])
In return, you can have :
This trait proposes two things :
This project proposes a system for upload image, nothing to configure, just the directory_upload
value in config file.
"directory_upload" => "img/uploads"
This project proposes a system to get tweets. I use thujohn/twitter project.
This class need a parser, a configuration and a view by default.
You can use the binding of this class :
App::make('caouecs.sirtrevorjs.converter')
Convert text from Sir Trevor Js to html :
string App::make('caouecs.sirtrevorjs.converter')->toHtml($text)
These methods return a string with html and js codes.
Convert text from Sir Trevor Js to Amp:
string App::make('caouecs.sirtrevorjs.converter')->toAmp($text);
All modules have an amp's version, if it exists an equivalence.
This method returns an array ( text and js).
Convert text from Sir Trevor Js to Facebook Instant Articles:
string App::make('caouecs.sirtrevorjs.converter')->toFb($text);
All modules have an FBArticles's version, if it exists an equivalence.
This method returns a string with html and js codes.
You can choose to add custom blocks in config file or add them by extending SirTrevorJsConverter class.
'customBlocks' => [
'image_extended' => '\App\SirTrevorConverters\ImageExtendedConverter',
],
<?php
namespace App\SirTrevorConverters;
use \Caouecs\Sirtrevorjs\SirTrevorJsConverter;
class SirTrevorJsConverterEditor extends SirTrevorJsConverter
{
/**
* Custom blocks.
*
* @var array
*/
protected $customBlocks = [
'gallery' => '{Your namespace}\\Editor\\Converter\\GalleryConverterEditor',
'readmore' => '{Your namespace}\\Editor\\Converter\\ReadMoreConverterEditor',
];
}
And you need to call this class in your service provider, in register :
$this->app->bind('editor.converter', function ($app) {
return new App\SirTrevorConverters\SirTrevorJsConverterEditor(
new ParsedownExtraParser(),
config('sir-trevor-js'),
'html'
);
});
For the moment, the code can convert :