承接 caouecs/sirtrevorjs 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

caouecs/sirtrevorjs

Composer 安装命令:

composer require caouecs/sirtrevorjs

包简介

Sir Trevor JS in Laravel project

README 文档

README

Quality Gate Status

Integrate the tool Sir Trevor JS in a Laravel 5/6/7/8/9 project.

Installation

This package is available through Packagist and Composer.

For PHP 8 version, use the branch master : "caouecs/sirtrevorjs": "~4.1.0"

For PHP 7 version, use the branch v3.0 : "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.

Service Provider

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.

Twitter

To get tweets, this project uses thujohn/twitter. Please visit the page of the project to know how to install and configure.

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
  • custom blocks
  • 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 :

    string SirTrevorJs::transformText(string $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

Controller

SirTrevorJsable

This trait 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"

Tweet

This project proposes a system to get tweets. I use thujohn/twitter project.

SirTrevorJsConverter class

This class need a parser, a configuration and a view by default.

You can use the binding of this class :

    app('caouecs.sirtrevorjs.converter')

Html

Convert text from Sir Trevor Js to html :

    string app('caouecs.sirtrevorjs.converter')->toHtml($text)

These methods return a string with html and js codes.

Amp

Convert text from Sir Trevor Js to Amp:

    string app('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).

Facebook Instant Articles

Convert text from Sir Trevor Js to Facebook Instant Articles:

    string app('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.

Adding custom blocks

You can choose to add custom blocks in config file or add them by extending SirTrevorJsConverter class.

config

'customBlocks' => [
    'image_extended' => '\App\SirTrevorConverters\ImageExtendedConverter',
],

SirTrevorConverter

<?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 LaravelParser(),
        config('sir-trevor-js'),
        'html'
    );
});

Modules

For the moment, the code can convert :

caouecs/sirtrevorjs 适用场景与选型建议

caouecs/sirtrevorjs 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 21.63k 次下载、GitHub Stars 达 54, 最近一次更新时间为 2013 年 12 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「lpm」 「sir trevor js」 「sir-trevor-js」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 caouecs/sirtrevorjs 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 caouecs/sirtrevorjs 我们能提供哪些服务?
定制开发 / 二次开发

基于 caouecs/sirtrevorjs 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 21.63k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 54
  • 点击次数: 17
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 54
  • Watchers: 4
  • Forks: 17
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-12-04