-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from inovector/develop
Unsplash trigger download Job & Media improvements
- Loading branch information
Showing
17 changed files
with
267 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<template> | ||
<div class="absolute z-10 bottom-0 mb-xs left-0 ml-xs hidden group-hover:block"> | ||
<div class="absolute z-10 bottom-0 mb-xs left-0 ml-xs hidden group-hover:block shadow-mix"> | ||
<div class="bg-white shadow-mix py-xs px-sm text-left rounded-md"><slot/></div> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Inovector\Mixpost\Integrations\Unsplash\Jobs; | ||
|
||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Foundation\Bus\Dispatchable; | ||
use Illuminate\Queue\InteractsWithQueue; | ||
use Illuminate\Queue\SerializesModels; | ||
use Inovector\Mixpost\Integrations\Unsplash\Unsplash; | ||
|
||
class TriggerDownloadJob implements ShouldQueue | ||
{ | ||
use Dispatchable; | ||
use InteractsWithQueue; | ||
use Queueable; | ||
use SerializesModels; | ||
|
||
public function __construct(public readonly string $downloadLocation) | ||
{ | ||
} | ||
|
||
public function handle(Unsplash $unsplash): void | ||
{ | ||
$unsplash->downloadPhoto($this->downloadLocation); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace Inovector\Mixpost\Integrations\Unsplash; | ||
|
||
use Illuminate\Support\Arr; | ||
use Illuminate\Support\Facades\Http; | ||
use Inovector\Mixpost\Facades\Services; | ||
use Inovector\Mixpost\Util; | ||
|
||
class Unsplash | ||
{ | ||
protected string $clientId; | ||
protected string $endpointUrl = 'https://api.unsplash.com'; | ||
|
||
public function __construct() | ||
{ | ||
$clientId = Services::get('unsplash', 'client_id'); | ||
|
||
if (!$clientId) { | ||
throw new \Exception('Unsplash is not configured.'); | ||
} | ||
|
||
$this->clientId = $clientId; | ||
} | ||
|
||
public function photos(string $query = '', int $page = 1): array | ||
{ | ||
return Http::get("$this->endpointUrl/search/photos", [ | ||
'client_id' => $this->clientId, | ||
'query' => $query ?: Arr::random(Util::config('external_media_terms')), | ||
'page' => $page, | ||
'per_page' => 30, | ||
])->json('results', []); | ||
} | ||
|
||
public function downloadPhoto(string $downloadLocation) | ||
{ | ||
$download_path = parse_url($downloadLocation, PHP_URL_PATH); | ||
$download_query = parse_url($downloadLocation, PHP_URL_QUERY); | ||
|
||
return Http::get("$this->endpointUrl$download_path?$download_query", [ | ||
'client_id' => $this->clientId, | ||
])->json(); | ||
} | ||
} |
Oops, something went wrong.