Git Product home page Git Product logo

laravel-twitter-text-formatter's Introduction

Laravel Twitter Text Formatter

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) !!}

laravel-twitter-text-formatter's People

Contributors

joe-pritchard avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.