rafaelbeckel / sirtrevor
Sir Trevor JS in Laravel 5 project
Requires
- erusev/parsedown-extra: ~0.7
- illuminate/support: ~5
- thujohn/twitter: ~2.0
Requires (Dev)
- phpunit/phpunit: 4.1.*
- dev-master
- 2.1.0
- 2.0.51
- 2.0.8
- 2.0.7
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.4.16
- 1.4.15
- 1.4.14
- 1.4.13
- 1.4.12
- 1.4.11
- 1.4.10
- 1.4.9
- 1.4.8
- 1.4.7
- 1.4.6
- 1.4.5
- 1.4.4
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.1
- 1.3.0
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.11
- 1.1.10
- 1.1.8
- 1.1.5
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-patch-1
- dev-develop
- dev-laravel4
- dev-feature_text-ishtml
This package is not auto-updated.
Last update: 2024-11-23 19:00:28 UTC
README
Integrate the tool Sir Trevor JS in a Laravel 5 project.
Installation
========== WARNING!!! ===============
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"
Aliases
In your app/config/app.php
, add in aliases :
'SirTrevorJs' => 'Caouecs\Sirtrevorjs\SirTrevorJs',
'STConverter' => 'Caouecs\Sirtrevorjs\SirTrevorJsConverter'
Service Provider
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.
thujohn/twitter
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
.
Configuration file
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 :
- the path for image upload
- the route for upload image
- the route for tweet
- the path of Sir Trevor files
- the list of block types
- the language
- the paths for Eventable.js and Underscore.js
- the view
- configuration for blocks
- soundcloud
- gettyimages
- etc...
SirTrevorJs class
Assets
For stylesheets :
SirTrevorJs::stylesheets()
For scripts, in your Blade files :
SirTrevorJs::scripts()
Fix for image block
Function to fix a problem with image block when you add a new image :
$text = SirTrevorJs::transformText($text);
Find first image
Get first image in text with findImage
method :
string SirTrevorJS::findImage(string $text);
In return, you have url of image or empty string.
Find elements by blocktypes
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 :
- array, if you choose "array" for $output
- json, if you choose "json" for $output
- false, if the script doesn't find an occurence of blocktype
SirTrevorJsController
This class proposes two things :
- upload image where you want
- get tweets
Upload image
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"));
Tweet
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"));
SirTrevorJsConverter class (or STConverter class)
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 :
- blockquote / quote
- embedly card
- facebook post
- getty images
- heading
- image
- basic version
- version with caption
- issuu
- sketchfab
- slideshare
- soundcloud
- spotify
- text with Markdown
- tweet
- unordered list
- video
- aol
- canal plus
- daily mail uk
- dailymotion
- france tv
- global news
- livestream
- metacafe
- metatube
- mlb
- nbc bay area
- nhl
- ooyala
- redtube
- ustream (live and recorded)
- veoh
- vevo
- vimeo
- vine
- wat
- yahoo
- youtube
- zoomin.tv
- video with caption