Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Share URL changes #62

Merged
merged 3 commits into from
Dec 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,18 @@ This is a fork of John's share for Laravel 4.

## Services available

- Delicious : delicious
- Digg : digg
- Email : email
- Evernote : evernote
- Facebook : facebook
- Gmail : gmail
- Google Plus : gplus
- LinkedIn : linkedin
- Pinterest : pinterest
- Reddit : reddit
- Scoop.it : scoopit
- Telegram.me : telegramMe
- Tumblr : tumblr
- Twitter : twitter
- Viadeo : viadeo
- vk.com : vk


Expand Down Expand Up @@ -48,13 +45,12 @@ Get many links

Route::get('/', function()
{
return Share::load('http://www.example.com', 'Link description')->services('facebook', 'gplus', 'twitter');
return Share::load('http://www.example.com', 'Link description')->services('facebook', 'twitter');
});

Returns an array :

{
"gplus" : "https://plus.google.com/share?url=http%3A%2F%2Fwww.example.com",
"twitter" : "https://twitter.com/intent/tweet?url=http%3A%2F%2Fwww.example.com&text=Link+description",
"facebook" : "https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fwww.example.com&title=Link+description"
}
Expand Down Expand Up @@ -102,3 +98,11 @@ Localizing? Easy, use Laravel's trans() call:
Create a file at resources/lang/en/share.php with your choice of subject and body. URLs arguably have a maximum length of 2000 characters.

Notice the use of *<?php echo $sep; ?>*. It's the only way to print out an unencoded ampersand (if configured that way).

## Upgrades

When the package is upgraded, changes to the config and views should be republished into your project:

php artisan vendor:publish --provider='Chencha\Share\ShareServiceProvider'

