mpratt / Embera

A Oembed consumer library, that gives you information about urls. It helps you replace urls to youtube or vimeo for example, with their html embed code. It has advanced features like offline support, responsive embeds and caching support.
MIT License
335 stars 59 forks source link

Added Wordwall provider #71

Closed azeos closed 4 years ago

azeos commented 4 years ago

Hi, First of all, thanks for this package.

I've just added wordwall.net provider to our platform. Are you accepting PR?

Documentation

/**
 * Wordwall Provider
 * @link https://wordwall.net/
 * @link https://wordwall.net/about/oembed
 */
class Wordwall extends ProviderAdapter implements ProviderInterface
{
    /** inline {@inheritdoc} */
    protected $endpoint = 'https://wordwall.net/api/oembed/?format=json';

    /** inline {@inheritdoc} */
    protected static $hosts = [
        'wordwall.net'
    ];

    /** inline {@inheritdoc} */
    protected $httpsSupport = true;

    /** inline {@inheritdoc} */
    public function validateUrl(Url $url)
    {
        return (bool) (preg_match('~wordwall\.net/(?:[^/]+/)?(?:resource|play)/.*+~i', (string) $url));
    }

    /** inline {@inheritdoc} */
    public function normalizeUrl(Url $url)
    {
        $url->convertToHttps();
        $url->removeQueryString();

        return $url;
    }

}
mpratt commented 4 years ago

Hi @azeos Thank you very much for the code! If you want, you can add a PR with Tests and register it to the 02-providers.md file inside the documentation folder. Let me know if you have time to do it or I will add it myself next week.

mpratt commented 4 years ago

Thanks for the PR! :+1:

azeos commented 4 years ago

You're welcome mate!