chore: synchronize project dependencies and update vendor directory files

This commit is contained in:
2026-07-15 13:15:05 +07:00
parent 2ab9f65c99
commit 3203c6e129
10000 changed files with 1501312 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
; This file is for unifying the coding style for different editors and IDEs.
; More information at http://editorconfig.org
root = true
[*]
charset = utf-8
indent_size = 4
indent_style = space
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
@@ -0,0 +1,51 @@
name: Tests
on: [push, pull_request]
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]
php: [8.1, 8.0, 7.4]
laravel: [8.*, 9.*]
dependency-version: [prefer-lowest, prefer-stable]
include:
- laravel: 9.*
testbench: 7.*
- laravel: 8.*
testbench: 6.*
exclude:
- laravel: 9.*
php: 7.4
- laravel: 8.*
php: 8.1
dependency-version: prefer-lowest
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Cache dependencies
uses: actions/cache@v1
with:
path: ~/.composer/cache/files
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick
coverage: none
- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest
- name: Execute tests
run: vendor/bin/phpunit
+6
View File
@@ -0,0 +1,6 @@
preset: laravel
linting: true
disabled:
- single_class_element_per_statement
+70
View File
@@ -0,0 +1,70 @@
# Changelog
All Notable changes to `laravel-share` will be documented in this file
## 1.0.0 - 2016-11-20
- initial release
## 1.0.1 - 2016-11-27
- Add currentPage method
- Apply some cleanups
## 1.0.2 - 2017-06-30
- Fix publish path for translation files
## 1.0.3 - 2017-08-30
- Add support for Laravel 5.5 Package Auto-Discovery
## 1.0.4 - 2017-09-28
- Bug fix for Laravel 5.5 Package Auto-Discovery, this fixes issue #9
## 2.0 - 2018-01-20
- Add support for Font Awesome 5, next to Font Awesome 4. PR #16
## 2.0.1 - 2018-05-18
- Urlencode optional title & message parameters (Fixes issue #23)
## 2.0.2 - 2018-05-18
- Adapt tests to changed responses with urlencoded title & message parameters
## 2.0.3 - 2018-12-29
- Add Whatsapp share provider
## 2.0.4 - 2019-05-19
- Add Pinterest share provider
## 3.0.0 - 2019-08-28
- Remove Google Plus share provider
## 3.1.0 - 2019-09-06
- Add Redit share provider
- Add Telegram share provider
## 3.2.0 - 2019-12-30
- Add support for the title attribute. (credit to Bogdan Cismariu)
## 3.3.0 - 2020-09-11
- Add `getRawLinks` method to only return the raw links
## 3.3.1 - 2020-09-19
- use `Arr::first` instead of `array_first` helper
## 4.0.0 - 2021-01-09
Breaking changes:
- The minimum required php version is now php 7.3
- Dropped out of the box support for Font Awesome 4
- Upgraded phpunit unit version to v9.4
Other changes:
- Updated the Linkedin base url to the 2020 version
- Updated the Pintreset base url to use https
## 4.1.0 - 2021-08-09
- Added support for "rel" attribute on the generated share links
## 4.2.0 - 2021-08-09
- Add Laravel 9 support
- Increase minimum required php version to php 7.4
+55
View File
@@ -0,0 +1,55 @@
# Contributing
Contributions are **welcome** and will be fully **credited**.
Please read and understand the contribution guide before creating an issue or pull request.
## Etiquette
This project is open source, and as such, the maintainers give their free time to build and maintain the source code
held within. They make the code freely available in the hope that it will be of use to other developers. It would be
extremely unfair for them to suffer abuse or anger for their hard work.
Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the
world that developers are civilized and selfless people.
It's the duty of the maintainer to ensure that all submissions to the project are of sufficient
quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used.
## Viability
When requesting or submitting new features, first consider whether it might be useful to others. Open
source projects are used by many developers, who may have entirely different needs to your own. Think about
whether or not your feature is likely to be used by other users of the project.
## Procedure
Before filing an issue:
- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident.
- Check to make sure your feature suggestion isn't already present within the project.
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
- Check the pull requests tab to ensure that the feature isn't already in progress.
Before submitting a pull request:
- Check the codebase to ensure that your feature doesn't already exist.
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.
## Requirements
If the project maintainer has any additional requirements, you will find them listed here.
- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer).
- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.
**Happy coding**!
+21
View File
@@ -0,0 +1,21 @@
# The MIT License (MIT)
Copyright (c) 2016 Joren Van Hocht <jorenvh@gmail.com>
> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
> in the Software without restriction, including without limitation the rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in
> all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> THE SOFTWARE.
+259
View File
@@ -0,0 +1,259 @@
# Laravel Share
[![Latest Version on Packagist](https://img.shields.io/packagist/v/jorenvanhocht/laravel-share.svg?style=flat-square)](https://packagist.org/packages/jorenvanhocht/laravel-share)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
[![Build Status](https://img.shields.io/travis/jorenvh/laravel-share/master.svg?style=flat-square)](https://travis-ci.org/jorenvh/laravel-share)
[![SensioLabsInsight](https://img.shields.io/sensiolabs/i/dde6008b-ccc6-4a3f-8a98-37d76532f956.svg?style=flat-square)](https://insight.sensiolabs.com/projects/dde6008b-ccc6-4a3f-8a98-37d76532f956)
[![Total Downloads](https://img.shields.io/packagist/dt/jorenvanhocht/laravel-share.svg?style=flat-square)](https://packagist.org/packages/jorenvanhocht/laravel-share)
Share links exist on almost every page in every project, creating the code for these share links over and over again can be a pain in the ass.
With Laravel Share you can generate these links in just seconds in a way tailored for Laravel.
### Available services
* Facebook
* Twitter
* Linkedin
* WhatsApp
* Reddit
* Telegram
## Installation
You can install the package via composer:
``` bash
composer require jorenvanhocht/laravel-share
```
If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php
```php
// config/app.php
'providers' => [
Jorenvh\Share\Providers\ShareServiceProvider::class,
];
```
And optionally add the facade in config/app.php
```php
// config/app.php
'aliases' => [
'Share' => Jorenvh\Share\ShareFacade::class,
];
```
Publish the package config & resource files.
```bash
php artisan vendor:publish --provider="Jorenvh\Share\Providers\ShareServiceProvider"
```
> You might need to republish the config file when updating to a newer version of Laravel Share
This will publish the ```laravel-share.php``` config file to your config folder, ```share.js``` in ```public/js/``` and ```laravel-share.php``` in your ```resources/lang/vendor/en/``` folder.
### Fontawesome
Since this package relies on Fontawesome, you will have to require it's css, js & fonts in your app.
You can do that by requesting a embed code [via their website](http://fontawesome.io/get-started/) or by installing it locally in your project.
Laravel share supports Font Awesome v5. For Font Awsome 4 support use version [3](https://github.com/jorenvh/laravel-share/tree/3.3.1) of this package.
### Javascript
Load jquery.min.js & share.js by adding the following lines to your template files.
```html
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha256-4+XzXVhsDmqanXGHaHvgh1gMQKX40OUvDEBTu8JcmNs=" crossorigin="anonymous"></script>
<script src="{{ asset('js/share.js') }}"></script>
```
## Usage
### Creating one share link
#### Facebook
``` php
Share::page('http://jorenvanhocht.be')->facebook();
```
#### Twitter
``` php
Share::page('http://jorenvanhocht.be', 'Your share text can be placed here')->twitter();
```
#### Reddit
``` php
Share::page('http://jorenvanhocht.be', 'Your share text can be placed here')->reddit();
```
#### Linkedin
``` php
Share::page('http://jorenvanhocht.be', 'Share title')->linkedin('Extra linkedin summary can be passed here')
```
#### Whatsapp
``` php
Share::page('http://jorenvanhocht.be')->whatsapp()
```
#### Telegram
``` php
Share::page('http://jorenvanhocht.be', 'Your share text can be placed here')->telegram();
```
### Sharing the current url
Instead of manually passing an url, you can opt to use the `currentPage` function.
```php
Share::currentPage()->facebook();
```
### Creating multiple share Links
If want multiple share links for (multiple) providers you can just chain the methods like this.
```php
Share::page('http://jorenvanhocht.be', 'Share title')
->facebook()
->twitter()
->linkedin('Extra linkedin summary can be passed here')
->whatsapp();
```
This will generate the following html
```html
<div id="social-links">
<ul>
<li><a href="https://www.facebook.com/sharer/sharer.php?u=http://jorenvanhocht.be" class="social-button " id=""><span class="fa fa-facebook-official"></span></a></li>
<li><a href="https://twitter.com/intent/tweet?text=my share text&amp;url=http://jorenvanhocht.be" class="social-button " id=""><span class="fa fa-twitter"></span></a></li>
<li><a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://jorenvanhocht.be&amp;title=my share text&amp;summary=dit is de linkedin summary" class="social-button " id=""><span class="fa fa-linkedin"></span></a></li>
<li><a href="https://wa.me/?text=http://jorenvanhocht.be" class="social-button " id=""><span class="fa fa-whatsapp"></span></a></li>
</ul>
</div>
```
### Getting the raw links
In some cases you may only need the raw links without any html, you can get these by calling the `getRawLinks` method.
**A single link**
```php
Share::page('http://jorenvanhocht.be', 'Share title')
->facebook()
->getRawLinks();
```
Outputs:
```html
https://www.facebook.com/sharer/sharer.php?u=http://jorenvanhocht.be
```
**Multiple links**
```php
Share::page('http://jorenvanhocht.be', 'Share title')
->facebook()
->twitter()
->linkedin('Extra linkedin summary can be passed here')
->whatsapp()
->getRawLinks();
```
Outputs:
```
[
"facebook" => "https://www.facebook.com/sharer/sharer.php?u=http://jorenvanhocht.be",
"twitter" => "https://twitter.com/intent/tweet?text=Share+title&url=http://jorenvanhocht.be",
"linkedin" => "http://www.linkedin.com/shareArticle?mini=true&url=http://jorenvanhocht.be&title=Share+title&summary=Extra+linkedin+summary+can+be+passed+here",
"whatsapp" => "https://wa.me/?text=http://jorenvanhocht.be",
]
```
### Optional parameters
#### Add extra classes, id's or titles to the social buttons
You can simply add extra class(es), id('s), title(s) or relationship(s) by passing an array as the third parameter on the page method.
```php
Share::page('http://jorenvanhocht.be', null, ['class' => 'my-class', 'id' => 'my-id', 'title' => 'my-title', 'rel' => 'nofollow noopener noreferrer'])
->facebook();
```
Which will result in the following html
```html
<div id="social-links">
<ul>
<li><a href="https://www.facebook.com/sharer/sharer.php?u=http://jorenvanhocht.be" class="social-button my-class" id="my-id" rel="nofollow noopener noreferrer"><span class="fa fa-facebook-official"></span></a></li>
</ul>
</div>
```
#### Custom wrapping
By default social links will be wrapped in the following html
```html
<div id="social-links">
<ul>
<!-- social links will be added here -->
</ul>
</div>
```
This can be customised by passing the prefix & suffix as a parameter.
```php
Share::page('http://jorenvanhocht.be', null, [], '<ul>', '</ul>')
->facebook();
```
This will output the following html.
```html
<ul>
<li><a href="https://www.facebook.com/sharer/sharer.php?u=http://jorenvanhocht.be" class="social-button " id=""><span class="fa fa-facebook-official"></span></a></li>
</ul>
```
## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
## Testing
``` bash
$ composer test
```
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
## Security
If you discover any security related issues, please email jorenvh@gmail.com instead of using the issue tracker.
## Credits
- [Joren Van Hocht](https://github.com/jorenvh)
- [All Contributors](../../contributors)
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
+53
View File
@@ -0,0 +1,53 @@
{
"name": "jorenvanhocht/laravel-share",
"description": "Optional package for Laravel to generate social share links.",
"keywords": [
"laravel",
"share",
"social links",
"social share links"
],
"homepage": "https://github.com/jorenvh/laravel-share",
"license": "MIT",
"authors": [
{
"name": "Joren Van Hocht",
"email": "joren@codeswitch.be",
"homepage": "https://codeswitch.be",
"role": "Developer"
}
],
"require": {
"php": "^7.4|^8.0"
},
"require-dev": {
"phpunit/phpunit": "^9.3",
"orchestra/testbench": "^6.13|^7.0"
},
"autoload": {
"psr-4": {
"Jorenvh\\Share\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Jorenvh\\Share\\Test\\": "tests"
}
},
"scripts": {
"test": "vendor/bin/phpunit tests"
},
"config": {
"sort-packages": true
},
"extra": {
"laravel": {
"providers": [
"Jorenvh\\Share\\Providers\\ShareServiceProvider"
],
"aliases": {
"Share": "Jorenvh\\Share\\ShareFacade"
}
}
}
}
@@ -0,0 +1,57 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Services
|--------------------------------------------------------------------------
|
| Specify the base uri for each service.
|
|
|
*/
'services' => [
'facebook' => [
'uri' => 'https://www.facebook.com/sharer/sharer.php?u=',
],
'twitter' => [
'uri' => 'https://twitter.com/intent/tweet',
'text' => 'Default share text',
],
'linkedin' => [
'uri' => 'https://www.linkedin.com/sharing/share-offsite', // oud: http://www.linkedin.com/shareArticle
'extra' => ['mini' => 'true'],
],
'whatsapp' => [
'uri' => 'https://wa.me/?text=',
'extra' => ['mini' => 'true'],
],
'pinterest' => [
'uri' => 'https://pinterest.com/pin/create/button/?url=',
],
'reddit' => [
'uri' => 'https://www.reddit.com/submit',
'text' => 'Default share text',
],
'telegram' => [
'uri' => 'https://telegram.me/share/url',
'text' => 'Default share text',
],
],
/*
|--------------------------------------------------------------------------
| Font Awesome
|--------------------------------------------------------------------------
|
| Specify the version of Font Awesome that you want to use.
| We support version 4 and 5.
|
|
*/
'fontAwesomeVersion' => 5,
];
+34
View File
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
verbose="true"
>
<testsuites>
<testsuite name="CodeSwitch Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<php>
<env name="APP_URL" value="http://mysite.com"/>
</php>
</phpunit>
+20
View File
@@ -0,0 +1,20 @@
var popupSize = {
width: 780,
height: 550
};
$(document).on('click', '.social-button', function (e) {
var verticalPos = Math.floor(($(window).width() - popupSize.width) / 2),
horisontalPos = Math.floor(($(window).height() - popupSize.height) / 2);
var popup = window.open($(this).prop('href'), 'social',
'width=' + popupSize.width + ',height=' + popupSize.height +
',left=' + verticalPos + ',top=' + horisontalPos +
',location=0,menubar=0,toolbar=0,status=0,scrollbars=1,resizable=1');
if (popup) {
popup.focus();
e.preventDefault();
}
});
@@ -0,0 +1,11 @@
<?php
return [
'facebook' => '<li><a href=":url" class="social-button :class" id=":id" title=":title" rel=":rel"><span class="fab fa-facebook-square"></span></a></li>',
'twitter' => '<li><a href=":url" class="social-button :class" id=":id" title=":title" rel=":rel"><span class="fab fa-twitter"></span></a></li>',
'linkedin' => '<li><a href=":url" class="social-button :class" id=":id" title=":title" rel=":rel"><span class="fab fa-linkedin"></span></a></li>',
'whatsapp' => '<li><a target="_blank" href=":url" class="social-button :class" id=":id" title=":title" rel=":rel"><span class="fab fa-whatsapp"></span></a></li>',
'pinterest' => '<li><a href=":url" class="social-button :class" id=":id" title=":title" rel=":rel"><span class="fab fa-pinterest"></span></a></li>',
'reddit' => '<li><a target="_blank" href=":url" class="social-button :class" id=":id" title=":title" rel=":rel"><span class="fab fa-reddit"></span></a></li>',
'telegram' => '<li><a target="_blank" href=":url" class="social-button :class" id=":id" title=":title" rel=":rel"><span class="fab fa-telegram"></span></a></li>',
];
@@ -0,0 +1,42 @@
<?php
namespace Jorenvh\Share\Providers;
use Illuminate\Support\ServiceProvider;
use Jorenvh\Share\Share;
class ShareServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*/
public function boot()
{
$this->loadTranslationsFrom(__DIR__ . '/../../resources/lang/', 'laravel-share');
$this->publishes([
__DIR__ . '/../../config/laravel-share.php' => config_path('laravel-share.php'),
], 'config');
$this->publishes([
__DIR__ . '/../../public/js/share.js' => public_path('js/share.js'),
], 'assets');
$this->publishes([
__DIR__ . '/../../resources/lang/' => resource_path('lang/vendor/laravel-share'),
], 'translations');
}
/**
* Register the application services.
*/
public function register()
{
$this->app->bind(Share::class, function () {
return new Share();
});
$this->mergeConfigFrom(__DIR__ . '/../../config/laravel-share.php', 'laravel-share');
}
}
+284
View File
@@ -0,0 +1,284 @@
<?php
namespace Jorenvh\Share;
use Illuminate\Support\Arr;
class Share
{
/**
* The url of the page to share
*
* @var string
*/
protected $url;
/**
* The generated urls
*
* @var string
*/
protected $generatedUrls = [];
/**
* Optional text for Twitter
* and Linkedin title
*
* @var string
*/
protected $title;
/**
* Extra options for the share links
*
* @var array
*/
protected $options = [];
/**
* Html to prefix before the share links
*
* @var string
*/
protected $prefix = '<div id="social-links"><ul>';
/**
* Html to append after the share links
*
* @var string
*/
protected $suffix = '</ul></div>';
/**
* The generated html
*
* @var string
*/
protected $html = '';
/**
* Return a string with html at the end
* of the chain.
*
* @return string
*/
public function __toString()
{
$this->html = $this->prefix . $this->html;
$this->html .= $this->suffix;
return $this->html;
}
/**
* @param string $url
* @param string|null $title
* @param array $options
* @param string|null $prefix
* @param string|null $suffix
* @return $this
*/
public function page($url, $title = null, $options = [], $prefix = null, $suffix = null)
{
$this->url = $url;
$this->title = $title;
$this->options = $options;
$this->html = '';
$this->setPrefixAndSuffix($prefix, $suffix);
return $this;
}
/**
* @param string|null $title
* @param array $options
* @param string|null $prefix
* @param string|null $suffix
* @return $this
*/
public function currentPage($title = null, $options = [], $prefix = null, $suffix = null)
{
$url = request()->getUri();
return $this->page($url, $title, $options, $prefix, $suffix);
}
/**
* Facebook share link
*
* @return $this
*/
public function facebook()
{
$url = config('laravel-share.services.facebook.uri') . $this->url;
$this->buildLink('facebook', $url);
return $this;
}
/**
* Twitter share link
*
* @return $this
*/
public function twitter()
{
if (is_null($this->title)) {
$this->title = config('laravel-share.services.twitter.text');
}
$base = config('laravel-share.services.twitter.uri');
$url = $base . '?text=' . urlencode($this->title) . '&url=' . $this->url;
$this->buildLink('twitter', $url);
return $this;
}
/**
* Reddit share link
*
* @return $this
*/
public function reddit()
{
if (is_null($this->title)) {
$this->title = config('laravel-share.services.reddit.text');
}
$base = config('laravel-share.services.reddit.uri');
$url = $base . '?title=' . urlencode($this->title) . '&url=' . $this->url;
$this->buildLink('reddit', $url);
return $this;
}
/**
* Telegram share link
*
* @return $this
*/
public function telegram()
{
if (is_null($this->title)) {
$this->title = config('laravel-share.services.telegram.text');
}
$base = config('laravel-share.services.telegram.uri');
$url = $base . '?url=' . $this->url . '&text=' . urlencode($this->title);
$this->buildLink('telegram', $url);
return $this;
}
/**
* Whatsapp share link
*
* @return $this
*/
public function whatsapp()
{
$url = config('laravel-share.services.whatsapp.uri') . $this->url;
$this->buildLink('whatsapp', $url);
return $this;
}
/**
* Linked in share link
*
* @param string $summary
* @return $this
*/
public function linkedin($summary = '')
{
$base = config('laravel-share.services.linkedin.uri');
$mini = config('laravel-share.services.linkedin.extra.mini');
$url = $base . '?mini=' . $mini . '&url=' . $this->url . '&title=' . urlencode($this->title) . '&summary=' . urlencode($summary);
$this->buildLink('linkedin', $url);
return $this;
}
/**
* Pinterest share link
*
* @return $this
*/
public function pinterest()
{
$url = config('laravel-share.services.pinterest.uri') . $this->url;
$this->buildLink('pinterest', $url);
return $this;
}
/**
* Get the raw generated links.
*
* @return string|array
*/
public function getRawLinks()
{
if(count($this->generatedUrls) === 1) {
return Arr::first($this->generatedUrls);
}
return $this->generatedUrls;
}
/**
* Build a single link
*
* @param string $provider
* @param string $url
*/
protected function buildLink($provider, $url)
{
$fontAwesomeVersion = config('laravel-share.fontAwesomeVersion', 5);
$this->rememberRawLink($provider, $url);
$this->html .= trans("laravel-share::laravel-share-fa$fontAwesomeVersion.$provider", [
'url' => $url,
'class' => key_exists('class', $this->options) ? $this->options['class'] : '',
'id' => key_exists('id', $this->options) ? $this->options['id'] : '',
'title' => key_exists('title', $this->options) ? $this->options['title'] : '',
'rel' => key_exists('rel', $this->options) ? $this->options['rel'] : '',
]);
}
/**
* Optionally Set custom prefix and/or suffix
*
* @param string $prefix
* @param string $suffix
*/
protected function setPrefixAndSuffix($prefix, $suffix)
{
if (!is_null($prefix)) {
$this->prefix = $prefix;
}
if (!is_null($suffix)) {
$this->suffix = $suffix;
}
}
/**
* @param string $provider
* @param string $socialNetworkUrl
*/
protected function rememberRawLink($provider, $socialNetworkUrl)
{
$this->generatedUrls[$provider] = $socialNetworkUrl;
}
}
+30
View File
@@ -0,0 +1,30 @@
<?php
namespace Jorenvh\Share;
use Illuminate\Support\Facades\Facade;
/**
* @method page($url, ?string $title = null, array $options = [], ?string $prefix = null, ?string $suffix = null)
* @method currentPage($url, ?string $title = null, array $options = [], ?string $prefix = null, ?string $suffix = null)
* @method facebook()
* @method twitter()
* @method reddit()
* @method telegram()
* @method whatsapp()
* @method linkedin(string $summary = '')
* @method pinterest()
* @method array getRawLinks()
*/
class ShareFacade extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return Share::class;
}
}