-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MediaEmbed: added support for custom Mastodon instances
- Loading branch information
Showing
7 changed files
with
190 additions
and
79 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<h2>Federated sites</h2> | ||
|
||
### Mastodon | ||
|
||
The default Mastodon media site can be customized with additional hosts. This can be done by modifying the original configuration in `$configurator->MediaEmbed->defaultSites['mastodon']`, or by assigning `mastodon` to the desired hostname in `$configurator->registeredVars['MediaEmbed.hosts']`. In the example below, we declare that the host `infosec.exchange` should be mapped to the `mastodon` site. | ||
|
||
```php | ||
$configurator = new s9e\TextFormatter\Configurator; | ||
|
||
// Add Mastodon, then create an entry that maps the hostname 'infosec.exchange' | ||
// to the 'mastodon' site | ||
$configurator->MediaEmbed->add('mastodon'); | ||
$configurator->registeredVars['MediaEmbed.hosts']['infosec.exchange'] = 'mastodon'; | ||
|
||
// Get an instance of the parser and the renderer | ||
extract($configurator->finalize()); | ||
|
||
$text = 'https://infosec.exchange/@SwiftOnSecurity/109579438603578302'; | ||
$xml = $parser->parse($text); | ||
$html = $renderer->render($xml); | ||
|
||
echo $html; | ||
``` | ||
```html | ||
<iframe data-s9e-mediaembed="mastodon" allowfullscreen="" loading="lazy" onload="let c=new MessageChannel;c.port1.onmessage=e=>this.style.height=e.data+'px';this.contentWindow.postMessage('s9e:init','*',[c.port2])" scrolling="no" style="border:0;height:300px;max-width:550px;width:100%" src="https://s9e.github.io/iframe/2/mastodon.min.html#SwiftOnSecurity@infosec.exchange/109579438603578302"></iframe> | ||
``` |
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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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