2020-05-17 20:58:19 +03:00
|
|
|
<?php
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2020-05-17 20:58:19 +03:00
|
|
|
class AwwwardsBridge extends BridgeAbstract
|
|
|
|
{
|
|
|
|
const NAME = 'Awwwards';
|
|
|
|
const URI = 'https://www.awwwards.com/';
|
|
|
|
const DESCRIPTION = 'Fetches the latest ten sites of the day from Awwwards';
|
|
|
|
const MAINTAINER = 'Paroleen';
|
|
|
|
const CACHE_TIMEOUT = 3600;
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2020-05-17 20:58:19 +03:00
|
|
|
const SITESURI = 'https://www.awwwards.com/websites/sites_of_the_day/';
|
|
|
|
const SITEURI = 'https://www.awwwards.com/sites/';
|
|
|
|
const ASSETSURI = 'https://assets.awwwards.com/awards/media/cache/thumb_417_299/';
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2020-05-17 20:58:19 +03:00
|
|
|
private $sites = [];
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2020-05-17 20:58:19 +03:00
|
|
|
public function getIcon()
|
|
|
|
{
|
|
|
|
return 'https://www.awwwards.com/favicon.ico';
|
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2020-05-17 20:58:19 +03:00
|
|
|
private function fetchSites()
|
|
|
|
{
|
|
|
|
Debug::log('Fetching all sites');
|
2022-01-02 12:36:09 +03:00
|
|
|
$sites = getSimpleHTMLDOM(self::SITESURI);
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2020-05-17 20:58:19 +03:00
|
|
|
Debug::log('Parsing all JSON data');
|
2022-11-11 20:33:28 +03:00
|
|
|
foreach ($sites->find('.grid-sites li') as $site) {
|
|
|
|
$decode = html_entity_decode($site->attr['data-collectable-model-value'], ENT_QUOTES, 'utf-8');
|
2020-05-17 20:58:19 +03:00
|
|
|
$decode = json_decode($decode, true);
|
|
|
|
$this->sites[] = $decode;
|
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
}
|
|
|
|
|
2020-05-17 20:58:19 +03:00
|
|
|
public function collectData()
|
|
|
|
{
|
|
|
|
$this->fetchSites();
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2020-05-17 20:58:19 +03:00
|
|
|
Debug::log('Building RSS feed');
|
|
|
|
foreach ($this->sites as $site) {
|
|
|
|
$item = [];
|
|
|
|
$item['title'] = $site['title'];
|
|
|
|
$item['timestamp'] = $site['createdAt'];
|
|
|
|
$item['categories'] = $site['tags'];
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2020-05-17 20:58:19 +03:00
|
|
|
$item['content'] = '<img src="'
|
|
|
|
. self::ASSETSURI
|
|
|
|
. $site['images']['thumbnail']
|
|
|
|
. '">';
|
|
|
|
$item['uri'] = self::SITEURI . $site['slug'];
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2020-05-17 20:58:19 +03:00
|
|
|
$this->items[] = $item;
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2020-05-17 20:58:19 +03:00
|
|
|
if (count($this->items) >= 10) {
|
|
|
|
break;
|
2022-07-01 16:10:30 +03:00
|
|
|
}
|
2020-05-17 20:58:19 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|