Use source control to work out what has changed if you have customized the files.
20 changes: 8 additions & 12 deletions config/social-share.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,25 @@
return [
'separator' => '&',
'services' => [
'delicious' => [ 'uri' => 'https://delicious.com/post' ],
'digg' => [ 'uri' => 'http://www.digg.com/submit' ],
'blogger' => [ 'uri' => 'https://www.blogger.com/blog-this.g', 'urlName' => 'u', 'titleName' => 'n' ],
'digg' => [ 'uri' => 'https://digg.com/news/submit-link', 'only' => [ 'url' ] ],
'email' => [ 'view' => 'social-share::email' ],
'evernote' => [ 'uri' => 'http://www.evernote.com/clip.action' ],
'facebook' => [ 'uri' => 'https://www.facebook.com/sharer/sharer.php', 'urlName' => 'u', ],
'facebook' => [ 'uri' => 'https://www.facebook.com/sharer/sharer.php', 'urlName' => 'u', 'titleName' => 'quote'],
'gmail' => [ 'uri' => 'https://mail.google.com/mail/', 'urlName' => 'su', 'titleName' => 'body', 'extra' => [
'view' => 'cm',
'fs' => 1,
'to' => '',
'ui' => 2,
'tf' => 1,
]],
'gplus' => [ 'uri' => 'https://plus.google.com/share', 'only' => [ 'url' ] ],
'linkedin' => [ 'uri' => 'http://www.linkedin.com/shareArticle', 'extra' => [ 'mini' => 'true' ] ],
'pinterest' => [ 'uri' => 'http://pinterest.com/pin/create/button/', 'titleName' => 'description', 'mediaName' => 'media' ],
'reddit' => [ 'uri' => 'http://www.reddit.com/submit' ],
'scoopit' => [ 'uri' => 'http://www.scoop.it/oexchange/share' ],
'linkedin' => [ 'uri' => 'https://www.linkedin.com/sharing/share-offsite/', 'only' => [ 'url' ] ],
'pinterest' => [ 'uri' => 'https://pinterest.com/pin/create/button/', 'only' => [ 'url' ] ],
'reddit' => [ 'uri' => 'https://www.reddit.com/submit' ],
'scoopit' => [ 'uri' => 'https://www.scoop.it/bookmarklet', 'only' => [ 'url' ] ],
'telegramMe' => [ 'uri' => 'https://telegram.me/share/url', 'titleName' => 'text' ],
'tumblr' => [ 'uri' => 'http://www.tumblr.com/share', 'urlName' => 'u', 'titleName' => 't', 'extra' => [
'v' => 3,
]],
'tumblr' => [ 'uri' => 'https://www.tumblr.com/widgets/share/tool', 'urlName' => 'canonicalUrl' ],
'twitter' => [ 'uri' => 'https://twitter.com/intent/tweet', 'titleName' => 'text' ],
'viadeo' => [ 'uri' => 'http://www.viadeo.com/' ],
'vk' => [ 'uri' => 'http://vk.com/share.php', 'mediaName' => 'image', 'extra' => [
'noparse' => 'false',
]],
Expand Down
95 changes: 33 additions & 62 deletions tests/ShareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,23 @@
class ShareTest extends TestCase
{
protected $expected = [
"delicious" => "https://delicious.com/post?url=http%3A%2F%2Fwww.example.com&title=Example",
"digg" => "http://www.digg.com/submit?url=http%3A%2F%2Fwww.example.com&title=Example",
"email" => "mailto:?subject=Example&body=http%3A%2F%2Fwww.example.com",
"evernote" => "http://www.evernote.com/clip.action?url=http%3A%2F%2Fwww.example.com&title=Example",
"facebook" => "https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fwww.example.com&title=Example",
"gmail" => "https://mail.google.com/mail/?su=http%3A%2F%2Fwww.example.com&body=Example&view=cm&fs=1&to=&ui=2&tf=1",
"gplus" => "https://plus.google.com/share?url=http%3A%2F%2Fwww.example.com",
"linkedin" => "http://www.linkedin.com/shareArticle?url=http%3A%2F%2Fwww.example.com&title=Example&mini=true",
"pinterest" => "http://pinterest.com/pin/create/button/?url=http%3A%2F%2Fwww.example.com&description=Example&media=Media",
"reddit" => "http://www.reddit.com/submit?url=http%3A%2F%2Fwww.example.com&title=Example",
"scoopit" => "http://www.scoop.it/oexchange/share?url=http%3A%2F%2Fwww.example.com&title=Example",
"telegramMe" => "https://telegram.me/share/url?url=http%3A%2F%2Fwww.example.com&text=Example",
"tumblr" => "http://www.tumblr.com/share?u=http%3A%2F%2Fwww.example.com&t=Example&v=3",
"twitter" => "https://twitter.com/intent/tweet?url=http%3A%2F%2Fwww.example.com&text=Example",
"viadeo" => "http://www.viadeo.com/?url=http%3A%2F%2Fwww.example.com&title=Example",
"vk" => "http://vk.com/share.php?url=http%3A%2F%2Fwww.example.com&title=Example&image=Media&noparse=false",
"whatsapp" => "whatsapp://send?text=Example%20http%3A%2F%2Fwww.example.com",
"whatsapp" => "whatsapp://send?text=Example%20http%3A%2F%2Fwww.example.com",

"service" => "http://service.example.com?url=http%3A%2F%2Fwww.example.com&title=Example&media=Media",
"service2" => "http://service2.example.com?url=http%3A%2F%2Fwww.example.com&title=Example&extra1=Extra%201&extra2=Extra%202",
'blogger' => 'https://www.blogger.com/blog-this.g?u=http%3A%2F%2Fwww.example.com&n=Example',
'digg' => 'https://digg.com/news/submit-link?url=http%3A%2F%2Fwww.example.com',
'email' => 'mailto:?subject=Example&body=http%3A%2F%2Fwww.example.com',
'evernote' => 'http://www.evernote.com/clip.action?url=http%3A%2F%2Fwww.example.com&title=Example',
'facebook' => 'https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fwww.example.com&quote=Example',
'gmail' => 'https://mail.google.com/mail/?su=http%3A%2F%2Fwww.example.com&body=Example&view=cm&fs=1&to=&ui=2&tf=1',
'linkedin' => 'https://www.linkedin.com/sharing/share-offsite/?url=http%3A%2F%2Fwww.example.com',
'pinterest' => 'https://pinterest.com/pin/create/button/?url=http%3A%2F%2Fwww.example.com',
'reddit' => 'https://www.reddit.com/submit?url=http%3A%2F%2Fwww.example.com&title=Example',
'scoopit' => 'https://www.scoop.it/bookmarklet?url=http%3A%2F%2Fwww.example.com',
'telegramMe' => 'https://telegram.me/share/url?url=http%3A%2F%2Fwww.example.com&text=Example',
'tumblr' => 'https://www.tumblr.com/widgets/share/tool?canonicalUrl=http%3A%2F%2Fwww.example.com&title=Example',
'twitter' => 'https://twitter.com/intent/tweet?url=http%3A%2F%2Fwww.example.com&text=Example',
'vk' => 'http://vk.com/share.php?url=http%3A%2F%2Fwww.example.com&title=Example&image=Media&noparse=false',
'whatsapp' => 'whatsapp://send?text=Example%20http%3A%2F%2Fwww.example.com',
'service' => 'http://service.example.com?url=http%3A%2F%2Fwww.example.com&title=Example&media=Media',
'service2' => 'http://service2.example.com?url=http%3A%2F%2Fwww.example.com&title=Example&extra1=Extra%201&extra2=Extra%202',
];

protected function getPackageProviders($app)
Expand Down Expand Up @@ -141,21 +137,19 @@ public function testSeparator()
public function testServices()
{
$actual = Share::load('http://www.example.com', 'Example', 'Media')->services(
'delicious',
'blogger',
'digg',
'email',
'evernote',
'facebook',
'gmail',
'gplus',
'linkedin',
'pinterest',
'reddit',
'scoopit',
'telegramMe',
'tumblr',
'twitter',
'viadeo',
'vk',
'whatsapp',
'service',
Expand All @@ -169,24 +163,21 @@ public function testServicesWithArray()
{
$actual = Share::load('http://www.example.com', 'Example', 'Media')->services(
[
'delicious',
'blogger',
'digg',
'email',
'evernote',
'facebook',
'gmail',
'gplus',
'linkedin',
'pinterest',
'reddit',
'scoopit',
'telegramMe',
'tumblr',
'twitter',
'viadeo',
'vk',
'whatsapp',

'service',
'service2',
]
Expand Down Expand Up @@ -214,10 +205,10 @@ protected function assertPageFound($url)
/**
* @group live
*/
public function testDelicious()
public function testBlogger()
{
$url = 'https://delicious.com/post?url=http%3A%2F%2Fwww.example.com&title=Example';
$this->assertEquals($url, Share::load('http://www.example.com', 'Example')->delicious());
$url = 'https://www.blogger.com/blog-this.g?u=http%3A%2F%2Fwww.example.com&n=Example';
$this->assertEquals($url, Share::load('http://www.example.com', 'Example')->blogger());
// $this->assertPageFound($url);
}

Expand All @@ -226,8 +217,8 @@ public function testDelicious()
*/
public function testDigg()
{
$url = 'http://www.digg.com/submit?url=http%3A%2F%2Fwww.example.com&title=Example';
$this->assertEquals($url, Share::load('http://www.example.com', 'Example')->digg());
$url = 'https://digg.com/news/submit-link?url=http%3A%2F%2Fwww.example.com';
$this->assertEquals($url, Share::load('http://www.example.com')->digg());
// $this->assertPageFound($url);
}

Expand Down Expand Up @@ -256,7 +247,7 @@ public function testEvernote()
*/
public function testFacebook()
{
$url = 'https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fwww.example.com&title=Example';
$url = 'https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fwww.example.com&quote=Example';
$this->assertEquals($url, Share::load('http://www.example.com', 'Example')->facebook());
// $this->assertPageFound($url);
}
Expand All @@ -271,23 +262,13 @@ public function testGmail()
// $this->assertPageFound($url);
}

/**
* @group live
*/
public function testGplus()
{
$url = 'https://plus.google.com/share?url=http%3A%2F%2Fwww.example.com';
$this->assertEquals($url, Share::load('http://www.example.com')->gplus());
// $this->assertPageFound($url);
}

/**
* @group live
*/
public function testLinkedin()
{
$url = 'http://www.linkedin.com/shareArticle?url=http%3A%2F%2Fwww.example.com&title=Example&mini=true';
$this->assertEquals($url, Share::load('http://www.example.com', 'Example')->linkedin());
$url = 'https://www.linkedin.com/sharing/share-offsite/?url=http%3A%2F%2Fwww.example.com';
$this->assertEquals($url, Share::load('http://www.example.com')->linkedin());
// $this->assertPageFound($url);
}

Expand All @@ -296,8 +277,8 @@ public function testLinkedin()
*/
public function testPinterest()
{
$url = 'http://pinterest.com/pin/create/button/?url=http%3A%2F%2Fwww.example.com&description=Example&media=Media';
$this->assertEquals($url, Share::load('http://www.example.com', 'Example', 'Media')->pinterest());
$url = 'https://pinterest.com/pin/create/button/?url=http%3A%2F%2Fwww.example.com';
$this->assertEquals($url, Share::load('http://www.example.com')->pinterest());
// $this->assertPageFound($url);
}

Expand All @@ -306,7 +287,7 @@ public function testPinterest()
*/
public function testReddit()
{
$url = 'http://www.reddit.com/submit?url=http%3A%2F%2Fwww.example.com&title=Example';
$url = 'https://www.reddit.com/submit?url=http%3A%2F%2Fwww.example.com&title=Example';
$this->assertEquals($url, Share::load('http://www.example.com', 'Example')->reddit());
// $this->assertPageFound($url);
}
Expand All @@ -316,8 +297,8 @@ public function testReddit()
*/
public function testScoopit()
{
$url = 'http://www.scoop.it/oexchange/share?url=http%3A%2F%2Fwww.example.com&title=Example';
$this->assertEquals($url, Share::load('http://www.example.com', 'Example')->scoopit());
$url = 'https://www.scoop.it/bookmarklet?url=http%3A%2F%2Fwww.example.com';
$this->assertEquals($url, Share::load('http://www.example.com')->scoopit());
// $this->assertPageFound($url);
}

Expand All @@ -336,7 +317,7 @@ public function testTelegramMe()
*/
public function testTumblr()
{
$url = 'http://www.tumblr.com/share?u=http%3A%2F%2Fwww.example.com&t=Example&v=3';
$url = 'https://www.tumblr.com/widgets/share/tool?canonicalUrl=http%3A%2F%2Fwww.example.com&title=Example';
$this->assertEquals($url, Share::load('http://www.example.com', 'Example')->tumblr());
// $this->assertPageFound($url);
}
Expand All @@ -351,16 +332,6 @@ public function testTwitter()
// $this->assertPageFound($url);
}

/**
* @group live
*/
public function testViadeo()
{
$url = 'http://www.viadeo.com/?url=http%3A%2F%2Fwww.example.com&title=Example';
$this->assertEquals($url, Share::load('http://www.example.com', 'Example')->viadeo());
// $this->assertPageFound($url);
}

/**
* @group live
*/
Expand Down