rafaelbeckel/sirtrevor is a Laravel package for sir trevor js in laravel 5 project.
It currently has 0 GitHub stars and 34 downloads on Packagist (latest version 2.1.0).
Install it with composer require rafaelbeckel/sirtrevor.
Discover more Laravel packages by rafaelbeckel
or browse all Laravel packages to compare alternatives.
Last updated
Integrate the tool Sir Trevor JS in a Laravel 5 project.
I just cloned this repository for a personal project and in the next days I'll make some changes that may break things. DO NOT USE IT IN PRODUCTION (unless if you are me). I recommend using original author's repository instead (link below).
I plan to release a stable version with a different API in a near future, but right now I cannot tell exactly when I'll do it.
This package is available through Packagist and Composer.
For Laravel 5, use the branch master :
"caouecs/sirtrevorjs": "~2.0"
In your app/config/app.php, add in aliases :
'SirTrevorJs' => 'Caouecs\Sirtrevorjs\SirTrevorJs',
'STConverter' => 'Caouecs\Sirtrevorjs\SirTrevorJsConverter'
If you want to use routing, controllers, views 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 twitter-l4, so you must have a valid developer account of Twitter and add config file of twitter-l4 :
php artisan config:publish thujohn/twitter
and add "Thujohn\Twitter\TwitterServiceProvider" to your list of providers in your app/config/app.php.
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 :
$text = SirTrevorJs::transformText($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 class 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"
The uploader is in SirTrevorJsController class, and the project has a route.php file for it.
Route::any("/sirtrevorjs/upload", array("uses" => "SirTrevorJsController@upload"));
This project proposes a system to get tweets. I use twitter-l4 project.
The installation of twitter-l4 is done by Composer, but you need to configure it ( see Instructions).
The tweet converter is in SirTrevorJsController class, and the project has a route.php file for it.
Route::any("/sirtrevorjs/tweet", array("uses" => "SirTrevorJsController@tweet"));
Convert text from Sir Trevor Js to html :
$convert = new STConverter();
$convert->toHtml($text)
Or via SirTrevorJS class :
{{ SirTrevorJs::render($text) }}
For the moment, the code can convert :