rafaelbeckel/sirtrevor
Composer 安装命令:
composer require rafaelbeckel/sirtrevor
包简介
Sir Trevor JS in Laravel 5 project
README 文档
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
rafaelbeckel/sirtrevor 适用场景与选型建议
rafaelbeckel/sirtrevor 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 34 次下载、GitHub Stars 达 0, 最近一次更新时间为 2015 年 07 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「lpm」 「sir trevor js」 「sir-trevor-js」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rafaelbeckel/sirtrevor 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rafaelbeckel/sirtrevor 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rafaelbeckel/sirtrevor 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Sir Trevor to HTML conversion helper for PHP
Sir Trevor JS in Laravel project
A SimpleSAMLphp module adding support for the PAPI protocol.
Yii 2 Sir Trevor JS widget
Bootstrap 3 for Laravel 4
A SimpleSAMLphp module for pre-installing an IdP.
统计信息
- 总下载量: 34
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-07-29