定制 joe-pritchard/laravel-twitter-text-formatter 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

joe-pritchard/laravel-twitter-text-formatter

Composer 安装命令:

composer require joe-pritchard/laravel-twitter-text-formatter

包简介

A wrapper package around a text formatter which takes output from twitter's API and returns an HTML string of the full tweet

README 文档

README

A simple wrapper based on this code, providing a service provider, a config file, and a class you can inject into your controllers. For me this is a more friendly way to include the work in my projects.

Installation

composer require joe-pritchard/laravel-twitter-text-formatter

Configuration

To override the default display templates, publish and modify the config file:

php artisan vendor:publish --provider=JoePritchard\\LaravelTwitterTextFormatter\\Providers\\ServiceProvider

The following config options can be then changed ne changed in config/twitter-formatter.php:

  • show_retweeted_by (Control whether or not to show the "retweeted by..." text below retweets that appear in your timeline. Defaults to true)
  • retweeted_by_template (The template that should be used to display the "retweeted by..." section. Defaults to <em> Retweeted by {{user_name}}</em>)
  • hashtag_link_template (defaults to <a href="{{hashtag_link}}" rel="nofollow" target="_blank">#{{hashtag_text}}</a>)
  • url_link_template (defaults to <a href="{{url_link}}" rel="nofollow" target="_blank" title="{{url_title}}">{{url_text}}</a>)
  • user_mention_link_template (defaults to <a href="{{user_mention_link}}" rel="nofollow" target="_blank" title="{{user_mention_title}}">@{{user_mention_text}}</a>)
  • media_link_template (defaults to <a href="{{media_link}}" rel="nofollow" target="_blank" title="{{media_title}}">{{media_text}}</a>)

Usage

In Controllers/Classes

Just call JoePritchard\TwitterTextFormatter\Formatter::format() on the tweet you'd like to format. The format method takes one argument, which is a tweet as returned by the twitter API. For more details on how to retrieve that, head to the official API docs or take a look at this article, which is where I first encountered Andrea Zanelli's work before deciding to roll it into this package.

In Views

In blade files etc it may be more convenient to use the helper method: {!! twitter_format($tweet) !!}

统计信息

  • 总下载量: 715
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2018-07-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固